| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); | 396 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*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().updateScrollbarOverlayStyle(*scrollbar); |
| 402 scrollbar->setNeedsPaintInvalidation(AllParts); | 402 scrollbar->setNeedsPaintInvalidation(AllParts); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor) { | 406 ScrollbarOverlayStyle ScrollableArea::calculateScrollbarOverlayStyle( |
| 407 ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle(); | 407 Color backgroundColor) { |
| 408 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; | |
| 409 | |
| 410 // Reduce the background color from RGB to a lightness value | 408 // Reduce the background color from RGB to a lightness value |
| 411 // and determine which scrollbar style to use based on a lightness | 409 // and determine which scrollbar style to use based on a lightness |
| 412 // heuristic. | 410 // heuristic. |
| 413 double hue, saturation, lightness; | 411 double hue, saturation, lightness; |
| 414 backgroundColor.getHSL(hue, saturation, lightness); | 412 backgroundColor.getHSL(hue, saturation, lightness); |
| 415 if (lightness <= .5) | 413 if (lightness <= .5) |
| 416 overlayStyle = ScrollbarOverlayStyleLight; | 414 return ScrollbarOverlayStyleLight; |
| 415 return ScrollbarOverlayStyleDark; |
| 416 } |
| 417 |
| 418 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor, |
| 419 bool isTransparent) { |
| 420 ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle(); |
| 421 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; |
| 422 |
| 423 // will calc color when paint if it is transparent |
| 424 if (!isTransparent) { |
| 425 overlayStyle = calculateScrollbarOverlayStyle(backgroundColor); |
| 426 } |
| 417 | 427 |
| 418 if (oldOverlayStyle != overlayStyle) | 428 if (oldOverlayStyle != overlayStyle) |
| 419 setScrollbarOverlayStyle(overlayStyle); | 429 setScrollbarOverlayStyle(overlayStyle); |
| 420 } | 430 } |
| 421 | 431 |
| 422 void ScrollableArea::setScrollbarNeedsPaintInvalidation( | 432 void ScrollableArea::setScrollbarNeedsPaintInvalidation( |
| 423 ScrollbarOrientation orientation) { | 433 ScrollbarOrientation orientation) { |
| 424 if (orientation == HorizontalScrollbar) { | 434 if (orientation == HorizontalScrollbar) { |
| 425 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | 435 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { |
| 426 graphicsLayer->setNeedsDisplay(); | 436 graphicsLayer->setNeedsDisplay(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), | 600 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), |
| 591 std::max(0, size.height() - horizontalScrollbarHeight())); | 601 std::max(0, size.height() - horizontalScrollbarHeight())); |
| 592 } | 602 } |
| 593 | 603 |
| 594 DEFINE_TRACE(ScrollableArea) { | 604 DEFINE_TRACE(ScrollableArea) { |
| 595 visitor->trace(m_scrollAnimator); | 605 visitor->trace(m_scrollAnimator); |
| 596 visitor->trace(m_programmaticScrollAnimator); | 606 visitor->trace(m_programmaticScrollAnimator); |
| 597 } | 607 } |
| 598 | 608 |
| 599 } // namespace blink | 609 } // namespace blink |
| OLD | NEW |