| 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 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); | 2153 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.height, vie
wportSize.width)); |
| 2154 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal
eRelativeToViewportWidth ? 1 / aspectRatio : 1); | 2154 float expectedPageScaleFactor = initialPageScaleFactor * (shouldScal
eRelativeToViewportWidth ? 1 / aspectRatio : 1); |
| 2155 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); | 2155 EXPECT_NEAR(expectedPageScaleFactor, webViewHelper.webViewImpl()->pa
geScaleFactor(), 0.05f); |
| 2156 EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrol
lOffset()); | 2156 EXPECT_EQ(WebSize(), webViewHelper.webViewImpl()->mainFrame()->scrol
lOffset()); |
| 2157 } | 2157 } |
| 2158 | 2158 |
| 2159 // Resizing just the height should not affect pageScaleFactor or scrollO
ffset. | 2159 // Resizing just the height should not affect pageScaleFactor or scrollO
ffset. |
| 2160 { | 2160 { |
| 2161 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); | 2161 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height)); |
| 2162 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact
or); | 2162 webViewHelper.webViewImpl()->setPageScaleFactor(initialPageScaleFact
or); |
| 2163 webViewHelper.webViewImpl()->setMainFrameScrollOffset(WebPoint(scrol
lOffset.width, scrollOffset.height)); | 2163 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(scrollOffs
et); |
| 2164 webViewHelper.webViewImpl()->layout(); | 2164 webViewHelper.webViewImpl()->layout(); |
| 2165 const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->ma
inFrame()->scrollOffset(); | 2165 const WebSize expectedScrollOffset = webViewHelper.webViewImpl()->ma
inFrame()->scrollOffset(); |
| 2166 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); | 2166 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); |
| 2167 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); | 2167 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); |
| 2168 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); | 2168 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); |
| 2169 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); | 2169 webViewHelper.webViewImpl()->resize(WebSize(viewportSize.width, view
portSize.height * 0.8f)); |
| 2170 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); | 2170 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS
caleFactor()); |
| 2171 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); | 2171 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra
me()->scrollOffset()); |
| 2172 } | 2172 } |
| 2173 } | 2173 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 | 2313 |
| 2314 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); | 2314 webViewHelper.webView()->resize(WebSize(viewWidth * 10, viewHeight * 10)); |
| 2315 webViewHelper.webView()->layout(); | 2315 webViewHelper.webView()->layout(); |
| 2316 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); | 2316 EXPECT_FALSE(view->layoutView()->compositor()->layerForHorizontalScrollbar()
); |
| 2317 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); | 2317 EXPECT_FALSE(view->layoutView()->compositor()->layerForVerticalScrollbar()); |
| 2318 } | 2318 } |
| 2319 | 2319 |
| 2320 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca
le) | 2320 void setScaleAndScrollAndLayout(WebViewImpl* webView, WebPoint scroll, float sca
le) |
| 2321 { | 2321 { |
| 2322 webView->setPageScaleFactor(scale); | 2322 webView->setPageScaleFactor(scale); |
| 2323 webView->setMainFrameScrollOffset(WebPoint(scroll.x, scroll.y)); | 2323 webView->mainFrame()->setScrollOffset(WebSize(scroll.x, scroll.y)); |
| 2324 webView->layout(); | 2324 webView->layout(); |
| 2325 } | 2325 } |
| 2326 | 2326 |
| 2327 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | 2327 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) |
| 2328 { | 2328 { |
| 2329 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 2329 IntSize scrollDelta = webViewImpl->fakePageScaleAnimationTargetPositionForTe
sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); |
| 2330 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); | 2330 float scaleDelta = webViewImpl->fakePageScaleAnimationPageScaleForTesting()
/ webViewImpl->pageScaleFactor(); |
| 2331 webViewImpl->applyViewportDeltas(WebFloatSize(), FloatSize(scrollDelta), Web
FloatSize(), scaleDelta, 0); | 2331 webViewImpl->applyViewportDeltas(WebFloatSize(), FloatSize(scrollDelta), Web
FloatSize(), scaleDelta, 0); |
| 2332 scale = webViewImpl->pageScaleFactor(); | 2332 scale = webViewImpl->pageScaleFactor(); |
| 2333 } | 2333 } |
| (...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4677 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, conf
igureAndroid); | 4677 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, conf
igureAndroid); |
| 4678 | 4678 |
| 4679 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); | 4679 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); |
| 4680 ASSERT_TRUE(webViewImpl); | 4680 ASSERT_TRUE(webViewImpl); |
| 4681 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); | 4681 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); |
| 4682 ASSERT_TRUE(frame); | 4682 ASSERT_TRUE(frame); |
| 4683 | 4683 |
| 4684 webViewHelper.webView()->resize(WebSize(100, 200)); | 4684 webViewHelper.webView()->resize(WebSize(100, 200)); |
| 4685 | 4685 |
| 4686 // Scroll main frame to the bottom of the document | 4686 // Scroll main frame to the bottom of the document |
| 4687 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 400)); | 4687 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 400)); |
| 4688 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); | 4688 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); |
| 4689 | 4689 |
| 4690 webViewImpl->setPageScaleFactor(2.0); | 4690 webViewImpl->setPageScaleFactor(2.0); |
| 4691 | 4691 |
| 4692 // Scroll pinch viewport to the top of the main frame. | 4692 // Scroll pinch viewport to the top of the main frame. |
| 4693 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); | 4693 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
| 4694 pinchViewport.setLocation(FloatPoint(0, 0)); | 4694 pinchViewport.setLocation(FloatPoint(0, 0)); |
| 4695 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); | 4695 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); |
| 4696 | 4696 |
| 4697 // Tap at the top: there is nothing there. | 4697 // Tap at the top: there is nothing there. |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6110 | 6110 |
| 6111 WebViewImpl* webView = webViewHelper.webViewImpl(); | 6111 WebViewImpl* webView = webViewHelper.webViewImpl(); |
| 6112 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 6112 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| 6113 | 6113 |
| 6114 float topControlsHeight = 40; | 6114 float topControlsHeight = 40; |
| 6115 webView->setTopControlsHeight(topControlsHeight, false); | 6115 webView->setTopControlsHeight(topControlsHeight, false); |
| 6116 webView->resize(WebSize(100, 100)); | 6116 webView->resize(WebSize(100, 100)); |
| 6117 webView->setPageScaleFactor(2.0f); | 6117 webView->setPageScaleFactor(2.0f); |
| 6118 webView->layout(); | 6118 webView->layout(); |
| 6119 | 6119 |
| 6120 webView->setMainFrameScrollOffset(WebPoint(0, 2000)); | 6120 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6121 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); | 6121 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); |
| 6122 | 6122 |
| 6123 // Simulate the top controls showing by 20px, thus shrinking the viewport | 6123 // Simulate the top controls showing by 20px, thus shrinking the viewport |
| 6124 // and allowing it to scroll an additional 20px. | 6124 // and allowing it to scroll an additional 20px. |
| 6125 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6125 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6126 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); | 6126 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); |
| 6127 | 6127 |
| 6128 // Show more, make sure the scroll actually gets clamped. | 6128 // Show more, make sure the scroll actually gets clamped. |
| 6129 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6129 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6130 webView->setMainFrameScrollOffset(WebPoint(0, 2000)); | 6130 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6131 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); | 6131 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); |
| 6132 | 6132 |
| 6133 // Hide until there's 10px showing. | 6133 // Hide until there's 10px showing. |
| 6134 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); | 6134 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); |
| 6135 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); | 6135 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); |
| 6136 | 6136 |
| 6137 // Simulate a LayoutPart::resize. The frame is resized to accomodate | 6137 // Simulate a LayoutPart::resize. The frame is resized to accomodate |
| 6138 // the top controls and Blink's view of the top controls matches that of | 6138 // the top controls and Blink's view of the top controls matches that of |
| 6139 // the CC | 6139 // the CC |
| 6140 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); | 6140 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7405 | 7405 |
| 7406 EXPECT_EQ(parent, firstFrame->parent()); | 7406 EXPECT_EQ(parent, firstFrame->parent()); |
| 7407 EXPECT_EQ(parent, secondFrame->parent()); | 7407 EXPECT_EQ(parent, secondFrame->parent()); |
| 7408 EXPECT_EQ(parent, thirdFrame->parent()); | 7408 EXPECT_EQ(parent, thirdFrame->parent()); |
| 7409 EXPECT_EQ(parent, fourthFrame->parent()); | 7409 EXPECT_EQ(parent, fourthFrame->parent()); |
| 7410 | 7410 |
| 7411 view->close(); | 7411 view->close(); |
| 7412 } | 7412 } |
| 7413 | 7413 |
| 7414 } // namespace blink | 7414 } // namespace blink |
| OLD | NEW |