| 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/RootFrameViewport.h" | 5 #include "core/frame/RootFrameViewport.h" |
| 6 | 6 |
| 7 #include "core/layout/ScrollAlignment.h" | 7 #include "core/layout/ScrollAlignment.h" |
| 8 #include "platform/geometry/DoubleRect.h" | 8 #include "platform/geometry/DoubleRect.h" |
| 9 #include "platform/geometry/LayoutRect.h" | 9 #include "platform/geometry/LayoutRect.h" |
| 10 #include "platform/scroll/ScrollableArea.h" | 10 #include "platform/scroll/ScrollableArea.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 #define EXPECT_POINT_EQ(expected, actual) \ | 13 #define EXPECT_POINT_EQ(expected, actual) \ |
| 14 do { \ | 14 do { \ |
| 15 EXPECT_EQ((expected).x(), (actual).x()); \ | 15 EXPECT_EQ((expected).x(), (actual).x()); \ |
| 16 EXPECT_EQ((expected).y(), (actual).y()); \ | 16 EXPECT_EQ((expected).y(), (actual).y()); \ |
| 17 } while (false) | 17 } while (false) |
| 18 #define EXPECT_SIZE_EQ(expected, actual) \ | 18 #define EXPECT_SIZE_EQ(expected, actual) \ |
| 19 do { \ | 19 do { \ |
| 20 EXPECT_EQ((expected).width(), (actual).width()); \ | 20 EXPECT_EQ((expected).width(), (actual).width()); \ |
| 21 EXPECT_EQ((expected).height(), (actual).height()); \ | 21 EXPECT_EQ((expected).height(), (actual).height()); \ |
| 22 } while (false) | 22 } while (false) |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 class ScrollableAreaStub : public NoBaseWillBeGarbageCollectedFinalized<Scrollab
leAreaStub>, public ScrollableArea { | 26 class ScrollableAreaStub : public GarbageCollectedFinalized<ScrollableAreaStub>,
public ScrollableArea { |
| 27 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScrollableAreaStub); | 27 USING_GARBAGE_COLLECTED_MIXIN(ScrollableAreaStub); |
| 28 public: | 28 public: |
| 29 static PassOwnPtrWillBeRawPtr<ScrollableAreaStub> create(const IntSize& view
portSize, const IntSize& contentsSize) | 29 static RawPtr<ScrollableAreaStub> create(const IntSize& viewportSize, const
IntSize& contentsSize) |
| 30 { | 30 { |
| 31 return adoptPtrWillBeNoop(new ScrollableAreaStub(viewportSize, contentsS
ize)); | 31 return (new ScrollableAreaStub(viewportSize, contentsSize)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void setViewportSize(const IntSize& viewportSize) | 34 void setViewportSize(const IntSize& viewportSize) |
| 35 { | 35 { |
| 36 m_viewportSize = viewportSize; | 36 m_viewportSize = viewportSize; |
| 37 } | 37 } |
| 38 | 38 |
| 39 IntSize viewportSize() const { return m_viewportSize; } | 39 IntSize viewportSize() const { return m_viewportSize; } |
| 40 | 40 |
| 41 // ScrollableArea Impl | 41 // ScrollableArea Impl |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 bool m_userInputScrollableX; | 107 bool m_userInputScrollableX; |
| 108 bool m_userInputScrollableY; | 108 bool m_userInputScrollableY; |
| 109 DoublePoint m_scrollPosition; | 109 DoublePoint m_scrollPosition; |
| 110 IntSize m_viewportSize; | 110 IntSize m_viewportSize; |
| 111 IntSize m_contentsSize; | 111 IntSize m_contentsSize; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class RootFrameViewStub : public ScrollableAreaStub { | 114 class RootFrameViewStub : public ScrollableAreaStub { |
| 115 public: | 115 public: |
| 116 static PassOwnPtrWillBeRawPtr<RootFrameViewStub> create(const IntSize& viewp
ortSize, const IntSize& contentsSize) | 116 static RawPtr<RootFrameViewStub> create(const IntSize& viewportSize, const I
ntSize& contentsSize) |
| 117 { | 117 { |
| 118 return adoptPtrWillBeNoop(new RootFrameViewStub(viewportSize, contentsSi
ze)); | 118 return (new RootFrameViewStub(viewportSize, contentsSize)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 DoublePoint maximumScrollPositionDouble() const override | 121 DoublePoint maximumScrollPositionDouble() const override |
| 122 { | 122 { |
| 123 return IntPoint(contentsSize() - viewportSize()); | 123 return IntPoint(contentsSize() - viewportSize()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 RootFrameViewStub(const IntSize& viewportSize, const IntSize& contentsSize) | 127 RootFrameViewStub(const IntSize& viewportSize, const IntSize& contentsSize) |
| 128 : ScrollableAreaStub(viewportSize, contentsSize) | 128 : ScrollableAreaStub(viewportSize, contentsSize) |
| 129 { | 129 { |
| 130 } | 130 } |
| 131 | 131 |
| 132 int visibleWidth() const override { return m_viewportSize.width(); } | 132 int visibleWidth() const override { return m_viewportSize.width(); } |
| 133 int visibleHeight() const override { return m_viewportSize.height(); } | 133 int visibleHeight() const override { return m_viewportSize.height(); } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 class VisualViewportStub : public ScrollableAreaStub { | 136 class VisualViewportStub : public ScrollableAreaStub { |
| 137 public: | 137 public: |
| 138 static PassOwnPtrWillBeRawPtr<VisualViewportStub> create(const IntSize& view
portSize, const IntSize& contentsSize) | 138 static RawPtr<VisualViewportStub> create(const IntSize& viewportSize, const
IntSize& contentsSize) |
| 139 { | 139 { |
| 140 return adoptPtrWillBeNoop(new VisualViewportStub(viewportSize, contentsS
ize)); | 140 return (new VisualViewportStub(viewportSize, contentsSize)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 DoublePoint maximumScrollPositionDouble() const override | 143 DoublePoint maximumScrollPositionDouble() const override |
| 144 { | 144 { |
| 145 DoubleSize visibleViewport = viewportSize(); | 145 DoubleSize visibleViewport = viewportSize(); |
| 146 visibleViewport.scale(1 / m_scale); | 146 visibleViewport.scale(1 / m_scale); |
| 147 | 147 |
| 148 DoubleSize maxPosition = DoubleSize(contentsSize()) - visibleViewport; | 148 DoubleSize maxPosition = DoubleSize(contentsSize()) - visibleViewport; |
| 149 return DoublePoint(maxPosition); | 149 return DoublePoint(maxPosition); |
| 150 } | 150 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 { | 182 { |
| 183 } | 183 } |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // Tests that scrolling the viewport when the layout viewport is | 186 // Tests that scrolling the viewport when the layout viewport is |
| 187 // !userInputScrollable (as happens when overflow:hidden is set) works | 187 // !userInputScrollable (as happens when overflow:hidden is set) works |
| 188 // correctly, that is, the visual viewport can scroll, but not the layout. | 188 // correctly, that is, the visual viewport can scroll, but not the layout. |
| 189 TEST_F(RootFrameViewportTest, UserInputScrollable) | 189 TEST_F(RootFrameViewportTest, UserInputScrollable) |
| 190 { | 190 { |
| 191 IntSize viewportSize(100, 150); | 191 IntSize viewportSize(100, 150); |
| 192 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(200, 300)); | 192 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(200, 300)); |
| 193 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 193 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 194 | 194 |
| 195 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr
eate(*visualViewport.get(), *layoutViewport.get()); | 195 RawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::create(*visual
Viewport.get(), *layoutViewport.get()); |
| 196 | 196 |
| 197 visualViewport->setScale(2); | 197 visualViewport->setScale(2); |
| 198 | 198 |
| 199 // Disable just the layout viewport's horizontal scrolling, the | 199 // Disable just the layout viewport's horizontal scrolling, the |
| 200 // RootFrameViewport should remain scrollable overall. | 200 // RootFrameViewport should remain scrollable overall. |
| 201 layoutViewport->setUserInputScrollable(false, true); | 201 layoutViewport->setUserInputScrollable(false, true); |
| 202 visualViewport->setUserInputScrollable(true, true); | 202 visualViewport->setUserInputScrollable(true, true); |
| 203 | 203 |
| 204 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); | 204 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); |
| 205 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); | 205 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 EXPECT_POINT_EQ(DoublePoint(50, 0), visualViewport->scrollPositionDouble()); | 293 EXPECT_POINT_EQ(DoublePoint(50, 0), visualViewport->scrollPositionDouble()); |
| 294 EXPECT_POINT_EQ(DoublePoint(150, 0), rootFrameViewport->scrollPositionDouble
()); | 294 EXPECT_POINT_EQ(DoublePoint(150, 0), rootFrameViewport->scrollPositionDouble
()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Make sure scrolls using the scroll animator (scroll(), setScrollPosition()) | 297 // Make sure scrolls using the scroll animator (scroll(), setScrollPosition()) |
| 298 // work correctly when one of the subviewports is explicitly scrolled without us
ing the | 298 // work correctly when one of the subviewports is explicitly scrolled without us
ing the |
| 299 // RootFrameViewport interface. | 299 // RootFrameViewport interface. |
| 300 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) | 300 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) |
| 301 { | 301 { |
| 302 IntSize viewportSize(100, 150); | 302 IntSize viewportSize(100, 150); |
| 303 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(200, 300)); | 303 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(200, 300)); |
| 304 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 304 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 305 | 305 |
| 306 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr
eate(*visualViewport.get(), *layoutViewport.get()); | 306 RawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::create(*visual
Viewport.get(), *layoutViewport.get()); |
| 307 | 307 |
| 308 visualViewport->setScale(2); | 308 visualViewport->setScale(2); |
| 309 | 309 |
| 310 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); | 310 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); |
| 311 EXPECT_POINT_EQ(DoublePoint(50, 75), rootFrameViewport->scrollPositionDouble
()); | 311 EXPECT_POINT_EQ(DoublePoint(50, 75), rootFrameViewport->scrollPositionDouble
()); |
| 312 | 312 |
| 313 // If the scroll animator doesn't update, it will still think it's at (0, 0)
and so it | 313 // If the scroll animator doesn't update, it will still think it's at (0, 0)
and so it |
| 314 // may early exit. | 314 // may early exit. |
| 315 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); | 315 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); |
| 316 EXPECT_POINT_EQ(DoublePoint(0, 0), rootFrameViewport->scrollPositionDouble()
); | 316 EXPECT_POINT_EQ(DoublePoint(0, 0), rootFrameViewport->scrollPositionDouble()
); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 332 rootFrameViewport->userScroll(ScrollLeft, ScrollByPixel, 100); | 332 rootFrameViewport->userScroll(ScrollLeft, ScrollByPixel, 100); |
| 333 EXPECT_POINT_EQ(DoublePoint(0, 150), rootFrameViewport->scrollPositionDouble
()); | 333 EXPECT_POINT_EQ(DoublePoint(0, 150), rootFrameViewport->scrollPositionDouble
()); |
| 334 EXPECT_POINT_EQ(DoublePoint(0, 150), layoutViewport->scrollPositionDouble())
; | 334 EXPECT_POINT_EQ(DoublePoint(0, 150), layoutViewport->scrollPositionDouble())
; |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Test that the scrollIntoView correctly scrolls the main frame | 337 // Test that the scrollIntoView correctly scrolls the main frame |
| 338 // and visual viewport such that the given rect is centered in the viewport. | 338 // and visual viewport such that the given rect is centered in the viewport. |
| 339 TEST_F(RootFrameViewportTest, ScrollIntoView) | 339 TEST_F(RootFrameViewportTest, ScrollIntoView) |
| 340 { | 340 { |
| 341 IntSize viewportSize(100, 150); | 341 IntSize viewportSize(100, 150); |
| 342 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(200, 300)); | 342 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(200, 300)); |
| 343 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 343 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 344 | 344 |
| 345 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr
eate(*visualViewport.get(), *layoutViewport.get()); | 345 RawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::create(*visual
Viewport.get(), *layoutViewport.get()); |
| 346 | 346 |
| 347 // Test that the visual viewport is scrolled if the viewport has been | 347 // Test that the visual viewport is scrolled if the viewport has been |
| 348 // resized (as is the case when the ChromeOS keyboard comes up) but not | 348 // resized (as is the case when the ChromeOS keyboard comes up) but not |
| 349 // scaled. | 349 // scaled. |
| 350 visualViewport->setViewportSize(IntSize(100, 100)); | 350 visualViewport->setViewportSize(IntSize(100, 100)); |
| 351 rootFrameViewport->scrollIntoView( | 351 rootFrameViewport->scrollIntoView( |
| 352 LayoutRect(100, 250, 50, 50), | 352 LayoutRect(100, 250, 50, 50), |
| 353 ScrollAlignment::alignToEdgeIfNeeded, | 353 ScrollAlignment::alignToEdgeIfNeeded, |
| 354 ScrollAlignment::alignToEdgeIfNeeded); | 354 ScrollAlignment::alignToEdgeIfNeeded); |
| 355 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble()
); | 355 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble()
); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 ScrollAlignment::alignTopAlways, | 407 ScrollAlignment::alignTopAlways, |
| 408 ScrollAlignment::alignTopAlways); | 408 ScrollAlignment::alignTopAlways); |
| 409 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble())
; | 409 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble())
; |
| 410 EXPECT_POINT_EQ(DoublePoint(0, 10), visualViewport->scrollPositionDouble()); | 410 EXPECT_POINT_EQ(DoublePoint(0, 10), visualViewport->scrollPositionDouble()); |
| 411 } | 411 } |
| 412 | 412 |
| 413 // Tests that the setScrollPosition method works correctly with both viewports. | 413 // Tests that the setScrollPosition method works correctly with both viewports. |
| 414 TEST_F(RootFrameViewportTest, SetScrollPosition) | 414 TEST_F(RootFrameViewportTest, SetScrollPosition) |
| 415 { | 415 { |
| 416 IntSize viewportSize(500, 500); | 416 IntSize viewportSize(500, 500); |
| 417 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(1000, 2000)); | 417 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(1000, 2000)); |
| 418 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 418 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 419 | 419 |
| 420 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr
eate(*visualViewport.get(), *layoutViewport.get()); | 420 RawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::create(*visual
Viewport.get(), *layoutViewport.get()); |
| 421 | 421 |
| 422 visualViewport->setScale(2); | 422 visualViewport->setScale(2); |
| 423 | 423 |
| 424 // Ensure that the visual viewport scrolls first. | 424 // Ensure that the visual viewport scrolls first. |
| 425 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), ProgrammaticScro
ll); | 425 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), ProgrammaticScro
ll); |
| 426 EXPECT_POINT_EQ(DoublePoint(100, 100), visualViewport->scrollPositionDouble(
)); | 426 EXPECT_POINT_EQ(DoublePoint(100, 100), visualViewport->scrollPositionDouble(
)); |
| 427 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 427 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); |
| 428 | 428 |
| 429 // Scroll to the visual viewport's extent, the layout viewport should scroll
the | 429 // Scroll to the visual viewport's extent, the layout viewport should scroll
the |
| 430 // remainder. | 430 // remainder. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 442 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); | 442 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); |
| 443 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); | 443 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); |
| 444 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 444 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); |
| 445 } | 445 } |
| 446 | 446 |
| 447 // Tests that the visible rect (i.e. visual viewport rect) is correctly | 447 // Tests that the visible rect (i.e. visual viewport rect) is correctly |
| 448 // calculated, taking into account both viewports and page scale. | 448 // calculated, taking into account both viewports and page scale. |
| 449 TEST_F(RootFrameViewportTest, VisibleContentRect) | 449 TEST_F(RootFrameViewportTest, VisibleContentRect) |
| 450 { | 450 { |
| 451 IntSize viewportSize(500, 401); | 451 IntSize viewportSize(500, 401); |
| 452 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(1000, 2000)); | 452 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(1000, 2000)); |
| 453 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 453 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 454 | 454 |
| 455 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr
eate(*visualViewport.get(), *layoutViewport.get()); | 455 RawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::create(*visual
Viewport.get(), *layoutViewport.get()); |
| 456 | 456 |
| 457 rootFrameViewport->setScrollPosition(DoublePoint(100, 75), ProgrammaticScrol
l); | 457 rootFrameViewport->setScrollPosition(DoublePoint(100, 75), ProgrammaticScrol
l); |
| 458 | 458 |
| 459 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect(
).location()); | 459 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect(
).location()); |
| 460 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD
ouble().location()); | 460 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD
ouble().location()); |
| 461 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRect()
.size()); | 461 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRect()
.size()); |
| 462 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRectDo
uble().size()); | 462 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRectDo
uble().size()); |
| 463 | 463 |
| 464 visualViewport->setScale(2); | 464 visualViewport->setScale(2); |
| 465 | 465 |
| 466 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect(
).location()); | 466 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect(
).location()); |
| 467 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD
ouble().location()); | 467 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD
ouble().location()); |
| 468 EXPECT_SIZE_EQ(DoubleSize(250, 201), rootFrameViewport->visibleContentRect()
.size()); | 468 EXPECT_SIZE_EQ(DoubleSize(250, 201), rootFrameViewport->visibleContentRect()
.size()); |
| 469 EXPECT_SIZE_EQ(DoubleSize(250, 200.5), rootFrameViewport->visibleContentRect
Double().size()); | 469 EXPECT_SIZE_EQ(DoubleSize(250, 200.5), rootFrameViewport->visibleContentRect
Double().size()); |
| 470 } | 470 } |
| 471 | 471 |
| 472 // Tests that scrolls on the root frame scroll the visual viewport before | 472 // Tests that scrolls on the root frame scroll the visual viewport before |
| 473 // trying to scroll the layout viewport. | 473 // trying to scroll the layout viewport. |
| 474 TEST_F(RootFrameViewportTest, ViewportScrollOrder) | 474 TEST_F(RootFrameViewportTest, ViewportScrollOrder) |
| 475 { | 475 { |
| 476 IntSize viewportSize(100, 100); | 476 IntSize viewportSize(100, 100); |
| 477 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr
eate(viewportSize, IntSize(200, 300)); | 477 RawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::create(viewpor
tSize, IntSize(200, 300)); |
| 478 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub::
create(viewportSize, viewportSize); | 478 RawPtr<VisualViewportStub> visualViewport = VisualViewportStub::create(viewp
ortSize, viewportSize); |
| 479 | 479 |
| 480 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = | 480 RawPtr<ScrollableArea> rootFrameViewport = |
| 481 RootFrameViewport::create(*visualViewport.get(), *layoutViewport.get()); | 481 RootFrameViewport::create(*visualViewport.get(), *layoutViewport.get()); |
| 482 | 482 |
| 483 visualViewport->setScale(2); | 483 visualViewport->setScale(2); |
| 484 | 484 |
| 485 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll); | 485 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll); |
| 486 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble())
; | 486 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble())
; |
| 487 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 487 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); |
| 488 | 488 |
| 489 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll
); | 489 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll
); |
| 490 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble())
; | 490 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble())
; |
| 491 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble())
; | 491 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble())
; |
| 492 } | 492 } |
| 493 | 493 |
| 494 } // namespace blink | 494 } // namespace blink |
| OLD | NEW |