Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp

Issue 1738503003: Fix overlay scroll bar color on elements with dark background (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test after rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
index 2ac8b8d635bc885ec1edbfb9a6d7dfb028c499dd..f41e8ea4226d540579760839c8304ca3fc9a4aed 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
@@ -419,15 +419,32 @@ void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
if (Scrollbar* scrollbar = horizontalScrollbar()) {
ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar);
- setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
+ scrollbar->setNeedsPaintInvalidation(AllParts);
}
if (Scrollbar* scrollbar = verticalScrollbar()) {
ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar);
- setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
+ scrollbar->setNeedsPaintInvalidation(AllParts);
}
}
+void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor)
+{
+ ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle();
+ ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
+
+ // Reduce the background color from RGB to a lightness value
+ // and determine which scrollbar style to use based on a lightness
+ // heuristic.
+ double hue, saturation, lightness;
+ backgroundColor.getHSL(hue, saturation, lightness);
+ if (lightness <= .5)
+ overlayStyle = ScrollbarOverlayStyleLight;
+
+ if (oldOverlayStyle != overlayStyle)
+ setScrollbarOverlayStyle(overlayStyle);
+}
+
void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation orientation)
{
if (orientation == HorizontalScrollbar) {

Powered by Google App Engine
This is Rietveld 408576698