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

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

Issue 1558493002: Reland: Make ScrollbarThemeAura selectively invalidate scrollbar parts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ScrollableAreaTest.InvalidatesCompositedScrollbarsIfPartsNeedRepaint for Oilpan Created 5 years 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/Scrollbar.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
index a86da068c7f3476ad441ca7d09b13d5428fbc8d4..4b6a34163d9ce2b2565215fe0efc98e8dd0c64f7 100644
--- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
+++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
@@ -126,19 +126,27 @@ bool Scrollbar::isLeftSideVerticalScrollbar() const
return false;
}
-void Scrollbar::offsetDidChange()
+bool Scrollbar::offsetDidChange()
{
ASSERT(m_scrollableArea);
float position = scrollableAreaCurrentPos();
if (position == m_currentPos)
- return;
+ return false;
+ float oldPosition = m_currentPos;
int oldThumbPosition = theme().thumbPosition(*this);
m_currentPos = position;
- updateThumbPosition();
+
+ ScrollbarPart invalidParts = theme().invalidateOnThumbPositionChange(
+ *this, oldPosition, position);
+ if (invalidParts != NoPart)
+ setNeedsPaintInvalidation(invalidParts);
+
if (m_pressedPart == ThumbPart)
setPressedPos(m_pressedPos + theme().thumbPosition(*this) - oldThumbPosition);
+
+ return true;
}
void Scrollbar::disconnectFromScrollableArea()
@@ -154,24 +162,9 @@ void Scrollbar::setProportion(int visibleSize, int totalSize)
m_visibleSize = visibleSize;
m_totalSize = totalSize;
- updateThumbProportion();
-}
-
-void Scrollbar::updateThumb()
-{
setNeedsPaintInvalidation();
}
-void Scrollbar::updateThumbPosition()
-{
- updateThumb();
-}
-
-void Scrollbar::updateThumbProportion()
-{
- updateThumb();
-}
-
void Scrollbar::paint(GraphicsContext& context, const CullRect& cullRect) const
{
if (!cullRect.intersectsCullRect(frameRect()))
@@ -317,7 +310,7 @@ void Scrollbar::setHoveredPart(ScrollbarPart part)
if (((m_hoveredPart == NoPart || part == NoPart) && theme().invalidateOnMouseEnterExit())
// When there's a pressed part, we don't draw a hovered state, so there's no reason to invalidate.
|| m_pressedPart == NoPart)
- setNeedsPaintInvalidation();
+ setNeedsPaintInvalidation(static_cast<ScrollbarPart>(m_hoveredPart | part));
m_hoveredPart = part;
}
@@ -327,7 +320,7 @@ void Scrollbar::setPressedPart(ScrollbarPart part)
if (m_pressedPart != NoPart
// When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
|| m_hoveredPart != NoPart)
- setNeedsPaintInvalidation();
+ setNeedsPaintInvalidation(static_cast<ScrollbarPart>(m_pressedPart | m_hoveredPart | part));
m_pressedPart = part;
}
@@ -562,12 +555,14 @@ float Scrollbar::scrollableAreaCurrentPos() const
return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScrollPosition().y();
}
-void Scrollbar::setNeedsPaintInvalidation()
+void Scrollbar::setNeedsPaintInvalidation(ScrollbarPart parts)
{
- if (m_theme.shouldRepaintAllPartsOnInvalidation()) {
+ if (m_theme.shouldRepaintAllPartsOnInvalidation())
+ parts = AllParts;
+ if (parts & ~ThumbPart)
m_trackNeedsRepaint = true;
+ if (parts & ThumbPart)
m_thumbNeedsRepaint = true;
- }
if (m_scrollableArea)
m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation());
}
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/Scrollbar.h ('k') | third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698