| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return event; | 113 return event; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void verticalScroll(float deltaY) | 116 void verticalScroll(float deltaY) |
| 117 { | 117 { |
| 118 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llBegin)); | 118 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llBegin)); |
| 119 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llUpdate, 0, deltaY)); | 119 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llUpdate, 0, deltaY)); |
| 120 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llEnd)); | 120 webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScro
llEnd)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 PassRefPtrWillBeRawPtr<Element> getElementById(const WebString& id) | 123 RawPtr<Element> getElementById(const WebString& id) |
| 124 { | 124 { |
| 125 return static_cast<PassRefPtrWillBeRawPtr<Element>>( | 125 return static_cast<RawPtr<Element>>( |
| 126 webViewImpl()->mainFrame()->document().getElementById(id)); | 126 webViewImpl()->mainFrame()->document().getElementById(id)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } | 130 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } |
| 131 LocalFrame* frame() const { return m_helper.webViewImpl()->mainFrameImpl()->
frame(); } | 131 LocalFrame* frame() const { return m_helper.webViewImpl()->mainFrameImpl()->
frame(); } |
| 132 VisualViewport& visualViewport() const { return m_helper.webViewImpl()->page
()->frameHost().visualViewport(); } | 132 VisualViewport& visualViewport() const { return m_helper.webViewImpl()->page
()->frameHost().visualViewport(); } |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 std::string m_baseURL; | 135 std::string m_baseURL; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 WebTopControlsBoth, WebTopControlsShown, false); | 570 WebTopControlsBoth, WebTopControlsShown, false); |
| 571 webView->topControls().setShownRatio(1); | 571 webView->topControls().setShownRatio(1); |
| 572 webView->resize(WebSize(400, 300)); | 572 webView->resize(WebSize(400, 300)); |
| 573 webView->updateAllLifecyclePhases(); | 573 webView->updateAllLifecyclePhases(); |
| 574 | 574 |
| 575 ASSERT_EQ(100.f, webView->topControls().contentOffset()); | 575 ASSERT_EQ(100.f, webView->topControls().contentOffset()); |
| 576 | 576 |
| 577 // When the top controls are showing, there's 300px for the layout height so | 577 // When the top controls are showing, there's 300px for the layout height so |
| 578 // 50% should result in both the position:fixed and position: absolute divs | 578 // 50% should result in both the position:fixed and position: absolute divs |
| 579 // having 150px of height. | 579 // having 150px of height. |
| 580 RefPtrWillBeRawPtr<Element> absPos = | 580 RawPtr<Element> absPos = |
| 581 getElementById(WebString::fromUTF8("abs")); | 581 getElementById(WebString::fromUTF8("abs")); |
| 582 RefPtrWillBeRawPtr<Element> fixedPos = | 582 RawPtr<Element> fixedPos = |
| 583 getElementById(WebString::fromUTF8("fixed")); | 583 getElementById(WebString::fromUTF8("fixed")); |
| 584 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); | 584 EXPECT_FLOAT_EQ(150.f, absPos->getBoundingClientRect()->height()); |
| 585 EXPECT_FLOAT_EQ(150.f, fixedPos->getBoundingClientRect()->height()); | 585 EXPECT_FLOAT_EQ(150.f, fixedPos->getBoundingClientRect()->height()); |
| 586 | 586 |
| 587 // The layout size on the FrameView should not include the top controls. | 587 // The layout size on the FrameView should not include the top controls. |
| 588 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); | 588 EXPECT_EQ(300, frame()->view()->layoutSize(IncludeScrollbars).height()); |
| 589 | 589 |
| 590 // Hide the top controls. | 590 // Hide the top controls. |
| 591 verticalScroll(-100.f); | 591 verticalScroll(-100.f); |
| 592 webView->setTopControlsHeight(100.f, false); | 592 webView->setTopControlsHeight(100.f, false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 614 webView->updateTopControlsState( | 614 webView->updateTopControlsState( |
| 615 WebTopControlsBoth, WebTopControlsShown, false); | 615 WebTopControlsBoth, WebTopControlsShown, false); |
| 616 webView->topControls().setShownRatio(1); | 616 webView->topControls().setShownRatio(1); |
| 617 webView->resize(WebSize(400, 300)); | 617 webView->resize(WebSize(400, 300)); |
| 618 webView->updateAllLifecyclePhases(); | 618 webView->updateAllLifecyclePhases(); |
| 619 | 619 |
| 620 ASSERT_EQ(100.f, webView->topControls().contentOffset()); | 620 ASSERT_EQ(100.f, webView->topControls().contentOffset()); |
| 621 | 621 |
| 622 // 'vh' units should be based on the viewport when the top controls are | 622 // 'vh' units should be based on the viewport when the top controls are |
| 623 // hidden. | 623 // hidden. |
| 624 RefPtrWillBeRawPtr<Element> absPos = | 624 RawPtr<Element> absPos = |
| 625 getElementById(WebString::fromUTF8("abs")); | 625 getElementById(WebString::fromUTF8("abs")); |
| 626 RefPtrWillBeRawPtr<Element> fixedPos = | 626 RawPtr<Element> fixedPos = |
| 627 getElementById(WebString::fromUTF8("fixed")); | 627 getElementById(WebString::fromUTF8("fixed")); |
| 628 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height()); | 628 EXPECT_FLOAT_EQ(200.f, absPos->getBoundingClientRect()->height()); |
| 629 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); | 629 EXPECT_FLOAT_EQ(200.f, fixedPos->getBoundingClientRect()->height()); |
| 630 | 630 |
| 631 // The size used for viewport units should not be reduced by the top | 631 // The size used for viewport units should not be reduced by the top |
| 632 // controls. | 632 // controls. |
| 633 EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height()); | 633 EXPECT_EQ(400, frame()->view()->viewportSizeForViewportUnits().height()); |
| 634 | 634 |
| 635 // Hide the top controls. | 635 // Hide the top controls. |
| 636 verticalScroll(-100.f); | 636 verticalScroll(-100.f); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 668 |
| 669 // Device viewport is 400px but the page is width=800 so minimum-scale | 669 // Device viewport is 400px but the page is width=800 so minimum-scale |
| 670 // should be 0.5. This is also the scale at which the viewport fills the | 670 // should be 0.5. This is also the scale at which the viewport fills the |
| 671 // layout width. | 671 // layout width. |
| 672 ASSERT_EQ(0.5f, webView->minimumPageScaleFactor()); | 672 ASSERT_EQ(0.5f, webView->minimumPageScaleFactor()); |
| 673 | 673 |
| 674 // We should size vh units so that 100vh fills the viewport at min-scale so | 674 // We should size vh units so that 100vh fills the viewport at min-scale so |
| 675 // we have to account for the minimum page scale factor. Since both boxes | 675 // we have to account for the minimum page scale factor. Since both boxes |
| 676 // are 50vh, and layout scale = 0.5, we have a vh viewport of 400 / 0.5 = 80
0 | 676 // are 50vh, and layout scale = 0.5, we have a vh viewport of 400 / 0.5 = 80
0 |
| 677 // so we expect 50vh to be 400px. | 677 // so we expect 50vh to be 400px. |
| 678 RefPtrWillBeRawPtr<Element> absPos = | 678 RawPtr<Element> absPos = |
| 679 getElementById(WebString::fromUTF8("abs")); | 679 getElementById(WebString::fromUTF8("abs")); |
| 680 RefPtrWillBeRawPtr<Element> fixedPos = | 680 RawPtr<Element> fixedPos = |
| 681 getElementById(WebString::fromUTF8("fixed")); | 681 getElementById(WebString::fromUTF8("fixed")); |
| 682 EXPECT_FLOAT_EQ(400.f, absPos->getBoundingClientRect()->height()); | 682 EXPECT_FLOAT_EQ(400.f, absPos->getBoundingClientRect()->height()); |
| 683 EXPECT_FLOAT_EQ(400.f, fixedPos->getBoundingClientRect()->height()); | 683 EXPECT_FLOAT_EQ(400.f, fixedPos->getBoundingClientRect()->height()); |
| 684 | 684 |
| 685 // The size used for viewport units should not be reduced by the top | 685 // The size used for viewport units should not be reduced by the top |
| 686 // controls. | 686 // controls. |
| 687 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); | 687 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); |
| 688 | 688 |
| 689 // Hide the top controls. | 689 // Hide the top controls. |
| 690 verticalScroll(-100.f); | 690 verticalScroll(-100.f); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // that's 1600px wide so the minimum scale is 0.25 to encompass that. | 725 // that's 1600px wide so the minimum scale is 0.25 to encompass that. |
| 726 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor()); | 726 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor()); |
| 727 | 727 |
| 728 // The viewport will match the layout width at scale=0.5 so the height used | 728 // The viewport will match the layout width at scale=0.5 so the height used |
| 729 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top | 729 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top |
| 730 // controls = 800. | 730 // controls = 800. |
| 731 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); | 731 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); |
| 732 } | 732 } |
| 733 | 733 |
| 734 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |