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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 0f80cf82e11d0f746fc9515b75baacb6f38e9153..3942d5a8db868a7333cc2964369f74e9d02bbe30 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -167,10 +167,10 @@ const int touchPointPadding = 32;
EXPECT_EQ(expected.height(), actual.height()); \
} while (false)
-#define EXPECT_POINT_EQ(expected, actual) \
- do { \
- EXPECT_EQ(expected.x(), actual.x()); \
- EXPECT_EQ(expected.y(), actual.y()); \
+#define EXPECT_SIZE_EQ(expected, actual) \
+ do { \
+ EXPECT_EQ(expected.width(), actual.width()); \
+ EXPECT_EQ(expected.height(), actual.height()); \
} while (false)
#define EXPECT_FLOAT_POINT_EQ(expected, actual) \
@@ -2939,9 +2939,10 @@ void setScaleAndScrollAndLayout(WebViewImpl* webView,
}
void simulatePageScale(WebViewImpl* webViewImpl, float& scale) {
- IntSize scrollDelta =
- webViewImpl->fakePageScaleAnimationTargetPositionForTesting() -
- webViewImpl->mainFrameImpl()->frameView()->scrollPosition();
+ ScrollOffset scrollDelta =
+ toScrollOffset(
+ webViewImpl->fakePageScaleAnimationTargetPositionForTesting()) -
+ webViewImpl->mainFrameImpl()->frameView()->scrollOffset();
float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting() /
webViewImpl->pageScaleFactor();
webViewImpl->applyViewportDeltas(WebFloatSize(), FloatSize(scrollDelta),
@@ -5757,14 +5758,14 @@ TEST_F(WebFrameTest, DisambiguationPopupVisualViewport) {
// Scroll main frame to the bottom of the document
webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 400));
- EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 400), frame->view()->scrollOffset());
webViewImpl->setPageScaleFactor(2.0);
// Scroll visual viewport to the top of the main frame.
VisualViewport& visualViewport = frame->page()->frameHost().visualViewport();
visualViewport.setLocation(FloatPoint(0, 0));
- EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), visualViewport.location());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 0), visualViewport.scrollOffset());
// Tap at the top: there is nothing there.
client.resetTriggered();
@@ -5773,7 +5774,7 @@ TEST_F(WebFrameTest, DisambiguationPopupVisualViewport) {
// Scroll visual viewport to the bottom of the main frame.
visualViewport.setLocation(FloatPoint(0, 200));
- EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 200), visualViewport.location());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 200), visualViewport.scrollOffset());
// Now the tap with the same coordinates should hit two elements.
client.resetTriggered();
@@ -7306,24 +7307,24 @@ TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls) {
webView->updateAllLifecyclePhases();
webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
- EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset()));
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->scrollOffset());
// Simulate the top controls showing by 20px, thus shrinking the viewport
// and allowing it to scroll an additional 20px.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight);
- EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1920), frameView->maximumScrollOffset());
// Show more, make sure the scroll actually gets clamped.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight);
webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
- EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset()));
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->scrollOffset());
// Hide until there's 10px showing.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight);
- EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1910), frameView->maximumScrollOffset());
// Simulate a LayoutPart::resize. The frame is resized to accomodate
// the top controls and Blink's view of the top controls matches that of
@@ -7332,19 +7333,19 @@ TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls) {
1.0f, 30.0f / topControlsHeight);
webView->resizeWithTopControls(WebSize(100, 60), 40.0f, true);
webView->updateAllLifecyclePhases();
- EXPECT_POINT_EQ(IntPoint(0, 1940), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->maximumScrollOffset());
// Now simulate hiding.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -10.0f / topControlsHeight);
- EXPECT_POINT_EQ(IntPoint(0, 1930), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1930), frameView->maximumScrollOffset());
// Reset to original state: 100px widget height, top controls fully hidden.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight);
webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false);
webView->updateAllLifecyclePhases();
- EXPECT_POINT_EQ(IntPoint(0, 1900), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->maximumScrollOffset());
// Show the top controls by just 1px, since we're zoomed in to 2X, that
// should allow an extra 0.5px of scrolling in the visual viewport. Make
@@ -7352,11 +7353,11 @@ TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls) {
// main frame.
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 1.0f / topControlsHeight);
- EXPECT_POINT_EQ(IntPoint(0, 1901), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1901), frameView->maximumScrollOffset());
webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 2.0f / topControlsHeight);
- EXPECT_POINT_EQ(IntPoint(0, 1903), frameView->maximumScrollPosition());
+ EXPECT_SIZE_EQ(ScrollOffset(0, 1903), frameView->maximumScrollOffset());
}
TEST_F(WebFrameTest, MaximumScrollPositionCanBeNegative) {
@@ -7379,7 +7380,7 @@ TEST_F(WebFrameTest, MaximumScrollPositionCanBeNegative) {
webViewHelper.webView()->updateAllLifecyclePhases();
FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
- EXPECT_LT(frameView->maximumScrollPosition().x(), 0);
+ EXPECT_LT(frameView->maximumScrollOffset().width(), 0);
}
TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) {
« no previous file with comments | « third_party/WebKit/Source/web/tests/VisualViewportTest.cpp ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698