| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 Scrollbar* hScrollbar = horizontalScrollbar(); | 395 Scrollbar* hScrollbar = horizontalScrollbar(); |
| 396 return hScrollbar && hScrollbar->isOverlayScrollbar(); | 396 return hScrollbar && hScrollbar->isOverlayScrollbar(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) | 399 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
) |
| 400 { | 400 { |
| 401 m_scrollbarOverlayStyle = overlayStyle; | 401 m_scrollbarOverlayStyle = overlayStyle; |
| 402 | 402 |
| 403 if (Scrollbar* scrollbar = horizontalScrollbar()) { | 403 if (Scrollbar* scrollbar = horizontalScrollbar()) { |
| 404 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 404 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); |
| 405 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); | 405 scrollbar->setNeedsPaintInvalidation(AllParts); |
| 406 } | 406 } |
| 407 | 407 |
| 408 if (Scrollbar* scrollbar = verticalScrollbar()) { | 408 if (Scrollbar* scrollbar = verticalScrollbar()) { |
| 409 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 409 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); |
| 410 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); | 410 scrollbar->setNeedsPaintInvalidation(AllParts); |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor) |
| 415 { |
| 416 ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle(); |
| 417 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; |
| 418 |
| 419 // Reduce the background color from RGB to a lightness value |
| 420 // and determine which scrollbar style to use based on a lightness |
| 421 // heuristic. |
| 422 double hue, saturation, lightness; |
| 423 backgroundColor.getHSL(hue, saturation, lightness); |
| 424 if (lightness <= .5) |
| 425 overlayStyle = ScrollbarOverlayStyleLight; |
| 426 |
| 427 if (oldOverlayStyle != overlayStyle) |
| 428 setScrollbarOverlayStyle(overlayStyle); |
| 429 } |
| 430 |
| 414 void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation ori
entation) | 431 void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation ori
entation) |
| 415 { | 432 { |
| 416 if (orientation == HorizontalScrollbar) { | 433 if (orientation == HorizontalScrollbar) { |
| 417 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | 434 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { |
| 418 graphicsLayer->setNeedsDisplay(); | 435 graphicsLayer->setNeedsDisplay(); |
| 419 graphicsLayer->setContentsNeedsDisplay(); | 436 graphicsLayer->setContentsNeedsDisplay(); |
| 420 } | 437 } |
| 421 m_horizontalScrollbarNeedsPaintInvalidation = true; | 438 m_horizontalScrollbarNeedsPaintInvalidation = true; |
| 422 } else { | 439 } else { |
| 423 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { | 440 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 std::max(0, size.height() - horizontalScrollbarHeight)); | 634 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 618 } | 635 } |
| 619 | 636 |
| 620 DEFINE_TRACE(ScrollableArea) | 637 DEFINE_TRACE(ScrollableArea) |
| 621 { | 638 { |
| 622 visitor->trace(m_scrollAnimator); | 639 visitor->trace(m_scrollAnimator); |
| 623 visitor->trace(m_programmaticScrollAnimator); | 640 visitor->trace(m_programmaticScrollAnimator); |
| 624 } | 641 } |
| 625 | 642 |
| 626 } // namespace blink | 643 } // namespace blink |
| OLD | NEW |