Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 |
| 53 using namespace std; | 53 using namespace std; |
| 54 using namespace WebCore; | 54 using namespace WebCore; |
| 55 | 55 |
| 56 @interface NSColor (WebNSColorDetails) | 56 @interface NSColor (WebNSColorDetails) |
| 57 + (NSImage *)_linenPatternImage; | 57 + (NSImage *)_linenPatternImage; |
| 58 @end | 58 @end |
| 59 | 59 |
| 60 namespace WebCore { | 60 namespace WebCore { |
| 61 | 61 |
| 62 typedef HashMap<ScrollbarThemeClient*, RetainPtr<ScrollbarPainter> > ScrollbarPa interMap; | 62 typedef HashMap<ScrollbarThemeClient*, ScrollbarThemeClient*> ScrollbarMap; |
| 63 | 63 |
| 64 static ScrollbarPainterMap* scrollbarMap() | 64 static ScrollbarMap* scrollbarMap() |
|
ccameron
2013/07/31 02:10:25
scrollbarMap contains all scrollbars (so that they
| |
| 65 { | |
| 66 static ScrollbarMap* map = new ScrollbarMap; | |
| 67 return map; | |
| 68 } | |
| 69 | |
| 70 ScrollbarThemeMacOverlay::ScrollbarPainterMap* ScrollbarThemeMacOverlay::scrollb arPainterMap() | |
| 65 { | 71 { |
| 66 static ScrollbarPainterMap* map = new ScrollbarPainterMap; | 72 static ScrollbarPainterMap* map = new ScrollbarPainterMap; |
| 67 return map; | 73 return map; |
| 68 } | 74 } |
| 69 | 75 |
| 70 } | 76 } |
| 71 | 77 |
| 72 @interface WebScrollbarPrefsObserver : NSObject | 78 @interface WebScrollbarPrefsObserver : NSObject |
| 73 { | 79 { |
| 74 } | 80 } |
| 75 | 81 |
| 76 + (void)registerAsObserver; | 82 + (void)registerAsObserver; |
| 77 + (void)appearancePrefsChanged:(NSNotification*)theNotification; | 83 + (void)appearancePrefsChanged:(NSNotification*)theNotification; |
| 78 + (void)behaviorPrefsChanged:(NSNotification*)theNotification; | 84 + (void)behaviorPrefsChanged:(NSNotification*)theNotification; |
| 79 | 85 |
| 80 @end | 86 @end |
| 81 | 87 |
| 82 @implementation WebScrollbarPrefsObserver | 88 @implementation WebScrollbarPrefsObserver |
| 83 | 89 |
| 84 + (void)appearancePrefsChanged:(NSNotification*)unusedNotification | 90 + (void)appearancePrefsChanged:(NSNotification*)unusedNotification |
| 85 { | 91 { |
| 86 UNUSED_PARAM(unusedNotification); | 92 UNUSED_PARAM(unusedNotification); |
| 87 | 93 |
| 88 ScrollbarTheme* theme = ScrollbarTheme::theme(); | 94 ScrollbarTheme* theme = ScrollbarTheme::theme(); |
| 89 if (theme->isMockTheme()) | 95 if (theme->isMockTheme()) |
| 90 return; | 96 return; |
| 91 | 97 |
| 92 static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged (); | 98 static_cast<ScrollbarThemeMacCommon*>(ScrollbarTheme::theme())->preferencesC hanged(); |
| 93 if (scrollbarMap()->isEmpty()) | 99 if (scrollbarMap()->isEmpty()) |
| 94 return; | 100 return; |
| 95 ScrollbarPainterMap::iterator end = scrollbarMap()->end(); | 101 ScrollbarMap::iterator end = scrollbarMap()->end(); |
| 96 for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) { | 102 for (ScrollbarMap::iterator it = scrollbarMap()->begin(); it != end; ++it) { |
| 97 it->key->styleChanged(); | 103 it->key->styleChanged(); |
| 98 it->key->invalidate(); | 104 it->key->invalidate(); |
| 99 } | 105 } |
| 100 } | 106 } |
| 101 | 107 |
| 102 + (void)behaviorPrefsChanged:(NSNotification*)unusedNotification | 108 + (void)behaviorPrefsChanged:(NSNotification*)unusedNotification |
| 103 { | 109 { |
| 104 UNUSED_PARAM(unusedNotification); | 110 UNUSED_PARAM(unusedNotification); |
| 105 | 111 |
| 106 ScrollbarTheme* theme = ScrollbarTheme::theme(); | 112 ScrollbarTheme* theme = ScrollbarTheme::theme(); |
| 107 if (theme->isMockTheme()) | 113 if (theme->isMockTheme()) |
| 108 return; | 114 return; |
| 109 | 115 |
| 110 static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged (); | 116 static_cast<ScrollbarThemeMacCommon*>(ScrollbarTheme::theme())->preferencesC hanged(); |
| 111 } | 117 } |
| 112 | 118 |
| 113 + (void)registerAsObserver | 119 + (void)registerAsObserver |
| 114 { | 120 { |
| 115 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@ selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" objec t:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; | 121 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@ selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" objec t:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; |
| 116 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@ selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChang ed" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce]; | 122 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@ selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChang ed" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce]; |
| 117 } | 123 } |
| 118 | 124 |
| 119 @end | 125 @end |
| 120 | 126 |
| 121 namespace WebCore { | 127 namespace WebCore { |
| 122 | 128 |
| 123 // FIXME: Get these numbers from CoreUI. | 129 // FIXME: Get these numbers from CoreUI. |
| 124 static int cRealButtonLength[] = { 28, 21 }; | 130 int ScrollbarThemeMacNonOverlay::cRealButtonLength[ScrollbarControlSizeCount] = { 28, 21 }; |
| 125 static int cButtonHitInset[] = { 3, 2 }; | 131 int ScrollbarThemeMacNonOverlay::cButtonHitInset[ScrollbarControlSizeCount] = { 3, 2 }; |
| 126 // cRealButtonLength - cButtonInset | 132 // cRealButtonLength - cButtonInset |
| 127 static int cButtonLength[] = { 14, 10 }; | 133 int ScrollbarThemeMacNonOverlay::cButtonLength[ScrollbarControlSizeCount] = { 14 , 10 }; |
| 128 static int cScrollbarThickness[] = { 15, 11 }; | 134 int ScrollbarThemeMacNonOverlay::cScrollbarThickness[ScrollbarControlSizeCount] = { 15, 11 }; |
| 129 static int cButtonInset[] = { 14, 11 }; | 135 int ScrollbarThemeMacNonOverlay::cButtonInset[ScrollbarControlSizeCount] = { 14, 11 }; |
| 130 static int cThumbMinLength[] = { 26, 20 }; | 136 int ScrollbarThemeMacNonOverlay::cThumbMinLength[ScrollbarControlSizeCount] = { 26, 20 }; |
|
enne (OOO)
2013/07/31 18:23:59
Can you keep these as non-class statics? Is there
ccameron
2013/07/31 20:26:57
I sort-of liked them being scoped to be private to
| |
| 131 | 137 |
| 132 static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double bu tton pair is a bit bigger. | 138 int ScrollbarThemeMacNonOverlay::cOuterButtonLength[ScrollbarControlSizeCount] = { 16, 14 }; // The outer button in a double button pair is a bit bigger. |
| 133 static int cOuterButtonOverlap = 2; | 139 int ScrollbarThemeMacNonOverlay::cOuterButtonOverlap = 2; |
| 134 | 140 |
| 135 static float gInitialButtonDelay = 0.5f; | 141 float ScrollbarThemeMacCommon::gInitialButtonDelay = 0.5f; |
| 136 static float gAutoscrollButtonDelay = 0.05f; | 142 float ScrollbarThemeMacCommon::gAutoscrollButtonDelay = 0.05f; |
| 137 static bool gJumpOnTrackClick = false; | 143 bool ScrollbarThemeMacCommon::gJumpOnTrackClick = false; |
| 138 | 144 |
| 139 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd; | 145 ScrollbarButtonsPlacement ScrollbarThemeMacNonOverlay::gButtonPlacement = Scroll barButtonsDoubleEnd; |
| 140 | 146 |
| 141 static bool supportsExpandedScrollbars() | 147 static bool supportsExpandedScrollbars() |
| 142 { | 148 { |
| 143 // FIXME: This is temporary until all platforms that support ScrollbarPainte r support this part of the API. | 149 // FIXME: This is temporary until all platforms that support ScrollbarPainte r support this part of the API. |
| 144 static bool globalSupportsExpandedScrollbars = [NSClassFromString(@"NSScroll erImp") instancesRespondToSelector:@selector(setExpanded:)]; | 150 static bool globalSupportsExpandedScrollbars = [NSClassFromString(@"NSScroll erImp") instancesRespondToSelector:@selector(setExpanded:)]; |
| 145 return globalSupportsExpandedScrollbars; | 151 return globalSupportsExpandedScrollbars; |
| 146 } | 152 } |
| 147 | 153 |
| 148 static void updateArrowPlacement() | 154 void ScrollbarThemeMacNonOverlay::updateButtonPlacement() |
| 149 { | 155 { |
| 150 if (isScrollbarOverlayAPIAvailable()) | 156 if (isScrollbarOverlayAPIAvailable()) |
|
enne (OOO)
2013/07/31 18:23:59
No need to check this here, since this is a non ov
ccameron
2013/07/31 20:26:57
Oops -- yes, it's dead code -- removed (hmm, I'd r
| |
| 151 return; | 157 return; |
| 152 | 158 |
| 153 NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectFor Key:@"AppleScrollBarVariant"]; | 159 NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectFor Key:@"AppleScrollBarVariant"]; |
| 154 if ([buttonPlacement isEqualToString:@"Single"]) | 160 if ([buttonPlacement isEqualToString:@"Single"]) |
| 155 gButtonPlacement = ScrollbarButtonsSingle; | 161 gButtonPlacement = ScrollbarButtonsSingle; |
| 156 else if ([buttonPlacement isEqualToString:@"DoubleMin"]) | 162 else if ([buttonPlacement isEqualToString:@"DoubleMin"]) |
| 157 gButtonPlacement = ScrollbarButtonsDoubleStart; | 163 gButtonPlacement = ScrollbarButtonsDoubleStart; |
| 158 else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) | 164 else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) |
| 159 gButtonPlacement = ScrollbarButtonsDoubleBoth; | 165 gButtonPlacement = ScrollbarButtonsDoubleBoth; |
| 160 else { | 166 else { |
| 161 | |
| 162 gButtonPlacement = ScrollbarButtonsDoubleEnd; | 167 gButtonPlacement = ScrollbarButtonsDoubleEnd; |
| 163 } | 168 } |
| 164 } | 169 } |
| 165 | 170 |
| 166 ScrollbarTheme* ScrollbarTheme::nativeTheme() | 171 ScrollbarTheme* ScrollbarTheme::nativeTheme() |
| 167 { | 172 { |
| 168 DEFINE_STATIC_LOCAL(ScrollbarThemeMac, theme, ()); | 173 if (isScrollbarOverlayAPIAvailable()) { |
| 169 return &theme; | 174 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlay, theme, ()); |
| 175 return &theme; | |
| 176 } else { | |
| 177 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlay, theme, ()); | |
| 178 return &theme; | |
| 179 } | |
| 180 return NULL; | |
| 170 } | 181 } |
| 171 | 182 |
| 172 static WebKit::WebThemeEngine::State scrollbarStateToThemeState(ScrollbarThemeCl ient* scrollbar) | 183 static WebKit::WebThemeEngine::State scrollbarStateToThemeState(ScrollbarThemeCl ient* scrollbar) |
| 173 { | 184 { |
| 174 if (!scrollbar->enabled()) | 185 if (!scrollbar->enabled()) |
| 175 return WebKit::WebThemeEngine::StateDisabled; | 186 return WebKit::WebThemeEngine::StateDisabled; |
| 176 if (!scrollbar->isScrollableAreaActive()) | 187 if (!scrollbar->isScrollableAreaActive()) |
| 177 return WebKit::WebThemeEngine::StateInactive; | 188 return WebKit::WebThemeEngine::StateInactive; |
| 178 if (scrollbar->pressedPart() == ThumbPart) | 189 if (scrollbar->pressedPart() == ThumbPart) |
| 179 return WebKit::WebThemeEngine::StatePressed; | 190 return WebKit::WebThemeEngine::StatePressed; |
| 180 | 191 |
| 181 return WebKit::WebThemeEngine::StateActive; | 192 return WebKit::WebThemeEngine::StateActive; |
| 182 } | 193 } |
| 183 | 194 |
| 184 void ScrollbarThemeMac::registerScrollbar(ScrollbarThemeClient* scrollbar) | 195 void ScrollbarThemeMacOverlay::registerScrollbar(ScrollbarThemeClient* scrollbar ) |
| 185 { | 196 { |
| 186 if (isScrollbarOverlayAPIAvailable()) { | 197 ScrollbarThemeMacCommon::registerScrollbar(scrollbar); |
| 187 bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar; | 198 |
| 188 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:(NSControlSize)scro llbar->controlSize() horizontal:isHorizontal replacingScrollerImp:nil]; | 199 bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar; |
| 189 scrollbarMap()->add(scrollbar, scrollbarPainter); | 200 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr ollerImpWithStyle:recommendedScrollerStyle() controlSize:(NSControlSize)scrollba r->controlSize() horizontal:isHorizontal replacingScrollerImp:nil]; |
| 190 updateEnabledState(scrollbar); | 201 scrollbarPainterMap()->add(scrollbar, scrollbarPainter); |
| 191 updateScrollbarOverlayStyle(scrollbar); | 202 updateEnabledState(scrollbar); |
| 192 } else { | 203 updateScrollbarOverlayStyle(scrollbar); |
| 193 scrollbarMap()->add(scrollbar, nil); | |
| 194 } | |
| 195 } | 204 } |
| 196 | 205 |
| 197 void ScrollbarThemeMac::unregisterScrollbar(ScrollbarThemeClient* scrollbar) | 206 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) |
| 207 { | |
| 208 scrollbarMap()->add(scrollbar, scrollbar); | |
| 209 } | |
| 210 | |
| 211 void ScrollbarThemeMacOverlay::unregisterScrollbar(ScrollbarThemeClient* scrollb ar) | |
| 212 { | |
| 213 scrollbarPainterMap()->remove(scrollbar); | |
| 214 | |
| 215 ScrollbarThemeMacCommon::unregisterScrollbar(scrollbar); | |
| 216 } | |
| 217 | |
| 218 void ScrollbarThemeMacCommon::unregisterScrollbar(ScrollbarThemeClient* scrollba r) | |
| 198 { | 219 { |
| 199 scrollbarMap()->remove(scrollbar); | 220 scrollbarMap()->remove(scrollbar); |
| 200 } | 221 } |
| 201 | 222 |
| 202 void ScrollbarThemeMac::setNewPainterForScrollbar(ScrollbarThemeClient* scrollba r, ScrollbarPainter newPainter) | 223 void ScrollbarThemeMacOverlay::setNewPainterForScrollbar(ScrollbarThemeClient* s crollbar, ScrollbarPainter newPainter) |
| 203 { | 224 { |
| 204 scrollbarMap()->set(scrollbar, newPainter); | 225 scrollbarPainterMap()->set(scrollbar, newPainter); |
| 205 updateEnabledState(scrollbar); | 226 updateEnabledState(scrollbar); |
| 206 updateScrollbarOverlayStyle(scrollbar); | 227 updateScrollbarOverlayStyle(scrollbar); |
| 207 } | 228 } |
| 208 | 229 |
| 209 ScrollbarPainter ScrollbarThemeMac::painterForScrollbar(ScrollbarThemeClient* sc rollbar) | 230 ScrollbarPainter ScrollbarThemeMacOverlay::painterForScrollbar(ScrollbarThemeCli ent* scrollbar) |
| 210 { | 231 { |
| 211 return scrollbarMap()->get(scrollbar).get(); | 232 return scrollbarPainterMap()->get(scrollbar).get(); |
| 212 } | 233 } |
| 213 | 234 |
| 214 // Override ScrollbarThemeMac::paint() to add support for the following: | 235 // Override ScrollbarThemeMacCommon::paint() to add support for the following: |
| 215 // - drawing using WebThemeEngine functions | 236 // - drawing using WebThemeEngine functions |
| 216 // - drawing tickmarks | 237 // - drawing tickmarks |
| 217 // - Skia specific changes | 238 // - Skia specific changes |
| 218 bool ScrollbarThemeMac::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* context, const IntRect& damageRect) | 239 bool ScrollbarThemeMacNonOverlay::paint(ScrollbarThemeClient* scrollbar, Graphic sContext* context, const IntRect& damageRect) |
| 219 { | 240 { |
| 220 if (isScrollbarOverlayAPIAvailable()) | |
| 221 return ScrollbarThemeComposite::paint(scrollbar, context, damageRect); | |
| 222 | |
| 223 // Get the tickmarks for the frameview. | 241 // Get the tickmarks for the frameview. |
| 224 Vector<IntRect> tickmarks; | 242 Vector<IntRect> tickmarks; |
| 225 scrollbar->getTickmarks(tickmarks); | 243 scrollbar->getTickmarks(tickmarks); |
| 226 | 244 |
| 227 HIThemeTrackDrawInfo trackInfo; | 245 HIThemeTrackDrawInfo trackInfo; |
| 228 trackInfo.version = 0; | 246 trackInfo.version = 0; |
| 229 trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMedium ScrollBar : kThemeSmallScrollBar; | 247 trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMedium ScrollBar : kThemeSmallScrollBar; |
| 230 trackInfo.bounds = scrollbar->frameRect(); | 248 trackInfo.bounds = scrollbar->frameRect(); |
| 231 trackInfo.min = 0; | 249 trackInfo.min = 0; |
| 232 trackInfo.max = scrollbar->maximum(); | 250 trackInfo.max = scrollbar->maximum(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 WebKit::WebRect(scrollbar->frameRect()), | 318 WebKit::WebRect(scrollbar->frameRect()), |
| 301 scrollbarInfo); | 319 scrollbarInfo); |
| 302 } | 320 } |
| 303 | 321 |
| 304 if (!canDrawDirectly) | 322 if (!canDrawDirectly) |
| 305 context->drawImageBuffer(imageBuffer.get(), scrollbar->frameRect().locat ion()); | 323 context->drawImageBuffer(imageBuffer.get(), scrollbar->frameRect().locat ion()); |
| 306 | 324 |
| 307 return true; | 325 return true; |
| 308 } | 326 } |
| 309 | 327 |
| 310 void ScrollbarThemeMac::paintGivenTickmarks(GraphicsContext* context, ScrollbarT hemeClient* scrollbar, const IntRect& rect, const Vector<IntRect>& tickmarks) | 328 void ScrollbarThemeMacCommon::paintGivenTickmarks(GraphicsContext* context, Scro llbarThemeClient* scrollbar, const IntRect& rect, const Vector<IntRect>& tickmar ks) |
| 311 { | 329 { |
| 312 if (scrollbar->orientation() != VerticalScrollbar) | 330 if (scrollbar->orientation() != VerticalScrollbar) |
| 313 return; | 331 return; |
| 314 | 332 |
| 315 if (rect.height() <= 0 || rect.width() <= 0) | 333 if (rect.height() <= 0 || rect.width() <= 0) |
| 316 return; // nothing to draw on. | 334 return; // nothing to draw on. |
| 317 | 335 |
| 318 if (!tickmarks.size()) | 336 if (!tickmarks.size()) |
| 319 return; | 337 return; |
| 320 | 338 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 332 // Calculate how far down (in pixels) the tick-mark should appear. | 350 // Calculate how far down (in pixels) the tick-mark should appear. |
| 333 const int yPos = rect.y() + (rect.height() * percent); | 351 const int yPos = rect.y() + (rect.height() * percent); |
| 334 | 352 |
| 335 // Paint. | 353 // Paint. |
| 336 FloatRect tickRect(rect.x(), yPos, rect.width(), 2); | 354 FloatRect tickRect(rect.x(), yPos, rect.width(), 2); |
| 337 context->fillRect(tickRect); | 355 context->fillRect(tickRect); |
| 338 context->strokeRect(tickRect, 1); | 356 context->strokeRect(tickRect, 1); |
| 339 } | 357 } |
| 340 } | 358 } |
| 341 | 359 |
| 342 void ScrollbarThemeMac::paintOverhangAreas(ScrollView* view, GraphicsContext* co ntext, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRec t, const IntRect& dirtyRect) | 360 void ScrollbarThemeMacCommon::paintOverhangAreas(ScrollView* view, GraphicsConte xt* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverh angRect, const IntRect& dirtyRect) |
| 343 { | 361 { |
| 344 // The extent of each shadow in pixels. | 362 // The extent of each shadow in pixels. |
| 345 const int kShadowSize = 4; | 363 const int kShadowSize = 4; |
| 346 // Offset of negative one pixel to make the gradient blend with the toolbar' s bottom border. | 364 // Offset of negative one pixel to make the gradient blend with the toolbar' s bottom border. |
| 347 const int kToolbarShadowOffset = -1; | 365 const int kToolbarShadowOffset = -1; |
| 348 const struct { | 366 const struct { |
| 349 float stop; | 367 float stop; |
| 350 Color color; | 368 Color color; |
| 351 } kShadowColors[] = { | 369 } kShadowColors[] = { |
| 352 { 0.000, Color(0, 0, 0, 255) }, | 370 { 0.000, Color(0, 0, 0, 255) }, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 // If both rectangles present, draw a radial gradient for the corner. | 472 // If both rectangles present, draw a radial gradient for the corner. |
| 455 if (hasHorizontalOverhang && hasVerticalOverhang) { | 473 if (hasHorizontalOverhang && hasVerticalOverhang) { |
| 456 RefPtr<Gradient> gradient = Gradient::create(shadowCornerOrigin, 0, shad owCornerOrigin, kShadowSize); | 474 RefPtr<Gradient> gradient = Gradient::create(shadowCornerOrigin, 0, shad owCornerOrigin, kShadowSize); |
| 457 for (unsigned i = 0; i < kNumShadowColors; i++) | 475 for (unsigned i = 0; i < kNumShadowColors; i++) |
| 458 gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color ); | 476 gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color ); |
| 459 context->setFillGradient(gradient); | 477 context->setFillGradient(gradient); |
| 460 context->fillRect(FloatRect(shadowCornerOrigin.x() + shadowCornerOffset. x(), shadowCornerOrigin.y() + shadowCornerOffset.y(), kShadowSize, kShadowSize)) ; | 478 context->fillRect(FloatRect(shadowCornerOrigin.x() + shadowCornerOffset. x(), shadowCornerOrigin.y() + shadowCornerOffset.y(), kShadowSize, kShadowSize)) ; |
| 461 } | 479 } |
| 462 } | 480 } |
| 463 | 481 |
| 464 void ScrollbarThemeMac::paintTickmarks(GraphicsContext* context, ScrollbarThemeC lient* scrollbar, const IntRect& rect) | 482 void ScrollbarThemeMacCommon::paintTickmarks(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect) |
| 465 { | 483 { |
| 466 // Note: This is only used for css-styled scrollbars on mac. | 484 // Note: This is only used for css-styled scrollbars on mac. |
| 467 if (scrollbar->orientation() != VerticalScrollbar) | 485 if (scrollbar->orientation() != VerticalScrollbar) |
| 468 return; | 486 return; |
| 469 | 487 |
| 470 if (rect.height() <= 0 || rect.width() <= 0) | 488 if (rect.height() <= 0 || rect.width() <= 0) |
| 471 return; | 489 return; |
| 472 | 490 |
| 473 Vector<IntRect> tickmarks; | 491 Vector<IntRect> tickmarks; |
| 474 scrollbar->getTickmarks(tickmarks); | 492 scrollbar->getTickmarks(tickmarks); |
| 475 if (!tickmarks.size()) | 493 if (!tickmarks.size()) |
| 476 return; | 494 return; |
| 477 | 495 |
| 478 // Inset a bit. | 496 // Inset a bit. |
| 479 IntRect tickmarkTrackRect = rect; | 497 IntRect tickmarkTrackRect = rect; |
| 480 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 498 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
| 481 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 499 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
| 482 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); | 500 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); |
| 483 } | 501 } |
| 484 | 502 |
| 485 void ScrollbarThemeMac::paintTrackBackground(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect) { | 503 void ScrollbarThemeMacOverlay::paintTrackBackground(GraphicsContext* context, Sc rollbarThemeClient* scrollbar, const IntRect& rect) { |
| 486 ASSERT(isScrollbarOverlayAPIAvailable()); | 504 ASSERT(isScrollbarOverlayAPIAvailable()); |
| 487 | 505 |
| 488 GraphicsContextStateSaver stateSaver(*context); | 506 GraphicsContextStateSaver stateSaver(*context); |
| 489 context->translate(rect.x(), rect.y()); | 507 context->translate(rect.x(), rect.y()); |
| 490 LocalCurrentGraphicsContext localContext(context); | 508 LocalCurrentGraphicsContext localContext(context); |
| 491 | 509 |
| 492 CGRect frameRect = scrollbar->frameRect(); | 510 CGRect frameRect = scrollbar->frameRect(); |
| 493 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 511 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 494 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 512 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
| 495 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; | 513 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; |
| 496 | 514 |
| 497 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei ght); | 515 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei ght); |
| 498 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; | 516 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; |
| 499 } | 517 } |
| 500 | 518 |
| 501 void ScrollbarThemeMac::paintThumb(GraphicsContext* context, ScrollbarThemeClien t* scrollbar, const IntRect& rect) { | 519 void ScrollbarThemeMacOverlay::paintThumb(GraphicsContext* context, ScrollbarThe meClient* scrollbar, const IntRect& rect) { |
| 502 ASSERT(isScrollbarOverlayAPIAvailable()); | 520 ASSERT(isScrollbarOverlayAPIAvailable()); |
| 503 | 521 |
| 504 GraphicsContextStateSaver stateSaver(*context); | 522 GraphicsContextStateSaver stateSaver(*context); |
| 505 context->translate(rect.x(), rect.y()); | 523 context->translate(rect.x(), rect.y()); |
| 506 LocalCurrentGraphicsContext localContext(context); | 524 LocalCurrentGraphicsContext localContext(context); |
| 507 | 525 |
| 508 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); | 526 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); |
| 509 CGRect frameRect = scrollbar->frameRect(); | 527 CGRect frameRect = scrollbar->frameRect(); |
| 510 [scrollbarPainter setEnabled:scrollbar->enabled()]; | 528 [scrollbarPainter setEnabled:scrollbar->enabled()]; |
| 511 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; | 529 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; |
| 512 [scrollbarPainter setDoubleValue:0]; | 530 [scrollbarPainter setDoubleValue:0]; |
| 513 [scrollbarPainter setKnobProportion:1]; | 531 [scrollbarPainter setKnobProportion:1]; |
| 514 if (scrollbar->enabled()) | 532 if (scrollbar->enabled()) |
| 515 [scrollbarPainter drawKnob]; | 533 [scrollbarPainter drawKnob]; |
| 516 | 534 |
| 517 // If this state is not set, then moving the cursor over the scrollbar area will only cause the | 535 // If this state is not set, then moving the cursor over the scrollbar area will only cause the |
| 518 // scrollbar to engorge when moved over the top of the scrollbar area. | 536 // scrollbar to engorge when moved over the top of the scrollbar area. |
| 519 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz e())]; | 537 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(scrollbar->frameRect().siz e())]; |
| 520 } | 538 } |
| 521 | 539 |
| 522 ScrollbarThemeMac::ScrollbarThemeMac() | 540 ScrollbarThemeMacCommon::ScrollbarThemeMacCommon() |
| 523 { | 541 { |
| 524 static bool initialized; | 542 static bool initialized; |
| 525 if (!initialized) { | 543 if (!initialized) { |
| 526 initialized = true; | 544 initialized = true; |
| 527 gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNo ne : ScrollbarButtonsDoubleEnd; | |
| 528 [WebScrollbarPrefsObserver registerAsObserver]; | 545 [WebScrollbarPrefsObserver registerAsObserver]; |
| 529 preferencesChanged(); | 546 preferencesChanged(); |
| 530 } | 547 } |
| 531 | 548 |
| 532 // Load the linen pattern image used for overhang drawing. | 549 // Load the linen pattern image used for overhang drawing. |
| 533 RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern"); | 550 RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern"); |
| 534 m_overhangPattern = Pattern::create(patternImage, true, true); | 551 m_overhangPattern = Pattern::create(patternImage, true, true); |
| 535 } | 552 } |
| 536 | 553 |
| 537 ScrollbarThemeMac::~ScrollbarThemeMac() | 554 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
| 538 { | 555 { |
| 539 } | 556 } |
| 540 | 557 |
| 541 void ScrollbarThemeMac::preferencesChanged() | 558 void ScrollbarThemeMacCommon::preferencesChanged() |
| 542 { | 559 { |
| 543 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | 560 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
| 544 [defaults synchronize]; | 561 [defaults synchronize]; |
| 545 updateArrowPlacement(); | 562 updateButtonPlacement(); |
| 546 gInitialButtonDelay = [defaults floatForKey:@"NSScrollerButtonDelay"]; | 563 gInitialButtonDelay = [defaults floatForKey:@"NSScrollerButtonDelay"]; |
| 547 gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"]; | 564 gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"]; |
| 548 gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"]; | 565 gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"]; |
| 549 } | 566 } |
| 550 | 567 |
| 551 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize) | 568 int ScrollbarThemeMacOverlay::scrollbarThickness(ScrollbarControlSize controlSiz e) |
| 552 { | 569 { |
| 553 if (isScrollbarOverlayAPIAvailable()) { | 570 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scr ollerImpWithStyle:recommendedScrollerStyle() controlSize:controlSize horizontal: NO replacingScrollerImp:nil]; |
| 554 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:controlSize horizon tal:NO replacingScrollerImp:nil]; | 571 if (supportsExpandedScrollbars()) |
| 555 if (supportsExpandedScrollbars()) | 572 [scrollbarPainter setExpanded:YES]; |
| 556 [scrollbarPainter setExpanded:YES]; | 573 return [scrollbarPainter trackBoxWidth]; |
| 557 return [scrollbarPainter trackBoxWidth]; | |
| 558 } else | |
| 559 return cScrollbarThickness[controlSize]; | |
| 560 } | 574 } |
| 561 | 575 |
| 562 bool ScrollbarThemeMac::usesOverlayScrollbars() const | 576 int ScrollbarThemeMacNonOverlay::scrollbarThickness(ScrollbarControlSize control Size) |
| 563 { | 577 { |
| 564 if (isScrollbarOverlayAPIAvailable()) | 578 return cScrollbarThickness[controlSize]; |
| 565 return recommendedScrollerStyle() == NSScrollerStyleOverlay; | |
| 566 else | |
| 567 return false; | |
| 568 } | 579 } |
| 569 | 580 |
| 570 void ScrollbarThemeMac::updateScrollbarOverlayStyle(ScrollbarThemeClient* scroll bar) | 581 bool ScrollbarThemeMacOverlay::usesOverlayScrollbars() const |
| 582 { | |
| 583 return recommendedScrollerStyle() == NSScrollerStyleOverlay; | |
|
enne (OOO)
2013/07/31 18:23:59
Here's where I have a question about naming. My s
ccameron
2013/07/31 20:26:57
Yes -- that's it exactly. Maybe ScrollbarThemeMac(
| |
| 584 } | |
| 585 | |
| 586 void ScrollbarThemeMacOverlay::updateScrollbarOverlayStyle(ScrollbarThemeClient* scrollbar) | |
| 571 { | 587 { |
| 572 ScrollbarPainter painter = painterForScrollbar(scrollbar); | 588 ScrollbarPainter painter = painterForScrollbar(scrollbar); |
| 573 switch (scrollbar->scrollbarOverlayStyle()) { | 589 switch (scrollbar->scrollbarOverlayStyle()) { |
| 574 case ScrollbarOverlayStyleDefault: | 590 case ScrollbarOverlayStyleDefault: |
| 575 [painter setKnobStyle:NSScrollerKnobStyleDefault]; | 591 [painter setKnobStyle:NSScrollerKnobStyleDefault]; |
| 576 break; | 592 break; |
| 577 case ScrollbarOverlayStyleDark: | 593 case ScrollbarOverlayStyleDark: |
| 578 [painter setKnobStyle:NSScrollerKnobStyleDark]; | 594 [painter setKnobStyle:NSScrollerKnobStyleDark]; |
| 579 break; | 595 break; |
| 580 case ScrollbarOverlayStyleLight: | 596 case ScrollbarOverlayStyleLight: |
| 581 [painter setKnobStyle:NSScrollerKnobStyleLight]; | 597 [painter setKnobStyle:NSScrollerKnobStyleLight]; |
| 582 break; | 598 break; |
| 583 } | 599 } |
| 584 } | 600 } |
| 585 | 601 |
| 586 double ScrollbarThemeMac::initialAutoscrollTimerDelay() | 602 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
| 587 { | 603 { |
| 588 return gInitialButtonDelay; | 604 return gInitialButtonDelay; |
| 589 } | 605 } |
| 590 | 606 |
| 591 double ScrollbarThemeMac::autoscrollTimerDelay() | 607 double ScrollbarThemeMacCommon::autoscrollTimerDelay() |
| 592 { | 608 { |
| 593 return gAutoscrollButtonDelay; | 609 return gAutoscrollButtonDelay; |
| 594 } | 610 } |
| 611 | |
| 612 ScrollbarButtonsPlacement ScrollbarThemeMacOverlay::buttonsPlacement() const | |
| 613 { | |
| 614 return ScrollbarButtonsNone; | |
| 615 } | |
| 595 | 616 |
| 596 ScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const | 617 ScrollbarButtonsPlacement ScrollbarThemeMacNonOverlay::buttonsPlacement() const |
| 597 { | 618 { |
| 598 return gButtonPlacement; | 619 return gButtonPlacement; |
| 599 } | 620 } |
| 600 | 621 |
| 601 bool ScrollbarThemeMac::hasButtons(ScrollbarThemeClient* scrollbar) | 622 bool ScrollbarThemeMacNonOverlay::hasButtons(ScrollbarThemeClient* scrollbar) |
| 602 { | 623 { |
| 603 return scrollbar->enabled() && buttonsPlacement() != ScrollbarButtonsNone | 624 return scrollbar->enabled() && buttonsPlacement() != ScrollbarButtonsNone |
| 604 && (scrollbar->orientation() == HorizontalScrollbar | 625 && (scrollbar->orientation() == HorizontalScrollbar |
| 605 ? scrollbar->width() | 626 ? scrollbar->width() |
| 606 : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->control Size()] - cButtonHitInset[scrollbar->controlSize()]); | 627 : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->control Size()] - cButtonHitInset[scrollbar->controlSize()]); |
| 607 } | 628 } |
| 608 | 629 |
| 609 bool ScrollbarThemeMac::hasThumb(ScrollbarThemeClient* scrollbar) | 630 bool ScrollbarThemeMacOverlay::hasThumb(ScrollbarThemeClient* scrollbar) |
| 610 { | 631 { |
| 611 int minLengthForThumb; | 632 ScrollbarPainter painter = painterForScrollbar(scrollbar); |
| 612 if (isScrollbarOverlayAPIAvailable()) { | 633 int minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndIn set] + [painter knobOverlapEndInset] |
| 613 ScrollbarPainter painter = painterForScrollbar(scrollbar); | 634 + 2 * ([painter trackEndInset] + [painter knobEndInset]); |
| 614 minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndIn set] + [painter knobOverlapEndInset] | 635 return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScroll bar ? |
| 615 + 2 * ([painter trackEndInset] + [painter knobEndInset]); | 636 scrollbar->width() : |
| 616 } else | |
| 617 minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbM inLength[scrollbar->controlSize()] + 1; | |
| 618 return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScroll bar ? | |
| 619 scrollbar->width() : | |
| 620 scrollbar->height()) >= minLengthForThumb; | 637 scrollbar->height()) >= minLengthForThumb; |
| 621 } | 638 } |
| 622 | 639 |
| 623 static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start) | 640 bool ScrollbarThemeMacNonOverlay::hasThumb(ScrollbarThemeClient* scrollbar) |
| 641 { | |
| 642 int minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbM inLength[scrollbar->controlSize()] + 1; | |
| 643 return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScroll bar ? | |
| 644 scrollbar->width() : | |
| 645 scrollbar->height()) >= minLengthForThumb; | |
| 646 } | |
| 647 | |
| 648 IntRect ScrollbarThemeMacNonOverlay::buttonRepaintRect(const IntRect& buttonRect , ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start ) | |
| 624 { | 649 { |
| 625 ASSERT(gButtonPlacement != ScrollbarButtonsNone); | 650 ASSERT(gButtonPlacement != ScrollbarButtonsNone); |
| 626 | 651 |
| 627 IntRect paintRect(buttonRect); | 652 IntRect paintRect(buttonRect); |
| 628 if (orientation == HorizontalScrollbar) { | 653 if (orientation == HorizontalScrollbar) { |
| 629 paintRect.setWidth(cRealButtonLength[controlSize]); | 654 paintRect.setWidth(cRealButtonLength[controlSize]); |
| 630 if (!start) | 655 if (!start) |
| 631 paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - bu ttonRect.width())); | 656 paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - bu ttonRect.width())); |
| 632 } else { | 657 } else { |
| 633 paintRect.setHeight(cRealButtonLength[controlSize]); | 658 paintRect.setHeight(cRealButtonLength[controlSize]); |
| 634 if (!start) | 659 if (!start) |
| 635 paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - bu ttonRect.height())); | 660 paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - bu ttonRect.height())); |
| 636 } | 661 } |
| 637 | 662 |
| 638 return paintRect; | 663 return paintRect; |
| 639 } | 664 } |
| 640 | 665 |
| 641 IntRect ScrollbarThemeMac::backButtonRect(ScrollbarThemeClient* scrollbar, Scrol lbarPart part, bool painting) | 666 IntRect ScrollbarThemeMacOverlay::backButtonRect(ScrollbarThemeClient* scrollbar , ScrollbarPart part, bool painting) |
| 667 { | |
| 668 return IntRect(); | |
|
ccameron
2013/07/31 02:10:25
Note here that for Overlay, buttonsPlacement() is
enne (OOO)
2013/07/31 18:23:59
Can this ASSERT that's the case too as documentati
ccameron
2013/07/31 20:26:57
Good call. Done.
| |
| 669 } | |
| 670 | |
| 671 IntRect ScrollbarThemeMacNonOverlay::backButtonRect(ScrollbarThemeClient* scroll bar, ScrollbarPart part, bool painting) | |
| 642 { | 672 { |
| 643 IntRect result; | 673 IntRect result; |
| 644 | 674 |
| 645 if (part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNo ne || buttonsPlacement() == ScrollbarButtonsDoubleEnd)) | 675 if (part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNo ne || buttonsPlacement() == ScrollbarButtonsDoubleEnd)) |
| 646 return result; | 676 return result; |
| 647 | 677 |
| 648 if (part == BackButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == S crollbarButtonsSingle)) | 678 if (part == BackButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == S crollbarButtonsSingle)) |
| 649 return result; | 679 return result; |
| 650 | 680 |
| 651 int thickness = scrollbarThickness(scrollbar->controlSize()); | 681 int thickness = scrollbarThickness(scrollbar->controlSize()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 665 } else { | 695 } else { |
| 666 int start = part == BackButtonStartPart ? scrollbar->y() : scrollbar->y( ) + scrollbar->height() - cOuterButtonLength[scrollbar->controlSize()] - cButton Length[scrollbar->controlSize()]; | 696 int start = part == BackButtonStartPart ? scrollbar->y() : scrollbar->y( ) + scrollbar->height() - cOuterButtonLength[scrollbar->controlSize()] - cButton Length[scrollbar->controlSize()]; |
| 667 result = IntRect(scrollbar->x(), start, thickness, cButtonLength[scrollb ar->controlSize()]); | 697 result = IntRect(scrollbar->x(), start, thickness, cButtonLength[scrollb ar->controlSize()]); |
| 668 } | 698 } |
| 669 | 699 |
| 670 if (painting) | 700 if (painting) |
| 671 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->co ntrolSize(), part == BackButtonStartPart); | 701 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->co ntrolSize(), part == BackButtonStartPart); |
| 672 return result; | 702 return result; |
| 673 } | 703 } |
| 674 | 704 |
| 675 IntRect ScrollbarThemeMac::forwardButtonRect(ScrollbarThemeClient* scrollbar, Sc rollbarPart part, bool painting) | 705 IntRect ScrollbarThemeMacOverlay::forwardButtonRect(ScrollbarThemeClient* scroll bar, ScrollbarPart part, bool painting) |
| 706 { | |
| 707 return IntRect(); | |
| 708 } | |
| 709 | |
| 710 IntRect ScrollbarThemeMacNonOverlay::forwardButtonRect(ScrollbarThemeClient* scr ollbar, ScrollbarPart part, bool painting) | |
| 676 { | 711 { |
| 677 IntRect result; | 712 IntRect result; |
| 678 | 713 |
| 679 if (part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsN one || buttonsPlacement() == ScrollbarButtonsDoubleStart)) | 714 if (part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsN one || buttonsPlacement() == ScrollbarButtonsDoubleStart)) |
| 680 return result; | 715 return result; |
| 681 | 716 |
| 682 if (part == ForwardButtonStartPart && (buttonsPlacement() == ScrollbarButton sNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() = = ScrollbarButtonsSingle)) | 717 if (part == ForwardButtonStartPart && (buttonsPlacement() == ScrollbarButton sNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() = = ScrollbarButtonsSingle)) |
| 683 return result; | 718 return result; |
| 684 | 719 |
| 685 int thickness = scrollbarThickness(scrollbar->controlSize()); | 720 int thickness = scrollbarThickness(scrollbar->controlSize()); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 705 result = IntRect(start, scrollbar->y(), buttonLength, thickness); | 740 result = IntRect(start, scrollbar->y(), buttonLength, thickness); |
| 706 } else { | 741 } else { |
| 707 int start = part == ForwardButtonEndPart ? scrollbar->y() + scrollbar->h eight() - buttonLength : scrollbar->y() + outerButtonLength; | 742 int start = part == ForwardButtonEndPart ? scrollbar->y() + scrollbar->h eight() - buttonLength : scrollbar->y() + outerButtonLength; |
| 708 result = IntRect(scrollbar->x(), start, thickness, buttonLength); | 743 result = IntRect(scrollbar->x(), start, thickness, buttonLength); |
| 709 } | 744 } |
| 710 if (painting) | 745 if (painting) |
| 711 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->co ntrolSize(), part == ForwardButtonStartPart); | 746 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->co ntrolSize(), part == ForwardButtonStartPart); |
| 712 return result; | 747 return result; |
| 713 } | 748 } |
| 714 | 749 |
| 715 IntRect ScrollbarThemeMac::trackRect(ScrollbarThemeClient* scrollbar, bool paint ing) | 750 IntRect ScrollbarThemeMacOverlay::trackRect(ScrollbarThemeClient* scrollbar, boo l painting) |
| 751 { | |
| 752 return scrollbar->frameRect(); | |
|
ccameron
2013/07/31 02:10:25
Likewise, hasButtons in the full verison would alw
enne (OOO)
2013/07/31 18:23:59
You mean false?
ccameron
2013/07/31 20:26:57
Yes (!hasButtons...) added an assert to be more ex
| |
| 753 } | |
| 754 | |
| 755 IntRect ScrollbarThemeMacNonOverlay::trackRect(ScrollbarThemeClient* scrollbar, bool painting) | |
| 716 { | 756 { |
| 717 if (painting || !hasButtons(scrollbar)) | 757 if (painting || !hasButtons(scrollbar)) |
| 718 return scrollbar->frameRect(); | 758 return scrollbar->frameRect(); |
| 719 | 759 |
| 720 IntRect result; | 760 IntRect result; |
| 721 int thickness = scrollbarThickness(scrollbar->controlSize()); | 761 int thickness = scrollbarThickness(scrollbar->controlSize()); |
| 722 int startWidth = 0; | 762 int startWidth = 0; |
| 723 int endWidth = 0; | 763 int endWidth = 0; |
| 724 int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()]; | 764 int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()]; |
| 725 int buttonLength = cButtonLength[scrollbar->controlSize()]; | 765 int buttonLength = cButtonLength[scrollbar->controlSize()]; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 742 default: | 782 default: |
| 743 break; | 783 break; |
| 744 } | 784 } |
| 745 | 785 |
| 746 int totalWidth = startWidth + endWidth; | 786 int totalWidth = startWidth + endWidth; |
| 747 if (scrollbar->orientation() == HorizontalScrollbar) | 787 if (scrollbar->orientation() == HorizontalScrollbar) |
| 748 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness); | 788 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness); |
| 749 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth); | 789 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth); |
| 750 } | 790 } |
| 751 | 791 |
| 752 int ScrollbarThemeMac::minimumThumbLength(ScrollbarThemeClient* scrollbar) | 792 int ScrollbarThemeMacOverlay::minimumThumbLength(ScrollbarThemeClient* scrollbar ) |
| 753 { | 793 { |
| 754 if (isScrollbarOverlayAPIAvailable()) { | 794 return [painterForScrollbar(scrollbar) knobMinLength]; |
| 755 return [painterForScrollbar(scrollbar) knobMinLength]; | |
| 756 } else { | |
| 757 return cThumbMinLength[scrollbar->controlSize()]; | |
| 758 } | |
| 759 } | 795 } |
| 760 | 796 |
| 761 bool ScrollbarThemeMac::shouldCenterOnThumb(ScrollbarThemeClient*, const Platfor mMouseEvent& evt) | 797 int ScrollbarThemeMacNonOverlay::minimumThumbLength(ScrollbarThemeClient* scroll bar) |
| 798 { | |
| 799 return cThumbMinLength[scrollbar->controlSize()]; | |
| 800 } | |
| 801 | |
| 802 bool ScrollbarThemeMacCommon::shouldCenterOnThumb(ScrollbarThemeClient*, const P latformMouseEvent& evt) | |
| 762 { | 803 { |
| 763 if (evt.button() != LeftButton) | 804 if (evt.button() != LeftButton) |
| 764 return false; | 805 return false; |
| 765 if (gJumpOnTrackClick) | 806 if (gJumpOnTrackClick) |
| 766 return !evt.altKey(); | 807 return !evt.altKey(); |
| 767 return evt.altKey(); | 808 return evt.altKey(); |
| 768 } | 809 } |
| 769 | 810 |
| 770 bool ScrollbarThemeMac::shouldDragDocumentInsteadOfThumb(ScrollbarThemeClient*, const PlatformMouseEvent& event) | 811 bool ScrollbarThemeMacCommon::shouldDragDocumentInsteadOfThumb(ScrollbarThemeCli ent*, const PlatformMouseEvent& event) |
| 771 { | 812 { |
| 772 return event.altKey(); | 813 return event.altKey(); |
| 773 } | 814 } |
| 774 | 815 |
| 775 int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part) | 816 int ScrollbarThemeMacCommon::scrollbarPartToHIPressedState(ScrollbarPart part) |
| 776 { | 817 { |
| 777 switch (part) { | 818 switch (part) { |
| 778 case BackButtonStartPart: | 819 case BackButtonStartPart: |
| 779 return kThemeTopOutsideArrowPressed; | 820 return kThemeTopOutsideArrowPressed; |
| 780 case BackButtonEndPart: | 821 case BackButtonEndPart: |
| 781 return kThemeTopOutsideArrowPressed; // This does not make much sens e. For some reason the outside constant is required. | 822 return kThemeTopOutsideArrowPressed; // This does not make much sens e. For some reason the outside constant is required. |
| 782 case ForwardButtonStartPart: | 823 case ForwardButtonStartPart: |
| 783 return kThemeTopInsideArrowPressed; | 824 return kThemeTopInsideArrowPressed; |
| 784 case ForwardButtonEndPart: | 825 case ForwardButtonEndPart: |
| 785 return kThemeBottomOutsideArrowPressed; | 826 return kThemeBottomOutsideArrowPressed; |
| 786 case ThumbPart: | 827 case ThumbPart: |
| 787 return kThemeThumbPressed; | 828 return kThemeThumbPressed; |
| 788 default: | 829 default: |
| 789 return 0; | 830 return 0; |
| 790 } | 831 } |
| 791 } | 832 } |
| 792 | 833 |
| 793 void ScrollbarThemeMac::updateEnabledState(ScrollbarThemeClient* scrollbar) | 834 void ScrollbarThemeMacOverlay::updateEnabledState(ScrollbarThemeClient* scrollba r) |
| 794 { | 835 { |
| 795 if (isScrollbarOverlayAPIAvailable()) | 836 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; |
| 796 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; | |
| 797 } | 837 } |
| 798 | 838 |
| 799 } // namespace WebCore | 839 } // namespace WebCore |
| OLD | NEW |