| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/frame/VisualViewport.h" | 7 #include "core/frame/VisualViewport.h" |
| 8 | 8 |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // Initial visible rect should be the whole frame. | 452 // Initial visible rect should be the whole frame. |
| 453 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size()); | 453 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size()); |
| 454 | 454 |
| 455 // Viewport is whole frame. | 455 // Viewport is whole frame. |
| 456 IntSize size = IntSize(400, 200); | 456 IntSize size = IntSize(400, 200); |
| 457 webViewImpl()->resize(size); | 457 webViewImpl()->resize(size); |
| 458 webViewImpl()->updateAllLifecyclePhases(); | 458 webViewImpl()->updateAllLifecyclePhases(); |
| 459 visualViewport.setSize(size); | 459 visualViewport.setSize(size); |
| 460 | 460 |
| 461 // Scale the viewport to 2X; size should not change. | 461 // Scale the viewport to 2X; size should not change. |
| 462 FloatRect expectedRect(FloatPoint(0, 0), size); | 462 FloatRect expectedRect(FloatPoint(0, 0), FloatSize(size)); |
| 463 expectedRect.scale(0.5); | 463 expectedRect.scale(0.5); |
| 464 visualViewport.setScale(2); | 464 visualViewport.setScale(2); |
| 465 EXPECT_EQ(2, visualViewport.scale()); | 465 EXPECT_EQ(2, visualViewport.scale()); |
| 466 EXPECT_SIZE_EQ(size, visualViewport.size()); | 466 EXPECT_SIZE_EQ(size, visualViewport.size()); |
| 467 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 467 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 468 | 468 |
| 469 // Move the viewport. | 469 // Move the viewport. |
| 470 expectedRect.setLocation(FloatPoint(5, 7)); | 470 expectedRect.setLocation(FloatPoint(5, 7)); |
| 471 visualViewport.setLocation(expectedRect.location()); | 471 visualViewport.setLocation(expectedRect.location()); |
| 472 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 472 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 473 | 473 |
| 474 expectedRect.setLocation(FloatPoint(200, 100)); | 474 expectedRect.setLocation(FloatPoint(200, 100)); |
| 475 visualViewport.setLocation(expectedRect.location()); | 475 visualViewport.setLocation(expectedRect.location()); |
| 476 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 476 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 477 | 477 |
| 478 // Scale the viewport to 3X to introduce some non-int values. | 478 // Scale the viewport to 3X to introduce some non-int values. |
| 479 FloatPoint oldLocation = expectedRect.location(); | 479 FloatPoint oldLocation = expectedRect.location(); |
| 480 expectedRect = FloatRect(FloatPoint(), size); | 480 expectedRect = FloatRect(FloatPoint(), FloatSize(size)); |
| 481 expectedRect.scale(1 / 3.0f); | 481 expectedRect.scale(1 / 3.0f); |
| 482 expectedRect.setLocation(oldLocation); | 482 expectedRect.setLocation(oldLocation); |
| 483 visualViewport.setScale(3); | 483 visualViewport.setScale(3); |
| 484 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 484 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 485 | 485 |
| 486 expectedRect.setLocation(FloatPoint(0.25f, 0.333f)); | 486 expectedRect.setLocation(FloatPoint(0.25f, 0.333f)); |
| 487 visualViewport.setLocation(expectedRect.location()); | 487 visualViewport.setLocation(expectedRect.location()); |
| 488 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 488 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 489 } | 489 } |
| 490 | 490 |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 webViewImpl()->handleInputEvent(pinchUpdate); | 1608 webViewImpl()->handleInputEvent(pinchUpdate); |
| 1609 | 1609 |
| 1610 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); | 1610 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); |
| 1611 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1611 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1612 | 1612 |
| 1613 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); | 1613 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); |
| 1614 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); | 1614 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); |
| 1615 } | 1615 } |
| 1616 | 1616 |
| 1617 } // namespace | 1617 } // namespace |
| OLD | NEW |