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