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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 Scrollbar* hScrollbar = horizontalScrollbar(); 412 Scrollbar* hScrollbar = horizontalScrollbar();
413 return hScrollbar && hScrollbar->isOverlayScrollbar(); 413 return hScrollbar && hScrollbar->isOverlayScrollbar();
414 } 414 }
415 415
416 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle ) 416 void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle )
417 { 417 {
418 m_scrollbarOverlayStyle = overlayStyle; 418 m_scrollbarOverlayStyle = overlayStyle;
419 419
420 if (Scrollbar* scrollbar = horizontalScrollbar()) { 420 if (Scrollbar* scrollbar = horizontalScrollbar()) {
421 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); 421 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar);
422 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); 422 scrollbar->setNeedsPaintInvalidation(AllParts);
423 } 423 }
424 424
425 if (Scrollbar* scrollbar = verticalScrollbar()) { 425 if (Scrollbar* scrollbar = verticalScrollbar()) {
426 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar); 426 ScrollbarTheme::theme().updateScrollbarOverlayStyle(*scrollbar);
427 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); 427 scrollbar->setNeedsPaintInvalidation(AllParts);
428 } 428 }
429 } 429 }
430 430
431 void ScrollableArea::recalculateScrollbarOverlayStyle(Color backgroundColor)
432 {
433 ScrollbarOverlayStyle oldOverlayStyle = getScrollbarOverlayStyle();
434 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
435
436 // Reduce the background color from RGB to a lightness value
437 // and determine which scrollbar style to use based on a lightness
438 // heuristic.
439 double hue, saturation, lightness;
440 backgroundColor.getHSL(hue, saturation, lightness);
441 if (lightness <= .5)
442 overlayStyle = ScrollbarOverlayStyleLight;
443
444 if (oldOverlayStyle != overlayStyle)
445 setScrollbarOverlayStyle(overlayStyle);
446 }
447
431 void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation ori entation) 448 void ScrollableArea::setScrollbarNeedsPaintInvalidation(ScrollbarOrientation ori entation)
432 { 449 {
433 if (orientation == HorizontalScrollbar) { 450 if (orientation == HorizontalScrollbar) {
434 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { 451 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) {
435 graphicsLayer->setNeedsDisplay(); 452 graphicsLayer->setNeedsDisplay();
436 graphicsLayer->setContentsNeedsDisplay(); 453 graphicsLayer->setContentsNeedsDisplay();
437 } 454 }
438 m_horizontalScrollbarNeedsPaintInvalidation = true; 455 m_horizontalScrollbarNeedsPaintInvalidation = true;
439 } else { 456 } else {
440 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { 457 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 std::max(0, size.height() - horizontalScrollbarHeight)); 633 std::max(0, size.height() - horizontalScrollbarHeight));
617 } 634 }
618 635
619 DEFINE_TRACE(ScrollableArea) 636 DEFINE_TRACE(ScrollableArea)
620 { 637 {
621 visitor->trace(m_scrollAnimator); 638 visitor->trace(m_scrollAnimator);
622 visitor->trace(m_programmaticScrollAnimator); 639 visitor->trace(m_programmaticScrollAnimator);
623 } 640 }
624 641
625 } // namespace blink 642 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698