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

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

Issue 1406133005: Calculate paint invalidation rect for scrollbars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 f23801b9243c29badaf4540425180ae39d106b05..85016be74b5a15c2f326a65e4254a439ceac12f6 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
@@ -51,7 +51,6 @@ namespace blink {
struct SameSizeAsScrollableArea {
virtual ~SameSizeAsScrollableArea();
- IntRect scrollbarDamage[2];
#if ENABLE(ASSERT) && ENABLE(OILPAN)
VerifyEagerFinalization verifyEager;
#endif
@@ -82,6 +81,9 @@ ScrollableArea::ScrollableArea()
: m_inLiveResize(false)
, m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
, m_scrollOriginChanged(false)
+ , m_horizontalScrollbarNeedsPaintInvalidation(false)
+ , m_verticalScrollbarNeedsPaintInvalidation(false)
+ , m_scrollCornerNeedsPaintInvalidation(false)
{
}
@@ -246,22 +248,13 @@ void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollTy
// Tell the scrollbars to update their thumb postions.
if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
horizontalScrollbar->offsetDidChange();
- if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar()) {
- if (!verticalScrollbar)
- horizontalScrollbar->invalidate();
- else {
- // If there is both a horizontalScrollbar and a verticalScrollbar,
- // then we must also invalidate the corner between them.
- IntRect boundsAndCorner = horizontalScrollbar->boundsRect();
- boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width());
- horizontalScrollbar->invalidateRect(boundsAndCorner);
- }
- }
+ if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar())
+ setScrollbarNeedsPaintInvalidation(horizontalScrollbar);
}
if (verticalScrollbar) {
verticalScrollbar->offsetDidChange();
if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrollbar())
- verticalScrollbar->invalidate();
+ setScrollbarNeedsPaintInvalidation(verticalScrollbar);
}
if (scrollPositionDouble() != oldPosition) {
@@ -402,16 +395,16 @@ void ScrollableArea::setScrollbarOverlayStyle(ScrollbarOverlayStyle overlayStyle
if (Scrollbar* scrollbar = horizontalScrollbar()) {
ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar);
- scrollbar->invalidate();
+ setScrollbarNeedsPaintInvalidation(scrollbar);
}
if (Scrollbar* scrollbar = verticalScrollbar()) {
ScrollbarTheme::theme()->updateScrollbarOverlayStyle(scrollbar);
- scrollbar->invalidate();
+ setScrollbarNeedsPaintInvalidation(scrollbar);
}
}
-void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& rect)
+void ScrollableArea::setScrollbarNeedsPaintInvalidation(Scrollbar* scrollbar)
{
if (scrollbar == horizontalScrollbar()) {
if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) {
@@ -419,7 +412,8 @@ void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& re
graphicsLayer->setContentsNeedsDisplay();
return;
}
- invalidateScrollbarRect(scrollbar, rect);
+ m_horizontalScrollbarNeedsPaintInvalidation = true;
+ scrollControlWasSetNeedsPaintInvalidation();
return;
}
if (scrollbar == verticalScrollbar()) {
@@ -428,20 +422,22 @@ void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& re
graphicsLayer->setContentsNeedsDisplay();
return;
}
- invalidateScrollbarRect(scrollbar, rect);
+ m_verticalScrollbarNeedsPaintInvalidation = true;
+ scrollControlWasSetNeedsPaintInvalidation();
return;
}
// Otherwise the scrollbar is just created and has not been set as either
// horizontalScrollbar() or verticalScrollbar().
}
-void ScrollableArea::invalidateScrollCorner(const IntRect& rect)
+void ScrollableArea::setScrollCornerNeedsPaintInvalidation()
{
if (GraphicsLayer* graphicsLayer = layerForScrollCorner()) {
graphicsLayer->setNeedsDisplay();
return;
}
- invalidateScrollCornerRect(rect);
+ m_scrollCornerNeedsPaintInvalidation = true;
+ scrollControlWasSetNeedsPaintInvalidation();
}
bool ScrollableArea::hasLayerForHorizontalScrollbar() const

Powered by Google App Engine
This is Rietveld 408576698