| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2179 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
| 2180 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal
eRelativeToViewportWidth ? 1 / aspectRatio : 1); | 2180 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal
eRelativeToViewportWidth ? 1 / aspectRatio : 1); |
| 2181 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2181 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
| 2182 EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrol
lOffset()); | 2182 EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrol
lOffset()); |
| 2183 } | 2183 } |
| 2184 | 2184 |
| 2185 // Resizing just the height should not affect pageScaleFactor or scrollO
ffset. | 2185 // Resizing just the height should not affect pageScaleFactor or scrollO
ffset. |
| 2186 { | 2186 { |
| 2187 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); | 2187 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); |
| 2188 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact
or); | 2188 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact
or); |
| 2189 webViewHelper.webViewImpl()->setMainFrameScrollOffset(WebPoint(scrol
lOffset.width, scrollOffset.height)); | 2189 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); |
| 2190 webViewHelper.webViewImpl()->layout(); | 2190 webViewHelper.webViewImpl()->layout(); |
| 2191 const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->ma
inFrame()->scrollOffset(); | 2191 const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->ma
inFrame()->scrollOffset(); |
| 2192 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); | 2192 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); |
| 2193 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); | 2193 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); |
| 2194 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); | 2194 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); |
| 2195 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); | 2195 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); |
| 2196 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); | 2196 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); |
| 2197 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); | 2197 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); |
| 2198 } | 2198 } |
| 2199 } | 2199 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 | 2339 |
| 2340 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2340 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
| 2341 webViewHelper.webView()->layout(); | 2341 webViewHelper.webView()->layout(); |
| 2342 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); | 2342 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); |
| 2343 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); | 2343 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); |
| 2344 } | 2344 } |
| 2345 | 2345 |
| 2346 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca
le) | 2346 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca
le) |
| 2347 { | 2347 { |
| 2348 webView->setPageScaleFactor(scale); | 2348 webView->setPageScaleFactor(scale); |
| 2349 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2349 webView->mainFrame()->setScrollOffset(WebSize(scroll.x, scroll.y)); |
| 2350 webView->layout(); | 2350 webView->layout(); |
| 2351 } | 2351 } |
| 2352 | 2352 |
| 2353 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2353 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2354 { | 2354 { |
| 2355 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 2355 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2356 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 2356 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| 2357 webViewImpl->applyViewportDeltas(WebFloatSize(), FloatSize(scrollDelta), Web
FloatSize(), scaleDelta, 0); | 2357 webViewImpl->applyViewportDeltas(WebFloatSize(), FloatSize(scrollDelta), Web
FloatSize(), scaleDelta, 0); |
| 2358 scale = webViewImpl->pageScaleFactor(); | 2358 scale = webViewImpl->pageScaleFactor(); |
| 2359 } | 2359 } |
| (...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4703 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, conf
igureAndroid); | 4703 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, conf
igureAndroid); |
| 4704 | 4704 |
| 4705 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); | 4705 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); |
| 4706 ASSERT_TRUE(webViewImpl); | 4706 ASSERT_TRUE(webViewImpl); |
| 4707 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); | 4707 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); |
| 4708 ASSERT_TRUE(frame); | 4708 ASSERT_TRUE(frame); |
| 4709 | 4709 |
| 4710 webViewHelper.webView()->resize(WebSize(100, 200)); | 4710 webViewHelper.webView()->resize(WebSize(100, 200)); |
| 4711 | 4711 |
| 4712 // Scroll main frame to the bottom of the document | 4712 // Scroll main frame to the bottom of the document |
| 4713 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 400)); | 4713 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 400)); |
| 4714 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); | 4714 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); |
| 4715 | 4715 |
| 4716 webViewImpl->setPageScaleFactor(2.0); | 4716 webViewImpl->setPageScaleFactor(2.0); |
| 4717 | 4717 |
| 4718 // Scroll pinch viewport to the top of the main frame. | 4718 // Scroll pinch viewport to the top of the main frame. |
| 4719 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); | 4719 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
| 4720 pinchViewport.setLocation(FloatPoint(0, 0)); | 4720 pinchViewport.setLocation(FloatPoint(0, 0)); |
| 4721 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); | 4721 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); |
| 4722 | 4722 |
| 4723 // Tap at the top: there is nothing there. | 4723 // Tap at the top: there is nothing there. |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6136 | 6136 |
| 6137 WebViewImpl* webView = webViewHelper.webViewImpl(); | 6137 WebViewImpl* webView = webViewHelper.webViewImpl(); |
| 6138 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 6138 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| 6139 | 6139 |
| 6140 float topControlsHeight = 40; | 6140 float topControlsHeight = 40; |
| 6141 webView->setTopControlsHeight(topControlsHeight, false); | 6141 webView->setTopControlsHeight(topControlsHeight, false); |
| 6142 webView->resize(WebSize(100, 100)); | 6142 webView->resize(WebSize(100, 100)); |
| 6143 webView->setPageScaleFactor(2.0f); | 6143 webView->setPageScaleFactor(2.0f); |
| 6144 webView->layout(); | 6144 webView->layout(); |
| 6145 | 6145 |
| 6146 webView->setMainFrameScrollOffset(WebPoint(0, 2000)); | 6146 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6147 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); | 6147 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); |
| 6148 | 6148 |
| 6149 // Simulate the top controls showing by 20px, thus shrinking the viewport | 6149 // Simulate the top controls showing by 20px, thus shrinking the viewport |
| 6150 // and allowing it to scroll an additional 20px. | 6150 // and allowing it to scroll an additional 20px. |
| 6151 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6151 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6152 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); | 6152 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); |
| 6153 | 6153 |
| 6154 // Show more, make sure the scroll actually gets clamped. | 6154 // Show more, make sure the scroll actually gets clamped. |
| 6155 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6155 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6156 webView->setMainFrameScrollOffset(WebPoint(0, 2000)); | 6156 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6157 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); | 6157 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); |
| 6158 | 6158 |
| 6159 // Hide until there's 10px showing. | 6159 // Hide until there's 10px showing. |
| 6160 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); | 6160 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); |
| 6161 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); | 6161 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); |
| 6162 | 6162 |
| 6163 // Simulate a LayoutPart::resize. The frame is resized to accomodate | 6163 // Simulate a LayoutPart::resize. The frame is resized to accomodate |
| 6164 // the top controls and Blink's view of the top controls matches that of | 6164 // the top controls and Blink's view of the top controls matches that of |
| 6165 // the CC | 6165 // the CC |
| 6166 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); | 6166 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7431 | 7431 |
| 7432 EXPECT_EQ(parent, firstFrame->parent()); | 7432 EXPECT_EQ(parent, firstFrame->parent()); |
| 7433 EXPECT_EQ(parent, secondFrame->parent()); | 7433 EXPECT_EQ(parent, secondFrame->parent()); |
| 7434 EXPECT_EQ(parent, thirdFrame->parent()); | 7434 EXPECT_EQ(parent, thirdFrame->parent()); |
| 7435 EXPECT_EQ(parent, fourthFrame->parent()); | 7435 EXPECT_EQ(parent, fourthFrame->parent()); |
| 7436 | 7436 |
| 7437 view->close(); | 7437 view->close(); |
| 7438 } | 7438 } |
| 7439 | 7439 |
| 7440 } // namespace blink | 7440 } // namespace blink |
| OLD | NEW |