summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderThemeSafari.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/RenderThemeSafari.cpp')
-rw-r--r--Source/WebCore/rendering/RenderThemeSafari.cpp162
1 files changed, 105 insertions, 57 deletions
diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp
index 21d978c8b..2ab016d84 100644
--- a/Source/WebCore/rendering/RenderThemeSafari.cpp
+++ b/Source/WebCore/rendering/RenderThemeSafari.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc.
+ * Copyright (C) 2007, 2008, 2009, 2013 Apple Inc.
* Copyright (C) 2009 Kenneth Rohde Christiansen
*
* This library is free software; you can redistribute it and/or
@@ -35,9 +35,11 @@
#include "GraphicsContextCG.h"
#include "HTMLInputElement.h"
#include "HTMLMediaElement.h"
+#include "HTMLMeterElement.h"
#include "HTMLNames.h"
#include "PaintInfo.h"
#include "RenderMediaControls.h"
+#include "RenderMeter.h"
#include "RenderSlider.h"
#include "RenderView.h"
#include "SoftLinking.h"
@@ -170,7 +172,7 @@ Color RenderThemeSafari::platformFocusRingColor() const
if (!focusRingColor.isValid()) {
if (STCopyThemeColorPtr()) {
- RetainPtr<CGColorRef> color(AdoptCF, STCopyThemeColorPtr()(stFocusRingColorID, SafariTheme::ActiveState));
+ RetainPtr<CGColorRef> color = adoptCF(STCopyThemeColorPtr()(stFocusRingColorID, SafariTheme::ActiveState));
focusRingColor = makeRGBAFromCGColor(color.get());
}
if (!focusRingColor.isValid())
@@ -187,7 +189,7 @@ static float systemFontSizeForControlSize(NSControlSize controlSize)
return sizes[controlSize];
}
-void RenderThemeSafari::systemFont(int propId, FontDescription& fontDescription) const
+void RenderThemeSafari::systemFont(CSSValueID valueID, FontDescription& fontDescription) const
{
static FontDescription systemFont;
static FontDescription smallSystemFont;
@@ -199,47 +201,47 @@ void RenderThemeSafari::systemFont(int propId, FontDescription& fontDescription)
FontDescription* cachedDesc;
float fontSize = 0;
- switch (propId) {
- case CSSValueSmallCaption:
- cachedDesc = &smallSystemFont;
- if (!smallSystemFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSSmallControlSize);
- break;
- case CSSValueMenu:
- cachedDesc = &menuFont;
- if (!menuFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSRegularControlSize);
- break;
- case CSSValueStatusBar:
- cachedDesc = &labelFont;
- if (!labelFont.isAbsoluteSize())
- fontSize = 10.0f;
- break;
- case CSSValueWebkitMiniControl:
- cachedDesc = &miniControlFont;
- if (!miniControlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSMiniControlSize);
- break;
- case CSSValueWebkitSmallControl:
- cachedDesc = &smallControlFont;
- if (!smallControlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSSmallControlSize);
- break;
- case CSSValueWebkitControl:
- cachedDesc = &controlFont;
- if (!controlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSRegularControlSize);
- break;
- default:
- cachedDesc = &systemFont;
- if (!systemFont.isAbsoluteSize())
- fontSize = 13.0f;
+ switch (valueID) {
+ case CSSValueSmallCaption:
+ cachedDesc = &smallSystemFont;
+ if (!smallSystemFont.isAbsoluteSize())
+ fontSize = systemFontSizeForControlSize(NSSmallControlSize);
+ break;
+ case CSSValueMenu:
+ cachedDesc = &menuFont;
+ if (!menuFont.isAbsoluteSize())
+ fontSize = systemFontSizeForControlSize(NSRegularControlSize);
+ break;
+ case CSSValueStatusBar:
+ cachedDesc = &labelFont;
+ if (!labelFont.isAbsoluteSize())
+ fontSize = 10.0f;
+ break;
+ case CSSValueWebkitMiniControl:
+ cachedDesc = &miniControlFont;
+ if (!miniControlFont.isAbsoluteSize())
+ fontSize = systemFontSizeForControlSize(NSMiniControlSize);
+ break;
+ case CSSValueWebkitSmallControl:
+ cachedDesc = &smallControlFont;
+ if (!smallControlFont.isAbsoluteSize())
+ fontSize = systemFontSizeForControlSize(NSSmallControlSize);
+ break;
+ case CSSValueWebkitControl:
+ cachedDesc = &controlFont;
+ if (!controlFont.isAbsoluteSize())
+ fontSize = systemFontSizeForControlSize(NSRegularControlSize);
+ break;
+ default:
+ cachedDesc = &systemFont;
+ if (!systemFont.isAbsoluteSize())
+ fontSize = 13.0f;
}
if (fontSize) {
cachedDesc->setIsAbsoluteSize(true);
cachedDesc->setGenericFamily(FontDescription::NoFamily);
- cachedDesc->firstFamily().setFamily("Lucida Grande");
+ cachedDesc->setOneFamily("Lucida Grande");
cachedDesc->setSpecifiedSize(fontSize);
cachedDesc->setWeight(FontWeightNormal);
cachedDesc->setItalic(false);
@@ -390,7 +392,7 @@ void RenderThemeSafari::setFontFromControlSize(StyleResolver* styleResolver, Ren
fontDescription.setGenericFamily(FontDescription::SerifFamily);
float fontSize = systemFontSizeForControlSize(controlSize);
- fontDescription.firstFamily().setFamily("Lucida Grande");
+ fontDescription.setOneFamily("Lucida Grande");
fontDescription.setComputedSize(fontSize);
fontDescription.setSpecifiedSize(fontSize);
@@ -760,44 +762,44 @@ void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const Pain
FloatRect topGradient(r.x(), r.y(), r.width(), r.height() / 2.0f);
struct CGFunctionCallbacks topCallbacks = { 0, TopGradientInterpolate, NULL };
- RetainPtr<CGFunctionRef> topFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &topCallbacks));
- RetainPtr<CGShadingRef> topShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(topGradient.x(), topGradient.y()), CGPointMake(topGradient.x(), topGradient.maxY()), topFunction.get(), false, false));
+ RetainPtr<CGFunctionRef> topFunction = adoptCF(CGFunctionCreate(NULL, 1, NULL, 4, NULL, &topCallbacks));
+ RetainPtr<CGShadingRef> topShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(topGradient.x(), topGradient.y()), CGPointMake(topGradient.x(), topGradient.maxY()), topFunction.get(), false, false));
FloatRect bottomGradient(r.x() + radius, r.y() + r.height() / 2.0f, r.width() - 2.0f * radius, r.height() / 2.0f);
struct CGFunctionCallbacks bottomCallbacks = { 0, BottomGradientInterpolate, NULL };
- RetainPtr<CGFunctionRef> bottomFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &bottomCallbacks));
- RetainPtr<CGShadingRef> bottomShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(bottomGradient.x(), bottomGradient.y()), CGPointMake(bottomGradient.x(), bottomGradient.maxY()), bottomFunction.get(), false, false));
+ RetainPtr<CGFunctionRef> bottomFunction = adoptCF(CGFunctionCreate(NULL, 1, NULL, 4, NULL, &bottomCallbacks));
+ RetainPtr<CGShadingRef> bottomShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bottomGradient.x(), bottomGradient.y()), CGPointMake(bottomGradient.x(), bottomGradient.maxY()), bottomFunction.get(), false, false));
struct CGFunctionCallbacks mainCallbacks = { 0, MainGradientInterpolate, NULL };
- RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));
- RetainPtr<CGShadingRef> mainShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x(), r.maxY()), mainFunction.get(), false, false));
+ RetainPtr<CGFunctionRef> mainFunction = adoptCF(CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));
+ RetainPtr<CGShadingRef> mainShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x(), r.maxY()), mainFunction.get(), false, false));
- RetainPtr<CGShadingRef> leftShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x() + radius, r.y()), mainFunction.get(), false, false));
+ RetainPtr<CGShadingRef> leftShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x() + radius, r.y()), mainFunction.get(), false, false));
- RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.maxX(), r.y()), CGPointMake(r.maxX() - radius, r.y()), mainFunction.get(), false, false));
+ RetainPtr<CGShadingRef> rightShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(r.maxX(), r.y()), CGPointMake(r.maxX() - radius, r.y()), mainFunction.get(), false, false));
paintInfo.context->save();
CGContextClipToRect(context, bound.rect());
- paintInfo.context->addRoundedRectClip(bound);
+ paintInfo.context->clipRoundedRect(bound);
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
paintInfo.context->save();
CGContextClipToRect(context, topGradient);
- paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(topGradient), bound.radii().topLeft(), bound.radii().topRight(), IntSize(), IntSize()));
+ paintInfo.context->clipRoundedRect(RoundedRect(enclosingIntRect(topGradient), bound.radii().topLeft(), bound.radii().topRight(), IntSize(), IntSize()));
CGContextDrawShading(context, topShading.get());
paintInfo.context->restore();
if (!bottomGradient.isEmpty()) {
paintInfo.context->save();
CGContextClipToRect(context, bottomGradient);
- paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bound.radii().bottomLeft(), bound.radii().bottomRight()));
+ paintInfo.context->clipRoundedRect(RoundedRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bound.radii().bottomLeft(), bound.radii().bottomRight()));
CGContextDrawShading(context, bottomShading.get());
paintInfo.context->restore();
}
paintInfo.context->save();
CGContextClipToRect(context, bound.rect());
- paintInfo.context->addRoundedRectClip(bound);
+ paintInfo.context->clipRoundedRect(bound);
CGContextDrawShading(context, leftShading.get());
CGContextDrawShading(context, rightShading.get());
paintInfo.context->restore();
@@ -874,7 +876,7 @@ void RenderThemeSafari::adjustMenuListStyle(StyleResolver* styleResolver, Render
// Set the foreground color to black or gray when we have the aqua look.
// Cast to RGB32 is to work around a compiler bug.
- style->setColor(e && e->isEnabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
+ style->setColor(e && !e->isDisabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
// Set the button's vertical size.
setButtonSize(style);
@@ -974,14 +976,14 @@ bool RenderThemeSafari::paintSliderTrack(RenderObject* o, const PaintInfo& paint
CGContextClipToRect(context, bounds.rect());
struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NULL };
- RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));
+ RetainPtr<CGFunctionRef> mainFunction = adoptCF(CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));
RetainPtr<CGShadingRef> mainShading;
if (o->style()->appearance() == SliderVerticalPart)
- mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().maxY()), CGPointMake(bounds.rect().maxX(), bounds.rect().maxY()), mainFunction.get(), false, false));
+ mainShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().maxY()), CGPointMake(bounds.rect().maxX(), bounds.rect().maxY()), mainFunction.get(), false, false));
else
- mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().y()), CGPointMake(bounds.rect().x(), bounds.rect().maxY()), mainFunction.get(), false, false));
+ mainShading = adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().y()), CGPointMake(bounds.rect().x(), bounds.rect().maxY()), mainFunction.get(), false, false));
- paintInfo.context->addRoundedRectClip(bounds);
+ paintInfo.context->clipRoundedRect(bounds);
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
@@ -1202,6 +1204,52 @@ bool RenderThemeSafari::paintMediaSliderThumb(RenderObject* o, const PaintInfo&
}
#endif
+#if ENABLE(METER_ELEMENT)
+void RenderThemeSafari::adjustMeterStyle(StyleResolver*, RenderStyle* style, Element*) const
+{
+ style->setBoxShadow(nullptr);
+}
+
+bool RenderThemeSafari::supportsMeter(ControlPart part) const
+{
+ switch (part) {
+ case MeterPart:
+ return true;
+ default:
+ return false;
+ }
+}
+
+IntSize RenderThemeSafari::meterSizeForBounds(const RenderMeter*, const IntRect& bounds) const
+{
+ return bounds.size();
+}
+
+bool RenderThemeSafari::paintMeter(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ // NOTE: This routine is for testing only. It should be fleshed out with a real CG-based implementation.
+ // Right now it uses a slider, with the thumb positioned at the meter point.
+ if (!renderObject->isMeter())
+ return true;
+
+ HTMLMeterElement* element = toRenderMeter(renderObject)->meterElement();
+
+ int remaining = static_cast<int>((1.0 - element->valueRatio()) * static_cast<double>(rect.size().width()));
+
+ // Draw the background
+ paintSliderTrack(renderObject, paintInfo, rect);
+
+ // Draw the progress portion
+ IntRect completedRect(rect);
+ completedRect.contract(remaining, 0);
+
+ paintSliderThumb(renderObject, paintInfo, completedRect);
+
+ return true;
+}
+
+#endif
+
} // namespace WebCore
#endif // #if USE(SAFARI_THEME)