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

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

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Rebase and resolve 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/ScrollableAreaTest.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
index 13487d835d657377cc8cd2af7d229436487fdd1a..140849654a00273170c71633249e4e872369dbec 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
+++ b/third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "platform/scroll/ScrollableArea.h"
+#include "platform/scroll/ScrollbarTheme.h"
+#include "platform/scroll/ScrollbarThemeMock.h"
#include "platform/testing/TestingPlatformSupport.h"
#include "public/platform/Platform.h"
#include "public/platform/WebScheduler.h"
@@ -32,10 +34,10 @@ public:
MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect));
MOCK_CONST_METHOD0(contentsSize, IntSize());
- MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool());
MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect());
bool userInputScrollable(ScrollbarOrientation) const override { return true; }
+ bool scrollbarsCanBeActive () const override { return true; }
bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scrollPosition = offset.shrunkTo(m_maximumScrollPosition); }
IntPoint scrollPosition() const override { return m_scrollPosition; }
@@ -127,4 +129,36 @@ TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y());
}
+TEST_F(ScrollableAreaTest, ScrollbarTrackAndThumbRepaint)
+{
+ ScrollbarTheme::setMockScrollbarsEnabled(true);
+ ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(true);
+
+ OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(IntPoint(0, 100));
+ RefPtrWillBeRawPtr<Scrollbar> scrollbar = Scrollbar::create(scrollableArea.get(), HorizontalScrollbar, RegularScrollbar);
+
+ EXPECT_TRUE(scrollbar->trackNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_TRUE(scrollbar->trackNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+
+ scrollbar->setTrackNeedsRepaint(false);
+ scrollbar->setThumbNeedsRepaint(false);
+ EXPECT_FALSE(scrollbar->trackNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_TRUE(scrollbar->trackNeedsRepaint());
+ EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
+
+ ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(false);
+ scrollbar->setTrackNeedsRepaint(false);
+ scrollbar->setThumbNeedsRepaint(false);
+ EXPECT_FALSE(scrollbar->trackNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+ scrollbar->setNeedsPaintInvalidation();
+ EXPECT_FALSE(scrollbar->trackNeedsRepaint());
+ EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698