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

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

Issue 1456953003: Revert of 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/Scrollbar.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
index 19538b25345adfea775bd2084f30f5c464d38b67..e549491bede882e566d442ce698a1b9a5975291b 100644
--- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
+++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
@@ -34,6 +34,12 @@
#include "platform/scroll/ScrollableArea.h"
#include "platform/scroll/ScrollbarTheme.h"
+#if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN))
+// The position of the scrollbar thumb affects the appearance of the steppers, so
+// when the thumb moves, we have to invalidate them for painting.
+#define THUMB_POSITION_AFFECTS_BUTTONS
+#endif
+
namespace blink {
PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size)
@@ -59,6 +65,7 @@
, m_enabled(true)
, m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
, m_overlapsResizer(false)
+ , m_suppressInvalidation(false)
, m_isAlphaLocked(false)
, m_elasticOverscroll(0)
{
@@ -92,8 +99,9 @@
if (frameRect == this->frameRect())
return;
+ invalidate();
Widget::setFrameRect(frameRect);
- setNeedsPaintInvalidation();
+ invalidate();
}
ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const
@@ -152,7 +160,11 @@
void Scrollbar::updateThumb()
{
- setNeedsPaintInvalidation();
+#ifdef THUMB_POSITION_AFFECTS_BUTTONS
+ invalidate();
+#else
+ theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart);
+#endif
}
void Scrollbar::updateThumbPosition()
@@ -194,7 +206,7 @@
// Handle the track.
if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
- setNeedsPaintInvalidation();
+ theme()->invalidatePart(this, m_pressedPart);
setHoveredPart(ThumbPart);
return;
}
@@ -213,7 +225,7 @@
// Handle the track. We halt track scrolling once the thumb is level
// with us.
if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
- setNeedsPaintInvalidation();
+ theme()->invalidatePart(this, m_pressedPart);
setHoveredPart(ThumbPart);
return;
}
@@ -307,21 +319,24 @@
if (part == m_hoveredPart)
return;
- 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();
-
+ if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMouseEnterExit())
+ invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
+ else if (m_pressedPart == NoPart) { // When there's a pressed part, we don't draw a hovered state, so there's no reason to invalidate.
+ theme()->invalidatePart(this, part);
+ theme()->invalidatePart(this, m_hoveredPart);
+ }
m_hoveredPart = part;
}
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();
+ if (m_pressedPart != NoPart)
+ theme()->invalidatePart(this, m_pressedPart);
m_pressedPart = part;
+ if (m_pressedPart != NoPart)
+ theme()->invalidatePart(this, m_pressedPart);
+ else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
+ theme()->invalidatePart(this, m_hoveredPart);
}
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
@@ -391,12 +406,12 @@
// The mouse is moving back over the pressed part. We
// need to start up the timer action again.
startTimerIfNeeded(theme()->autoscrollTimerDelay());
- setNeedsPaintInvalidation();
+ theme()->invalidatePart(this, m_pressedPart);
} else if (m_hoveredPart == m_pressedPart) {
// The mouse is leaving the pressed part. Kill our timer
// if needed.
stopTimerIfNeeded();
- setNeedsPaintInvalidation();
+ theme()->invalidatePart(this, m_pressedPart);
}
}
@@ -475,7 +490,7 @@
return;
m_enabled = e;
theme()->updateEnabledState(this);
- setNeedsPaintInvalidation();
+ invalidate();
}
bool Scrollbar::isOverlayScrollbar() const
@@ -496,6 +511,15 @@
return m_scrollableArea && m_scrollableArea->isActive();
}
+void Scrollbar::invalidateRect(const IntRect& rect)
+{
+ if (suppressInvalidation())
+ return;
+
+ if (m_scrollableArea)
+ m_scrollableArea->invalidateScrollbar(this, rect);
+}
+
IntRect Scrollbar::convertToContainingView(const IntRect& localRect) const
{
if (m_scrollableArea)
@@ -539,10 +563,4 @@
return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScrollPosition().y();
}
-void Scrollbar::setNeedsPaintInvalidation()
-{
- if (m_scrollableArea)
- m_scrollableArea->setScrollbarNeedsPaintInvalidation(this);
-}
-
} // namespace blink
« 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