#import "config.h"
#import "core/rendering/RenderThemeChromiumMac.h"
-#import "CSSValueKeywords.h"
-#import "HTMLNames.h"
-#import "UserAgentStyleSheets.h"
+#import "core/CSSValueKeywords.h"
+#import "core/HTMLNames.h"
+#import "core/UserAgentStyleSheets.h"
#import "core/css/CSSValueList.h"
#import "core/dom/Document.h"
#import "core/dom/Element.h"
#import "core/html/TimeRanges.h"
#import "core/html/shadow/MediaControlElements.h"
#import "core/frame/FrameView.h"
-#import "core/platform/graphics/BitmapImage.h"
-#import "core/platform/graphics/GraphicsContextStateSaver.h"
-#import "core/platform/graphics/Image.h"
-#import "core/platform/graphics/ImageBuffer.h"
-#import "core/platform/graphics/StringTruncator.h"
-#import "core/platform/graphics/cg/GraphicsContextCG.h"
-#import "core/platform/graphics/mac/ColorMac.h"
-#import "core/platform/mac/LocalCurrentGraphicsContext.h"
-#import "core/platform/mac/ThemeMac.h"
-#import "core/platform/mac/WebCoreNSCellExtras.h"
#import "core/rendering/PaintInfo.h"
#import "core/rendering/RenderLayer.h"
#import "core/rendering/RenderMedia.h"
#import "core/rendering/style/ShadowList.h"
#import "platform/LayoutTestSupport.h"
#import "platform/SharedBuffer.h"
+#import "platform/graphics/BitmapImage.h"
+#import "platform/graphics/GraphicsContextStateSaver.h"
+#import "platform/graphics/Image.h"
+#import "platform/graphics/ImageBuffer.h"
+#import "platform/mac/ColorMac.h"
+#import "platform/mac/LocalCurrentGraphicsContext.h"
+#import "platform/mac/ThemeMac.h"
+#import "platform/mac/WebCoreNSCellExtras.h"
#import "platform/text/PlatformLocale.h"
+#import "platform/text/StringTruncator.h"
#import <AvailabilityMacros.h>
#import <Carbon/Carbon.h>
#import <wtf/RetainPtr.h>
#import <wtf/StdLibExtras.h>
-using namespace std;
-
// The methods in this file are specific to the Mac OS X platform.
// We estimate the animation rate of a Mac OS X progress bar is 33 fps.
@interface WebCoreRenderThemeNotificationObserver : NSObject
{
- WebCore::RenderTheme *_theme;
+ blink::RenderTheme *_theme;
}
-- (id)initWithTheme:(WebCore::RenderTheme *)theme;
+- (id)initWithTheme:(blink::RenderTheme *)theme;
- (void)systemColorsDidChange:(NSNotification *)notification;
@end
@implementation WebCoreRenderThemeNotificationObserver
-- (id)initWithTheme:(WebCore::RenderTheme *)theme
+- (id)initWithTheme:(blink::RenderTheme *)theme
{
if (!(self = [super init]))
return nil;
void _NSDrawCarbonThemeListBox(NSRect frame, BOOL enabled, BOOL flipped, BOOL always_yes);
}
-namespace WebCore {
+namespace blink {
using namespace HTMLNames;
return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent]));
}
+Color RenderThemeChromiumMac::platformActiveSelectionForegroundColor() const
+{
+ return Color::black;
+}
+
Color RenderThemeChromiumMac::platformActiveListBoxSelectionBackgroundColor() const
{
NSColor* color = [[NSColor alternateSelectedControlColor] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
Color RenderThemeChromiumMac::platformFocusRingColor() const
{
+ static const RGBA32 oldAquaFocusRingColor = 0xFF7DADD9;
if (usesTestModeFocusRingColor())
- return oldAquaFocusRingColor();
+ return oldAquaFocusRingColor;
return systemColor(CSSValueWebkitFocusRingColor);
}
cachedDesc->firstFamily().setFamily([font webCoreFamilyName]);
cachedDesc->setSpecifiedSize([font pointSize]);
cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font]));
- cachedDesc->setItalic([fontManager traitsOfFont:font] & NSItalicFontMask);
+ cachedDesc->setStyle([fontManager traitsOfFont:font] & NSItalicFontMask ? FontStyleItalic : FontStyleNormal);
}
fontDescription = *cachedDesc;
}
}
Color color;
+ bool needsFallback = false;
switch (cssValueId) {
case CSSValueActiveborder:
color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]);
break;
case CSSValueBackground:
// Use theme independent default
+ needsFallback = true;
break;
case CSSValueButtonface:
// We use this value instead of NSColor's controlColor to avoid website incompatibilities.
color = convertNSColorToColor([NSColor windowFrameTextColor]);
break;
default:
+ needsFallback = true;
break;
}
- if (!color.isValid())
+ if (needsFallback)
color = RenderTheme::systemColor(cssValueId);
- if (color.isValid())
- m_systemColorCache.set(cssValueId, color.rgb());
+ m_systemColorCache.set(cssValueId, color.rgb());
return color;
}
-bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const
+bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const CachedUAStyle* uaStyle) const
{
- if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart || style->appearance() == ListboxPart)
- return style->border() != uaStyle.border || style->boxShadow();
+ ASSERT(uaStyle);
+ if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart)
+ return style->border() != uaStyle->border || style->boxShadow();
// FIXME: This is horrible, but there is not much else that can be done. Menu lists cannot draw properly when
// scaled. They can't really draw properly when transformed either. We can't detect the transform case at style
[cell setHighlighted:pressed];
}
-bool RenderThemeChromiumMac::controlSupportsTints(const RenderObject* o) const
-{
- // An alternate way to implement this would be to get the appropriate cell object
- // and call the private _needRedrawOnWindowChangedKeyState method. An advantage of
- // that would be that we would match AppKit behavior more closely, but a disadvantage
- // would be that we would rely on an AppKit SPI method.
-
- if (!isEnabled(o))
- return false;
-
- // Checkboxes only have tint when checked.
- if (o->style()->appearance() == CheckboxPart)
- return isChecked(o);
-
- // For now assume other controls have tint if enabled.
- return true;
-}
-
NSControlSize RenderThemeChromiumMac::controlSizeForFont(RenderStyle* style) const
{
int fontSize = style->fontSize();
style->setLineHeight(RenderStyle::initialLineHeight());
if (style->setFontDescription(fontDescription))
- style->font().update(0);
+ style->font().update(nullptr);
}
NSControlSize RenderThemeChromiumMac::controlSizeForSystemFont(RenderStyle* style) const
bool RenderThemeChromiumMac::paintCapsLockIndicator(RenderObject*, const PaintInfo& paintInfo, const IntRect& r)
{
- if (paintInfo.context->paintingDisabled())
- return true;
-
// This draws the caps lock indicator as it was done by WKDrawCapsLockIndicator.
LocalCurrentGraphicsContext localContext(paintInfo.context);
CGContextRef c = localContext.cgContext();
inflatedRect.setWidth(inflatedRect.width() / zoomLevel);
inflatedRect.setHeight(inflatedRect.height() / zoomLevel);
paintInfo.context->translate(inflatedRect.x(), inflatedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y());
}
trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size());
trackInfo.min = 0;
- trackInfo.max = numeric_limits<SInt32>::max();
+ trackInfo.max = std::numeric_limits<SInt32>::max();
trackInfo.value = lround(renderProgress->position() * nextafter(trackInfo.max, 0));
trackInfo.trackInfo.progress.phase = lround(renderProgress->animationProgress() * nextafter(progressAnimationNumFrames, 0));
trackInfo.attributes = kThemeTrackHorizontal;
trackInfo.reserved = 0;
trackInfo.filler1 = 0;
- OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size(), 1);
+ OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size());
if (!imageBuffer)
return true;
if (!renderProgress->style()->isLeftToRightDirection()) {
paintInfo.context->translate(2 * inflatedRect.x() + inflatedRect.width(), 0);
- paintInfo.context->scale(FloatSize(-1, 1));
+ paintInfo.context->scale(-1, 1);
}
- paintInfo.context->drawImageBuffer(imageBuffer.get(), inflatedRect.location());
+ paintInfo.context->drawImageBuffer(imageBuffer.get(),
+ FloatRect(inflatedRect.location(), imageBuffer->size()));
return false;
}
const int styledPopupPaddingTop = 1;
const int styledPopupPaddingBottom = 2;
-static void TopGradientInterpolate(void*, const CGFloat* inData, CGFloat* outData)
-{
- static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.4f };
- static float light[4] = { 1.0f, 1.0f, 1.0f, 0.15f };
- float a = inData[0];
- int i = 0;
- for (i = 0; i < 4; i++)
- outData[i] = (1.0f - a) * dark[i] + a * light[i];
-}
-
-static void BottomGradientInterpolate(void*, const CGFloat* inData, CGFloat* outData)
-{
- static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.0f };
- static float light[4] = { 1.0f, 1.0f, 1.0f, 0.3f };
- float a = inData[0];
- int i = 0;
- for (i = 0; i < 4; i++)
- outData[i] = (1.0f - a) * dark[i] + a * light[i];
-}
-
-static void MainGradientInterpolate(void*, const CGFloat* inData, CGFloat* outData)
-{
- static float dark[4] = { 0.0f, 0.0f, 0.0f, 0.15f };
- static float light[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
- float a = inData[0];
- int i = 0;
- for (i = 0; i < 4; i++)
- outData[i] = (1.0f - a) * dark[i] + a * light[i];
-}
-
-void RenderThemeChromiumMac::paintMenuListButtonGradients(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
-{
- if (r.isEmpty())
- return;
-
- ContextContainer cgContextContainer(paintInfo.context);
- CGContextRef context = cgContextContainer.context();
-
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
-
- RoundedRect border = o->style()->getRoundedBorderFor(r, o->view());
- int radius = border.radii().topLeft().width();
-
- CGColorSpaceRef cspace = deviceRGBColorSpaceRef();
-
- 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));
-
- 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));
-
- 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<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));
-
- {
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
- CGContextClipToRect(context, r);
- paintInfo.context->clipRoundedRect(border);
- context = cgContextContainer.context();
- CGContextDrawShading(context, mainShading.get());
- }
-
- {
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
- CGContextClipToRect(context, topGradient);
- paintInfo.context->clipRoundedRect(RoundedRect(enclosingIntRect(topGradient), border.radii().topLeft(), border.radii().topRight(), IntSize(), IntSize()));
- context = cgContextContainer.context();
- CGContextDrawShading(context, topShading.get());
- }
-
- if (!bottomGradient.isEmpty()) {
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
- CGContextClipToRect(context, bottomGradient);
- paintInfo.context->clipRoundedRect(RoundedRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), border.radii().bottomLeft(), border.radii().bottomRight()));
- context = cgContextContainer.context();
- CGContextDrawShading(context, bottomShading.get());
- }
-
- {
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
- CGContextClipToRect(context, r);
- paintInfo.context->clipRoundedRect(border);
- context = cgContextContainer.context();
- CGContextDrawShading(context, leftShading.get());
- CGContextDrawShading(context, rightShading.get());
- }
-}
-
bool RenderThemeChromiumMac::paintMenuListButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
IntRect bounds = IntRect(r.x() + o->style()->borderLeftWidth(),
r.y() + o->style()->borderTopWidth(),
r.width() - o->style()->borderLeftWidth() - o->style()->borderRightWidth(),
r.height() - o->style()->borderTopWidth() - o->style()->borderBottomWidth());
- // Draw the gradients to give the styled popup menu a button appearance
- paintMenuListButtonGradients(o, paintInfo, bounds);
-
// Since we actually know the size of the control here, we restrict the font scale to make sure the arrows will fit vertically in the bounds
- float fontScale = min(o->style()->fontSize() / baseFontSize, bounds.height() / (baseArrowHeight * 2 + baseSpaceBetweenArrows));
+ float fontScale = std::min(o->style()->fontSize() / baseFontSize, bounds.height() / (baseArrowHeight * 2 + baseSpaceBetweenArrows));
float centerY = bounds.y() + bounds.height() / 2.0f;
float arrowHeight = baseArrowHeight * fontScale;
float arrowWidth = baseArrowWidth * fontScale;
// Draw the bottom arrow
paintInfo.context->drawConvexPolygon(3, arrow2, true);
-
- Color leftSeparatorColor(0, 0, 0, 40);
- Color rightSeparatorColor(255, 255, 255, 40);
-
- // FIXME: Should the separator thickness and space be scaled up by fontScale?
- int separatorSpace = 2; // Deliberately ignores zoom since it looks nicer if it stays thin.
- int leftEdgeOfSeparator = static_cast<int>(leftEdge - arrowPaddingLeft * o->style()->effectiveZoom()); // FIXME: Round?
-
- // Draw the separator to the left of the arrows
- paintInfo.context->setStrokeThickness(1.0f); // Deliberately ignores zoom since it looks nicer if it stays thin.
- paintInfo.context->setStrokeStyle(SolidStroke);
- paintInfo.context->setStrokeColor(leftSeparatorColor);
- paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator, bounds.y()),
- IntPoint(leftEdgeOfSeparator, bounds.maxY()));
-
- paintInfo.context->setStrokeColor(rightSeparatorColor);
- paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.y()),
- IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.maxY()));
return false;
}
GraphicsContextStateSaver stateSaver(*paintInfo.context);
if (zoomLevel != 1) {
paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
FloatRect unzoomedRect(r.x(), r.y(), sliderThumbWidth, sliderThumbHeight);
if (zoomLevel != 1.0f) {
paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
+ if (!o->node())
+ return false;
Element* input = o->node()->shadowHost();
if (!input)
input = toElement(o->node());
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
bool RenderThemeChromiumMac::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
+ if (!o->node())
+ return false;
Node* input = o->node()->shadowHost();
if (!input)
input = o->node();
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+ paintInfo.context->scale(zoomLevel, zoomLevel);
paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
}
[m_search.get() setBezeled:YES];
[m_search.get() setEditable:YES];
[m_search.get() setFocusRingType:NSFocusRingTypeExterior];
+ SEL sel = @selector(setCenteredLook:);
+ if ([m_search.get() respondsToSelector:sel]) {
+ BOOL boolValue = NO;
+ NSMethodSignature* signature = [NSSearchFieldCell instanceMethodSignatureForSelector:sel];
+ NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature];
+ [invocation setTarget:m_search.get()];
+ [invocation setSelector:sel];
+ [invocation setArgument:&boolValue atIndex:2];
+ [invocation invoke];
+ }
}
return m_search.get();
String strToTruncate;
if (fileList->isEmpty()) {
- strToTruncate = locale.queryString(WebKit::WebLocalizedString::FileButtonNoFileSelectedLabel);
+ strToTruncate = locale.queryString(WebLocalizedString::FileButtonNoFileSelectedLabel);
} else if (fileList->length() == 1) {
- strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(fileList->item(0)->path())];
+ File* file = fileList->item(0);
+ if (file->userVisibility() == File::IsUserVisible)
+ strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(fileList->item(0)->path())];
+ else
+ strToTruncate = file->name();
} else {
// FIXME: Localization of fileList->length().
- return StringTruncator::rightTruncate(locale.queryString(WebKit::WebLocalizedString::MultipleFileUploadText, String::number(fileList->length())), width, font, StringTruncator::EnableRoundingHacks);
+ return StringTruncator::rightTruncate(locale.queryString(WebLocalizedString::MultipleFileUploadText, String::number(fileList->length())), width, font);
}
- return StringTruncator::centerTruncate(strToTruncate, width, font, StringTruncator::EnableRoundingHacks);
+ return StringTruncator::centerTruncate(strToTruncate, width, font);
}
NSView* FlippedView()
RenderTheme& RenderTheme::theme()
{
- static RenderTheme* renderTheme = RenderThemeChromiumMac::create().leakRef();
+ DEFINE_STATIC_REF(RenderTheme, renderTheme, (RenderThemeChromiumMac::create()));
return *renderTheme;
}
bool RenderThemeChromiumMac::usesTestModeFocusRingColor() const
{
- return isRunningLayoutTest();
+ return LayoutTestSupport::isRunningLayoutTest();
}
NSView* RenderThemeChromiumMac::documentViewFor(RenderObject*) const
return RenderMediaControls::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect);
}
+bool RenderThemeChromiumMac::paintMediaOverlayPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ return RenderMediaControls::paintMediaControlsPart(MediaOverlayPlayButton, object, paintInfo, rect);
+}
+
bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
return RenderMediaControls::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect);
String RenderThemeChromiumMac::extraDefaultStyleSheet()
{
return RenderTheme::extraDefaultStyleSheet() +
- String(themeChromiumUserAgentStyleSheet, sizeof(themeChromiumUserAgentStyleSheet));
+ String(themeChromiumCss, sizeof(themeChromiumCss)) +
+ String(themeInputMultipleFieldsCss, sizeof(themeInputMultipleFieldsCss)) +
+ String(themeMacCss, sizeof(themeMacCss));
}
bool RenderThemeChromiumMac::paintMediaVolumeSliderContainer(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
return false;
}
-} // namespace WebCore
+} // namespace blink