diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-06 20:27:06 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-06 20:27:06 +0000 |
commit | c1d30c3b23ee24c2932a94ba19089d404822b4c1 (patch) | |
tree | 581c61373ef275a6321745aa00707a63c78d26c0 | |
parent | 8c46a646092ee205bf10312e9d5f1eac822a3a59 (diff) | |
download | chromium_src-c1d30c3b23ee24c2932a94ba19089d404822b4c1.zip chromium_src-c1d30c3b23ee24c2932a94ba19089d404822b4c1.tar.gz chromium_src-c1d30c3b23ee24c2932a94ba19089d404822b4c1.tar.bz2 |
port RenderTheme
Review URL: http://codereview.chromium.org/6280
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2895 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/pending/RenderThemeMac.h | 21 | ||||
-rw-r--r-- | webkit/port/rendering/RenderThemeMac.mm | 638 |
2 files changed, 514 insertions, 145 deletions
diff --git a/webkit/pending/RenderThemeMac.h b/webkit/pending/RenderThemeMac.h index f6fe7fe..19f424a 100644 --- a/webkit/pending/RenderThemeMac.h +++ b/webkit/pending/RenderThemeMac.h @@ -24,6 +24,7 @@ #define RenderThemeMac_h #import "RenderTheme.h" +#import <wtf/HashMap.h> #import <wtf/RetainPtr.h> #ifdef __OBJC__ @@ -44,7 +45,7 @@ public: // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of // controls that need to do this. - virtual short baselinePosition(const RenderObject*) const; + virtual int baselinePosition(const RenderObject*) const; // A method asking if the control changes its tint when the window has focus or not. virtual bool controlSupportsTints(const RenderObject*) const; @@ -55,16 +56,16 @@ public: virtual void adjustRepaintRect(const RenderObject*, IntRect&); virtual bool isControlStyled(const RenderStyle*, const BorderData&, - const BackgroundLayer&, const Color& backgroundColor) const; - - virtual void paintResizeControl(GraphicsContext*, const IntRect&); + const FillLayer&, const Color& backgroundColor) const; virtual Color platformActiveSelectionBackgroundColor() const; virtual Color platformInactiveSelectionBackgroundColor() const; virtual Color activeListBoxSelectionBackgroundColor() const; + + virtual void platformColorsDidChange(); // System fonts. - virtual void systemFont(int cssValueId, Document*, FontDescription&) const; + virtual void systemFont(int cssValueId, Document* document, FontDescription&) const; virtual int minimumMenuListSize(RenderStyle*) const; @@ -77,6 +78,8 @@ public: virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); + virtual Color systemColor(int cssValueId) const; + protected: // Methods for each appearance value. virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); @@ -131,12 +134,12 @@ protected: virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); private: - IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const; + IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const; // Get the control size based off the font. Used by some of the controls (like buttons). NSControlSize controlSizeForFont(RenderStyle*) const; NSControlSize controlSizeForSystemFont(RenderStyle*) const; - void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize); + void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const; IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const; @@ -182,7 +185,6 @@ private: NSMenu* searchMenuTemplate() const; NSSliderCell* sliderThumbHorizontal() const; NSSliderCell* sliderThumbVertical() const; - Image* resizeCornerImage() const; private: mutable RetainPtr<NSButtonCell> m_checkbox; @@ -193,11 +195,12 @@ private: mutable RetainPtr<NSMenu> m_searchMenuTemplate; mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal; mutable RetainPtr<NSSliderCell> m_sliderThumbVertical; - mutable Image* m_resizeCornerImage; bool m_isSliderThumbHorizontalPressed; bool m_isSliderThumbVerticalPressed; + mutable HashMap<int, RGBA32> m_systemColorCache; + RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; }; diff --git a/webkit/port/rendering/RenderThemeMac.mm b/webkit/port/rendering/RenderThemeMac.mm index e44862f..6abe73f 100644 --- a/webkit/port/rendering/RenderThemeMac.mm +++ b/webkit/port/rendering/RenderThemeMac.mm @@ -43,6 +43,7 @@ #import <math.h> #ifdef BUILDING_ON_TIGER +typedef int NSInteger; typedef unsigned NSUInteger; #endif @@ -50,8 +51,7 @@ using std::min; // The methods in this file are specific to the Mac OS X platform. -// FIXME: The platform-independent code in this class should be factored out and -// merged with RenderThemeSafari. +// FIXME: The platform-independent code in this class should be factored out and merged with RenderThemeSafari. @interface WebCoreRenderThemeNotificationObserver : NSObject { @@ -106,8 +106,7 @@ RenderTheme* theme() } RenderThemeMac::RenderThemeMac() - : m_resizeCornerImage(0) - , m_isSliderThumbHorizontalPressed(false) + : m_isSliderThumbHorizontalPressed(false) , m_isSliderThumbVerticalPressed(false) , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver alloc] initWithTheme:this]) { @@ -120,7 +119,6 @@ RenderThemeMac::RenderThemeMac() RenderThemeMac::~RenderThemeMac() { [[NSNotificationCenter defaultCenter] removeObserver:m_notificationObserver.get()]; - delete m_resizeCornerImage; } Color RenderThemeMac::platformActiveSelectionBackgroundColor() const @@ -141,7 +139,34 @@ Color RenderThemeMac::activeListBoxSelectionBackgroundColor() const return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent])); } -void RenderThemeMac::systemFont(int cssValueId, Document*, FontDescription& fontDescription) const +static FontWeight toFontWeight(NSInteger appKitFontWeight) +{ + ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15); + if (appKitFontWeight > 14) + appKitFontWeight = 14; + else if (appKitFontWeight < 1) + appKitFontWeight = 1; + + static FontWeight fontWeights[] = { + FontWeight100, + FontWeight100, + FontWeight200, + FontWeight300, + FontWeight400, + FontWeight500, + FontWeight600, + FontWeight600, + FontWeight700, + FontWeight800, + FontWeight800, + FontWeight900, + FontWeight900, + FontWeight900 + }; + return fontWeights[appKitFontWeight - 1]; +} + +void RenderThemeMac::systemFont(int cssValueId, Document* document, FontDescription& fontDescription) const { static FontDescription systemFont; static FontDescription smallSystemFont; @@ -154,32 +179,32 @@ void RenderThemeMac::systemFont(int cssValueId, Document*, FontDescription& font FontDescription* cachedDesc; NSFont* font = nil; switch (cssValueId) { - case CSS_VAL_SMALL_CAPTION: + case CSSValueSmallCaption: cachedDesc = &smallSystemFont; if (!smallSystemFont.isAbsoluteSize()) font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; break; - case CSS_VAL_MENU: + case CSSValueMenu: cachedDesc = &menuFont; if (!menuFont.isAbsoluteSize()) font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; break; - case CSS_VAL_STATUS_BAR: + case CSSValueStatusBar: cachedDesc = &labelFont; if (!labelFont.isAbsoluteSize()) font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; break; - case CSS_VAL__WEBKIT_MINI_CONTROL: + case CSSValueWebkitMiniControl: cachedDesc = &miniControlFont; if (!miniControlFont.isAbsoluteSize()) font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]; break; - case CSS_VAL__WEBKIT_SMALL_CONTROL: + case CSSValueWebkitSmallControl: cachedDesc = &smallControlFont; if (!smallControlFont.isAbsoluteSize()) font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; break; - case CSS_VAL__WEBKIT_CONTROL: + case CSSValueWebkitControl: cachedDesc = &controlFont; if (!controlFont.isAbsoluteSize()) font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; @@ -191,34 +216,213 @@ void RenderThemeMac::systemFont(int cssValueId, Document*, FontDescription& font } if (font) { + NSFontManager *fontManager = [NSFontManager sharedFontManager]; cachedDesc->setIsAbsoluteSize(true); cachedDesc->setGenericFamily(FontDescription::NoFamily); cachedDesc->firstFamily().setFamily([font familyName]); cachedDesc->setSpecifiedSize([font pointSize]); - NSFontTraitMask traits = [[NSFontManager sharedFontManager] traitsOfFont:font]; - cachedDesc->setBold(traits & NSBoldFontMask); - cachedDesc->setItalic(traits & NSItalicFontMask); + cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); + cachedDesc->setItalic([fontManager traitsOfFont:font] & NSItalicFontMask); } fontDescription = *cachedDesc; } +static RGBA32 convertNSColorToColor(NSColor *color) +{ + NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + if (colorInColorSpace) { + static const double scaleFactor = nextafter(256.0, 0.0); + return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComponent]), + static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), + static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); + } + + // This conversion above can fail if the NSColor in question is an NSPatternColor + // (as many system colors are). These colors are actually a repeating pattern + // not just a solid color. To work around this we simply draw a 1x1 image of + // the color and use that pixel's color. It might be better to use an average of + // the colors in the pattern instead. + NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil + pixelsWide:1 + pixelsHigh:1 + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bytesPerRow:4 + bitsPerPixel:32]; + + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]]; + NSEraseRect(NSMakeRect(0, 0, 1, 1)); + [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)]; + [NSGraphicsContext restoreGraphicsState]; + + NSUInteger pixel[4]; + [offscreenRep getPixel:pixel atX:0 y:0]; + + [offscreenRep release]; + + return makeRGB(pixel[0], pixel[1], pixel[2]); +} + +static RGBA32 menuBackgroundColor() +{ + NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil + pixelsWide:1 + pixelsHigh:1 + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bytesPerRow:4 + bitsPerPixel:32]; + + CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep] graphicsPort]); + CGRect rect = CGRectMake(0, 0, 1, 1); + HIThemeMenuDrawInfo drawInfo; + drawInfo.version = 0; + drawInfo.menuType = kThemeMenuTypePopUp; + HIThemeDrawMenuBackground(&rect, &drawInfo, context, kHIThemeOrientationInverted); + + NSUInteger pixel[4]; + [offscreenRep getPixel:pixel atX:0 y:0]; + + [offscreenRep release]; + + return makeRGB(pixel[0], pixel[1], pixel[2]); +} + +void RenderThemeMac::platformColorsDidChange() +{ + m_systemColorCache.clear(); + RenderTheme::platformColorsDidChange(); +} + +Color RenderThemeMac::systemColor(int cssValueId) const +{ + if (m_systemColorCache.contains(cssValueId)) + return m_systemColorCache.get(cssValueId); + + Color color; + switch (cssValueId) { + case CSSValueActiveborder: + color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]); + break; + case CSSValueActivecaption: + color = convertNSColorToColor([NSColor windowFrameTextColor]); + break; + case CSSValueAppworkspace: + color = convertNSColorToColor([NSColor headerColor]); + break; + case CSSValueBackground: + // Use theme independent default + break; + case CSSValueButtonface: + // We use this value instead of NSColor's controlColor to avoid website incompatibilities. + // We may want to change this to use the NSColor in future. + color = 0xFFC0C0C0; + break; + case CSSValueButtonhighlight: + color = convertNSColorToColor([NSColor controlHighlightColor]); + break; + case CSSValueButtonshadow: + color = convertNSColorToColor([NSColor controlShadowColor]); + break; + case CSSValueButtontext: + color = convertNSColorToColor([NSColor controlTextColor]); + break; + case CSSValueCaptiontext: + color = convertNSColorToColor([NSColor textColor]); + break; + case CSSValueGraytext: + color = convertNSColorToColor([NSColor disabledControlTextColor]); + break; + case CSSValueHighlight: + color = convertNSColorToColor([NSColor selectedTextBackgroundColor]); + break; + case CSSValueHighlighttext: + color = convertNSColorToColor([NSColor selectedTextColor]); + break; + case CSSValueInactiveborder: + color = convertNSColorToColor([NSColor controlBackgroundColor]); + break; + case CSSValueInactivecaption: + color = convertNSColorToColor([NSColor controlBackgroundColor]); + break; + case CSSValueInactivecaptiontext: + color = convertNSColorToColor([NSColor textColor]); + break; + case CSSValueInfobackground: + // There is no corresponding NSColor for this so we use a hard coded value. + color = 0xFFFBFCC5; + break; + case CSSValueInfotext: + color = convertNSColorToColor([NSColor textColor]); + break; + case CSSValueMenu: + color = menuBackgroundColor(); + break; + case CSSValueMenutext: + color = convertNSColorToColor([NSColor selectedMenuItemTextColor]); + break; + case CSSValueScrollbar: + color = convertNSColorToColor([NSColor scrollBarColor]); + break; + case CSSValueText: + color = convertNSColorToColor([NSColor textColor]); + break; + case CSSValueThreeddarkshadow: + color = convertNSColorToColor([NSColor controlDarkShadowColor]); + break; + case CSSValueThreedshadow: + color = convertNSColorToColor([NSColor shadowColor]); + break; + case CSSValueThreedface: + // We use this value instead of NSColor's controlColor to avoid website incompatibilities. + // We may want to change this to use the NSColor in future. + color = 0xFFC0C0C0; + break; + case CSSValueThreedhighlight: + color = convertNSColorToColor([NSColor highlightColor]); + break; + case CSSValueThreedlightshadow: + color = convertNSColorToColor([NSColor controlLightHighlightColor]); + break; + case CSSValueWindow: + color = convertNSColorToColor([NSColor windowBackgroundColor]); + break; + case CSSValueWindowframe: + color = convertNSColorToColor([NSColor windowFrameColor]); + break; + case CSSValueWindowtext: + color = convertNSColorToColor([NSColor windowFrameTextColor]); + break; + } + + if (!color.isValid()) + color = RenderTheme::systemColor(cssValueId); + + if (color.isValid()) + m_systemColorCache.set(cssValueId, color.rgb()); + + return color; +} + bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData& border, - const BackgroundLayer& background, const Color& backgroundColor) const + const FillLayer& background, const Color& backgroundColor) const { if (style->appearance() == TextFieldAppearance || style->appearance() == TextAreaAppearance || style->appearance() == ListboxAppearance) return style->border() != border; return RenderTheme::isControlStyled(style, border, background, backgroundColor); } -void RenderThemeMac::paintResizeControl(GraphicsContext* c, const IntRect& r) -{ - Image* resizeCornerImage = this->resizeCornerImage(); - IntPoint imagePoint(r.right() - resizeCornerImage->width(), r.bottom() - resizeCornerImage->height()); - c->drawImage(resizeCornerImage, imagePoint); -} - void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) { + float zoomLevel = o->style()->effectiveZoom(); + switch (o->style()->appearance()) { case CheckboxAppearance: { // Since we query the prototype cell, we need to update its state to match. @@ -226,7 +430,10 @@ void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - r = inflateRect(r, checkboxSizes()[[checkbox() controlSize]], checkboxMargins()); + IntSize size = checkboxSizes()[[checkbox() controlSize]]; + size.setHeight(size.height() * zoomLevel); + size.setWidth(size.width() * zoomLevel); + r = inflateRect(r, size, checkboxMargins(), zoomLevel); break; } case RadioAppearance: { @@ -235,23 +442,34 @@ void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - r = inflateRect(r, radioSizes()[[radio() controlSize]], radioMargins()); + IntSize size = radioSizes()[[radio() controlSize]]; + size.setHeight(size.height() * zoomLevel); + size.setWidth(size.width() * zoomLevel); + r = inflateRect(r, size, radioMargins(), zoomLevel); break; } case PushButtonAppearance: + case DefaultButtonAppearance: case ButtonAppearance: { // Since we query the prototype cell, we need to update its state to match. setButtonCellState(o, r); // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - if ([button() bezelStyle] == NSRoundedBezelStyle) - r = inflateRect(r, buttonSizes()[[button() controlSize]], buttonMargins()); + if ([button() bezelStyle] == NSRoundedBezelStyle) { + IntSize size = buttonSizes()[[button() controlSize]]; + size.setHeight(size.height() * zoomLevel); + size.setWidth(r.width()); + r = inflateRect(r, size, buttonMargins(), zoomLevel); + } break; } case MenulistAppearance: { setPopupButtonCellState(o, r); - r = inflateRect(r, popupButtonSizes()[[popupButton() controlSize]], popupButtonMargins()); + IntSize size = popupButtonSizes()[[popupButton() controlSize]]; + size.setHeight(size.height() * zoomLevel); + size.setWidth(r.width()); + r = inflateRect(r, size, popupButtonMargins(), zoomLevel); break; } default: @@ -259,19 +477,19 @@ void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) } } -IntRect RenderThemeMac::inflateRect(const IntRect& r, const IntSize& size, const int* margins) const +IntRect RenderThemeMac::inflateRect(const IntRect& r, const IntSize& size, const int* margins, float zoomLevel) const { // Only do the inflation if the available width/height are too small. Otherwise try to // fit the glow/check space into the available box's width/height. - int widthDelta = r.width() - (size.width() + margins[leftMargin] + margins[rightMargin]); - int heightDelta = r.height() - (size.height() + margins[topMargin] + margins[bottomMargin]); + int widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel + margins[rightMargin] * zoomLevel); + int heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLevel + margins[bottomMargin] * zoomLevel); IntRect result(r); if (widthDelta < 0) { - result.setX(result.x() - margins[leftMargin]); + result.setX(result.x() - margins[leftMargin] * zoomLevel); result.setWidth(result.width() - widthDelta); } if (heightDelta < 0) { - result.setY(result.y() - margins[topMargin]); + result.setY(result.y() - margins[topMargin] * zoomLevel); result.setHeight(result.height() - heightDelta); } return result; @@ -317,10 +535,10 @@ void RenderThemeMac::updatePressedState(NSCell* cell, const RenderObject* o) [cell setHighlighted:pressed]; } -short RenderThemeMac::baselinePosition(const RenderObject* o) const +int RenderThemeMac::baselinePosition(const RenderObject* o) const { if (o->style()->appearance() == CheckboxAppearance || o->style()->appearance() == RadioAppearance) - return o->marginTop() + o->height() - 2; // The baseline is 2px up from the bottom of the checkbox/radio in AppKit. + return o->marginTop() + o->height() - 2 * o->style()->effectiveZoom(); // The baseline is 2px up from the bottom of the checkbox/radio in AppKit. return RenderTheme::baselinePosition(o); } @@ -352,14 +570,14 @@ NSControlSize RenderThemeMac::controlSizeForFont(RenderStyle* style) const return NSMiniControlSize; } -void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize) +void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minSize, float zoomLevel) { NSControlSize size; - if (minSize.width() >= sizes[NSRegularControlSize].width() && - minSize.height() >= sizes[NSRegularControlSize].height()) + if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomLevel) && + minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomLevel)) size = NSRegularControlSize; - else if (minSize.width() >= sizes[NSSmallControlSize].width() && - minSize.height() >= sizes[NSSmallControlSize].height()) + else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomLevel) && + minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomLevel)) size = NSSmallControlSize; else size = NSMiniControlSize; @@ -369,11 +587,19 @@ void RenderThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const In IntSize RenderThemeMac::sizeForFont(RenderStyle* style, const IntSize* sizes) const { + if (style->effectiveZoom() != 1.0f) { + IntSize result = sizes[controlSizeForFont(style)]; + return IntSize(result.width() * style->effectiveZoom(), result.height() * style->effectiveZoom()); + } return sizes[controlSizeForFont(style)]; } IntSize RenderThemeMac::sizeForSystemFont(RenderStyle* style, const IntSize* sizes) const { + if (style->effectiveZoom() != 1.0f) { + IntSize result = sizes[controlSizeForSystemFont(style)]; + return IntSize(result.width() * style->effectiveZoom(), result.height() * style->effectiveZoom()); + } return sizes[controlSizeForSystemFont(style)]; } @@ -395,8 +621,8 @@ void RenderThemeMac::setFontFromControlSize(CSSStyleSelector* selector, RenderSt NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]]; fontDescription.firstFamily().setFamily([font familyName]); - fontDescription.setComputedSize([font pointSize]); - fontDescription.setSpecifiedSize([font pointSize]); + fontDescription.setComputedSize([font pointSize] * style->effectiveZoom()); + fontDescription.setSpecifiedSize([font pointSize] * style->effectiveZoom()); // Reset line height style->setLineHeight(RenderStyle::initialLineHeight()); @@ -415,22 +641,37 @@ NSControlSize RenderThemeMac::controlSizeForSystemFont(RenderStyle* style) const return NSMiniControlSize; } -bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r) +bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { - struct HIThemeButtonDrawInfo button_info = { - 0, kThemeStateActive, kThemeCheckBox, 0, kThemeAdornmentNone, { 0 } - }; - // Determine the width and height needed for the control and prepare the cell for painting. - setCheckboxCellState(o, r); - // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox - // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - IntRect inflatedRect = inflateRect(r, checkboxSizes()[NSSmallControlSize], checkboxMargins()); - // draw the button - HIRect bounds = { { inflatedRect.x(), inflatedRect.y() }, { inflatedRect.width(), inflatedRect.height() } }; - HIRect label = { { 0, 0 }, { 0, 0 } }; - HIThemeDrawButton(&bounds, &button_info, static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), kHIThemeOrientationNormal, &label); + // Determine the width and height needed for the control and prepare the cell for painting. + setCheckboxCellState(o, r); + + paintInfo.context->save(); - return false; + float zoomLevel = o->style()->effectiveZoom(); + + // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox + // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. + NSButtonCell* checkbox = this->checkbox(); + IntSize size = checkboxSizes()[[checkbox controlSize]]; + size.setWidth(size.width() * zoomLevel); + size.setHeight(size.height() * zoomLevel); + IntRect inflatedRect = inflateRect(r, size, checkboxMargins(), zoomLevel); + + if (zoomLevel != 1.0f) { + 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->translate(-inflatedRect.x(), -inflatedRect.y()); + } + + [checkbox drawWithFrame:NSRect(inflatedRect) inView:o->view()->frameView()->documentView()]; + [checkbox setControlView:nil]; + + paintInfo.context->restore(); + + return false; } const IntSize* RenderThemeMac::checkboxSizes() const @@ -455,7 +696,7 @@ void RenderThemeMac::setCheckboxCellState(const RenderObject* o, const IntRect& NSButtonCell* checkbox = this->checkbox(); // Set the control size based off the rectangle we're painting into. - setControlSize(checkbox, checkboxSizes(), r.size()); + setControlSize(checkbox, checkboxSizes(), r.size(), o->style()->effectiveZoom()); // Update the various states we respond to. updateCheckedState(checkbox, o); @@ -474,22 +715,37 @@ void RenderThemeMac::setCheckboxSize(RenderStyle* style) const setSizeFromFont(style, checkboxSizes()); } -bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r) +bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { - struct HIThemeButtonDrawInfo button_info = { - 0, kThemeStateActive, kThemeRadioButton, 0, kThemeAdornmentNone, { 0 } - }; - // Determine the width and height needed for the control and prepare the cell for painting. - setRadioCellState(o, r); - // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox - // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - IntRect inflatedRect = inflateRect(r, radioSizes()[NSSmallControlSize], radioMargins()); - // draw the button - HIRect bounds = { { inflatedRect.x(), inflatedRect.y() }, { inflatedRect.width(), inflatedRect.height() } }; - HIRect label = { { 0, 0 }, { 0, 0 } }; - HIThemeDrawButton(&bounds, &button_info, static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), kHIThemeOrientationNormal, &label); - - return false; + // Determine the width and height needed for the control and prepare the cell for painting. + setRadioCellState(o, r); + + paintInfo.context->save(); + + float zoomLevel = o->style()->effectiveZoom(); + + // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox + // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. + NSButtonCell* radio = this->radio(); + IntSize size = radioSizes()[[radio controlSize]]; + size.setWidth(size.width() * zoomLevel); + size.setHeight(size.height() * zoomLevel); + IntRect inflatedRect = inflateRect(r, size, radioMargins(), zoomLevel); + + if (zoomLevel != 1.0f) { + 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->translate(-inflatedRect.x(), -inflatedRect.y()); + } + + [radio drawWithFrame:NSRect(inflatedRect) inView:o->view()->frameView()->documentView()]; + [radio setControlView:nil]; + + paintInfo.context->restore(); + + return false; } const IntSize* RenderThemeMac::radioSizes() const @@ -514,7 +770,7 @@ void RenderThemeMac::setRadioCellState(const RenderObject* o, const IntRect& r) NSButtonCell* radio = this->radio(); // Set the control size based off the rectangle we're painting into. - setControlSize(radio, radioSizes(), r.size()); + setControlSize(radio, radioSizes(), r.size(), o->style()->effectiveZoom()); // Update the various states we respond to. updateCheckedState(radio, o); @@ -541,7 +797,7 @@ void RenderThemeMac::setButtonPaddingFromControlSize(RenderStyle* style, NSContr // by definition constrained, since we select mini only for small cramped environments. // This also guarantees the HTML4 <button> will match our rendering by default, since we're using a consistent // padding. - const int padding = 8; + const int padding = 8 * style->effectiveZoom(); style->setPaddingLeft(Length(padding, Fixed)); style->setPaddingRight(Length(padding, Fixed)); style->setPaddingTop(Length(0, Fixed)); @@ -584,7 +840,7 @@ void RenderThemeMac::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* setFontFromControlSize(selector, style, controlSize); } else { // Set a min-height so that we can't get smaller than the mini button. - style->setMinHeight(Length(15, Fixed)); + style->setMinHeight(Length(static_cast<int>(15 * style->effectiveZoom()), Fixed)); // Reset the top and bottom borders. style->resetBorderTop(); @@ -627,14 +883,18 @@ void RenderThemeMac::setButtonCellState(const RenderObject* o, const IntRect& r) // Set the control size based off the rectangle we're painting into. if (o->style()->appearance() == SquareButtonAppearance || - r.height() > buttonSizes()[NSRegularControlSize].height()) { + r.height() > buttonSizes()[NSRegularControlSize].height() * o->style()->effectiveZoom()) { // Use the square button if ([button bezelStyle] != NSShadowlessSquareBezelStyle) [button setBezelStyle:NSShadowlessSquareBezelStyle]; } else if ([button bezelStyle] != NSRoundedBezelStyle) [button setBezelStyle:NSRoundedBezelStyle]; - setControlSize(button, buttonSizes(), r.size()); + setControlSize(button, buttonSizes(), r.size(), o->style()->effectiveZoom()); + + NSWindow *window = [o->view()->frameView()->documentView() window]; + BOOL isDefaultButton = (isDefault(o) && [window isKeyWindow]); + [button setKeyEquivalent:(isDefaultButton ? @"\r" : @"")]; // Update the various states we respond to. updateCheckedState(button, o); @@ -645,20 +905,59 @@ void RenderThemeMac::setButtonCellState(const RenderObject* o, const IntRect& r) bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { - struct HIThemeButtonDrawInfo button_info = { - 0, kThemeStateActive, kThemePushButton, 0, kThemeAdornmentNone, { 0 } - }; - // Determine the width and height needed for the control and prepare the cell for painting. - setButtonCellState(o, r); - // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox - // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. - IntRect inflatedRect = inflateRect(r, radioSizes()[NSSmallControlSize], radioMargins()); - // draw the button - HIRect bounds = { { inflatedRect.x(), inflatedRect.y() }, { inflatedRect.width(), inflatedRect.height() } }; - HIRect label = { { 0, 0 }, { 0, 0 } }; - HIThemeDrawButton(&bounds, &button_info, static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), kHIThemeOrientationNormal, &label); + NSButtonCell* button = this->button(); + LocalCurrentGraphicsContext localContext(paintInfo.context); + + // Determine the width and height needed for the control and prepare the cell for painting. + setButtonCellState(o, r); + + paintInfo.context->save(); + + // We inflate the rect as needed to account for padding included in the cell to accommodate the button + // shadow. We don't consider this part of the bounds of the control in WebKit. + float zoomLevel = o->style()->effectiveZoom(); + IntSize size = buttonSizes()[[button controlSize]]; + size.setWidth(r.width()); + size.setHeight(size.height() * zoomLevel); + IntRect inflatedRect = r; + if ([button bezelStyle] == NSRoundedBezelStyle) { + // Center the button within the available space. + if (inflatedRect.height() > size.height()) { + inflatedRect.setY(inflatedRect.y() + (inflatedRect.height() - size.height()) / 2); + inflatedRect.setHeight(size.height()); + } - return false; + // Now inflate it to account for the shadow. + inflatedRect = inflateRect(inflatedRect, size, buttonMargins(), zoomLevel); + + if (zoomLevel != 1.0f) { + 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->translate(-inflatedRect.x(), -inflatedRect.y()); + } + } + + NSView *view = o->view()->frameView()->documentView(); + NSWindow *window = [view window]; + NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell]; + + if (isDefault(o) && [window isKeyWindow]) { + [window setDefaultButtonCell:button]; + wkAdvanceDefaultButtonPulseAnimation(button); + } else if ([previousDefaultButtonCell isEqual:button]) + [window setDefaultButtonCell:nil]; + + [button drawWithFrame:NSRect(inflatedRect) inView:view]; + [button setControlView:nil]; + + if (![previousDefaultButtonCell isEqual:button]) + [window setDefaultButtonCell:previousDefaultButtonCell]; + + paintInfo.context->restore(); + + return false; } bool RenderThemeMac::paintTextField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) @@ -728,26 +1027,35 @@ bool RenderThemeMac::paintMenuList(RenderObject* o, const RenderObject::PaintInf NSPopUpButtonCell* popupButton = this->popupButton(); - IntRect inflatedRect = r; + float zoomLevel = o->style()->effectiveZoom(); IntSize size = popupButtonSizes()[[popupButton controlSize]]; + size.setHeight(size.height() * zoomLevel); size.setWidth(r.width()); // Now inflate it to account for the shadow. + IntRect inflatedRect = r; if (r.width() >= minimumMenuListSize(o->style())) - inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins()); + inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel); + paintInfo.context->save(); + #ifndef BUILDING_ON_TIGER // On Leopard, the cell will draw outside of the given rect, so we have to clip to the rect - paintInfo.context->save(); paintInfo.context->clip(inflatedRect); #endif -// [popupButton drawWithFrame:inflatedRect inView:o->view()->frameView()->getDocumentView()]; + if (zoomLevel != 1.0f) { + 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->translate(-inflatedRect.x(), -inflatedRect.y()); + } + + [popupButton drawWithFrame:inflatedRect inView:o->view()->frameView()->documentView()]; [popupButton setControlView:nil]; -#ifndef BUILDING_ON_TIGER paintInfo.context->restore(); -#endif return false; } @@ -883,10 +1191,10 @@ bool RenderThemeMac::paintMenuListButton(RenderObject* o, const RenderObject::Pa float centerY = bounds.y() + bounds.height() / 2.0f; float arrowHeight = baseArrowHeight * fontScale; float arrowWidth = baseArrowWidth * fontScale; - float leftEdge = bounds.right() - arrowPaddingRight - arrowWidth; + float leftEdge = bounds.right() - arrowPaddingRight * o->style()->effectiveZoom() - arrowWidth; float spaceBetweenArrows = baseSpaceBetweenArrows * fontScale; - if (bounds.width() < arrowWidth + arrowPaddingLeft) + if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZoom()) return false; paintInfo.context->setFillColor(o->style()->color()); @@ -912,11 +1220,11 @@ bool RenderThemeMac::paintMenuListButton(RenderObject* o, const RenderObject::Pa Color rightSeparatorColor(255, 255, 255, 40); // FIXME: Should the separator thickness and space be scaled up by fontScale? - int separatorSpace = 2; - int leftEdgeOfSeparator = static_cast<int>(leftEdge - arrowPaddingLeft); // FIXME: Round? + 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); + 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()), @@ -961,20 +1269,20 @@ void RenderThemeMac::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle int RenderThemeMac::popupInternalPaddingLeft(RenderStyle* style) const { if (style->appearance() == MenulistAppearance) - return popupButtonPadding(controlSizeForFont(style))[leftPadding]; + return popupButtonPadding(controlSizeForFont(style))[leftPadding] * style->effectiveZoom(); if (style->appearance() == MenulistButtonAppearance) - return styledPopupPaddingLeft; + return styledPopupPaddingLeft * style->effectiveZoom(); return 0; } int RenderThemeMac::popupInternalPaddingRight(RenderStyle* style) const { if (style->appearance() == MenulistAppearance) - return popupButtonPadding(controlSizeForFont(style))[rightPadding]; + return popupButtonPadding(controlSizeForFont(style))[rightPadding] * style->effectiveZoom(); if (style->appearance() == MenulistButtonAppearance) { float fontScale = style->fontSize() / baseFontSize; float arrowWidth = baseArrowWidth * fontScale; - return static_cast<int>(ceilf(arrowWidth + arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator)); + return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator) * style->effectiveZoom())); } return 0; } @@ -982,18 +1290,18 @@ int RenderThemeMac::popupInternalPaddingRight(RenderStyle* style) const int RenderThemeMac::popupInternalPaddingTop(RenderStyle* style) const { if (style->appearance() == MenulistAppearance) - return popupButtonPadding(controlSizeForFont(style))[topPadding]; + return popupButtonPadding(controlSizeForFont(style))[topPadding] * style->effectiveZoom(); if (style->appearance() == MenulistButtonAppearance) - return styledPopupPaddingTop; + return styledPopupPaddingTop * style->effectiveZoom(); return 0; } int RenderThemeMac::popupInternalPaddingBottom(RenderStyle* style) const { if (style->appearance() == MenulistAppearance) - return popupButtonPadding(controlSizeForFont(style))[bottomPadding]; + return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * style->effectiveZoom(); if (style->appearance() == MenulistButtonAppearance) - return styledPopupPaddingBottom; + return styledPopupPaddingBottom * style->effectiveZoom(); return 0; } @@ -1015,7 +1323,7 @@ void RenderThemeMac::setPopupButtonCellState(const RenderObject* o, const IntRec NSPopUpButtonCell* popupButton = this->popupButton(); // Set the control size based off the rectangle we're painting into. - setControlSize(popupButton, popupButtonSizes(), r.size()); + setControlSize(popupButton, popupButtonSizes(), r.size(), o->style()->effectiveZoom()); // Update the various states we respond to. updateCheckedState(popupButton, o); @@ -1046,13 +1354,15 @@ void RenderThemeMac::adjustSliderTrackStyle(CSSStyleSelector* selector, RenderSt bool RenderThemeMac::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { IntRect bounds = r; + float zoomLevel = o->style()->effectiveZoom(); + float zoomedTrackWidth = trackWidth * zoomLevel; if (o->style()->appearance() == SliderHorizontalAppearance || o->style()->appearance() == MediaSliderAppearance) { - bounds.setHeight(trackWidth); - bounds.setY(r.y() + r.height() / 2 - trackWidth / 2); + bounds.setHeight(zoomedTrackWidth); + bounds.setY(r.y() + r.height() / 2 - zoomedTrackWidth / 2); } else if (o->style()->appearance() == SliderVerticalAppearance) { - bounds.setWidth(trackWidth); - bounds.setX(r.x() + r.width() / 2 - trackWidth / 2); + bounds.setWidth(zoomedTrackWidth); + bounds.setX(r.x() + r.width() / 2 - zoomedTrackWidth / 2); } LocalCurrentGraphicsContext localContext(paintInfo.context); @@ -1125,11 +1435,25 @@ bool RenderThemeMac::paintSliderThumb(RenderObject* o, const RenderObject::Paint FloatRect bounds = r; // Make the height of the vertical slider slightly larger so NSSliderCell will draw a vertical slider. if (o->style()->appearance() == SliderThumbVerticalAppearance) - bounds.setHeight(bounds.height() + verticalSliderHeightPadding); + bounds.setHeight(bounds.height() + verticalSliderHeightPadding * o->style()->effectiveZoom()); -// [sliderThumbCell drawWithFrame:NSRect(bounds) inView:o->view()->frameView()->getDocumentView()]; + paintInfo.context->save(); + float zoomLevel = o->style()->effectiveZoom(); + + FloatRect unzoomedRect = bounds; + if (zoomLevel != 1.0f) { + 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->translate(-unzoomedRect.x(), -unzoomedRect.y()); + } + + [sliderThumbCell drawWithFrame:unzoomedRect inView:o->view()->frameView()->documentView()]; [sliderThumbCell setControlView:nil]; + paintInfo.context->restore(); + return false; } @@ -1140,9 +1464,10 @@ const int mediaSliderThumbHeight = 14; void RenderThemeMac::adjustSliderThumbSize(RenderObject* o) const { + float zoomLevel = o->style()->effectiveZoom(); if (o->style()->appearance() == SliderThumbHorizontalAppearance || o->style()->appearance() == SliderThumbVerticalAppearance) { - o->style()->setWidth(Length(sliderThumbWidth, Fixed)); - o->style()->setHeight(Length(sliderThumbHeight, Fixed)); + o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed)); + o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed)); } else if (o->style()->appearance() == MediaSliderThumbAppearance) { o->style()->setWidth(Length(mediaSliderThumbWidth, Fixed)); o->style()->setHeight(Length(mediaSliderThumbHeight, Fixed)); @@ -1156,18 +1481,34 @@ bool RenderThemeMac::paintSearchField(RenderObject* o, const RenderObject::Paint setSearchCellState(o, r); + paintInfo.context->save(); + + float zoomLevel = o->style()->effectiveZoom(); + + IntRect unzoomedRect = r; + + if (zoomLevel != 1.0f) { + 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->translate(-unzoomedRect.x(), -unzoomedRect.y()); + } + // Set the search button to nil before drawing. Then reset it so we can draw it later. [search setSearchButtonCell:nil]; -// [search drawWithFrame:NSRect(r) inView:o->view()->frameView()->getDocumentView()]; + [search drawWithFrame:NSRect(unzoomedRect) inView:o->view()->frameView()->documentView()]; #ifdef BUILDING_ON_TIGER if ([search showsFirstResponder]) - wkDrawTextFieldCellFocusRing(search, NSRect(r)); + wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect)); #endif [search setControlView:nil]; [search resetSearchButtonCell]; + paintInfo.context->restore(); + return false; } @@ -1202,7 +1543,7 @@ void RenderThemeMac::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderSt { // Override border. style->resetBorder(); - const short borderWidth = 2; + const short borderWidth = 2 * style->effectiveZoom(); style->setBorderLeftWidth(borderWidth); style->setBorderLeftStyle(INSET); style->setBorderRightWidth(borderWidth); @@ -1217,7 +1558,7 @@ void RenderThemeMac::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderSt setSearchFieldSize(style); // Override padding size to match AppKit text positioning. - const int padding = 1; + const int padding = 1 * style->effectiveZoom(); style->setPaddingLeft(Length(padding, Fixed)); style->setPaddingRight(Length(padding, Fixed)); style->setPaddingTop(Length(padding, Fixed)); @@ -1238,10 +1579,25 @@ bool RenderThemeMac::paintSearchFieldCancelButton(RenderObject* o, const RenderO updatePressedState([search cancelButtonCell], o); + paintInfo.context->save(); + + float zoomLevel = o->style()->effectiveZoom(); + NSRect bounds = [search cancelButtonRectForBounds:NSRect(input->renderer()->absoluteBoundingBoxRect())]; -// [[search cancelButtonCell] drawWithFrame:bounds inView:o->view()->frameView()->getDocumentView()]; + + IntRect unzoomedRect(bounds); + if (zoomLevel != 1.0f) { + 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->translate(-unzoomedRect.x(), -unzoomedRect.y()); + } + + [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:o->view()->frameView()->documentView()]; [[search cancelButtonCell] setControlView:nil]; + paintInfo.context->restore(); return false; } @@ -1298,7 +1654,7 @@ bool RenderThemeMac::paintSearchFieldResultsDecoration(RenderObject* o, const Re [search setSearchMenuTemplate:nil]; NSRect bounds = [search searchButtonRectForBounds:NSRect(input->renderer()->absoluteBoundingBoxRect())]; -// [[search searchButtonCell] drawWithFrame:bounds inView:o->view()->frameView()->getDocumentView()]; + [[search searchButtonCell] drawWithFrame:bounds inView:o->view()->frameView()->documentView()]; [[search searchButtonCell] setControlView:nil]; return false; } @@ -1322,9 +1678,26 @@ bool RenderThemeMac::paintSearchFieldResultsButton(RenderObject* o, const Render if (![search searchMenuTemplate]) [search setSearchMenuTemplate:searchMenuTemplate()]; + paintInfo.context->save(); + + float zoomLevel = o->style()->effectiveZoom(); + NSRect bounds = [search searchButtonRectForBounds:NSRect(input->renderer()->absoluteBoundingBoxRect())]; -// [[search searchButtonCell] drawWithFrame:bounds inView:o->view()->frameView()->getDocumentView()]; + + IntRect unzoomedRect(bounds); + if (zoomLevel != 1.0f) { + 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->translate(-unzoomedRect.x(), -unzoomedRect.y()); + } + + [[search searchButtonCell] drawWithFrame:unzoomedRect inView:o->view()->frameView()->documentView()]; [[search searchButtonCell] setControlView:nil]; + + paintInfo.context->restore(); + return false; } @@ -1341,12 +1714,12 @@ bool RenderThemeMac::paintMediaFullscreenButton(RenderObject* o, const RenderObj bool RenderThemeMac::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { +#if ENABLE(VIDEO) Node* node = o->element(); Node* mediaNode = node ? node->shadowAncestorNode() : 0; if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag))) return false; -#if ENABLE(VIDEO) HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); if (!mediaElement) return false; @@ -1362,12 +1735,12 @@ bool RenderThemeMac::paintMediaMuteButton(RenderObject* o, const RenderObject::P bool RenderThemeMac::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { +#if ENABLE(VIDEO) Node* node = o->element(); Node* mediaNode = node ? node->shadowAncestorNode() : 0; if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag))) return false; -#if ENABLE(VIDEO) HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); if (!mediaElement) return false; @@ -1376,7 +1749,7 @@ bool RenderThemeMac::paintMediaPlayButton(RenderObject* o, const RenderObject::P if (mediaElement->canPlay()) wkDrawMediaPlayButton(paintInfo.context->platformContext(), r, node->active()); else - wkDrawMediaPauseButton(paintInfo.context->platformContext(), r, node->active()); + wkDrawMediaPauseButton(paintInfo.context->platformContext(), r, node->active()); #endif return false; } @@ -1405,12 +1778,12 @@ bool RenderThemeMac::paintMediaSeekForwardButton(RenderObject* o, const RenderOb bool RenderThemeMac::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { +#if ENABLE(VIDEO) Node* node = o->element(); Node* mediaNode = node ? node->shadowAncestorNode() : 0; if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag))) return false; -#if ENABLE(VIDEO) HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); if (!mediaElement) return false; @@ -1530,11 +1903,4 @@ NSSliderCell* RenderThemeMac::sliderThumbVertical() const return m_sliderThumbVertical.get(); } -Image* RenderThemeMac::resizeCornerImage() const -{ - if (!m_resizeCornerImage) - m_resizeCornerImage = Image::loadPlatformResource("textAreaResizeCorner"); - return m_resizeCornerImage; -} - } // namespace WebCore |