| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/VisualViewport.h" | 5 #include "core/frame/VisualViewport.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 visualViewport.setScale(2); | 258 visualViewport.setScale(2); |
| 259 | 259 |
| 260 // Fully scroll both viewports. | 260 // Fully scroll both viewports. |
| 261 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(1000
0, 10000), ProgrammaticScroll); | 261 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(1000
0, 10000), ProgrammaticScroll); |
| 262 visualViewport.move(FloatSize(10000, 10000)); | 262 visualViewport.move(FloatSize(10000, 10000)); |
| 263 | 263 |
| 264 // Sanity check. | 264 // Sanity check. |
| 265 ASSERT_POINT_EQ(FloatPoint(400, 300), visualViewport.location()); | 265 ASSERT_POINT_EQ(FloatPoint(400, 300), visualViewport.location()); |
| 266 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.layoutViewportScrollableAr
ea()->scrollPositionDouble()); | 266 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.layoutViewportScrollableAr
ea()->scrollPositionDouble()); |
| 267 | 267 |
| 268 DoublePoint expectedLocation = frameView.scrollableArea()->visibleContentRec
tDouble().location(); | 268 DoublePoint expectedLocation = frameView.getScrollableArea()->visibleContent
RectDouble().location(); |
| 269 | 269 |
| 270 // Shrink the WebView, this should cause both viewports to shrink and | 270 // Shrink the WebView, this should cause both viewports to shrink and |
| 271 // WebView should do whatever it needs to do to preserve the visible | 271 // WebView should do whatever it needs to do to preserve the visible |
| 272 // location. | 272 // location. |
| 273 webViewImpl()->resize(IntSize(700, 550)); | 273 webViewImpl()->resize(IntSize(700, 550)); |
| 274 | 274 |
| 275 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); | 275 EXPECT_POINT_EQ(expectedLocation, frameView.getScrollableArea()->visibleCont
entRectDouble().location()); |
| 276 | 276 |
| 277 webViewImpl()->resize(IntSize(800, 600)); | 277 webViewImpl()->resize(IntSize(800, 600)); |
| 278 | 278 |
| 279 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); | 279 EXPECT_POINT_EQ(expectedLocation, frameView.getScrollableArea()->visibleCont
entRectDouble().location()); |
| 280 } | 280 } |
| 281 | 281 |
| 282 | 282 |
| 283 // Test that the VisualViewport works as expected in case of a scaled | 283 // Test that the VisualViewport works as expected in case of a scaled |
| 284 // and scrolled viewport - scroll down. | 284 // and scrolled viewport - scroll down. |
| 285 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) | 285 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) |
| 286 { | 286 { |
| 287 /* | 287 /* |
| 288 200 200 | 288 200 200 |
| 289 | | | | | 289 | | | | |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 webViewImpl()->handleInputEvent(pinchUpdate); | 1740 webViewImpl()->handleInputEvent(pinchUpdate); |
| 1741 | 1741 |
| 1742 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); | 1742 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); |
| 1743 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1743 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1744 | 1744 |
| 1745 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); | 1745 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); |
| 1746 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); | 1746 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 } // namespace | 1749 } // namespace |
| OLD | NEW |