| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return kMinFractionToStepWhenPaging; | 67 return kMinFractionToStepWhenPaging; |
| 68 } | 68 } |
| 69 | 69 |
| 70 int ScrollableArea::maxOverlapBetweenPages() { | 70 int ScrollableArea::maxOverlapBetweenPages() { |
| 71 static int maxOverlapBetweenPages = | 71 static int maxOverlapBetweenPages = |
| 72 ScrollbarTheme::theme().maxOverlapBetweenPages(); | 72 ScrollbarTheme::theme().maxOverlapBetweenPages(); |
| 73 return maxOverlapBetweenPages; | 73 return maxOverlapBetweenPages; |
| 74 } | 74 } |
| 75 | 75 |
| 76 ScrollableArea::ScrollableArea() | 76 ScrollableArea::ScrollableArea() |
| 77 : m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault), | 77 : m_scrollbarOverlayColorTheme(ScrollbarOverlayColorThemeDefault), |
| 78 m_scrollOriginChanged(false), | 78 m_scrollOriginChanged(false), |
| 79 m_horizontalScrollbarNeedsPaintInvalidation(false), | 79 m_horizontalScrollbarNeedsPaintInvalidation(false), |
| 80 m_verticalScrollbarNeedsPaintInvalidation(false), | 80 m_verticalScrollbarNeedsPaintInvalidation(false), |
| 81 m_scrollCornerNeedsPaintInvalidation(false) {} | 81 m_scrollCornerNeedsPaintInvalidation(false) {} |
| 82 | 82 |
| 83 ScrollableArea::~ScrollableArea() {} | 83 ScrollableArea::~ScrollableArea() {} |
| 84 | 84 |
| 85 void ScrollableArea::clearScrollAnimators() { | 85 void ScrollableArea::clearScrollAnimators() { |
| 86 #if OS(MACOSX) | 86 #if OS(MACOSX) |
| 87 if (m_scrollAnimator) | 87 if (m_scrollAnimator) |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 void ScrollableArea::didAddScrollbar(Scrollbar& scrollbar, | 356 void ScrollableArea::didAddScrollbar(Scrollbar& scrollbar, |
| 357 ScrollbarOrientation orientation) { | 357 ScrollbarOrientation orientation) { |
| 358 if (orientation == VerticalScrollbar) | 358 if (orientation == VerticalScrollbar) |
| 359 scrollAnimator().didAddVerticalScrollbar(scrollbar); | 359 scrollAnimator().didAddVerticalScrollbar(scrollbar); |
| 360 else | 360 else |
| 361 scrollAnimator().didAddHorizontalScrollbar(scrollbar); | 361 scrollAnimator().didAddHorizontalScrollbar(scrollbar); |
| 362 | 362 |
| 363 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you | 363 // <rdar://problem/9797253> AppKit resets the scrollbar's style when you |
| 364 // attach a scrollbar | 364 // attach a scrollbar |
| 365 setScrollbarOverlayStyle(getScrollbarOverlayStyle()); | 365 setScrollbarOverlayColorTheme(getScrollbarOverlayColorTheme()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void ScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, | 368 void ScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, |
| 369 ScrollbarOrientation orientation) { | 369 ScrollbarOrientation orientation) { |
| 370 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { | 370 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { |
| 371 if (orientation == VerticalScrollbar) | 371 if (orientation == VerticalScrollbar) |
| 372 scrollAnimator->willRemoveVerticalScrollbar(scrollbar); | 372 scrollAnimator->willRemoveVerticalScrollbar(scrollbar); |
| 373 else | 373 else |
| 374 scrollAnimator->willRemoveHorizontalScrollbar(scrollbar); | 374 scrollAnimator->willRemoveHorizontalScrollbar(scrollbar); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 void ScrollableArea::contentsResized() { | 378 void ScrollableArea::contentsResized() { |
| 379 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 379 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 380 scrollAnimator->contentsResized(); | 380 scrollAnimator->contentsResized(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool ScrollableArea::hasOverlayScrollbars() const { | 383 bool ScrollableArea::hasOverlayScrollbars() const { |
| 384 Scrollbar* vScrollbar = verticalScrollbar(); | 384 Scrollbar* vScrollbar = verticalScrollbar(); |
| 385 if (vScrollbar && vScrollbar->isOverlayScrollbar()) | 385 if (vScrollbar && vScrollbar->isOverlayScrollbar()) |
| 386 return true; | 386 return true; |
| 387 Scrollbar* hScrollbar = horizontalScrollbar(); | 387 Scrollbar* hScrollbar = horizontalScrollbar(); |
| 388 return hScrollbar && hScrollbar->isOverlayScrollbar(); | 388 return hScrollbar && hScrollbar->isOverlayScrollbar(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void ScrollableArea::setScrollbarOverlayStyle( | 391 void ScrollableArea::setScrollbarOverlayColorTheme( |
| 392 ScrollbarOverlayStyle overlayStyle) { | 392 ScrollbarOverlayColorTheme overlayTheme) { |
| 393 m_scrollbarOverlayStyle = overlayStyle; | 393 m_scrollbarOverlayColorTheme = overlayTheme; |
| 394 | 394 |
| 395 if (Scrollbar* scrollbar = horizontalScrollbar()) { | 395 if (Scrollbar* scrollbar = horizontalScrollbar()) { |
| 396 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 396 ScrollbarTheme::theme().updateScrollbarOverlayColorTheme(*scrollbar); |
| 397 scrollbar->setNeedsPaintInvalidation(AllParts); | 397 scrollbar->setNeedsPaintInvalidation(AllParts); |
| 398 } | 398 } |
| 399 | 399 |
| 400 if (Scrollbar* scrollbar = verticalScrollbar()) { | 400 if (Scrollbar* scrollbar = verticalScrollbar()) { |
| 401 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 401 ScrollbarTheme::theme().updateScrollbarOverlayColorTheme(*scrollbar); |
| 402 scrollbar->setNeedsPaintInvalidation(AllParts); | 402 scrollbar->setNeedsPaintInvalidation(AllParts); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor) { | 406 void ScrollableArea::recalculateScrollbarOverlayColorTheme( |
| 407 ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle(); | 407 Color backgroundColor) { |
| 408 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; | 408 ScrollbarOverlayColorTheme oldOverlayTheme = getScrollbarOverlayColorTheme(); |
| 409 ScrollbarOverlayColorTheme overlayTheme = ScrollbarOverlayColorThemeDefault; |
| 409 | 410 |
| 410 // Reduce the background color from RGB to a lightness value | 411 // Reduce the background color from RGB to a lightness value |
| 411 // and determine which scrollbar style to use based on a lightness | 412 // and determine which scrollbar style to use based on a lightness |
| 412 // heuristic. | 413 // heuristic. |
| 413 double hue, saturation, lightness; | 414 double hue, saturation, lightness; |
| 414 backgroundColor.getHSL(hue, saturation, lightness); | 415 backgroundColor.getHSL(hue, saturation, lightness); |
| 415 if (lightness <= .5) | 416 if (lightness <= .5) |
| 416 overlayStyle = ScrollbarOverlayStyleLight; | 417 overlayTheme = ScrollbarOverlayColorThemeLight; |
| 417 | 418 |
| 418 if (oldOverlayStyle != overlayStyle) | 419 if (oldOverlayTheme != overlayTheme) |
| 419 setScrollbarOverlayStyle(overlayStyle); | 420 setScrollbarOverlayColorTheme(overlayTheme); |
| 420 } | 421 } |
| 421 | 422 |
| 422 void ScrollableArea::setScrollbarNeedsPaintInvalidation( | 423 void ScrollableArea::setScrollbarNeedsPaintInvalidation( |
| 423 ScrollbarOrientation orientation) { | 424 ScrollbarOrientation orientation) { |
| 424 if (orientation == HorizontalScrollbar) { | 425 if (orientation == HorizontalScrollbar) { |
| 425 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | 426 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { |
| 426 graphicsLayer->setNeedsDisplay(); | 427 graphicsLayer->setNeedsDisplay(); |
| 427 graphicsLayer->setContentsNeedsDisplay(); | 428 graphicsLayer->setContentsNeedsDisplay(); |
| 428 } | 429 } |
| 429 m_horizontalScrollbarNeedsPaintInvalidation = true; | 430 m_horizontalScrollbarNeedsPaintInvalidation = true; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), | 591 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), |
| 591 std::max(0, size.height() - horizontalScrollbarHeight())); | 592 std::max(0, size.height() - horizontalScrollbarHeight())); |
| 592 } | 593 } |
| 593 | 594 |
| 594 DEFINE_TRACE(ScrollableArea) { | 595 DEFINE_TRACE(ScrollableArea) { |
| 595 visitor->trace(m_scrollAnimator); | 596 visitor->trace(m_scrollAnimator); |
| 596 visitor->trace(m_programmaticScrollAnimator); | 597 visitor->trace(m_programmaticScrollAnimator); |
| 597 } | 598 } |
| 598 | 599 |
| 599 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |