| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Google, Inc. | 3 * Copyright (C) 2008, 2009 Google, Inc. |
| 4 * Copyright (C) 2009 Kenneth Rohde Christiansen | |
| 5 * | 4 * |
| 6 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 10 * | 9 * |
| 11 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 15 * | 14 * |
| 16 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 20 */ | 19 */ |
| 21 | 20 |
| 22 // FIXME: we still need to figure out if passing a null view to the cell | |
| 23 // drawing routines will work. I expect not, and if that's the case we'll have | |
| 24 // to figure out something else. For now, at least leave the lines commented | |
| 25 // in, but the procurement of the view if 0'd. | |
| 26 | |
| 27 #import "config.h" | 21 #import "config.h" |
| 28 #import "RenderThemeChromiumMac.h" | 22 #import "RenderThemeChromiumMac.h" |
| 29 | 23 |
| 30 #import <Carbon/Carbon.h> | |
| 31 #import <Cocoa/Cocoa.h> | |
| 32 #import <math.h> | |
| 33 | |
| 34 #import "BitmapImage.h" | 24 #import "BitmapImage.h" |
| 35 #import "ChromiumBridge.h" | 25 #import "ChromiumBridge.h" |
| 36 #import "ColorMac.h" | 26 #import "ColorMac.h" |
| 37 #import "CSSStyleSelector.h" | 27 #import "CSSStyleSelector.h" |
| 38 #import "CSSValueKeywords.h" | 28 #import "CSSValueKeywords.h" |
| 29 #import "Document.h" |
| 39 #import "Element.h" | 30 #import "Element.h" |
| 40 #import "FoundationExtras.h" | |
| 41 #import "FrameView.h" | 31 #import "FrameView.h" |
| 42 #import "GraphicsContext.h" | 32 #import "GraphicsContext.h" |
| 43 #import "HTMLInputElement.h" | 33 #import "HTMLInputElement.h" |
| 44 #import "HTMLMediaElement.h" | 34 #import "HTMLMediaElement.h" |
| 45 #import "HTMLNames.h" | 35 #import "HTMLNames.h" |
| 46 #import "Image.h" | 36 #import "Image.h" |
| 47 #import "LocalCurrentGraphicsContext.h" | 37 #import "LocalCurrentGraphicsContext.h" |
| 48 #import "MediaControlElements.h" | 38 #import "MediaControlElements.h" |
| 49 #import "RenderMedia.h" | 39 #import "RenderMedia.h" |
| 50 #import "RenderSlider.h" | 40 #import "RenderSlider.h" |
| 51 #import "RenderView.h" | 41 #import "RenderView.h" |
| 52 #import "SharedBuffer.h" | 42 #import "SharedBuffer.h" |
| 53 #import "WebCoreSystemInterface.h" | 43 #import "WebCoreSystemInterface.h" |
| 44 #import "UserAgentStyleSheets.h" |
| 45 #import <Carbon/Carbon.h> |
| 46 #import <Cocoa/Cocoa.h> |
| 54 #import <wtf/RetainPtr.h> | 47 #import <wtf/RetainPtr.h> |
| 48 #import <wtf/StdLibExtras.h> |
| 49 #import <math.h> |
| 55 | 50 |
| 56 #ifdef BUILDING_ON_TIGER | 51 #ifdef BUILDING_ON_TIGER |
| 57 typedef int NSInteger; | 52 typedef int NSInteger; |
| 58 typedef unsigned NSUInteger; | 53 typedef unsigned NSUInteger; |
| 59 #endif | 54 #endif |
| 60 | 55 |
| 61 using std::min; | 56 using std::min; |
| 62 | 57 |
| 58 // This file (and its associated .h file) is a clone of RenderThemeMac.mm. |
| 59 // Because the original file is designed to run in-process inside a Cocoa view, |
| 60 // we must maintain a fork. Please maintain this file by performing parallel |
| 61 // changes to it. |
| 62 // |
| 63 // The only changes from RenderThemeMac should be: |
| 64 // - The classname change from RenderThemeMac to RenderThemeChromiumMac. |
| 65 // - The introduction of RTCMFlippedView and FlippedView() and its use as the |
| 66 // parent view for cell rendering. |
| 67 // - In platformFocusRingColor(), the use of ChromiumBridge to determine if |
| 68 // we're in layout test mode. |
| 69 // - updateActiveState() and its use to update the cells' visual appearance. |
| 70 // |
| 71 // For all other differences, if it was introduced in this file, then the |
| 72 // maintainer forgot to include it in the list; otherwise it is an update that |
| 73 // should have been applied to this file but was not. |
| 74 |
| 63 // The methods in this file are specific to the Mac OS X platform. | 75 // The methods in this file are specific to the Mac OS X platform. |
| 64 | 76 |
| 65 // FIXME: The platform-independent code in this class should be factored out and
merged with RenderThemeSafari. | 77 // FIXME: The platform-independent code in this class should be factored out and
merged with RenderThemeSafari. |
| 66 | 78 |
| 67 @interface WebCoreRenderThemeNotificationObserver : NSObject | 79 @interface WebCoreRenderThemeNotificationObserver : NSObject |
| 68 { | 80 { |
| 69 WebCore::RenderTheme *_theme; | 81 WebCore::RenderTheme *_theme; |
| 70 } | 82 } |
| 71 | 83 |
| 72 - (id)initWithTheme:(WebCore::RenderTheme *)theme; | 84 - (id)initWithTheme:(WebCore::RenderTheme *)theme; |
| 73 - (void)systemColorsDidChange:(NSNotification *)notification; | 85 - (void)systemColorsDidChange:(NSNotification *)notification; |
| 74 | 86 |
| 75 @end | 87 @end |
| 76 | 88 |
| 77 @implementation WebCoreRenderThemeNotificationObserver | 89 @implementation WebCoreRenderThemeNotificationObserver |
| 78 | 90 |
| 79 - (id)initWithTheme:(WebCore::RenderTheme *)theme | 91 - (id)initWithTheme:(WebCore::RenderTheme *)theme |
| 80 { | 92 { |
| 81 [super init]; | 93 [super init]; |
| 82 _theme = theme; | 94 _theme = theme; |
| 83 | 95 |
| 84 return self; | 96 return self; |
| 85 } | 97 } |
| 86 | 98 |
| 87 - (void)systemColorsDidChange:(NSNotification *)notification | 99 - (void)systemColorsDidChange:(NSNotification *)unusedNotification |
| 88 { | 100 { |
| 89 ASSERT([[notification name] isEqualToString:NSSystemColorsDidChangeNotificat
ion]); | 101 ASSERT_UNUSED(unusedNotification, [[unusedNotification name] isEqualToString
:NSSystemColorsDidChangeNotification]); |
| 90 _theme->platformColorsDidChange(); | 102 _theme->platformColorsDidChange(); |
| 91 } | 103 } |
| 92 | 104 |
| 93 @end | 105 @end |
| 94 | 106 |
| 107 @interface RTCMFlippedView : NSView |
| 108 {} |
| 109 |
| 110 - (BOOL)isFlipped; |
| 111 - (NSText *)currentEditor; |
| 112 |
| 113 @end |
| 114 |
| 115 @implementation RTCMFlippedView |
| 116 |
| 117 - (BOOL)isFlipped { |
| 118 return [[NSGraphicsContext currentContext] isFlipped]; |
| 119 } |
| 120 |
| 121 - (NSText *)currentEditor { |
| 122 return nil; |
| 123 } |
| 124 |
| 125 @end |
| 126 |
| 95 namespace WebCore { | 127 namespace WebCore { |
| 96 | 128 |
| 97 using namespace HTMLNames; | 129 using namespace HTMLNames; |
| 98 | 130 |
| 99 enum { | 131 enum { |
| 100 TopMargin, | 132 topMargin, |
| 101 RightMargin, | 133 rightMargin, |
| 102 BottomMargin, | 134 bottomMargin, |
| 103 LeftMargin | 135 leftMargin |
| 104 }; | 136 }; |
| 105 | 137 |
| 106 enum { | 138 enum { |
| 107 TopPadding, | 139 topPadding, |
| 108 RightPadding, | 140 rightPadding, |
| 109 BottomPadding, | 141 bottomPadding, |
| 110 LeftPadding | 142 leftPadding |
| 111 }; | 143 }; |
| 112 | 144 |
| 113 // In our Mac port, we don't define PLATFORM(MAC) and thus don't pick up the | 145 // In Snow Leopard, many cells only check to see if the view they're passed is |
| 114 // |operator NSRect()| on WebCore::IntRect and FloatRect. This substitues for | 146 // flipped, and if a nil view is passed, neglect to check if the current |
| 115 // that missing conversion operator. | 147 // graphics context is flipped. Thus we pass a sham view to them, one whose |
| 116 NSRect IntRectToNSRect(const IntRect & rect) | 148 // flipped state just reflects the state of the context. |
| 149 NSView* FlippedView() |
| 117 { | 150 { |
| 118 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); | 151 static NSView* view = [[RTCMFlippedView alloc] init]; |
| 152 return view; |
| 119 } | 153 } |
| 120 | 154 |
| 121 NSRect FloatRectToNSRect(const FloatRect & rect) | 155 PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page*) |
| 122 { | 156 { |
| 123 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); | 157 static RenderTheme* rt = RenderThemeChromiumMac::create().releaseRef(); |
| 124 } | 158 return rt; |
| 125 | |
| 126 IntRect NSRectToIntRect(const NSRect & rect) | |
| 127 { | |
| 128 return IntRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.heig
ht); | |
| 129 } | 159 } |
| 130 | 160 |
| 131 PassRefPtr<RenderTheme> RenderThemeChromiumMac::create() | 161 PassRefPtr<RenderTheme> RenderThemeChromiumMac::create() |
| 132 { | 162 { |
| 133 return adoptRef(new RenderThemeChromiumMac); | 163 return adoptRef(new RenderThemeChromiumMac); |
| 134 } | 164 } |
| 135 | 165 |
| 136 PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) | |
| 137 { | |
| 138 static RenderTheme* rt = RenderThemeChromiumMac::create().releaseRef(); | |
| 139 return rt; | |
| 140 } | |
| 141 | |
| 142 RenderThemeChromiumMac::RenderThemeChromiumMac() | 166 RenderThemeChromiumMac::RenderThemeChromiumMac() |
| 143 : m_isSliderThumbHorizontalPressed(false) | 167 : m_isSliderThumbHorizontalPressed(false) |
| 144 , m_isSliderThumbVerticalPressed(false) | 168 , m_isSliderThumbVerticalPressed(false) |
| 145 , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver a
lloc] initWithTheme:this]) | 169 , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver a
lloc] initWithTheme:this]) |
| 146 { | 170 { |
| 147 [[NSNotificationCenter defaultCenter] addObserver:m_notificationObserver.get
() | 171 [[NSNotificationCenter defaultCenter] addObserver:m_notificationObserver.get
() |
| 148 selector:@selector(syste
mColorsDidChange:) | 172 selector:@selector(syste
mColorsDidChange:) |
| 149 name:NSSystemColorsD
idChangeNotification | 173 name:NSSystemColorsD
idChangeNotification |
| 150 object:nil]; | 174 object:nil]; |
| 151 } | 175 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 166 NSColor* color = [[NSColor secondarySelectedControlColor] colorUsingColorSpa
ceName:NSDeviceRGBColorSpace]; | 190 NSColor* color = [[NSColor secondarySelectedControlColor] colorUsingColorSpa
ceName:NSDeviceRGBColorSpace]; |
| 167 return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int
>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent
])); | 191 return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int
>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent
])); |
| 168 } | 192 } |
| 169 | 193 |
| 170 Color RenderThemeChromiumMac::platformActiveListBoxSelectionBackgroundColor() co
nst | 194 Color RenderThemeChromiumMac::platformActiveListBoxSelectionBackgroundColor() co
nst |
| 171 { | 195 { |
| 172 NSColor* color = [[NSColor alternateSelectedControlColor] colorUsingColorSpa
ceName:NSDeviceRGBColorSpace]; | 196 NSColor* color = [[NSColor alternateSelectedControlColor] colorUsingColorSpa
ceName:NSDeviceRGBColorSpace]; |
| 173 return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int
>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent
])); | 197 return Color(static_cast<int>(255.0 * [color redComponent]), static_cast<int
>(255.0 * [color greenComponent]), static_cast<int>(255.0 * [color blueComponent
])); |
| 174 } | 198 } |
| 175 | 199 |
| 200 Color RenderThemeChromiumMac::platformActiveListBoxSelectionForegroundColor() co
nst |
| 201 { |
| 202 return Color::white; |
| 203 } |
| 204 |
| 205 Color RenderThemeChromiumMac::platformInactiveListBoxSelectionForegroundColor()
const |
| 206 { |
| 207 return Color::black; |
| 208 } |
| 209 |
| 176 Color RenderThemeChromiumMac::platformFocusRingColor() const | 210 Color RenderThemeChromiumMac::platformFocusRingColor() const |
| 177 { | 211 { |
| 178 if (ChromiumBridge::layoutTestMode()) | 212 if (ChromiumBridge::layoutTestMode()) |
| 179 return oldAquaFocusRingColor(); | 213 return oldAquaFocusRingColor(); |
| 180 | 214 |
| 181 return systemColor(CSSValueWebkitFocusRingColor); | 215 return systemColor(CSSValueWebkitFocusRingColor); |
| 182 } | 216 } |
| 183 | 217 |
| 218 Color RenderThemeChromiumMac::platformInactiveListBoxSelectionBackgroundColor()
const |
| 219 { |
| 220 return platformInactiveSelectionBackgroundColor(); |
| 221 } |
| 222 |
| 184 static FontWeight toFontWeight(NSInteger appKitFontWeight) | 223 static FontWeight toFontWeight(NSInteger appKitFontWeight) |
| 185 { | 224 { |
| 186 ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15); | 225 ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15); |
| 187 if (appKitFontWeight > 14) | 226 if (appKitFontWeight > 14) |
| 188 appKitFontWeight = 14; | 227 appKitFontWeight = 14; |
| 189 else if (appKitFontWeight < 1) | 228 else if (appKitFontWeight < 1) |
| 190 appKitFontWeight = 1; | 229 appKitFontWeight = 1; |
| 191 | 230 |
| 192 static FontWeight fontWeights[] = { | 231 static FontWeight fontWeights[] = { |
| 193 FontWeight100, | 232 FontWeight100, |
| 194 FontWeight100, | 233 FontWeight100, |
| 195 FontWeight200, | 234 FontWeight200, |
| 196 FontWeight300, | 235 FontWeight300, |
| 197 FontWeight400, | 236 FontWeight400, |
| 198 FontWeight500, | 237 FontWeight500, |
| 199 FontWeight600, | 238 FontWeight600, |
| 200 FontWeight600, | 239 FontWeight600, |
| 201 FontWeight700, | 240 FontWeight700, |
| 202 FontWeight800, | 241 FontWeight800, |
| 203 FontWeight800, | 242 FontWeight800, |
| 204 FontWeight900, | 243 FontWeight900, |
| 205 FontWeight900, | 244 FontWeight900, |
| 206 FontWeight900 | 245 FontWeight900 |
| 207 }; | 246 }; |
| 208 return fontWeights[appKitFontWeight - 1]; | 247 return fontWeights[appKitFontWeight - 1]; |
| 209 } | 248 } |
| 210 | 249 |
| 211 void RenderThemeChromiumMac::systemFont(int cssValueId, FontDescription& fontDes
cription) const | 250 void RenderThemeChromiumMac::systemFont(int cssValueId, FontDescription& fontDes
cription) const |
| 212 { | 251 { |
| 213 static FontDescription systemFont; | 252 DEFINE_STATIC_LOCAL(FontDescription, systemFont, ()); |
| 214 static FontDescription smallSystemFont; | 253 DEFINE_STATIC_LOCAL(FontDescription, smallSystemFont, ()); |
| 215 static FontDescription menuFont; | 254 DEFINE_STATIC_LOCAL(FontDescription, menuFont, ()); |
| 216 static FontDescription labelFont; | 255 DEFINE_STATIC_LOCAL(FontDescription, labelFont, ()); |
| 217 static FontDescription miniControlFont; | 256 DEFINE_STATIC_LOCAL(FontDescription, miniControlFont, ()); |
| 218 static FontDescription smallControlFont; | 257 DEFINE_STATIC_LOCAL(FontDescription, smallControlFont, ()); |
| 219 static FontDescription controlFont; | 258 DEFINE_STATIC_LOCAL(FontDescription, controlFont, ()); |
| 220 | 259 |
| 221 FontDescription* cachedDesc; | 260 FontDescription* cachedDesc; |
| 222 NSFont* font = nil; | 261 NSFont* font = nil; |
| 223 switch (cssValueId) { | 262 switch (cssValueId) { |
| 224 case CSSValueSmallCaption: | 263 case CSSValueSmallCaption: |
| 225 cachedDesc = &smallSystemFont; | 264 cachedDesc = &smallSystemFont; |
| 226 if (!smallSystemFont.isAbsoluteSize()) | 265 if (!smallSystemFont.isAbsoluteSize()) |
| 227 font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | 266 font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
| 228 break; | 267 break; |
| 229 case CSSValueMenu: | 268 case CSSValueMenu: |
| 230 cachedDesc = &menuFont; | 269 cachedDesc = &menuFont; |
| 231 if (!menuFont.isAbsoluteSize()) | 270 if (!menuFont.isAbsoluteSize()) |
| 232 font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; | 271 font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; |
| 233 break; | 272 break; |
| 234 case CSSValueStatusBar: | 273 case CSSValueStatusBar: |
| 235 cachedDesc = &labelFont; | 274 cachedDesc = &labelFont; |
| 236 if (!labelFont.isAbsoluteSize()) | 275 if (!labelFont.isAbsoluteSize()) |
| 237 font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; | 276 font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; |
| 238 break; | 277 break; |
| 239 case CSSValueWebkitMiniControl: | 278 case CSSValueWebkitMiniControl: |
| 240 cachedDesc = &miniControlFont; | 279 cachedDesc = &miniControlFont; |
| 241 if (!miniControlFont.isAbsoluteSize()) | 280 if (!miniControlFont.isAbsoluteSize()) |
| 242 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSMiniControlSize]]; | 281 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSMiniControlSize]]; |
| 243 break; | 282 break; |
| 244 case CSSValueWebkitSmallControl: | 283 case CSSValueWebkitSmallControl: |
| 245 cachedDesc = &smallControlFont; | 284 cachedDesc = &smallControlFont; |
| 246 if (!smallControlFont.isAbsoluteSize()) | 285 if (!smallControlFont.isAbsoluteSize()) |
| 247 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSSmallControlSize]]; | 286 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSSmallControlSize]]; |
| 248 break; | 287 break; |
| 249 case CSSValueWebkitControl: | 288 case CSSValueWebkitControl: |
| 250 cachedDesc = &controlFont; | 289 cachedDesc = &controlFont; |
| 251 if (!controlFont.isAbsoluteSize()) | 290 if (!controlFont.isAbsoluteSize()) |
| 252 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSRegularControlSize]]; | 291 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSRegularControlSize]]; |
| 253 break; | 292 break; |
| 254 default: | 293 default: |
| 255 cachedDesc = &systemFont; | 294 cachedDesc = &systemFont; |
| 256 if (!systemFont.isAbsoluteSize()) | 295 if (!systemFont.isAbsoluteSize()) |
| 257 font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; | 296 font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; |
| 258 } | 297 } |
| 259 | 298 |
| 260 if (font) { | 299 if (font) { |
| 261 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 300 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 262 cachedDesc->setIsAbsoluteSize(true); | 301 cachedDesc->setIsAbsoluteSize(true); |
| 263 cachedDesc->setGenericFamily(FontDescription::NoFamily); | 302 cachedDesc->setGenericFamily(FontDescription::NoFamily); |
| 264 cachedDesc->firstFamily().setFamily([font familyName]); | 303 cachedDesc->firstFamily().setFamily([font familyName]); |
| 265 cachedDesc->setSpecifiedSize([font pointSize]); | 304 cachedDesc->setSpecifiedSize([font pointSize]); |
| 266 cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); | 305 cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); |
| 267 cachedDesc->setItalic([fontManager traitsOfFont:font] & NSItalicFontMask
); | 306 cachedDesc->setItalic([fontManager traitsOfFont:font] & NSItalicFontMask
); |
| 268 } | 307 } |
| 269 fontDescription = *cachedDesc; | 308 fontDescription = *cachedDesc; |
| 270 } | 309 } |
| 271 | 310 |
| 272 static RGBA32 convertNSColorToColor(NSColor *color) | 311 static RGBA32 convertNSColorToColor(NSColor *color) |
| 273 { | 312 { |
| 274 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSCalibratedRGB
ColorSpace]; | 313 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; |
| 275 if (colorInColorSpace) { | 314 if (colorInColorSpace) { |
| 276 static const double scaleFactor = nextafter(256.0, 0.0); | 315 static const double scaleFactor = nextafter(256.0, 0.0); |
| 277 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), | 316 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), |
| 278 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), | 317 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), |
| 279 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); | 318 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); |
| 280 } | 319 } |
| 281 | 320 |
| 282 // This conversion above can fail if the NSColor in question is an NSPattern
Color | 321 // This conversion above can fail if the NSColor in question is an NSPattern
Color |
| 283 // (as many system colors are). These colors are actually a repeating patter
n | 322 // (as many system colors are). These colors are actually a repeating patter
n |
| 284 // not just a solid color. To work around this we simply draw a 1x1 image of | 323 // not just a solid color. To work around this we simply draw a 1x1 image of |
| 285 // the color and use that pixel's color. It might be better to use an averag
e of | 324 // the color and use that pixel's color. It might be better to use an averag
e of |
| 286 // the colors in the pattern instead. | 325 // the colors in the pattern instead. |
| 287 NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDat
aPlanes:nil | 326 NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDat
aPlanes:nil |
| 288 pix
elsWide:1 | 327 pix
elsWide:1 |
| 289 pix
elsHigh:1 | 328 pix
elsHigh:1 |
| 290 bitsPe
rSample:8 | 329 bitsPe
rSample:8 |
| 291 samplesP
erPixel:4 | 330 samplesP
erPixel:4 |
| 292 h
asAlpha:YES | 331 h
asAlpha:YES |
| 293 i
sPlanar:NO | 332 i
sPlanar:NO |
| 294 colorSp
aceName:NSCalibratedRGBColorSpace | 333 colorSp
aceName:NSDeviceRGBColorSpace |
| 295 byte
sPerRow:4 | 334 byte
sPerRow:4 |
| 296 bitsP
erPixel:32]; | 335 bitsP
erPixel:32]; |
| 297 | 336 |
| 298 [NSGraphicsContext saveGraphicsState]; | 337 [NSGraphicsContext saveGraphicsState]; |
| 299 [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithB
itmapImageRep:offscreenRep]]; | 338 [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithB
itmapImageRep:offscreenRep]]; |
| 300 NSEraseRect(NSMakeRect(0, 0, 1, 1)); | 339 NSEraseRect(NSMakeRect(0, 0, 1, 1)); |
| 301 [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)]; | 340 [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)]; |
| 302 [NSGraphicsContext restoreGraphicsState]; | 341 [NSGraphicsContext restoreGraphicsState]; |
| 303 | 342 |
| 304 NSUInteger pixel[4]; | 343 NSUInteger pixel[4]; |
| 305 [offscreenRep getPixel:pixel atX:0 y:0]; | 344 [offscreenRep getPixel:pixel atX:0 y:0]; |
| 306 | 345 |
| 307 [offscreenRep release]; | 346 [offscreenRep release]; |
| 308 | 347 |
| 309 return makeRGB(pixel[0], pixel[1], pixel[2]); | 348 return makeRGB(pixel[0], pixel[1], pixel[2]); |
| 310 } | 349 } |
| 311 | 350 |
| 312 static RGBA32 menuBackgroundColor() | 351 static RGBA32 menuBackgroundColor() |
| 313 { | 352 { |
| 314 NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDat
aPlanes:nil | 353 NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDat
aPlanes:nil |
| 315 pix
elsWide:1 | 354 pix
elsWide:1 |
| 316 pix
elsHigh:1 | 355 pix
elsHigh:1 |
| 317 bitsPe
rSample:8 | 356 bitsPe
rSample:8 |
| 318 samplesP
erPixel:4 | 357 samplesP
erPixel:4 |
| 319 h
asAlpha:YES | 358 h
asAlpha:YES |
| 320 i
sPlanar:NO | 359 i
sPlanar:NO |
| 321 colorSp
aceName:NSCalibratedRGBColorSpace | 360 colorSp
aceName:NSDeviceRGBColorSpace |
| 322 byte
sPerRow:4 | 361 byte
sPerRow:4 |
| 323 bitsP
erPixel:32]; | 362 bitsP
erPixel:32]; |
| 324 | 363 |
| 325 CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext graphic
sContextWithBitmapImageRep:offscreenRep] graphicsPort]); | 364 CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext graphic
sContextWithBitmapImageRep:offscreenRep] graphicsPort]); |
| 326 CGRect rect = CGRectMake(0, 0, 1, 1); | 365 CGRect rect = CGRectMake(0, 0, 1, 1); |
| 327 HIThemeMenuDrawInfo drawInfo; | 366 HIThemeMenuDrawInfo drawInfo; |
| 328 drawInfo.version = 0; | 367 drawInfo.version = 0; |
| 329 drawInfo.menuType = kThemeMenuTypePopUp; | 368 drawInfo.menuType = kThemeMenuTypePopUp; |
| 330 HIThemeDrawMenuBackground(&rect, &drawInfo, context, kHIThemeOrientationInve
rted); | 369 HIThemeDrawMenuBackground(&rect, &drawInfo, context, kHIThemeOrientationInve
rted); |
| 331 | 370 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 343 RenderTheme::platformColorsDidChange(); | 382 RenderTheme::platformColorsDidChange(); |
| 344 } | 383 } |
| 345 | 384 |
| 346 Color RenderThemeChromiumMac::systemColor(int cssValueId) const | 385 Color RenderThemeChromiumMac::systemColor(int cssValueId) const |
| 347 { | 386 { |
| 348 if (m_systemColorCache.contains(cssValueId)) | 387 if (m_systemColorCache.contains(cssValueId)) |
| 349 return m_systemColorCache.get(cssValueId); | 388 return m_systemColorCache.get(cssValueId); |
| 350 | 389 |
| 351 Color color; | 390 Color color; |
| 352 switch (cssValueId) { | 391 switch (cssValueId) { |
| 353 case CSSValueActiveborder: | 392 case CSSValueActiveborder: |
| 354 color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]); | 393 color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor])
; |
| 355 break; | 394 break; |
| 356 case CSSValueActivecaption: | 395 case CSSValueActivecaption: |
| 357 color = convertNSColorToColor([NSColor windowFrameTextColor]); | 396 color = convertNSColorToColor([NSColor windowFrameTextColor]); |
| 358 break; | 397 break; |
| 359 case CSSValueAppworkspace: | 398 case CSSValueAppworkspace: |
| 360 color = convertNSColorToColor([NSColor headerColor]); | 399 color = convertNSColorToColor([NSColor headerColor]); |
| 361 break; | 400 break; |
| 362 case CSSValueBackground: | 401 case CSSValueBackground: |
| 363 // Use theme independent default | 402 // Use theme independent default |
| 364 break; | 403 break; |
| 365 case CSSValueButtonface: | 404 case CSSValueButtonface: |
| 366 // We use this value instead of NSColor's controlColor to avoid website
incompatibilities. | 405 // We use this value instead of NSColor's controlColor to avoid webs
ite incompatibilities. |
| 367 // We may want to change this to use the NSColor in future. | 406 // We may want to change this to use the NSColor in future. |
| 368 color = 0xFFC0C0C0; | 407 color = 0xFFC0C0C0; |
| 369 break; | 408 break; |
| 370 case CSSValueButtonhighlight: | 409 case CSSValueButtonhighlight: |
| 371 color = convertNSColorToColor([NSColor controlHighlightColor]); | 410 color = convertNSColorToColor([NSColor controlHighlightColor]); |
| 372 break; | 411 break; |
| 373 case CSSValueButtonshadow: | 412 case CSSValueButtonshadow: |
| 374 color = convertNSColorToColor([NSColor controlShadowColor]); | 413 color = convertNSColorToColor([NSColor controlShadowColor]); |
| 375 break; | 414 break; |
| 376 case CSSValueButtontext: | 415 case CSSValueButtontext: |
| 377 color = convertNSColorToColor([NSColor controlTextColor]); | 416 color = convertNSColorToColor([NSColor controlTextColor]); |
| 378 break; | 417 break; |
| 379 case CSSValueCaptiontext: | 418 case CSSValueCaptiontext: |
| 380 color = convertNSColorToColor([NSColor textColor]); | 419 color = convertNSColorToColor([NSColor textColor]); |
| 381 break; | 420 break; |
| 382 case CSSValueGraytext: | 421 case CSSValueGraytext: |
| 383 color = convertNSColorToColor([NSColor disabledControlTextColor]); | 422 color = convertNSColorToColor([NSColor disabledControlTextColor]); |
| 384 break; | 423 break; |
| 385 case CSSValueHighlight: | 424 case CSSValueHighlight: |
| 386 color = convertNSColorToColor([NSColor selectedTextBackgroundColor]); | 425 color = convertNSColorToColor([NSColor selectedTextBackgroundColor])
; |
| 387 break; | 426 break; |
| 388 case CSSValueHighlighttext: | 427 case CSSValueHighlighttext: |
| 389 color = convertNSColorToColor([NSColor selectedTextColor]); | 428 color = convertNSColorToColor([NSColor selectedTextColor]); |
| 390 break; | 429 break; |
| 391 case CSSValueInactiveborder: | 430 case CSSValueInactiveborder: |
| 392 color = convertNSColorToColor([NSColor controlBackgroundColor]); | 431 color = convertNSColorToColor([NSColor controlBackgroundColor]); |
| 393 break; | 432 break; |
| 394 case CSSValueInactivecaption: | 433 case CSSValueInactivecaption: |
| 395 color = convertNSColorToColor([NSColor controlBackgroundColor]); | 434 color = convertNSColorToColor([NSColor controlBackgroundColor]); |
| 396 break; | 435 break; |
| 397 case CSSValueInactivecaptiontext: | 436 case CSSValueInactivecaptiontext: |
| 398 color = convertNSColorToColor([NSColor textColor]); | 437 color = convertNSColorToColor([NSColor textColor]); |
| 399 break; | 438 break; |
| 400 case CSSValueInfobackground: | 439 case CSSValueInfobackground: |
| 401 // There is no corresponding NSColor for this so we use a hard coded val
ue. | 440 // There is no corresponding NSColor for this so we use a hard coded
value. |
| 402 color = 0xFFFBFCC5; | 441 color = 0xFFFBFCC5; |
| 403 break; | 442 break; |
| 404 case CSSValueInfotext: | 443 case CSSValueInfotext: |
| 405 color = convertNSColorToColor([NSColor textColor]); | 444 color = convertNSColorToColor([NSColor textColor]); |
| 406 break; | 445 break; |
| 407 case CSSValueMenu: | 446 case CSSValueMenu: |
| 408 color = menuBackgroundColor(); | 447 color = menuBackgroundColor(); |
| 409 break; | 448 break; |
| 410 case CSSValueMenutext: | 449 case CSSValueMenutext: |
| 411 color = convertNSColorToColor([NSColor selectedMenuItemTextColor]); | 450 color = convertNSColorToColor([NSColor selectedMenuItemTextColor]); |
| 412 break; | 451 break; |
| 413 case CSSValueScrollbar: | 452 case CSSValueScrollbar: |
| 414 color = convertNSColorToColor([NSColor scrollBarColor]); | 453 color = convertNSColorToColor([NSColor scrollBarColor]); |
| 415 break; | 454 break; |
| 416 case CSSValueText: | 455 case CSSValueText: |
| 417 color = convertNSColorToColor([NSColor textColor]); | 456 color = convertNSColorToColor([NSColor textColor]); |
| 418 break; | 457 break; |
| 419 case CSSValueThreeddarkshadow: | 458 case CSSValueThreeddarkshadow: |
| 420 color = convertNSColorToColor([NSColor controlDarkShadowColor]); | 459 color = convertNSColorToColor([NSColor controlDarkShadowColor]); |
| 421 break; | 460 break; |
| 422 case CSSValueThreedshadow: | 461 case CSSValueThreedshadow: |
| 423 color = convertNSColorToColor([NSColor shadowColor]); | 462 color = convertNSColorToColor([NSColor shadowColor]); |
| 424 break; | 463 break; |
| 425 case CSSValueThreedface: | 464 case CSSValueThreedface: |
| 426 // We use this value instead of NSColor's controlColor to avoid website
incompatibilities. | 465 // We use this value instead of NSColor's controlColor to avoid webs
ite incompatibilities. |
| 427 // We may want to change this to use the NSColor in future. | 466 // We may want to change this to use the NSColor in future. |
| 428 color = 0xFFC0C0C0; | 467 color = 0xFFC0C0C0; |
| 429 break; | 468 break; |
| 430 case CSSValueThreedhighlight: | 469 case CSSValueThreedhighlight: |
| 431 color = convertNSColorToColor([NSColor highlightColor]); | 470 color = convertNSColorToColor([NSColor highlightColor]); |
| 432 break; | 471 break; |
| 433 case CSSValueThreedlightshadow: | 472 case CSSValueThreedlightshadow: |
| 434 color = convertNSColorToColor([NSColor controlLightHighlightColor]); | 473 color = convertNSColorToColor([NSColor controlLightHighlightColor]); |
| 435 break; | 474 break; |
| 436 case CSSValueWebkitFocusRingColor: | 475 case CSSValueWebkitFocusRingColor: |
| 437 color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]); | 476 color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor])
; |
| 438 break; | 477 break; |
| 439 case CSSValueWindow: | 478 case CSSValueWindow: |
| 440 color = convertNSColorToColor([NSColor windowBackgroundColor]); | 479 color = convertNSColorToColor([NSColor windowBackgroundColor]); |
| 441 break; | 480 break; |
| 442 case CSSValueWindowframe: | 481 case CSSValueWindowframe: |
| 443 color = convertNSColorToColor([NSColor windowFrameColor]); | 482 color = convertNSColorToColor([NSColor windowFrameColor]); |
| 444 break; | 483 break; |
| 445 case CSSValueWindowtext: | 484 case CSSValueWindowtext: |
| 446 color = convertNSColorToColor([NSColor windowFrameTextColor]); | 485 color = convertNSColorToColor([NSColor windowFrameTextColor]); |
| 447 break; | 486 break; |
| 448 } | 487 } |
| 449 | 488 |
| 450 if (!color.isValid()) | 489 if (!color.isValid()) |
| 451 color = RenderTheme::systemColor(cssValueId); | 490 color = RenderTheme::systemColor(cssValueId); |
| 452 | 491 |
| 453 if (color.isValid()) | 492 if (color.isValid()) |
| 454 m_systemColorCache.set(cssValueId, color.rgb()); | 493 m_systemColorCache.set(cssValueId, color.rgb()); |
| 455 | 494 |
| 456 return color; | 495 return color; |
| 457 } | 496 } |
| 458 | 497 |
| 459 bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const Bor
derData& border, | 498 bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const Bor
derData& border, |
| 460 const FillLayer& background, const
Color& backgroundColor) const | 499 const FillLayer& background, const Color& b
ackgroundColor) const |
| 461 { | 500 { |
| 462 if (style->appearance() == TextFieldPart || style->appearance() == TextAreaP
art || style->appearance() == ListboxPart) | 501 if (style->appearance() == TextFieldPart || style->appearance() == TextAreaP
art || style->appearance() == ListboxPart) |
| 463 return style->border() != border; | 502 return style->border() != border; |
| 464 | 503 |
| 465 // FIXME: This is horrible, but there is not much else that can be done. Me
nu lists cannot draw properly when | 504 // FIXME: This is horrible, but there is not much else that can be done. Me
nu lists cannot draw properly when |
| 466 // scaled. They can't really draw properly when transformed either. We can
't detect the transform case at style | 505 // scaled. They can't really draw properly when transformed either. We can
't detect the transform case at style |
| 467 // adjustment time so that will just have to stay broken. We can however de
tect that we're zooming. If zooming | 506 // adjustment time so that will just have to stay broken. We can however de
tect that we're zooming. If zooming |
| 468 // is in effect we treat it like the control is styled. | 507 // is in effect we treat it like the control is styled. |
| 469 if (style->appearance() == MenulistPart && style->effectiveZoom() != 1.0f) | 508 if (style->appearance() == MenulistPart && style->effectiveZoom() != 1.0f) |
| 470 return true; | 509 return true; |
| 471 | 510 |
| 472 return RenderTheme::isControlStyled(style, border, background, backgroundCol
or); | 511 return RenderTheme::isControlStyled(style, border, background, backgroundCol
or); |
| 473 } | 512 } |
| 474 | 513 |
| 475 // FIXME: Use the code from the old upstream version, before it was converted to
the new theme API in r37731. | |
| 476 void RenderThemeChromiumMac::adjustRepaintRect(const RenderObject* o, IntRect& r
) | 514 void RenderThemeChromiumMac::adjustRepaintRect(const RenderObject* o, IntRect& r
) |
| 477 { | 515 { |
| 516 ControlPart part = o->style()->appearance(); |
| 517 |
| 518 #if USE(NEW_THEME) |
| 519 switch (part) { |
| 520 case CheckboxPart: |
| 521 case RadioPart: |
| 522 case PushButtonPart: |
| 523 case SquareButtonPart: |
| 524 case DefaultButtonPart: |
| 525 case ButtonPart: |
| 526 return RenderTheme::adjustRepaintRect(o, r); |
| 527 default: |
| 528 break; |
| 529 } |
| 530 #endif |
| 531 |
| 478 float zoomLevel = o->style()->effectiveZoom(); | 532 float zoomLevel = o->style()->effectiveZoom(); |
| 479 | 533 |
| 480 switch (o->style()->appearance()) { | 534 if (part == MenulistPart) { |
| 481 case CheckboxPart: { | |
| 482 // Since we query the prototype cell, we need to update its state to mat
ch. | |
| 483 setCheckboxCellState(o, r); | |
| 484 | |
| 485 // We inflate the rect as needed to account for padding included in the
cell to accommodate the checkbox | |
| 486 // shadow" and the check. We don't consider this part of the bounds of
the control in WebKit. | |
| 487 IntSize size = checkboxSizes()[[checkbox() controlSize]]; | |
| 488 size.setHeight(size.height() * zoomLevel); | |
| 489 size.setWidth(size.width() * zoomLevel); | |
| 490 r = inflateRect(r, size, checkboxMargins(), zoomLevel); | |
| 491 break; | |
| 492 } | |
| 493 case RadioPart: { | |
| 494 // Since we query the prototype cell, we need to update its state to mat
ch. | |
| 495 setRadioCellState(o, r); | |
| 496 | |
| 497 // We inflate the rect as needed to account for padding included in the
cell to accommodate the checkbox | |
| 498 // shadow" and the check. We don't consider this part of the bounds of
the control in WebKit. | |
| 499 IntSize size = radioSizes()[[radio() controlSize]]; | |
| 500 size.setHeight(size.height() * zoomLevel); | |
| 501 size.setWidth(size.width() * zoomLevel); | |
| 502 r = inflateRect(r, size, radioMargins(), zoomLevel); | |
| 503 break; | |
| 504 } | |
| 505 case PushButtonPart: | |
| 506 case DefaultButtonPart: | |
| 507 case ButtonPart: { | |
| 508 // Since we query the prototype cell, we need to update its state to mat
ch. | |
| 509 setButtonCellState(o, r); | |
| 510 | |
| 511 // We inflate the rect as needed to account for padding included in the
cell to accommodate the checkbox | |
| 512 // shadow" and the check. We don't consider this part of the bounds of
the control in WebKit. | |
| 513 if ([button() bezelStyle] == NSRoundedBezelStyle) { | |
| 514 IntSize size = buttonSizes()[[button() controlSize]]; | |
| 515 size.setHeight(size.height() * zoomLevel); | |
| 516 size.setWidth(r.width()); | |
| 517 r = inflateRect(r, size, buttonMargins(), zoomLevel); | |
| 518 } | |
| 519 break; | |
| 520 } | |
| 521 case MenulistPart: { | |
| 522 setPopupButtonCellState(o, r); | 535 setPopupButtonCellState(o, r); |
| 523 IntSize size = popupButtonSizes()[[popupButton() controlSize]]; | 536 IntSize size = popupButtonSizes()[[popupButton() controlSize]]; |
| 524 size.setHeight(size.height() * zoomLevel); | 537 size.setHeight(size.height() * zoomLevel); |
| 525 size.setWidth(r.width()); | 538 size.setWidth(r.width()); |
| 526 r = inflateRect(r, size, popupButtonMargins(), zoomLevel); | 539 r = inflateRect(r, size, popupButtonMargins(), zoomLevel); |
| 527 break; | |
| 528 } | |
| 529 default: | |
| 530 break; | |
| 531 } | 540 } |
| 532 } | 541 } |
| 533 | 542 |
| 534 IntRect RenderThemeChromiumMac::inflateRect(const IntRect& r, const IntSize& siz
e, const int* margins, float zoomLevel) const | 543 IntRect RenderThemeChromiumMac::inflateRect(const IntRect& r, const IntSize& siz
e, const int* margins, float zoomLevel) const |
| 535 { | 544 { |
| 536 // Only do the inflation if the available width/height are too small. Other
wise try to | 545 // Only do the inflation if the available width/height are too small. Other
wise try to |
| 537 // fit the glow/check space into the available box's width/height. | 546 // fit the glow/check space into the available box's width/height. |
| 538 int widthDelta = r.width() - (size.width() + margins[LeftMargin] * zoomLevel
+ margins[RightMargin] * zoomLevel); | 547 int widthDelta = r.width() - (size.width() + margins[leftMargin] * zoomLevel
+ margins[rightMargin] * zoomLevel); |
| 539 int heightDelta = r.height() - (size.height() + margins[TopMargin] * zoomLev
el + margins[BottomMargin] * zoomLevel); | 548 int heightDelta = r.height() - (size.height() + margins[topMargin] * zoomLev
el + margins[bottomMargin] * zoomLevel); |
| 540 IntRect result(r); | 549 IntRect result(r); |
| 541 if (widthDelta < 0) { | 550 if (widthDelta < 0) { |
| 542 result.setX(result.x() - margins[LeftMargin] * zoomLevel); | 551 result.setX(result.x() - margins[leftMargin] * zoomLevel); |
| 543 result.setWidth(result.width() - widthDelta); | 552 result.setWidth(result.width() - widthDelta); |
| 544 } | 553 } |
| 545 if (heightDelta < 0) { | 554 if (heightDelta < 0) { |
| 546 result.setY(result.y() - margins[TopMargin] * zoomLevel); | 555 result.setY(result.y() - margins[topMargin] * zoomLevel); |
| 547 result.setHeight(result.height() - heightDelta); | 556 result.setHeight(result.height() - heightDelta); |
| 548 } | 557 } |
| 549 return result; | 558 return result; |
| 550 } | 559 } |
| 551 | 560 |
| 561 FloatRect RenderThemeChromiumMac::convertToPaintingRect(const RenderObject* inpu
tRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const I
ntRect& r) const |
| 562 { |
| 563 FloatRect partRect(inputRect); |
| 564 |
| 565 // Compute an offset between the part renderer and the input renderer |
| 566 FloatSize offsetFromInputRenderer; |
| 567 const RenderObject* renderer = partRenderer; |
| 568 while (renderer && renderer != inputRenderer) { |
| 569 RenderObject* containingRenderer = renderer->container(); |
| 570 offsetFromInputRenderer -= renderer->offsetFromContainer(containingRende
rer); |
| 571 renderer = containingRenderer; |
| 572 } |
| 573 // If the input renderer was not a container, something went wrong |
| 574 ASSERT(renderer == inputRenderer); |
| 575 // Move the rect into partRenderer's coords |
| 576 partRect.move(offsetFromInputRenderer); |
| 577 // Account for the local drawing offset (tx, ty) |
| 578 partRect.move(r.x(), r.y()); |
| 579 |
| 580 return partRect; |
| 581 } |
| 582 |
| 552 // Updates the control tint (a.k.a. active state) of |cell| (from |o|). | 583 // Updates the control tint (a.k.a. active state) of |cell| (from |o|). |
| 553 // In the Chromium port, the renderer runs as a background process and controls' | 584 // In the Chromium port, the renderer runs as a background process and controls' |
| 554 // NSCell(s) lack a parent NSView. Therefore controls don't have their tint | 585 // NSCell(s) lack a parent NSView. Therefore controls don't have their tint |
| 555 // color updated correctly when the application is activated/deactivated. | 586 // color updated correctly when the application is activated/deactivated. |
| 556 // FocusController's setActive() is called when the application is | 587 // FocusController's setActive() is called when the application is |
| 557 // activated/deactivated, which causes a repaint at which time this code is | 588 // activated/deactivated, which causes a repaint at which time this code is |
| 558 // called. | 589 // called. |
| 559 // This function should be called before drawing any NSCell-derived controls, | 590 // This function should be called before drawing any NSCell-derived controls, |
| 560 // unless you're sure it isn't needed. | 591 // unless you're sure it isn't needed. |
| 561 void RenderThemeChromiumMac::updateActiveState(NSCell* cell, const RenderObject*
o) | 592 void RenderThemeChromiumMac::updateActiveState(NSCell* cell, const RenderObject*
o) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 632 } |
| 602 | 633 |
| 603 void RenderThemeChromiumMac::updatePressedState(NSCell* cell, const RenderObject
* o) | 634 void RenderThemeChromiumMac::updatePressedState(NSCell* cell, const RenderObject
* o) |
| 604 { | 635 { |
| 605 bool oldPressed = [cell isHighlighted]; | 636 bool oldPressed = [cell isHighlighted]; |
| 606 bool pressed = (o->node() && o->node()->active()); | 637 bool pressed = (o->node() && o->node()->active()); |
| 607 if (pressed != oldPressed) | 638 if (pressed != oldPressed) |
| 608 [cell setHighlighted:pressed]; | 639 [cell setHighlighted:pressed]; |
| 609 } | 640 } |
| 610 | 641 |
| 611 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 612 int RenderThemeChromiumMac::baselinePosition(const RenderObject* o) const | |
| 613 { | |
| 614 if (!o->isBox()) | |
| 615 return 0; | |
| 616 | |
| 617 if (o->style()->appearance() == CheckboxPart || o->style()->appearance() ==
RadioPart) { | |
| 618 const RenderBox* box = toRenderBox(o); | |
| 619 return box->marginTop() + box->height() - 2 * o->style()->effectiveZoom(
); // The baseline is 2px up from the bottom of the checkbox/radio in AppKit. | |
| 620 } | |
| 621 return RenderTheme::baselinePosition(o); | |
| 622 } | |
| 623 | |
| 624 bool RenderThemeChromiumMac::controlSupportsTints(const RenderObject* o) const | 642 bool RenderThemeChromiumMac::controlSupportsTints(const RenderObject* o) const |
| 625 { | 643 { |
| 626 // An alternate way to implement this would be to get the appropriate cell o
bject | 644 // An alternate way to implement this would be to get the appropriate cell o
bject |
| 627 // and call the private _needRedrawOnWindowChangedKeyState method. An advant
age of | 645 // and call the private _needRedrawOnWindowChangedKeyState method. An advant
age of |
| 628 // that would be that we would match AppKit behavior more closely, but a dis
advantage | 646 // that would be that we would match AppKit behavior more closely, but a dis
advantage |
| 629 // would be that we would rely on an AppKit SPI method. | 647 // would be that we would rely on an AppKit SPI method. |
| 630 | 648 |
| 631 if (!isEnabled(o)) | 649 if (!isEnabled(o)) |
| 632 return false; | 650 return false; |
| 633 | 651 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 void RenderThemeChromiumMac::setSizeFromFont(RenderStyle* style, const IntSize*
sizes) const | 703 void RenderThemeChromiumMac::setSizeFromFont(RenderStyle* style, const IntSize*
sizes) const |
| 686 { | 704 { |
| 687 // FIXME: Check is flawed, since it doesn't take min-width/max-width into ac
count. | 705 // FIXME: Check is flawed, since it doesn't take min-width/max-width into ac
count. |
| 688 IntSize size = sizeForFont(style, sizes); | 706 IntSize size = sizeForFont(style, sizes); |
| 689 if (style->width().isIntrinsicOrAuto() && size.width() > 0) | 707 if (style->width().isIntrinsicOrAuto() && size.width() > 0) |
| 690 style->setWidth(Length(size.width(), Fixed)); | 708 style->setWidth(Length(size.width(), Fixed)); |
| 691 if (style->height().isAuto() && size.height() > 0) | 709 if (style->height().isAuto() && size.height() > 0) |
| 692 style->setHeight(Length(size.height(), Fixed)); | 710 style->setHeight(Length(size.height(), Fixed)); |
| 693 } | 711 } |
| 694 | 712 |
| 695 void RenderThemeChromiumMac::setFontFromControlSize(CSSStyleSelector* selector,
RenderStyle* style, NSControlSize controlSize) const | 713 void RenderThemeChromiumMac::setFontFromControlSize(CSSStyleSelector*, RenderSty
le* style, NSControlSize controlSize) const |
| 696 { | 714 { |
| 697 FontDescription fontDescription; | 715 FontDescription fontDescription; |
| 698 fontDescription.setIsAbsoluteSize(true); | 716 fontDescription.setIsAbsoluteSize(true); |
| 699 fontDescription.setGenericFamily(FontDescription::SerifFamily); | 717 fontDescription.setGenericFamily(FontDescription::SerifFamily); |
| 700 | 718 |
| 701 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; | 719 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; |
| 702 fontDescription.firstFamily().setFamily([font familyName]); | 720 fontDescription.firstFamily().setFamily([font familyName]); |
| 703 fontDescription.setComputedSize([font pointSize] * style->effectiveZoom()); | 721 fontDescription.setComputedSize([font pointSize] * style->effectiveZoom()); |
| 704 fontDescription.setSpecifiedSize([font pointSize] * style->effectiveZoom()); | 722 fontDescription.setSpecifiedSize([font pointSize] * style->effectiveZoom()); |
| 705 | 723 |
| 706 // Reset line height | 724 // Reset line height |
| 707 style->setLineHeight(RenderStyle::initialLineHeight()); | 725 style->setLineHeight(RenderStyle::initialLineHeight()); |
| 708 | 726 |
| 709 if (style->setFontDescription(fontDescription)) | 727 if (style->setFontDescription(fontDescription)) |
| 710 style->font().update(0); | 728 style->font().update(0); |
| 711 } | 729 } |
| 712 | 730 |
| 713 NSControlSize RenderThemeChromiumMac::controlSizeForSystemFont(RenderStyle* styl
e) const | 731 NSControlSize RenderThemeChromiumMac::controlSizeForSystemFont(RenderStyle* styl
e) const |
| 714 { | 732 { |
| 715 int fontSize = style->fontSize(); | 733 int fontSize = style->fontSize(); |
| 716 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) | 734 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) |
| 717 return NSRegularControlSize; | 735 return NSRegularControlSize; |
| 718 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) | 736 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) |
| 719 return NSSmallControlSize; | 737 return NSSmallControlSize; |
| 720 return NSMiniControlSize; | 738 return NSMiniControlSize; |
| 721 } | 739 } |
| 722 | 740 |
| 723 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 724 bool RenderThemeChromiumMac::paintCheckbox(RenderObject* o, const RenderObject::
PaintInfo& paintInfo, const IntRect& r) | |
| 725 { | |
| 726 LocalCurrentGraphicsContext localContext(paintInfo.context); | |
| 727 | |
| 728 // Determine the width and height needed for the control and prepare the cel
l for painting. | |
| 729 setCheckboxCellState(o, r); | |
| 730 | |
| 731 paintInfo.context->save(); | |
| 732 | |
| 733 float zoomLevel = o->style()->effectiveZoom(); | |
| 734 | |
| 735 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox | |
| 736 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. | |
| 737 NSButtonCell* checkbox = this->checkbox(); | |
| 738 IntSize size = checkboxSizes()[[checkbox controlSize]]; | |
| 739 size.setWidth(size.width() * zoomLevel); | |
| 740 size.setHeight(size.height() * zoomLevel); | |
| 741 IntRect inflatedRect = inflateRect(r, size, checkboxMargins(), zoomLevel); | |
| 742 | |
| 743 if (zoomLevel != 1.0f) { | |
| 744 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | |
| 745 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | |
| 746 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | |
| 747 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | |
| 748 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | |
| 749 } | |
| 750 | |
| 751 [checkbox drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:nil]; | |
| 752 [checkbox setControlView:nil]; | |
| 753 | |
| 754 paintInfo.context->restore(); | |
| 755 | |
| 756 return false; | |
| 757 } | |
| 758 | |
| 759 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 760 const IntSize* RenderThemeChromiumMac::checkboxSizes() const | |
| 761 { | |
| 762 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(
10, 10) }; | |
| 763 return sizes; | |
| 764 } | |
| 765 | |
| 766 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 767 const int* RenderThemeChromiumMac::checkboxMargins() const | |
| 768 { | |
| 769 static const int margins[3][4] = | |
| 770 { | |
| 771 { 3, 4, 4, 2 }, | |
| 772 { 4, 3, 3, 3 }, | |
| 773 { 4, 3, 3, 3 }, | |
| 774 }; | |
| 775 return margins[[checkbox() controlSize]]; | |
| 776 } | |
| 777 | |
| 778 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 779 void RenderThemeChromiumMac::setCheckboxCellState(const RenderObject* o, const I
ntRect& r) | |
| 780 { | |
| 781 NSButtonCell* checkbox = this->checkbox(); | |
| 782 | |
| 783 // Set the control size based off the rectangle we're painting into. | |
| 784 setControlSize(checkbox, checkboxSizes(), r.size(), o->style()->effectiveZoo
m()); | |
| 785 | |
| 786 // Update the various states we respond to. | |
| 787 updateActiveState(checkbox, o); | |
| 788 updateCheckedState(checkbox, o); | |
| 789 updateEnabledState(checkbox, o); | |
| 790 updatePressedState(checkbox, o); | |
| 791 updateFocusedState(checkbox, o); | |
| 792 } | |
| 793 | |
| 794 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 795 void RenderThemeChromiumMac::setCheckboxSize(RenderStyle* style) const | |
| 796 { | |
| 797 // If the width and height are both specified, then we have nothing to do. | |
| 798 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | |
| 799 return; | |
| 800 | |
| 801 // Use the font size to determine the intrinsic width of the control. | |
| 802 setSizeFromFont(style, checkboxSizes()); | |
| 803 } | |
| 804 | |
| 805 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 806 bool RenderThemeChromiumMac::paintRadio(RenderObject* o, const RenderObject::Pai
ntInfo& paintInfo, const IntRect& r) | |
| 807 { | |
| 808 LocalCurrentGraphicsContext localContext(paintInfo.context); | |
| 809 | |
| 810 // Determine the width and height needed for the control and prepare the cel
l for painting. | |
| 811 setRadioCellState(o, r); | |
| 812 | |
| 813 paintInfo.context->save(); | |
| 814 | |
| 815 float zoomLevel = o->style()->effectiveZoom(); | |
| 816 | |
| 817 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox | |
| 818 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. | |
| 819 NSButtonCell* radio = this->radio(); | |
| 820 IntSize size = radioSizes()[[radio controlSize]]; | |
| 821 size.setWidth(size.width() * zoomLevel); | |
| 822 size.setHeight(size.height() * zoomLevel); | |
| 823 IntRect inflatedRect = inflateRect(r, size, radioMargins(), zoomLevel); | |
| 824 | |
| 825 if (zoomLevel != 1.0f) { | |
| 826 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | |
| 827 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | |
| 828 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | |
| 829 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | |
| 830 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | |
| 831 } | |
| 832 | |
| 833 [radio drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:nil]; | |
| 834 [radio setControlView:nil]; | |
| 835 | |
| 836 paintInfo.context->restore(); | |
| 837 | |
| 838 return false; | |
| 839 } | |
| 840 | |
| 841 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 842 const IntSize* RenderThemeChromiumMac::radioSizes() const | |
| 843 { | |
| 844 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(
10, 10) }; | |
| 845 return sizes; | |
| 846 } | |
| 847 | |
| 848 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 849 const int* RenderThemeChromiumMac::radioMargins() const | |
| 850 { | |
| 851 static const int margins[3][4] = | |
| 852 { | |
| 853 { 2, 2, 4, 2 }, | |
| 854 { 3, 2, 3, 2 }, | |
| 855 { 1, 0, 2, 0 }, | |
| 856 }; | |
| 857 return margins[[radio() controlSize]]; | |
| 858 } | |
| 859 | |
| 860 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 861 void RenderThemeChromiumMac::setRadioCellState(const RenderObject* o, const IntR
ect& r) | |
| 862 { | |
| 863 NSButtonCell* radio = this->radio(); | |
| 864 | |
| 865 // Set the control size based off the rectangle we're painting into. | |
| 866 setControlSize(radio, radioSizes(), r.size(), o->style()->effectiveZoom()); | |
| 867 | |
| 868 // Update the various states we respond to. | |
| 869 updateActiveState(radio, o); | |
| 870 updateCheckedState(radio, o); | |
| 871 updateEnabledState(radio, o); | |
| 872 updatePressedState(radio, o); | |
| 873 updateFocusedState(radio, o); | |
| 874 } | |
| 875 | |
| 876 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 877 void RenderThemeChromiumMac::setRadioSize(RenderStyle* style) const | |
| 878 { | |
| 879 // If the width and height are both specified, then we have nothing to do. | |
| 880 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | |
| 881 return; | |
| 882 | |
| 883 // Use the font size to determine the intrinsic width of the control. | |
| 884 setSizeFromFont(style, radioSizes()); | |
| 885 } | |
| 886 | |
| 887 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 888 void RenderThemeChromiumMac::setButtonPaddingFromControlSize(RenderStyle* style,
NSControlSize size) const | |
| 889 { | |
| 890 // Just use 8px. AppKit wants to use 11px for mini buttons, but that paddin
g is just too large | |
| 891 // for real-world Web sites (creating a huge necessary minimum width for but
tons whose space is | |
| 892 // by definition constrained, since we select mini only for small cramped en
vironments. | |
| 893 // This also guarantees the HTML4 <button> will match our rendering by defau
lt, since we're using a consistent | |
| 894 // padding. | |
| 895 const int padding = 8 * style->effectiveZoom(); | |
| 896 style->setPaddingLeft(Length(padding, Fixed)); | |
| 897 style->setPaddingRight(Length(padding, Fixed)); | |
| 898 style->setPaddingTop(Length(0, Fixed)); | |
| 899 style->setPaddingBottom(Length(0, Fixed)); | |
| 900 } | |
| 901 | |
| 902 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 903 void RenderThemeChromiumMac::adjustButtonStyle(CSSStyleSelector* selector, Rende
rStyle* style, Element* e) const | |
| 904 { | |
| 905 // There are three appearance constants for buttons. | |
| 906 // (1) Push-button is the constant for the default Aqua system button. Push
buttons will not scale vertically and will not allow | |
| 907 // custom fonts or colors. <input>s use this constant. This button will al
low custom colors and font weights/variants but won't | |
| 908 // scale vertically. | |
| 909 // (2) square-button is the constant for the square button. This button wil
l allow custom fonts and colors and will scale vertically. | |
| 910 // (3) Button is the constant that means "pick the best button as appropriat
e." <button>s use this constant. This button will | |
| 911 // also scale vertically and allow custom fonts and colors. It will attempt
to use Aqua if possible and will make this determination | |
| 912 // solely on the rectangle of the control. | |
| 913 | |
| 914 // Determine our control size based off our font. | |
| 915 NSControlSize controlSize = controlSizeForFont(style); | |
| 916 | |
| 917 if (style->appearance() == PushButtonPart) { | |
| 918 // Ditch the border. | |
| 919 style->resetBorder(); | |
| 920 | |
| 921 // Height is locked to auto. | |
| 922 style->setHeight(Length(Auto)); | |
| 923 | |
| 924 // White-space is locked to pre | |
| 925 style->setWhiteSpace(PRE); | |
| 926 | |
| 927 // Set the button's vertical size. | |
| 928 setButtonSize(style); | |
| 929 | |
| 930 // Add in the padding that we'd like to use. | |
| 931 setButtonPaddingFromControlSize(style, controlSize); | |
| 932 | |
| 933 // Our font is locked to the appropriate system font size for the contro
l. To clarify, we first use the CSS-specified font to figure out | |
| 934 // a reasonable control size, but once that control size is determined,
we throw that font away and use the appropriate | |
| 935 // system font for the control size instead. | |
| 936 setFontFromControlSize(selector, style, controlSize); | |
| 937 } else { | |
| 938 // Set a min-height so that we can't get smaller than the mini button. | |
| 939 style->setMinHeight(Length(static_cast<int>(15 * style->effectiveZoom())
, Fixed)); | |
| 940 | |
| 941 // Reset the top and bottom borders. | |
| 942 style->resetBorderTop(); | |
| 943 style->resetBorderBottom(); | |
| 944 } | |
| 945 | |
| 946 style->setBoxShadow(0); | |
| 947 } | |
| 948 | |
| 949 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 950 const IntSize* RenderThemeChromiumMac::buttonSizes() const | |
| 951 { | |
| 952 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; | |
| 953 return sizes; | |
| 954 } | |
| 955 | |
| 956 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 957 const int* RenderThemeChromiumMac::buttonMargins() const | |
| 958 { | |
| 959 static const int margins[3][4] = | |
| 960 { | |
| 961 { 4, 6, 7, 6 }, | |
| 962 { 4, 5, 6, 5 }, | |
| 963 { 0, 1, 1, 1 }, | |
| 964 }; | |
| 965 return margins[[button() controlSize]]; | |
| 966 } | |
| 967 | |
| 968 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 969 void RenderThemeChromiumMac::setButtonSize(RenderStyle* style) const | |
| 970 { | |
| 971 // If the width and height are both specified, then we have nothing to do. | |
| 972 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | |
| 973 return; | |
| 974 | |
| 975 // Use the font size to determine the intrinsic width of the control. | |
| 976 setSizeFromFont(style, buttonSizes()); | |
| 977 } | |
| 978 | |
| 979 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 980 void RenderThemeChromiumMac::setButtonCellState(const RenderObject* o, const Int
Rect& r) | |
| 981 { | |
| 982 NSButtonCell* button = this->button(); | |
| 983 | |
| 984 // Set the control size based off the rectangle we're painting into. | |
| 985 if (o->style()->appearance() == SquareButtonPart || | |
| 986 r.height() > buttonSizes()[NSRegularControlSize].height() * o->style()->
effectiveZoom()) { | |
| 987 // Use the square button | |
| 988 if ([button bezelStyle] != NSShadowlessSquareBezelStyle) | |
| 989 [button setBezelStyle:NSShadowlessSquareBezelStyle]; | |
| 990 } else if ([button bezelStyle] != NSRoundedBezelStyle) | |
| 991 [button setBezelStyle:NSRoundedBezelStyle]; | |
| 992 | |
| 993 setControlSize(button, buttonSizes(), r.size(), o->style()->effectiveZoom())
; | |
| 994 | |
| 995 NSWindow *window = [nil window]; | |
| 996 BOOL isDefaultButton = (isDefault(o) && [window isKeyWindow]); | |
| 997 [button setKeyEquivalent:(isDefaultButton ? @"\r" : @"")]; | |
| 998 | |
| 999 // Update the various states we respond to. | |
| 1000 updateActiveState(button, o); | |
| 1001 updateCheckedState(button, o); | |
| 1002 updateEnabledState(button, o); | |
| 1003 updatePressedState(button, o); | |
| 1004 updateFocusedState(button, o); | |
| 1005 } | |
| 1006 | |
| 1007 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | |
| 1008 bool RenderThemeChromiumMac::paintButton(RenderObject* o, const RenderObject::Pa
intInfo& paintInfo, const IntRect& r) | |
| 1009 { | |
| 1010 NSButtonCell* button = this->button(); | |
| 1011 LocalCurrentGraphicsContext localContext(paintInfo.context); | |
| 1012 | |
| 1013 // Determine the width and height needed for the control and prepare the cel
l for painting. | |
| 1014 setButtonCellState(o, r); | |
| 1015 | |
| 1016 paintInfo.context->save(); | |
| 1017 | |
| 1018 // We inflate the rect as needed to account for padding included in the cell
to accommodate the button | |
| 1019 // shadow. We don't consider this part of the bounds of the control in WebK
it. | |
| 1020 float zoomLevel = o->style()->effectiveZoom(); | |
| 1021 IntSize size = buttonSizes()[[button controlSize]]; | |
| 1022 size.setWidth(r.width()); | |
| 1023 size.setHeight(size.height() * zoomLevel); | |
| 1024 IntRect inflatedRect = r; | |
| 1025 if ([button bezelStyle] == NSRoundedBezelStyle) { | |
| 1026 // Center the button within the available space. | |
| 1027 if (inflatedRect.height() > size.height()) { | |
| 1028 inflatedRect.setY(inflatedRect.y() + (inflatedRect.height() - size.h
eight()) / 2); | |
| 1029 inflatedRect.setHeight(size.height()); | |
| 1030 } | |
| 1031 | |
| 1032 // Now inflate it to account for the shadow. | |
| 1033 inflatedRect = inflateRect(inflatedRect, size, buttonMargins(), zoomLeve
l); | |
| 1034 | |
| 1035 if (zoomLevel != 1.0f) { | |
| 1036 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | |
| 1037 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | |
| 1038 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | |
| 1039 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | |
| 1040 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | |
| 1041 } | |
| 1042 } | |
| 1043 | |
| 1044 NSView *view = nil; | |
| 1045 NSWindow *window = [view window]; | |
| 1046 NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell]; | |
| 1047 | |
| 1048 if (isDefault(o) && [window isKeyWindow]) { | |
| 1049 [window setDefaultButtonCell:button]; | |
| 1050 wkAdvanceDefaultButtonPulseAnimation(button); | |
| 1051 } else if ([previousDefaultButtonCell isEqual:button]) | |
| 1052 [window setDefaultButtonCell:nil]; | |
| 1053 | |
| 1054 [button drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:view]; | |
| 1055 [button setControlView:nil]; | |
| 1056 | |
| 1057 if (![previousDefaultButtonCell isEqual:button]) | |
| 1058 [window setDefaultButtonCell:previousDefaultButtonCell]; | |
| 1059 | |
| 1060 paintInfo.context->restore(); | |
| 1061 | |
| 1062 return false; | |
| 1063 } | |
| 1064 | |
| 1065 bool RenderThemeChromiumMac::paintTextField(RenderObject* o, const RenderObject:
:PaintInfo& paintInfo, const IntRect& r) | 741 bool RenderThemeChromiumMac::paintTextField(RenderObject* o, const RenderObject:
:PaintInfo& paintInfo, const IntRect& r) |
| 1066 { | 742 { |
| 1067 LocalCurrentGraphicsContext localContext(paintInfo.context); | 743 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1068 wkDrawBezeledTextFieldCell(IntRectToNSRect(r), isEnabled(o) && !isReadOnlyCo
ntrol(o)); | 744 wkDrawBezeledTextFieldCell(r, isEnabled(o) && !isReadOnlyControl(o)); |
| 1069 return false; | 745 return false; |
| 1070 } | 746 } |
| 1071 | 747 |
| 1072 void RenderThemeChromiumMac::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle
*, Element*) const | 748 void RenderThemeChromiumMac::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle
*, Element*) const |
| 1073 { | 749 { |
| 1074 } | 750 } |
| 1075 | 751 |
| 1076 bool RenderThemeChromiumMac::paintCapsLockIndicator(RenderObject* o, const Rende
rObject::PaintInfo& paintInfo, const IntRect& r) | 752 bool RenderThemeChromiumMac::paintCapsLockIndicator(RenderObject*, const RenderO
bject::PaintInfo& paintInfo, const IntRect& r) |
| 1077 { | 753 { |
| 1078 if (paintInfo.context->paintingDisabled()) | 754 if (paintInfo.context->paintingDisabled()) |
| 1079 return true; | 755 return true; |
| 1080 | 756 |
| 1081 LocalCurrentGraphicsContext localContext(paintInfo.context); | 757 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1082 wkDrawCapsLockIndicator(paintInfo.context->platformContext(), r); | 758 wkDrawCapsLockIndicator(paintInfo.context->platformContext(), r); |
| 1083 | 759 |
| 1084 return false; | 760 return false; |
| 1085 } | 761 } |
| 1086 | 762 |
| 1087 bool RenderThemeChromiumMac::paintTextArea(RenderObject* o, const RenderObject::
PaintInfo& paintInfo, const IntRect& r) | 763 bool RenderThemeChromiumMac::paintTextArea(RenderObject* o, const RenderObject::
PaintInfo& paintInfo, const IntRect& r) |
| 1088 { | 764 { |
| 1089 LocalCurrentGraphicsContext localContext(paintInfo.context); | 765 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1090 wkDrawBezeledTextArea(IntRectToNSRect(r), isEnabled(o) && !isReadOnlyControl
(o)); | 766 wkDrawBezeledTextArea(r, isEnabled(o) && !isReadOnlyControl(o)); |
| 1091 return false; | 767 return false; |
| 1092 } | 768 } |
| 1093 | 769 |
| 1094 void RenderThemeChromiumMac::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*
, Element*) const | 770 void RenderThemeChromiumMac::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*
, Element*) const |
| 1095 { | 771 { |
| 1096 } | 772 } |
| 1097 | 773 |
| 1098 const int* RenderThemeChromiumMac::popupButtonMargins() const | 774 const int* RenderThemeChromiumMac::popupButtonMargins() const |
| 1099 { | 775 { |
| 1100 static const int margins[3][4] = | 776 static const int margins[3][4] = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1118 { | 794 { |
| 1119 { 2, 26, 3, 8 }, | 795 { 2, 26, 3, 8 }, |
| 1120 { 2, 23, 3, 8 }, | 796 { 2, 23, 3, 8 }, |
| 1121 { 2, 22, 3, 10 } | 797 { 2, 22, 3, 10 } |
| 1122 }; | 798 }; |
| 1123 return padding[size]; | 799 return padding[size]; |
| 1124 } | 800 } |
| 1125 | 801 |
| 1126 bool RenderThemeChromiumMac::paintMenuList(RenderObject* o, const RenderObject::
PaintInfo& paintInfo, const IntRect& r) | 802 bool RenderThemeChromiumMac::paintMenuList(RenderObject* o, const RenderObject::
PaintInfo& paintInfo, const IntRect& r) |
| 1127 { | 803 { |
| 1128 LocalCurrentGraphicsContext localContext(paintInfo.context); | |
| 1129 | |
| 1130 setPopupButtonCellState(o, r); | 804 setPopupButtonCellState(o, r); |
| 1131 | 805 |
| 1132 NSPopUpButtonCell* popupButton = this->popupButton(); | 806 NSPopUpButtonCell* popupButton = this->popupButton(); |
| 1133 | 807 |
| 1134 float zoomLevel = o->style()->effectiveZoom(); | 808 float zoomLevel = o->style()->effectiveZoom(); |
| 1135 IntSize size = popupButtonSizes()[[popupButton controlSize]]; | 809 IntSize size = popupButtonSizes()[[popupButton controlSize]]; |
| 1136 size.setHeight(size.height() * zoomLevel); | 810 size.setHeight(size.height() * zoomLevel); |
| 1137 size.setWidth(r.width()); | 811 size.setWidth(r.width()); |
| 1138 | 812 |
| 1139 // Now inflate it to account for the shadow. | 813 // Now inflate it to account for the shadow. |
| 1140 IntRect inflatedRect = r; | 814 IntRect inflatedRect = r; |
| 1141 if (r.width() >= minimumMenuListSize(o->style())) | 815 if (r.width() >= minimumMenuListSize(o->style())) |
| 1142 inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoo
mLevel); | 816 inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoo
mLevel); |
| 1143 | 817 |
| 1144 paintInfo.context->save(); | 818 paintInfo.context->save(); |
| 1145 | 819 |
| 1146 #ifndef BUILDING_ON_TIGER | 820 #ifndef BUILDING_ON_TIGER |
| 1147 // On Leopard, the cell will draw outside of the given rect, so we have to c
lip to the rect | 821 // On Leopard, the cell will draw outside of the given rect, so we have to c
lip to the rect |
| 1148 paintInfo.context->clip(inflatedRect); | 822 paintInfo.context->clip(inflatedRect); |
| 1149 #endif | 823 #endif |
| 1150 | 824 |
| 1151 if (zoomLevel != 1.0f) { | 825 if (zoomLevel != 1.0f) { |
| 1152 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 826 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 1153 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 827 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 1154 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | 828 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); |
| 1155 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 829 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1156 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | 830 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 1157 } | 831 } |
| 1158 | 832 |
| 1159 [popupButton drawWithFrame:IntRectToNSRect(inflatedRect) inView:nil]; | 833 [popupButton drawWithFrame:inflatedRect inView:FlippedView()]; |
| 1160 [popupButton setControlView:nil]; | 834 [popupButton setControlView:nil]; |
| 1161 | 835 |
| 1162 paintInfo.context->restore(); | 836 paintInfo.context->restore(); |
| 1163 | 837 |
| 1164 return false; | 838 return false; |
| 1165 } | 839 } |
| 1166 | 840 |
| 1167 static const float baseFontSize = 11.0f; | 841 const float baseFontSize = 11.0f; |
| 1168 static const float baseArrowHeight = 4.0f; | 842 const float baseArrowHeight = 4.0f; |
| 1169 static const float baseArrowWidth = 5.0f; | 843 const float baseArrowWidth = 5.0f; |
| 1170 static const float baseSpaceBetweenArrows = 2.0f; | 844 const float baseSpaceBetweenArrows = 2.0f; |
| 1171 static const int arrowPaddingLeft = 6; | 845 const int arrowPaddingLeft = 6; |
| 1172 static const int arrowPaddingRight = 6; | 846 const int arrowPaddingRight = 6; |
| 1173 static const int paddingBeforeSeparator = 4; | 847 const int paddingBeforeSeparator = 4; |
| 1174 static const int baseBorderRadius = 5; | 848 const int baseBorderRadius = 5; |
| 1175 static const int styledPopupPaddingLeft = 8; | 849 const int styledPopupPaddingLeft = 8; |
| 1176 static const int styledPopupPaddingTop = 1; | 850 const int styledPopupPaddingTop = 1; |
| 1177 static const int styledPopupPaddingBottom = 2; | 851 const int styledPopupPaddingBottom = 2; |
| 1178 | 852 |
| 1179 static void TopGradientInterpolate(void* info, const CGFloat* inData, CGFloat* o
utData) | 853 static void TopGradientInterpolate(void*, const CGFloat* inData, CGFloat* outDat
a) |
| 1180 { | 854 { |
| 1181 static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.4f }; | 855 static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.4f }; |
| 1182 static float light[4] = { 1.0f, 1.0f, 1.0f, 0.15f }; | 856 static float light[4] = { 1.0f, 1.0f, 1.0f, 0.15f }; |
| 1183 float a = inData[0]; | 857 float a = inData[0]; |
| 1184 int i = 0; | 858 int i = 0; |
| 1185 for (i = 0; i < 4; i++) | 859 for (i = 0; i < 4; i++) |
| 1186 outData[i] = (1.0f - a) * dark[i] + a * light[i]; | 860 outData[i] = (1.0f - a) * dark[i] + a * light[i]; |
| 1187 } | 861 } |
| 1188 | 862 |
| 1189 static void BottomGradientInterpolate(void* info, const CGFloat* inData, CGFloat
* outData) | 863 static void BottomGradientInterpolate(void*, const CGFloat* inData, CGFloat* out
Data) |
| 1190 { | 864 { |
| 1191 static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; | 865 static float dark[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; |
| 1192 static float light[4] = { 1.0f, 1.0f, 1.0f, 0.3f }; | 866 static float light[4] = { 1.0f, 1.0f, 1.0f, 0.3f }; |
| 1193 float a = inData[0]; | 867 float a = inData[0]; |
| 1194 int i = 0; | 868 int i = 0; |
| 1195 for (i = 0; i < 4; i++) | 869 for (i = 0; i < 4; i++) |
| 1196 outData[i] = (1.0f - a) * dark[i] + a * light[i]; | 870 outData[i] = (1.0f - a) * dark[i] + a * light[i]; |
| 1197 } | 871 } |
| 1198 | 872 |
| 1199 static void MainGradientInterpolate(void* info, const CGFloat* inData, CGFloat*
outData) | 873 static void MainGradientInterpolate(void*, const CGFloat* inData, CGFloat* outDa
ta) |
| 1200 { | 874 { |
| 1201 static float dark[4] = { 0.0f, 0.0f, 0.0f, 0.15f }; | 875 static float dark[4] = { 0.0f, 0.0f, 0.0f, 0.15f }; |
| 1202 static float light[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; | 876 static float light[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; |
| 1203 float a = inData[0]; | 877 float a = inData[0]; |
| 1204 int i = 0; | 878 int i = 0; |
| 1205 for (i = 0; i < 4; i++) | 879 for (i = 0; i < 4; i++) |
| 1206 outData[i] = (1.0f - a) * dark[i] + a * light[i]; | 880 outData[i] = (1.0f - a) * dark[i] + a * light[i]; |
| 1207 } | 881 } |
| 1208 | 882 |
| 1209 static void TrackGradientInterpolate(void* info, const CGFloat* inData, CGFloat*
outData) | 883 static void TrackGradientInterpolate(void*, const CGFloat* inData, CGFloat* outD
ata) |
| 1210 { | 884 { |
| 1211 static float dark[4] = { 0.0f, 0.0f, 0.0f, 0.678f }; | 885 static float dark[4] = { 0.0f, 0.0f, 0.0f, 0.678f }; |
| 1212 static float light[4] = { 0.0f, 0.0f, 0.0f, 0.13f }; | 886 static float light[4] = { 0.0f, 0.0f, 0.0f, 0.13f }; |
| 1213 float a = inData[0]; | 887 float a = inData[0]; |
| 1214 int i = 0; | 888 int i = 0; |
| 1215 for (i = 0; i < 4; i++) | 889 for (i = 0; i < 4; i++) |
| 1216 outData[i] = (1.0f - a) * dark[i] + a * light[i]; | 890 outData[i] = (1.0f - a) * dark[i] + a * light[i]; |
| 1217 } | 891 } |
| 1218 | 892 |
| 1219 void RenderThemeChromiumMac::paintMenuListButtonGradients(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) | 893 void RenderThemeChromiumMac::paintMenuListButtonGradients(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1220 { | 894 { |
| 895 if (r.isEmpty()) |
| 896 return; |
| 897 |
| 1221 CGContextRef context = paintInfo.context->platformContext(); | 898 CGContextRef context = paintInfo.context->platformContext(); |
| 1222 | 899 |
| 1223 paintInfo.context->save(); | 900 paintInfo.context->save(); |
| 1224 | 901 |
| 1225 int radius = o->style()->borderTopLeftRadius().width(); | 902 IntSize topLeftRadius; |
| 903 IntSize topRightRadius; |
| 904 IntSize bottomLeftRadius; |
| 905 IntSize bottomRightRadius; |
| 906 |
| 907 o->style()->getBorderRadiiForRect(r, topLeftRadius, topRightRadius, bottomLe
ftRadius, bottomRightRadius); |
| 908 |
| 909 int radius = topLeftRadius.width(); |
| 1226 | 910 |
| 1227 RetainPtr<CGColorSpaceRef> cspace(AdoptCF, CGColorSpaceCreateDeviceRGB()); | 911 RetainPtr<CGColorSpaceRef> cspace(AdoptCF, CGColorSpaceCreateDeviceRGB()); |
| 1228 | 912 |
| 1229 FloatRect topGradient(r.x(), r.y(), r.width(), r.height() / 2.0f); | 913 FloatRect topGradient(r.x(), r.y(), r.width(), r.height() / 2.0f); |
| 1230 struct CGFunctionCallbacks topCallbacks = { 0, TopGradientInterpolate, NULL
}; | 914 struct CGFunctionCallbacks topCallbacks = { 0, TopGradientInterpolate, NULL
}; |
| 1231 RetainPtr<CGFunctionRef> topFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL
, 4, NULL, &topCallbacks)); | 915 RetainPtr<CGFunctionRef> topFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL
, 4, NULL, &topCallbacks)); |
| 1232 RetainPtr<CGShadingRef> topShading(AdoptCF, CGShadingCreateAxial(cspace.get(
), CGPointMake(topGradient.x(), topGradient.y()), CGPointMake(topGradient.x(), t
opGradient.bottom()), topFunction.get(), false, false)); | 916 RetainPtr<CGShadingRef> topShading(AdoptCF, CGShadingCreateAxial(cspace.get(
), CGPointMake(topGradient.x(), topGradient.y()), CGPointMake(topGradient.x(), t
opGradient.bottom()), topFunction.get(), false, false)); |
| 1233 | 917 |
| 1234 FloatRect bottomGradient(r.x() + radius, r.y() + r.height() / 2.0f, r.width(
) - 2.0f * radius, r.height() / 2.0f); | 918 FloatRect bottomGradient(r.x() + radius, r.y() + r.height() / 2.0f, r.width(
) - 2.0f * radius, r.height() / 2.0f); |
| 1235 struct CGFunctionCallbacks bottomCallbacks = { 0, BottomGradientInterpolate,
NULL }; | 919 struct CGFunctionCallbacks bottomCallbacks = { 0, BottomGradientInterpolate,
NULL }; |
| 1236 RetainPtr<CGFunctionRef> bottomFunction(AdoptCF, CGFunctionCreate(NULL, 1, N
ULL, 4, NULL, &bottomCallbacks)); | 920 RetainPtr<CGFunctionRef> bottomFunction(AdoptCF, CGFunctionCreate(NULL, 1, N
ULL, 4, NULL, &bottomCallbacks)); |
| 1237 RetainPtr<CGShadingRef> bottomShading(AdoptCF, CGShadingCreateAxial(cspace.g
et(), CGPointMake(bottomGradient.x(), bottomGradient.y()), CGPointMake(bottomGr
adient.x(), bottomGradient.bottom()), bottomFunction.get(), false, false)); | 921 RetainPtr<CGShadingRef> bottomShading(AdoptCF, CGShadingCreateAxial(cspace.g
et(), CGPointMake(bottomGradient.x(), bottomGradient.y()), CGPointMake(bottomGr
adient.x(), bottomGradient.bottom()), bottomFunction.get(), false, false)); |
| 1238 | 922 |
| 1239 struct CGFunctionCallbacks mainCallbacks = { 0, MainGradientInterpolate, NUL
L }; | 923 struct CGFunctionCallbacks mainCallbacks = { 0, MainGradientInterpolate, NUL
L }; |
| 1240 RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NUL
L, 4, NULL, &mainCallbacks)); | 924 RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NUL
L, 4, NULL, &mainCallbacks)); |
| 1241 RetainPtr<CGShadingRef> mainShading(AdoptCF, CGShadingCreateAxial(cspace.get
(), CGPointMake(r.x(), r.y()), CGPointMake(r.x(), r.bottom()), mainFunction.get
(), false, false)); | 925 RetainPtr<CGShadingRef> mainShading(AdoptCF, CGShadingCreateAxial(cspace.get
(), CGPointMake(r.x(), r.y()), CGPointMake(r.x(), r.bottom()), mainFunction.get
(), false, false)); |
| 1242 | 926 |
| 1243 RetainPtr<CGShadingRef> leftShading(AdoptCF, CGShadingCreateAxial(cspace.get
(), CGPointMake(r.x(), r.y()), CGPointMake(r.x() + radius, r.y()), mainFunction
.get(), false, false)); | 927 RetainPtr<CGShadingRef> leftShading(AdoptCF, CGShadingCreateAxial(cspace.get
(), CGPointMake(r.x(), r.y()), CGPointMake(r.x() + radius, r.y()), mainFunction
.get(), false, false)); |
| 1244 | 928 |
| 1245 RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace.ge
t(), CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mai
nFunction.get(), false, false)); | 929 RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace.ge
t(), CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mai
nFunction.get(), false, false)); |
| 1246 paintInfo.context->save(); | 930 paintInfo.context->save(); |
| 1247 CGContextClipToRect(context, r); | 931 CGContextClipToRect(context, r); |
| 1248 paintInfo.context->addRoundedRectClip(r, | 932 paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bott
omLeftRadius, bottomRightRadius); |
| 1249 o->style()->borderTopLeftRadius(), o->style()->borderTopRightRadius(), | |
| 1250 o->style()->borderBottomLeftRadius(), o->style()->borderBottomRightRadiu
s()); | |
| 1251 CGContextDrawShading(context, mainShading.get()); | 933 CGContextDrawShading(context, mainShading.get()); |
| 1252 paintInfo.context->restore(); | 934 paintInfo.context->restore(); |
| 1253 | 935 |
| 1254 paintInfo.context->save(); | 936 paintInfo.context->save(); |
| 1255 CGContextClipToRect(context, topGradient); | 937 CGContextClipToRect(context, topGradient); |
| 1256 paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), | 938 paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), topLeft
Radius, topRightRadius, IntSize(), IntSize()); |
| 1257 o->style()->borderTopLeftRadius(), o->style()->borderTopRightRadius(), | |
| 1258 IntSize(), IntSize()); | |
| 1259 CGContextDrawShading(context, topShading.get()); | 939 CGContextDrawShading(context, topShading.get()); |
| 1260 paintInfo.context->restore(); | 940 paintInfo.context->restore(); |
| 1261 | 941 |
| 1262 paintInfo.context->save(); | 942 if (!bottomGradient.isEmpty()) { |
| 1263 CGContextClipToRect(context, bottomGradient); | 943 paintInfo.context->save(); |
| 1264 paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient), | 944 CGContextClipToRect(context, bottomGradient); |
| 1265 IntSize(), IntSize(), | 945 paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient),
IntSize(), IntSize(), bottomLeftRadius, bottomRightRadius); |
| 1266 o->style()->borderBottomLeftRadius(), o->style()->borderBottomRightRadiu
s()); | 946 CGContextDrawShading(context, bottomShading.get()); |
| 1267 CGContextDrawShading(context, bottomShading.get()); | 947 paintInfo.context->restore(); |
| 1268 paintInfo.context->restore(); | 948 } |
| 1269 | 949 |
| 1270 paintInfo.context->save(); | 950 paintInfo.context->save(); |
| 1271 CGContextClipToRect(context, r); | 951 CGContextClipToRect(context, r); |
| 1272 paintInfo.context->addRoundedRectClip(r, | 952 paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bott
omLeftRadius, bottomRightRadius); |
| 1273 o->style()->borderTopLeftRadius(), o->style()->borderTopRightRadius(), | |
| 1274 o->style()->borderBottomLeftRadius(), o->style()->borderBottomRightRadiu
s()); | |
| 1275 CGContextDrawShading(context, leftShading.get()); | 953 CGContextDrawShading(context, leftShading.get()); |
| 1276 CGContextDrawShading(context, rightShading.get()); | 954 CGContextDrawShading(context, rightShading.get()); |
| 1277 paintInfo.context->restore(); | 955 paintInfo.context->restore(); |
| 1278 | 956 |
| 1279 paintInfo.context->restore(); | 957 paintInfo.context->restore(); |
| 1280 } | 958 } |
| 1281 | 959 |
| 1282 bool RenderThemeChromiumMac::paintMenuListButton(RenderObject* o, const RenderOb
ject::PaintInfo& paintInfo, const IntRect& r) | 960 bool RenderThemeChromiumMac::paintMenuListButton(RenderObject* o, const RenderOb
ject::PaintInfo& paintInfo, const IntRect& r) |
| 1283 { | 961 { |
| 1284 paintInfo.context->save(); | |
| 1285 | |
| 1286 IntRect bounds = IntRect(r.x() + o->style()->borderLeftWidth(), | 962 IntRect bounds = IntRect(r.x() + o->style()->borderLeftWidth(), |
| 1287 r.y() + o->style()->borderTopWidth(), | 963 r.y() + o->style()->borderTopWidth(), |
| 1288 r.width() - o->style()->borderLeftWidth() - o->styl
e()->borderRightWidth(), | 964 r.width() - o->style()->borderLeftWidth() - o->styl
e()->borderRightWidth(), |
| 1289 r.height() - o->style()->borderTopWidth() - o->styl
e()->borderBottomWidth()); | 965 r.height() - o->style()->borderTopWidth() - o->styl
e()->borderBottomWidth()); |
| 1290 // Draw the gradients to give the styled popup menu a button appearance | 966 // Draw the gradients to give the styled popup menu a button appearance |
| 1291 paintMenuListButtonGradients(o, paintInfo, bounds); | 967 paintMenuListButtonGradients(o, paintInfo, bounds); |
| 1292 | 968 |
| 1293 // 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 | 969 // 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 |
| 1294 float fontScale = min(o->style()->fontSize() / baseFontSize, bounds.height()
/ (baseArrowHeight * 2 + baseSpaceBetweenArrows)); | 970 float fontScale = min(o->style()->fontSize() / baseFontSize, bounds.height()
/ (baseArrowHeight * 2 + baseSpaceBetweenArrows)); |
| 1295 float centerY = bounds.y() + bounds.height() / 2.0f; | 971 float centerY = bounds.y() + bounds.height() / 2.0f; |
| 1296 float arrowHeight = baseArrowHeight * fontScale; | 972 float arrowHeight = baseArrowHeight * fontScale; |
| 1297 float arrowWidth = baseArrowWidth * fontScale; | 973 float arrowWidth = baseArrowWidth * fontScale; |
| 1298 float leftEdge = bounds.right() - arrowPaddingRight * o->style()->effectiveZ
oom() - arrowWidth; | 974 float leftEdge = bounds.right() - arrowPaddingRight * o->style()->effectiveZ
oom() - arrowWidth; |
| 1299 float spaceBetweenArrows = baseSpaceBetweenArrows * fontScale; | 975 float spaceBetweenArrows = baseSpaceBetweenArrows * fontScale; |
| 1300 | 976 |
| 1301 if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZo
om()) | 977 if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZo
om()) |
| 1302 return false; | 978 return false; |
| 1303 | 979 |
| 980 paintInfo.context->save(); |
| 981 |
| 1304 paintInfo.context->setFillColor(o->style()->color()); | 982 paintInfo.context->setFillColor(o->style()->color()); |
| 1305 paintInfo.context->setStrokeStyle(NoStroke); | 983 paintInfo.context->setStrokeStyle(NoStroke); |
| 1306 | 984 |
| 1307 FloatPoint arrow1[3]; | 985 FloatPoint arrow1[3]; |
| 1308 arrow1[0] = FloatPoint(leftEdge, centerY - spaceBetweenArrows / 2.0f); | 986 arrow1[0] = FloatPoint(leftEdge, centerY - spaceBetweenArrows / 2.0f); |
| 1309 arrow1[1] = FloatPoint(leftEdge + arrowWidth, centerY - spaceBetweenArrows /
2.0f); | 987 arrow1[1] = FloatPoint(leftEdge + arrowWidth, centerY - spaceBetweenArrows /
2.0f); |
| 1310 arrow1[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY - spaceBetweenA
rrows / 2.0f - arrowHeight); | 988 arrow1[2] = FloatPoint(leftEdge + arrowWidth / 2.0f, centerY - spaceBetweenA
rrows / 2.0f - arrowHeight); |
| 1311 | 989 |
| 1312 // Draw the top arrow | 990 // Draw the top arrow |
| 1313 paintInfo.context->drawConvexPolygon(3, arrow1, true); | 991 paintInfo.context->drawConvexPolygon(3, arrow1, true); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 // a reasonable control size, but once that control size is determined, we t
hrow that font away and use the appropriate | 1050 // a reasonable control size, but once that control size is determined, we t
hrow that font away and use the appropriate |
| 1373 // system font for the control size instead. | 1051 // system font for the control size instead. |
| 1374 setFontFromControlSize(selector, style, controlSize); | 1052 setFontFromControlSize(selector, style, controlSize); |
| 1375 | 1053 |
| 1376 style->setBoxShadow(0); | 1054 style->setBoxShadow(0); |
| 1377 } | 1055 } |
| 1378 | 1056 |
| 1379 int RenderThemeChromiumMac::popupInternalPaddingLeft(RenderStyle* style) const | 1057 int RenderThemeChromiumMac::popupInternalPaddingLeft(RenderStyle* style) const |
| 1380 { | 1058 { |
| 1381 if (style->appearance() == MenulistPart) | 1059 if (style->appearance() == MenulistPart) |
| 1382 return popupButtonPadding(controlSizeForFont(style))[LeftPadding] * styl
e->effectiveZoom(); | 1060 return popupButtonPadding(controlSizeForFont(style))[leftPadding] * styl
e->effectiveZoom(); |
| 1383 if (style->appearance() == MenulistButtonPart) | 1061 if (style->appearance() == MenulistButtonPart) |
| 1384 return styledPopupPaddingLeft * style->effectiveZoom(); | 1062 return styledPopupPaddingLeft * style->effectiveZoom(); |
| 1385 return 0; | 1063 return 0; |
| 1386 } | 1064 } |
| 1387 | 1065 |
| 1388 int RenderThemeChromiumMac::popupInternalPaddingRight(RenderStyle* style) const | 1066 int RenderThemeChromiumMac::popupInternalPaddingRight(RenderStyle* style) const |
| 1389 { | 1067 { |
| 1390 if (style->appearance() == MenulistPart) | 1068 if (style->appearance() == MenulistPart) |
| 1391 return popupButtonPadding(controlSizeForFont(style))[RightPadding] * sty
le->effectiveZoom(); | 1069 return popupButtonPadding(controlSizeForFont(style))[rightPadding] * sty
le->effectiveZoom(); |
| 1392 if (style->appearance() == MenulistButtonPart) { | 1070 if (style->appearance() == MenulistButtonPart) { |
| 1393 float fontScale = style->fontSize() / baseFontSize; | 1071 float fontScale = style->fontSize() / baseFontSize; |
| 1394 float arrowWidth = baseArrowWidth * fontScale; | 1072 float arrowWidth = baseArrowWidth * fontScale; |
| 1395 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style->effectiveZoom())); | 1073 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style->effectiveZoom())); |
| 1396 } | 1074 } |
| 1397 return 0; | 1075 return 0; |
| 1398 } | 1076 } |
| 1399 | 1077 |
| 1400 int RenderThemeChromiumMac::popupInternalPaddingTop(RenderStyle* style) const | 1078 int RenderThemeChromiumMac::popupInternalPaddingTop(RenderStyle* style) const |
| 1401 { | 1079 { |
| 1402 if (style->appearance() == MenulistPart) | 1080 if (style->appearance() == MenulistPart) |
| 1403 return popupButtonPadding(controlSizeForFont(style))[TopPadding] * style
->effectiveZoom(); | 1081 return popupButtonPadding(controlSizeForFont(style))[topPadding] * style
->effectiveZoom(); |
| 1404 if (style->appearance() == MenulistButtonPart) | 1082 if (style->appearance() == MenulistButtonPart) |
| 1405 return styledPopupPaddingTop * style->effectiveZoom(); | 1083 return styledPopupPaddingTop * style->effectiveZoom(); |
| 1406 return 0; | 1084 return 0; |
| 1407 } | 1085 } |
| 1408 | 1086 |
| 1409 int RenderThemeChromiumMac::popupInternalPaddingBottom(RenderStyle* style) const | 1087 int RenderThemeChromiumMac::popupInternalPaddingBottom(RenderStyle* style) const |
| 1410 { | 1088 { |
| 1411 if (style->appearance() == MenulistPart) | 1089 if (style->appearance() == MenulistPart) |
| 1412 return popupButtonPadding(controlSizeForFont(style))[BottomPadding] * st
yle->effectiveZoom(); | 1090 return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * st
yle->effectiveZoom(); |
| 1413 if (style->appearance() == MenulistButtonPart) | 1091 if (style->appearance() == MenulistButtonPart) |
| 1414 return styledPopupPaddingBottom * style->effectiveZoom(); | 1092 return styledPopupPaddingBottom * style->effectiveZoom(); |
| 1415 return 0; | 1093 return 0; |
| 1416 } | 1094 } |
| 1417 | 1095 |
| 1418 void RenderThemeChromiumMac::adjustMenuListButtonStyle(CSSStyleSelector* selecto
r, RenderStyle* style, Element* e) const | 1096 void RenderThemeChromiumMac::adjustMenuListButtonStyle(CSSStyleSelector*, Render
Style* style, Element*) const |
| 1419 { | 1097 { |
| 1420 float fontScale = style->fontSize() / baseFontSize; | 1098 float fontScale = style->fontSize() / baseFontSize; |
| 1421 | 1099 |
| 1422 style->resetPadding(); | 1100 style->resetPadding(); |
| 1423 style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(ba
seBorderRadius + fontScale - 1))); // FIXME: Round up? | 1101 style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(ba
seBorderRadius + fontScale - 1))); // FIXME: Round up? |
| 1424 | 1102 |
| 1425 const int minHeight = 15; | 1103 const int minHeight = 15; |
| 1426 style->setMinHeight(Length(minHeight, Fixed)); | 1104 style->setMinHeight(Length(minHeight, Fixed)); |
| 1427 | 1105 |
| 1428 style->setLineHeight(RenderStyle::initialLineHeight()); | 1106 style->setLineHeight(RenderStyle::initialLineHeight()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1447 { | 1125 { |
| 1448 static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0
) }; | 1126 static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0
) }; |
| 1449 return sizes; | 1127 return sizes; |
| 1450 } | 1128 } |
| 1451 | 1129 |
| 1452 int RenderThemeChromiumMac::minimumMenuListSize(RenderStyle* style) const | 1130 int RenderThemeChromiumMac::minimumMenuListSize(RenderStyle* style) const |
| 1453 { | 1131 { |
| 1454 return sizeForSystemFont(style, menuListSizes()).width(); | 1132 return sizeForSystemFont(style, menuListSizes()).width(); |
| 1455 } | 1133 } |
| 1456 | 1134 |
| 1457 static const int trackWidth = 5; | 1135 const int trackWidth = 5; |
| 1458 static const int trackRadius = 2; | 1136 const int trackRadius = 2; |
| 1459 | 1137 |
| 1460 void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector* selector,
RenderStyle* style, Element* e) const | 1138 void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector*, RenderSty
le* style, Element*) const |
| 1461 { | 1139 { |
| 1462 style->setBoxShadow(0); | 1140 style->setBoxShadow(0); |
| 1463 } | 1141 } |
| 1464 | 1142 |
| 1465 bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) | 1143 bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) |
| 1466 { | 1144 { |
| 1467 IntRect bounds = r; | 1145 IntRect bounds = r; |
| 1468 float zoomLevel = o->style()->effectiveZoom(); | 1146 float zoomLevel = o->style()->effectiveZoom(); |
| 1469 float zoomedTrackWidth = trackWidth * zoomLevel; | 1147 float zoomedTrackWidth = trackWidth * zoomLevel; |
| 1470 | 1148 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1494 IntSize radius(trackRadius, trackRadius); | 1172 IntSize radius(trackRadius, trackRadius); |
| 1495 paintInfo.context->addRoundedRectClip(bounds, | 1173 paintInfo.context->addRoundedRectClip(bounds, |
| 1496 radius, radius, | 1174 radius, radius, |
| 1497 radius, radius); | 1175 radius, radius); |
| 1498 CGContextDrawShading(context, mainShading.get()); | 1176 CGContextDrawShading(context, mainShading.get()); |
| 1499 paintInfo.context->restore(); | 1177 paintInfo.context->restore(); |
| 1500 | 1178 |
| 1501 return false; | 1179 return false; |
| 1502 } | 1180 } |
| 1503 | 1181 |
| 1504 void RenderThemeChromiumMac::adjustSliderThumbStyle(CSSStyleSelector* selector,
RenderStyle* style, Element* e) const | 1182 void RenderThemeChromiumMac::adjustSliderThumbStyle(CSSStyleSelector*, RenderSty
le* style, Element*) const |
| 1505 { | 1183 { |
| 1506 style->setBoxShadow(0); | 1184 style->setBoxShadow(0); |
| 1507 } | 1185 } |
| 1508 | 1186 |
| 1509 static const float verticalSliderHeightPadding = 0.1f; | 1187 const float verticalSliderHeightPadding = 0.1f; |
| 1510 | 1188 |
| 1511 bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) | 1189 bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) |
| 1512 { | 1190 { |
| 1513 ASSERT(o->parent()->isSlider()); | 1191 ASSERT(o->parent()->isSlider()); |
| 1514 | 1192 |
| 1515 NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerti
calPart | 1193 NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerti
calPart |
| 1516 ? sliderThumbVertical() | 1194 ? sliderThumbVertical() |
| 1517 : sliderThumbHorizontal(); | 1195 : sliderThumbHorizontal(); |
| 1518 | 1196 |
| 1519 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1197 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 | 1232 |
| 1555 FloatRect unzoomedRect = bounds; | 1233 FloatRect unzoomedRect = bounds; |
| 1556 if (zoomLevel != 1.0f) { | 1234 if (zoomLevel != 1.0f) { |
| 1557 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1235 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1558 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1236 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1559 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1237 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1560 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1238 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1561 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1239 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1562 } | 1240 } |
| 1563 | 1241 |
| 1564 [sliderThumbCell drawWithFrame:FloatRectToNSRect(unzoomedRect) inView:nil]; | 1242 [sliderThumbCell drawWithFrame:unzoomedRect inView:FlippedView()]; |
| 1565 [sliderThumbCell setControlView:nil]; | 1243 [sliderThumbCell setControlView:nil]; |
| 1566 | 1244 |
| 1567 paintInfo.context->restore(); | 1245 paintInfo.context->restore(); |
| 1568 | 1246 |
| 1569 return false; | 1247 return false; |
| 1570 } | 1248 } |
| 1571 | 1249 |
| 1572 const int sliderThumbWidth = 15; | |
| 1573 const int sliderThumbHeight = 15; | |
| 1574 const int mediaSliderThumbWidth = 13; | |
| 1575 const int mediaSliderThumbHeight = 14; | |
| 1576 | |
| 1577 void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const | |
| 1578 { | |
| 1579 float zoomLevel = o->style()->effectiveZoom(); | |
| 1580 if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->app
earance() == SliderThumbVerticalPart) { | |
| 1581 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLeve
l), Fixed)); | |
| 1582 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLe
vel), Fixed)); | |
| 1583 } else if (o->style()->appearance() == MediaSliderThumbPart) { | |
| 1584 o->style()->setWidth(Length(mediaSliderThumbWidth, Fixed)); | |
| 1585 o->style()->setHeight(Length(mediaSliderThumbHeight, Fixed)); | |
| 1586 } | |
| 1587 } | |
| 1588 | |
| 1589 bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) | 1250 bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) |
| 1590 { | 1251 { |
| 1591 NSSearchFieldCell* search = this->search(); | 1252 NSSearchFieldCell* search = this->search(); |
| 1592 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1253 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1593 | 1254 |
| 1594 setSearchCellState(o, r); | 1255 setSearchCellState(o, r); |
| 1595 | 1256 |
| 1596 paintInfo.context->save(); | 1257 paintInfo.context->save(); |
| 1597 | 1258 |
| 1598 float zoomLevel = o->style()->effectiveZoom(); | 1259 float zoomLevel = o->style()->effectiveZoom(); |
| 1599 | 1260 |
| 1600 IntRect unzoomedRect = r; | 1261 IntRect unzoomedRect = r; |
| 1601 | 1262 |
| 1602 if (zoomLevel != 1.0f) { | 1263 if (zoomLevel != 1.0f) { |
| 1603 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1264 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1604 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1265 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1605 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1266 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1606 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1267 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1607 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1268 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1608 } | 1269 } |
| 1609 | 1270 |
| 1610 // Set the search button to nil before drawing. Then reset it so we can dra
w it later. | 1271 // Set the search button to nil before drawing. Then reset it so we can dra
w it later. |
| 1611 [search setSearchButtonCell:nil]; | 1272 [search setSearchButtonCell:nil]; |
| 1612 | 1273 |
| 1613 [search drawWithFrame:NSRect(IntRectToNSRect(unzoomedRect)) inView:nil]; | 1274 [search drawWithFrame:NSRect(unzoomedRect) inView:FlippedView()]; |
| 1614 #ifdef BUILDING_ON_TIGER | 1275 #ifdef BUILDING_ON_TIGER |
| 1615 if ([search showsFirstResponder]) | 1276 if ([search showsFirstResponder]) |
| 1616 wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect)); | 1277 wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect)); |
| 1617 #endif | 1278 #endif |
| 1618 | 1279 |
| 1619 [search setControlView:nil]; | 1280 [search setControlView:nil]; |
| 1620 [search resetSearchButtonCell]; | 1281 [search resetSearchButtonCell]; |
| 1621 | 1282 |
| 1622 paintInfo.context->restore(); | 1283 paintInfo.context->restore(); |
| 1623 | 1284 |
| 1624 return false; | 1285 return false; |
| 1625 } | 1286 } |
| 1626 | 1287 |
| 1627 void RenderThemeChromiumMac::setSearchCellState(RenderObject* o, const IntRect&
r) | 1288 void RenderThemeChromiumMac::setSearchCellState(RenderObject* o, const IntRect&) |
| 1628 { | 1289 { |
| 1629 NSSearchFieldCell* search = this->search(); | 1290 NSSearchFieldCell* search = this->search(); |
| 1630 | 1291 |
| 1631 [search setControlSize:controlSizeForFont(o->style())]; | 1292 [search setControlSize:controlSizeForFont(o->style())]; |
| 1632 | 1293 |
| 1633 // Update the various states we respond to. | 1294 // Update the various states we respond to. |
| 1634 updateActiveState(search, o); | 1295 updateActiveState(search, o); |
| 1635 updateEnabledState(search, o); | 1296 updateEnabledState(search, o); |
| 1636 updateFocusedState(search, o); | 1297 updateFocusedState(search, o); |
| 1637 } | 1298 } |
| 1638 | 1299 |
| 1639 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const | 1300 const IntSize* RenderThemeChromiumMac::searchFieldSizes() const |
| 1640 { | 1301 { |
| 1641 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0,
17) }; | 1302 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0,
17) }; |
| 1642 return sizes; | 1303 return sizes; |
| 1643 } | 1304 } |
| 1644 | 1305 |
| 1645 void RenderThemeChromiumMac::setSearchFieldSize(RenderStyle* style) const | 1306 void RenderThemeChromiumMac::setSearchFieldSize(RenderStyle* style) const |
| 1646 { | 1307 { |
| 1647 // If the width and height are both specified, then we have nothing to do. | 1308 // If the width and height are both specified, then we have nothing to do. |
| 1648 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 1309 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
| 1649 return; | 1310 return; |
| 1650 | 1311 |
| 1651 // Use the font size to determine the intrinsic width of the control. | 1312 // Use the font size to determine the intrinsic width of the control. |
| 1652 setSizeFromFont(style, searchFieldSizes()); | 1313 setSizeFromFont(style, searchFieldSizes()); |
| 1653 } | 1314 } |
| 1654 | 1315 |
| 1655 void RenderThemeChromiumMac::adjustSearchFieldStyle(CSSStyleSelector* selector,
RenderStyle* style, Element* e) const | 1316 void RenderThemeChromiumMac::adjustSearchFieldStyle(CSSStyleSelector* selector,
RenderStyle* style, Element*) const |
| 1656 { | 1317 { |
| 1657 // Override border. | 1318 // Override border. |
| 1658 style->resetBorder(); | 1319 style->resetBorder(); |
| 1659 const short borderWidth = 2 * style->effectiveZoom(); | 1320 const short borderWidth = 2 * style->effectiveZoom(); |
| 1660 style->setBorderLeftWidth(borderWidth); | 1321 style->setBorderLeftWidth(borderWidth); |
| 1661 style->setBorderLeftStyle(INSET); | 1322 style->setBorderLeftStyle(INSET); |
| 1662 style->setBorderRightWidth(borderWidth); | 1323 style->setBorderRightWidth(borderWidth); |
| 1663 style->setBorderRightStyle(INSET); | 1324 style->setBorderRightStyle(INSET); |
| 1664 style->setBorderBottomWidth(borderWidth); | 1325 style->setBorderBottomWidth(borderWidth); |
| 1665 style->setBorderBottomStyle(INSET); | 1326 style->setBorderBottomStyle(INSET); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1678 style->setPaddingBottom(Length(padding, Fixed)); | 1339 style->setPaddingBottom(Length(padding, Fixed)); |
| 1679 | 1340 |
| 1680 NSControlSize controlSize = controlSizeForFont(style); | 1341 NSControlSize controlSize = controlSizeForFont(style); |
| 1681 setFontFromControlSize(selector, style, controlSize); | 1342 setFontFromControlSize(selector, style, controlSize); |
| 1682 | 1343 |
| 1683 style->setBoxShadow(0); | 1344 style->setBoxShadow(0); |
| 1684 } | 1345 } |
| 1685 | 1346 |
| 1686 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) | 1347 bool RenderThemeChromiumMac::paintSearchFieldCancelButton(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1687 { | 1348 { |
| 1688 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1349 Node* input = o->node()->shadowAncestorNode(); |
| 1350 if (!input->renderer()->isBox()) |
| 1351 return false; |
| 1689 | 1352 |
| 1690 Node* input = o->node()->shadowAncestorNode(); | |
| 1691 setSearchCellState(input->renderer(), r); | 1353 setSearchCellState(input->renderer(), r); |
| 1692 | 1354 |
| 1693 NSSearchFieldCell* search = this->search(); | 1355 NSSearchFieldCell* search = this->search(); |
| 1694 | 1356 |
| 1695 updateActiveState([search cancelButtonCell], o); | 1357 updateActiveState([search cancelButtonCell], o); |
| 1696 updatePressedState([search cancelButtonCell], o); | 1358 updatePressedState([search cancelButtonCell], o); |
| 1697 | 1359 |
| 1698 paintInfo.context->save(); | 1360 paintInfo.context->save(); |
| 1699 | 1361 |
| 1700 float zoomLevel = o->style()->effectiveZoom(); | 1362 float zoomLevel = o->style()->effectiveZoom(); |
| 1701 | 1363 |
| 1702 NSRect bounds = [search cancelButtonRectForBounds:NSRect(IntRectToNSRect(inp
ut->renderer()->absoluteBoundingBoxRect()))]; | 1364 FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(input->rend
erBox()->borderBoxRect())]; |
| 1703 | 1365 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); |
| 1704 IntRect unzoomedRect(NSRectToIntRect(bounds)); | 1366 |
| 1367 FloatRect unzoomedRect(localBounds); |
| 1705 if (zoomLevel != 1.0f) { | 1368 if (zoomLevel != 1.0f) { |
| 1706 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1369 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1707 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1370 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1708 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1371 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1709 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1372 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1710 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1373 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1711 } | 1374 } |
| 1712 | 1375 |
| 1713 [[search cancelButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:nil]; | 1376 [[search cancelButtonCell] drawWithFrame:unzoomedRect inView:FlippedView()]; |
| 1714 [[search cancelButtonCell] setControlView:nil]; | 1377 [[search cancelButtonCell] setControlView:nil]; |
| 1715 | 1378 |
| 1716 paintInfo.context->restore(); | 1379 paintInfo.context->restore(); |
| 1717 return false; | 1380 return false; |
| 1718 } | 1381 } |
| 1719 | 1382 |
| 1720 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const | 1383 const IntSize* RenderThemeChromiumMac::cancelButtonSizes() const |
| 1721 { | 1384 { |
| 1722 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(13, 11), IntSize(
13, 9) }; | 1385 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(13, 11), IntSize(
13, 9) }; |
| 1723 return sizes; | 1386 return sizes; |
| 1724 } | 1387 } |
| 1725 | 1388 |
| 1726 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(CSSStyleSelector
* selector, RenderStyle* style, Element* e) const | 1389 void RenderThemeChromiumMac::adjustSearchFieldCancelButtonStyle(CSSStyleSelector
*, RenderStyle* style, Element*) const |
| 1727 { | 1390 { |
| 1728 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); | 1391 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); |
| 1729 style->setWidth(Length(size.width(), Fixed)); | 1392 style->setWidth(Length(size.width(), Fixed)); |
| 1730 style->setHeight(Length(size.height(), Fixed)); | 1393 style->setHeight(Length(size.height(), Fixed)); |
| 1731 style->setBoxShadow(0); | 1394 style->setBoxShadow(0); |
| 1732 } | 1395 } |
| 1733 | 1396 |
| 1734 const IntSize* RenderThemeChromiumMac::resultsButtonSizes() const | 1397 const IntSize* RenderThemeChromiumMac::resultsButtonSizes() const |
| 1735 { | 1398 { |
| 1736 static const IntSize sizes[3] = { IntSize(19, 13), IntSize(17, 11), IntSize(
17, 9) }; | 1399 static const IntSize sizes[3] = { IntSize(19, 13), IntSize(17, 11), IntSize(
17, 9) }; |
| 1737 return sizes; | 1400 return sizes; |
| 1738 } | 1401 } |
| 1739 | 1402 |
| 1740 static const int emptyResultsOffset = 9; | 1403 const int emptyResultsOffset = 9; |
| 1741 void RenderThemeChromiumMac::adjustSearchFieldDecorationStyle(CSSStyleSelector*
selector, RenderStyle* style, Element* e) const | 1404 void RenderThemeChromiumMac::adjustSearchFieldDecorationStyle(CSSStyleSelector*,
RenderStyle* style, Element*) const |
| 1742 { | 1405 { |
| 1743 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); | 1406 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); |
| 1744 style->setWidth(Length(size.width() - emptyResultsOffset, Fixed)); | 1407 style->setWidth(Length(size.width() - emptyResultsOffset, Fixed)); |
| 1745 style->setHeight(Length(size.height(), Fixed)); | 1408 style->setHeight(Length(size.height(), Fixed)); |
| 1746 style->setBoxShadow(0); | 1409 style->setBoxShadow(0); |
| 1747 } | 1410 } |
| 1748 | 1411 |
| 1749 bool RenderThemeChromiumMac::paintSearchFieldDecoration(RenderObject* o, const R
enderObject::PaintInfo& paintInfo, const IntRect& r) | 1412 bool RenderThemeChromiumMac::paintSearchFieldDecoration(RenderObject*, const Ren
derObject::PaintInfo&, const IntRect&) |
| 1750 { | 1413 { |
| 1751 return false; | 1414 return false; |
| 1752 } | 1415 } |
| 1753 | 1416 |
| 1754 void RenderThemeChromiumMac::adjustSearchFieldResultsDecorationStyle(CSSStyleSel
ector* selector, RenderStyle* style, Element* e) const | 1417 void RenderThemeChromiumMac::adjustSearchFieldResultsDecorationStyle(CSSStyleSel
ector*, RenderStyle* style, Element*) const |
| 1755 { | 1418 { |
| 1756 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); | 1419 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); |
| 1757 style->setWidth(Length(size.width(), Fixed)); | 1420 style->setWidth(Length(size.width(), Fixed)); |
| 1758 style->setHeight(Length(size.height(), Fixed)); | 1421 style->setHeight(Length(size.height(), Fixed)); |
| 1759 style->setBoxShadow(0); | 1422 style->setBoxShadow(0); |
| 1760 } | 1423 } |
| 1761 | 1424 |
| 1762 bool RenderThemeChromiumMac::paintSearchFieldResultsDecoration(RenderObject* o,
const RenderObject::PaintInfo& paintInfo, const IntRect& r) | 1425 bool RenderThemeChromiumMac::paintSearchFieldResultsDecoration(RenderObject* o,
const RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1763 { | 1426 { |
| 1764 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1427 Node* input = o->node()->shadowAncestorNode(); |
| 1428 if (!input->renderer()->isBox()) |
| 1429 return false; |
| 1765 | 1430 |
| 1766 Node* input = o->node()->shadowAncestorNode(); | |
| 1767 setSearchCellState(input->renderer(), r); | 1431 setSearchCellState(input->renderer(), r); |
| 1768 | 1432 |
| 1769 NSSearchFieldCell* search = this->search(); | 1433 NSSearchFieldCell* search = this->search(); |
| 1770 | 1434 |
| 1771 updateActiveState([search searchButtonCell], o); | 1435 updateActiveState([search searchButtonCell], o); |
| 1772 | 1436 |
| 1773 if ([search searchMenuTemplate] != nil) | 1437 if ([search searchMenuTemplate] != nil) |
| 1774 [search setSearchMenuTemplate:nil]; | 1438 [search setSearchMenuTemplate:nil]; |
| 1775 | 1439 |
| 1776 NSRect bounds = [search searchButtonRectForBounds:NSRect(IntRectToNSRect(inp
ut->renderer()->absoluteBoundingBoxRect()))]; | 1440 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->rend
erBox()->borderBoxRect())]; |
| 1777 [[search searchButtonCell] drawWithFrame:bounds inView:nil]; | 1441 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); |
| 1442 |
| 1443 [[search searchButtonCell] drawWithFrame:localBounds inView:FlippedView()]; |
| 1778 [[search searchButtonCell] setControlView:nil]; | 1444 [[search searchButtonCell] setControlView:nil]; |
| 1779 return false; | 1445 return false; |
| 1780 } | 1446 } |
| 1781 | 1447 |
| 1782 static const int resultsArrowWidth = 5; | 1448 const int resultsArrowWidth = 5; |
| 1783 void RenderThemeChromiumMac::adjustSearchFieldResultsButtonStyle(CSSStyleSelecto
r* selector, RenderStyle* style, Element* e) const | 1449 void RenderThemeChromiumMac::adjustSearchFieldResultsButtonStyle(CSSStyleSelecto
r*, RenderStyle* style, Element*) const |
| 1784 { | 1450 { |
| 1785 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); | 1451 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); |
| 1786 style->setWidth(Length(size.width() + resultsArrowWidth, Fixed)); | 1452 style->setWidth(Length(size.width() + resultsArrowWidth, Fixed)); |
| 1787 style->setHeight(Length(size.height(), Fixed)); | 1453 style->setHeight(Length(size.height(), Fixed)); |
| 1788 style->setBoxShadow(0); | 1454 style->setBoxShadow(0); |
| 1789 } | 1455 } |
| 1790 | 1456 |
| 1791 bool RenderThemeChromiumMac::paintSearchFieldResultsButton(RenderObject* o, cons
t RenderObject::PaintInfo& paintInfo, const IntRect& r) | 1457 bool RenderThemeChromiumMac::paintSearchFieldResultsButton(RenderObject* o, cons
t RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1792 { | 1458 { |
| 1793 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1459 Node* input = o->node()->shadowAncestorNode(); |
| 1460 if (!input->renderer()->isBox()) |
| 1461 return false; |
| 1794 | 1462 |
| 1795 Node* input = o->node()->shadowAncestorNode(); | |
| 1796 setSearchCellState(input->renderer(), r); | 1463 setSearchCellState(input->renderer(), r); |
| 1797 | 1464 |
| 1798 NSSearchFieldCell* search = this->search(); | 1465 NSSearchFieldCell* search = this->search(); |
| 1799 | 1466 |
| 1800 updateActiveState([search searchButtonCell], o); | 1467 updateActiveState([search searchButtonCell], o); |
| 1801 | 1468 |
| 1802 if (![search searchMenuTemplate]) | 1469 if (![search searchMenuTemplate]) |
| 1803 [search setSearchMenuTemplate:searchMenuTemplate()]; | 1470 [search setSearchMenuTemplate:searchMenuTemplate()]; |
| 1804 | 1471 |
| 1805 paintInfo.context->save(); | 1472 paintInfo.context->save(); |
| 1806 | 1473 |
| 1807 float zoomLevel = o->style()->effectiveZoom(); | 1474 float zoomLevel = o->style()->effectiveZoom(); |
| 1808 | 1475 |
| 1809 NSRect bounds = [search searchButtonRectForBounds:NSRect(IntRectToNSRect(inp
ut->renderer()->absoluteBoundingBoxRect()))]; | 1476 FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->rend
erBox()->borderBoxRect())]; |
| 1477 localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); |
| 1810 | 1478 |
| 1811 IntRect unzoomedRect(NSRectToIntRect(bounds)); | 1479 IntRect unzoomedRect(localBounds); |
| 1812 if (zoomLevel != 1.0f) { | 1480 if (zoomLevel != 1.0f) { |
| 1813 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1481 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1814 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1482 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1815 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1483 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1816 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1484 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1817 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1485 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1818 } | 1486 } |
| 1819 | 1487 |
| 1820 [[search searchButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:nil]; | 1488 [[search searchButtonCell] drawWithFrame:unzoomedRect inView:FlippedView()]; |
| 1821 [[search searchButtonCell] setControlView:nil]; | 1489 [[search searchButtonCell] setControlView:nil]; |
| 1822 | 1490 |
| 1823 paintInfo.context->restore(); | 1491 paintInfo.context->restore(); |
| 1824 | 1492 |
| 1825 return false; | 1493 return false; |
| 1826 } | 1494 } |
| 1827 | 1495 |
| 1828 #if ENABLE(VIDEO) | 1496 #if ENABLE(VIDEO) |
| 1829 // FIXME: This enum is lifted from RenderThemeMac.mm We need to decide which th
eme to use for the default controls, or decide to avoid wkDrawMediaUIPart and re
nder our own. | |
| 1830 typedef enum { | 1497 typedef enum { |
| 1831 MediaControllerThemeClassic = 1, | 1498 MediaControllerThemeClassic = 1, |
| 1832 MediaControllerThemeQT = 2 | 1499 MediaControllerThemeQT = 2 |
| 1833 } MediaControllerThemeStyle; | 1500 } MediaControllerThemeStyle; |
| 1834 | 1501 |
| 1835 enum WKMediaControllerThemeState { | 1502 static int mediaControllerTheme() |
| 1503 { |
| 1504 static const long minimumQuickTimeVersion = 0x07630000; // 7.6.3 |
| 1505 static SInt32 quickTimeVersion = 0; |
| 1506 static int controllerTheme = -1; |
| 1507 |
| 1508 if (controllerTheme != -1) |
| 1509 return controllerTheme; |
| 1510 |
| 1511 controllerTheme = MediaControllerThemeClassic; |
| 1512 |
| 1513 if (!quickTimeVersion) { |
| 1514 OSErr err; |
| 1515 err = Gestalt(gestaltQuickTime, &quickTimeVersion); |
| 1516 if (err != noErr) |
| 1517 return controllerTheme; |
| 1518 } |
| 1519 if (quickTimeVersion < minimumQuickTimeVersion) |
| 1520 return controllerTheme; |
| 1521 |
| 1522 Boolean validKey; |
| 1523 Boolean useQTMediaUI = CFPreferencesGetAppBooleanValue(CFSTR("UseQuickTimeMe
diaUI"), CFSTR("com.apple.WebCore"), &validKey); |
| 1524 |
| 1525 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) |
| 1526 if (validKey && !useQTMediaUI) |
| 1527 return controllerTheme; |
| 1528 #else |
| 1529 if (!validKey || !useQTMediaUI) |
| 1530 return controllerTheme; |
| 1531 #endif |
| 1532 |
| 1533 controllerTheme = MediaControllerThemeQT; |
| 1534 return controllerTheme; |
| 1535 } |
| 1536 #endif |
| 1537 |
| 1538 const int sliderThumbWidth = 15; |
| 1539 const int sliderThumbHeight = 15; |
| 1540 const int mediaSliderThumbWidth = 13; |
| 1541 const int mediaSliderThumbHeight = 14; |
| 1542 |
| 1543 void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const |
| 1544 { |
| 1545 float zoomLevel = o->style()->effectiveZoom(); |
| 1546 if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->app
earance() == SliderThumbVerticalPart) { |
| 1547 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLeve
l), Fixed)); |
| 1548 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLe
vel), Fixed)); |
| 1549 } |
| 1550 |
| 1551 #if ENABLE(VIDEO) |
| 1552 else if (o->style()->appearance() == MediaSliderThumbPart) { |
| 1553 int width = mediaSliderThumbWidth; |
| 1554 int height = mediaSliderThumbHeight; |
| 1555 |
| 1556 if (mediaControllerTheme() == MediaControllerThemeQT) { |
| 1557 CGSize size; |
| 1558 |
| 1559 wkMeasureMediaUIPart(MediaSliderThumb, MediaControllerThemeQT, NULL,
&size); |
| 1560 width = size.width; |
| 1561 height = size.height; |
| 1562 } |
| 1563 |
| 1564 o->style()->setWidth(Length(static_cast<int>(width * zoomLevel), Fixed))
; |
| 1565 o->style()->setHeight(Length(static_cast<int>(height * zoomLevel), Fixed
)); |
| 1566 } |
| 1567 #endif |
| 1568 } |
| 1569 |
| 1570 |
| 1571 #if ENABLE(VIDEO) |
| 1572 |
| 1573 enum WKMediaControllerThemeState { |
| 1836 MediaUIPartDisabledFlag = 1 << 0, | 1574 MediaUIPartDisabledFlag = 1 << 0, |
| 1837 MediaUIPartPressedFlag = 1 << 1, | 1575 MediaUIPartPressedFlag = 1 << 1, |
| 1838 MediaUIPartDrawEndCapsFlag = 1 << 3, | 1576 MediaUIPartDrawEndCapsFlag = 1 << 3, |
| 1839 }; | 1577 }; |
| 1840 #endif | 1578 |
| 1579 static unsigned getMediaUIPartStateFlags(Node* node) |
| 1580 { |
| 1581 unsigned flags = 0; |
| 1582 |
| 1583 if (node->disabled()) |
| 1584 flags |= MediaUIPartDisabledFlag; |
| 1585 else if (node->active()) |
| 1586 flags |= MediaUIPartPressedFlag; |
| 1587 return flags; |
| 1588 } |
| 1589 |
| 1590 // Utility to scale when the UI part are not scaled by wkDrawMediaUIPart |
| 1591 static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const R
enderObject::PaintInfo& paintInfo, const IntRect &originalRect) |
| 1592 { |
| 1593 float zoomLevel = o->style()->effectiveZoom(); |
| 1594 FloatRect unzoomedRect(originalRect); |
| 1595 if (zoomLevel != 1.0f && mediaControllerTheme() == MediaControllerThemeQT) { |
| 1596 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1597 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1598 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1599 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1600 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1601 } |
| 1602 return unzoomedRect; |
| 1603 } |
| 1604 |
| 1841 | 1605 |
| 1842 bool RenderThemeChromiumMac::paintMediaFullscreenButton(RenderObject* o, const R
enderObject::PaintInfo& paintInfo, const IntRect& r) | 1606 bool RenderThemeChromiumMac::paintMediaFullscreenButton(RenderObject* o, const R
enderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1843 { | 1607 { |
| 1844 #if ENABLE(VIDEO) | |
| 1845 Node* node = o->node(); | 1608 Node* node = o->node(); |
| 1846 if (!node) | 1609 if (!node) |
| 1847 return false; | 1610 return false; |
| 1848 | 1611 |
| 1849 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1612 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1850 wkDrawMediaUIPart(MediaFullscreenButton, MediaControllerThemeClassic, paint
Info.context->platformContext(), r, | 1613 wkDrawMediaUIPart(MediaFullscreenButton, mediaControllerTheme(), paintInfo.c
ontext->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1851 node->active() ? MediaUIPartPressedFlag : 0); | |
| 1852 #endif | |
| 1853 return false; | 1614 return false; |
| 1854 } | 1615 } |
| 1855 | 1616 |
| 1856 bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* o, const RenderO
bject::PaintInfo& paintInfo, const IntRect& r) | 1617 bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* o, const RenderO
bject::PaintInfo& paintInfo, const IntRect& r) |
| 1857 { | 1618 { |
| 1858 #if ENABLE(VIDEO) | |
| 1859 Node* node = o->node(); | 1619 Node* node = o->node(); |
| 1860 Node* mediaNode = node ? node->shadowAncestorNode() : 0; | 1620 Node* mediaNode = node ? node->shadowAncestorNode() : 0; |
| 1861 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) | 1621 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) |
| 1862 return false; | 1622 return false; |
| 1863 | 1623 |
| 1864 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); | 1624 if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonE
lement*>(node)) { |
| 1865 if (!mediaElement) | 1625 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1866 return false; | 1626 wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.
context->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1867 | 1627 |
| 1868 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1628 } |
| 1869 wkDrawMediaUIPart(mediaElement->muted() ? MediaUnMuteButton : MediaMuteButto
n, MediaControllerThemeClassic, paintInfo.context->platformContext(), r, | |
| 1870 node->active() ? MediaUIPartPressedFlag : 0); | |
| 1871 #endif | |
| 1872 return false; | 1629 return false; |
| 1873 } | 1630 } |
| 1874 | 1631 |
| 1875 bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* o, const RenderO
bject::PaintInfo& paintInfo, const IntRect& r) | 1632 bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* o, const RenderO
bject::PaintInfo& paintInfo, const IntRect& r) |
| 1876 { | 1633 { |
| 1877 #if ENABLE(VIDEO) | |
| 1878 Node* node = o->node(); | 1634 Node* node = o->node(); |
| 1879 Node* mediaNode = node ? node->shadowAncestorNode() : 0; | 1635 Node* mediaNode = node ? node->shadowAncestorNode() : 0; |
| 1880 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) | 1636 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) |
| 1881 return false; | 1637 return false; |
| 1882 | 1638 |
| 1883 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); | 1639 if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonE
lement*>(node)) { |
| 1884 if (!mediaElement) | 1640 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1885 return false; | 1641 wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.
context->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1886 | 1642 } |
| 1887 LocalCurrentGraphicsContext localContext(paintInfo.context); | |
| 1888 wkDrawMediaUIPart(mediaElement->canPlay() ? MediaPlayButton : MediaPauseButt
on, MediaControllerThemeClassic, paintInfo.context->platformContext(), r, | |
| 1889 node->active() ? MediaUIPartPressedFlag : 0); | |
| 1890 #endif | |
| 1891 return false; | 1643 return false; |
| 1892 } | 1644 } |
| 1893 | 1645 |
| 1894 bool RenderThemeChromiumMac::paintMediaSeekBackButton(RenderObject* o, const Ren
derObject::PaintInfo& paintInfo, const IntRect& r) | 1646 bool RenderThemeChromiumMac::paintMediaSeekBackButton(RenderObject* o, const Ren
derObject::PaintInfo& paintInfo, const IntRect& r) |
| 1895 { | 1647 { |
| 1896 #if ENABLE(VIDEO) | |
| 1897 Node* node = o->node(); | 1648 Node* node = o->node(); |
| 1898 if (!node) | 1649 if (!node) |
| 1899 return false; | 1650 return false; |
| 1900 | 1651 |
| 1901 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1652 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1902 wkDrawMediaUIPart(MediaSeekBackButton, MediaControllerThemeClassic, paintInf
o.context->platformContext(), r, | 1653 wkDrawMediaUIPart(MediaSeekBackButton, mediaControllerTheme(), paintInfo.con
text->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1903 node->active() ? MediaUIPartPressedFlag : 0); | |
| 1904 #endif | |
| 1905 return false; | 1654 return false; |
| 1906 } | 1655 } |
| 1907 | 1656 |
| 1908 bool RenderThemeChromiumMac::paintMediaSeekForwardButton(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) | 1657 bool RenderThemeChromiumMac::paintMediaSeekForwardButton(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1909 { | 1658 { |
| 1910 #if ENABLE(VIDEO) | |
| 1911 Node* node = o->node(); | 1659 Node* node = o->node(); |
| 1912 if (!node) | 1660 if (!node) |
| 1913 return false; | 1661 return false; |
| 1914 | 1662 |
| 1915 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1663 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1916 wkDrawMediaUIPart(MediaSeekForwardButton, MediaControllerThemeClassic, paint
Info.context->platformContext(), r, | 1664 wkDrawMediaUIPart(MediaSeekForwardButton, mediaControllerTheme(), paintInfo.
context->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1917 node->active() ? MediaUIPartPressedFlag : 0); | |
| 1918 #endif | |
| 1919 return false; | 1665 return false; |
| 1920 } | 1666 } |
| 1921 | 1667 |
| 1922 bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* o, const Render
Object::PaintInfo& paintInfo, const IntRect& r) | 1668 bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* o, const Render
Object::PaintInfo& paintInfo, const IntRect& r) |
| 1923 { | 1669 { |
| 1924 #if ENABLE(VIDEO) | |
| 1925 Node* node = o->node(); | 1670 Node* node = o->node(); |
| 1926 Node* mediaNode = node ? node->shadowAncestorNode() : 0; | 1671 Node* mediaNode = node ? node->shadowAncestorNode() : 0; |
| 1927 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) | 1672 if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagNam
e(audioTag))) |
| 1928 return false; | 1673 return false; |
| 1929 | 1674 |
| 1930 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); | 1675 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); |
| 1931 if (!mediaElement) | 1676 if (!mediaElement) |
| 1932 return false; | 1677 return false; |
| 1933 | 1678 |
| 1934 float timeLoaded = 0; | 1679 float timeLoaded = 0; |
| 1935 float currentTime = 0; | 1680 float currentTime = 0; |
| 1936 float duration = 0; | 1681 float duration = 0; |
| 1937 if (MediaPlayer* player = mediaElement->player()) { | 1682 if (MediaPlayer* player = mediaElement->player()) { |
| 1938 duration = player->duration(); | 1683 duration = player->duration(); |
| 1939 timeLoaded = player->maxTimeBuffered(); | 1684 timeLoaded = player->maxTimeBuffered(); |
| 1940 currentTime = player->currentTime(); | 1685 currentTime = player->currentTime(); |
| 1941 } | 1686 } |
| 1942 | 1687 |
| 1943 bool shouldDrawEndCaps = !toRenderMedia(mediaElement->renderer())->shouldSho
wTimeDisplayControls(); | 1688 paintInfo.context->save(); |
| 1944 wkDrawMediaSliderTrack(MediaControllerThemeClassic, paintInfo.context->platf
ormContext(), r, timeLoaded, currentTime, duration, shouldDrawEndCaps ? MediaUIP
artDrawEndCapsFlag : 0); | 1689 FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo
, r); |
| 1945 #endif | 1690 wkDrawMediaSliderTrack(mediaControllerTheme(), paintInfo.context->platformCo
ntext(), unzoomedRect, |
| 1691 timeLoaded, currentTime, duration, getMediaUIPartStateFlags(node)); |
| 1692 |
| 1693 paintInfo.context->restore(); |
| 1946 return false; | 1694 return false; |
| 1947 } | 1695 } |
| 1948 | 1696 |
| 1949 bool RenderThemeChromiumMac::paintMediaSliderThumb(RenderObject* o, const Render
Object::PaintInfo& paintInfo, const IntRect& r) | 1697 bool RenderThemeChromiumMac::paintMediaSliderThumb(RenderObject* o, const Render
Object::PaintInfo& paintInfo, const IntRect& r) |
| 1950 { | 1698 { |
| 1951 #if ENABLE(VIDEO) | |
| 1952 Node* node = o->node(); | 1699 Node* node = o->node(); |
| 1953 if (!node) | 1700 if (!node) |
| 1954 return false; | 1701 return false; |
| 1955 | 1702 |
| 1956 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1703 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1957 wkDrawMediaUIPart(MediaSliderThumb, MediaControllerThemeClassic, paintInfo.c
ontext->platformContext(), r, | 1704 wkDrawMediaUIPart(MediaSliderThumb, mediaControllerTheme(), paintInfo.contex
t->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1958 node->active() ? MediaUIPartPressedFlag : 0); | 1705 return false; |
| 1959 #endif | 1706 } |
| 1707 |
| 1708 bool RenderThemeChromiumMac::paintMediaRewindButton(RenderObject* o, const Rende
rObject::PaintInfo& paintInfo, const IntRect& r) |
| 1709 { |
| 1710 Node* node = o->node(); |
| 1711 if (!node) |
| 1712 return false; |
| 1713 |
| 1714 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1715 wkDrawMediaUIPart(MediaRewindButton, mediaControllerTheme(), paintInfo.conte
xt->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1960 return false; | 1716 return false; |
| 1961 } | 1717 } |
| 1962 | 1718 |
| 1963 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | 1719 bool RenderThemeChromiumMac::paintMediaReturnToRealtimeButton(RenderObject* o, c
onst RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1964 NSButtonCell* RenderThemeChromiumMac::checkbox() const | |
| 1965 { | 1720 { |
| 1966 if (!m_checkbox) { | 1721 Node* node = o->node(); |
| 1967 m_checkbox.adoptNS([[NSButtonCell alloc] init]); | 1722 if (!node) |
| 1968 [m_checkbox.get() setButtonType:NSSwitchButton]; | 1723 return false; |
| 1969 [m_checkbox.get() setTitle:nil]; | |
| 1970 [m_checkbox.get() setAllowsMixedState:YES]; | |
| 1971 [m_checkbox.get() setFocusRingType:NSFocusRingTypeExterior]; | |
| 1972 } | |
| 1973 | 1724 |
| 1974 return m_checkbox.get(); | 1725 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1726 wkDrawMediaUIPart(MediaReturnToRealtimeButton, mediaControllerTheme(), paint
Info.context->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1727 return false; |
| 1975 } | 1728 } |
| 1976 | 1729 |
| 1977 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | 1730 |
| 1978 NSButtonCell* RenderThemeChromiumMac::radio() const | 1731 bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* o, const
RenderObject::PaintInfo& paintInfo, const IntRect& r) |
| 1979 { | 1732 { |
| 1980 if (!m_radio) { | 1733 Node* node = o->node(); |
| 1981 m_radio.adoptNS([[NSButtonCell alloc] init]); | 1734 if (!node) |
| 1982 [m_radio.get() setButtonType:NSRadioButton]; | 1735 return false; |
| 1983 [m_radio.get() setTitle:nil]; | 1736 |
| 1984 [m_radio.get() setFocusRingType:NSFocusRingTypeExterior]; | 1737 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1985 } | 1738 wkDrawMediaUIPart(MediaTimelineContainer, mediaControllerTheme(), paintInfo.
context->platformContext(), r, getMediaUIPartStateFlags(node)); |
| 1986 | 1739 return false; |
| 1987 return m_radio.get(); | |
| 1988 } | 1740 } |
| 1989 | 1741 |
| 1990 // FIXME: This used to be in the upstream version until it was converted to the
new theme API in r37731. | 1742 bool RenderThemeChromiumMac::paintMediaCurrentTime(RenderObject* o, const Render
Object::PaintInfo& paintInfo, const IntRect& r) |
| 1991 NSButtonCell* RenderThemeChromiumMac::button() const | |
| 1992 { | 1743 { |
| 1993 if (!m_button) { | 1744 Node* node = o->node(); |
| 1994 m_button.adoptNS([[NSButtonCell alloc] init]); | 1745 if (!node) |
| 1995 [m_button.get() setTitle:nil]; | 1746 return false; |
| 1996 [m_button.get() setButtonType:NSMomentaryPushInButton]; | 1747 |
| 1997 } | 1748 paintInfo.context->save(); |
| 1998 | 1749 FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo
, r); |
| 1999 return m_button.get(); | 1750 wkDrawMediaUIPart(MediaCurrentTimeDisplay, mediaControllerTheme(), paintInfo
.context->platformContext(), unzoomedRect, getMediaUIPartStateFlags(node)); |
| 1751 paintInfo.context->restore(); |
| 1752 return false; |
| 2000 } | 1753 } |
| 2001 | 1754 |
| 1755 bool RenderThemeChromiumMac::paintMediaTimeRemaining(RenderObject* o, const Rend
erObject::PaintInfo& paintInfo, const IntRect& r) |
| 1756 { |
| 1757 Node* node = o->node(); |
| 1758 if (!node) |
| 1759 return false; |
| 1760 |
| 1761 paintInfo.context->save(); |
| 1762 FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo
, r); |
| 1763 wkDrawMediaUIPart(MediaTimeRemainingDisplay, mediaControllerTheme(), paintIn
fo.context->platformContext(), unzoomedRect, getMediaUIPartStateFlags(node)); |
| 1764 paintInfo.context->restore(); |
| 1765 return false; |
| 1766 } |
| 1767 |
| 1768 String RenderThemeChromiumMac::extraMediaControlsStyleSheet() |
| 1769 { |
| 1770 return String(); |
| 1771 } |
| 1772 #endif |
| 1773 |
| 2002 NSPopUpButtonCell* RenderThemeChromiumMac::popupButton() const | 1774 NSPopUpButtonCell* RenderThemeChromiumMac::popupButton() const |
| 2003 { | 1775 { |
| 2004 if (!m_popupButton) { | 1776 if (!m_popupButton) { |
| 2005 m_popupButton.adoptNS([[NSPopUpButtonCell alloc] initTextCell:@"" pullsD
own:NO]); | 1777 m_popupButton.adoptNS([[NSPopUpButtonCell alloc] initTextCell:@"" pullsD
own:NO]); |
| 2006 [m_popupButton.get() setUsesItemFromMenu:NO]; | 1778 [m_popupButton.get() setUsesItemFromMenu:NO]; |
| 2007 [m_popupButton.get() setFocusRingType:NSFocusRingTypeExterior]; | 1779 [m_popupButton.get() setFocusRingType:NSFocusRingTypeExterior]; |
| 2008 } | 1780 } |
| 2009 | 1781 |
| 2010 return m_popupButton.get(); | 1782 return m_popupButton.get(); |
| 2011 } | 1783 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 [m_sliderThumbVertical.get() setTitle:nil]; | 1823 [m_sliderThumbVertical.get() setTitle:nil]; |
| 2052 [m_sliderThumbVertical.get() setSliderType:NSLinearSlider]; | 1824 [m_sliderThumbVertical.get() setSliderType:NSLinearSlider]; |
| 2053 [m_sliderThumbVertical.get() setControlSize:NSSmallControlSize]; | 1825 [m_sliderThumbVertical.get() setControlSize:NSSmallControlSize]; |
| 2054 [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; | 1826 [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; |
| 2055 } | 1827 } |
| 2056 | 1828 |
| 2057 return m_sliderThumbVertical.get(); | 1829 return m_sliderThumbVertical.get(); |
| 2058 } | 1830 } |
| 2059 | 1831 |
| 2060 } // namespace WebCore | 1832 } // namespace WebCore |
| OLD | NEW |