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