| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 | 1797 |
| 1798 WebSize WebViewImpl::Size() { | 1798 WebSize WebViewImpl::Size() { |
| 1799 return size_; | 1799 return size_; |
| 1800 } | 1800 } |
| 1801 | 1801 |
| 1802 void WebViewImpl::ResizeVisualViewport(const WebSize& new_size) { | 1802 void WebViewImpl::ResizeVisualViewport(const WebSize& new_size) { |
| 1803 GetPage()->GetVisualViewport().SetSize(new_size); | 1803 GetPage()->GetVisualViewport().SetSize(new_size); |
| 1804 GetPage()->GetVisualViewport().ClampToBoundaries(); | 1804 GetPage()->GetVisualViewport().ClampToBoundaries(); |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 void WebViewImpl::PerformResize() { | 1807 void WebViewImpl::UpdateICBAndResizeViewport() { |
| 1808 // We'll keep the initial containing block size from changing when the top | 1808 // We'll keep the initial containing block size from changing when the top |
| 1809 // controls hide so that the ICB will always be the same size as the | 1809 // controls hide so that the ICB will always be the same size as the |
| 1810 // viewport with the browser controls shown. | 1810 // viewport with the browser controls shown. |
| 1811 IntSize icb_size = size_; | 1811 IntSize icb_size = size_; |
| 1812 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && | 1812 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && |
| 1813 GetBrowserControls().PermittedState() == kWebBrowserControlsBoth && | 1813 GetBrowserControls().PermittedState() == kWebBrowserControlsBoth && |
| 1814 !GetBrowserControls().ShrinkViewport()) | 1814 !GetBrowserControls().ShrinkViewport()) |
| 1815 icb_size.Expand(0, -GetBrowserControls().Height()); | 1815 icb_size.Expand(0, -GetBrowserControls().Height()); |
| 1816 | 1816 |
| 1817 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(icb_size); | 1817 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(icb_size); |
| 1818 | 1818 |
| 1819 UpdatePageDefinedViewportConstraints( | 1819 UpdatePageDefinedViewportConstraints( |
| 1820 MainFrameImpl()->GetFrame()->GetDocument()->GetViewportDescription()); | 1820 MainFrameImpl()->GetFrame()->GetDocument()->GetViewportDescription()); |
| 1821 UpdateMainFrameLayoutSize(); | 1821 UpdateMainFrameLayoutSize(); |
| 1822 | 1822 |
| 1823 GetPage()->GetVisualViewport().SetSize(size_); | 1823 GetPage()->GetVisualViewport().SetSize(size_); |
| 1824 | 1824 |
| 1825 if (MainFrameImpl()->GetFrameView()) { | 1825 if (MainFrameImpl()->GetFrameView()) { |
| 1826 MainFrameImpl()->GetFrameView()->SetInitialViewportSize(icb_size); | 1826 MainFrameImpl()->GetFrameView()->SetInitialViewportSize(icb_size); |
| 1827 if (!MainFrameImpl()->GetFrameView()->NeedsLayout()) | 1827 if (!MainFrameImpl()->GetFrameView()->NeedsLayout()) |
| 1828 PostLayoutResize(MainFrameImpl()); | 1828 ResizeFrameView(MainFrameImpl()); |
| 1829 } | 1829 } |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 void WebViewImpl::UpdateBrowserControlsState(WebBrowserControlsState constraint, | 1832 void WebViewImpl::UpdateBrowserControlsState(WebBrowserControlsState constraint, |
| 1833 WebBrowserControlsState current, | 1833 WebBrowserControlsState current, |
| 1834 bool animate) { | 1834 bool animate) { |
| 1835 WebBrowserControlsState old_permitted_state = | 1835 WebBrowserControlsState old_permitted_state = |
| 1836 GetBrowserControls().PermittedState(); | 1836 GetBrowserControls().PermittedState(); |
| 1837 | 1837 |
| 1838 GetBrowserControls().UpdateConstraintsAndState(constraint, current, animate); | 1838 GetBrowserControls().UpdateConstraintsAndState(constraint, current, animate); |
| 1839 | 1839 |
| 1840 // If the controls are going from a locked hidden to unlocked state, or vice | 1840 // If the controls are going from a locked hidden to unlocked state, or vice |
| 1841 // versa, the ICB size needs to change but we can't rely on getting a | 1841 // versa, the ICB size needs to change but we can't rely on getting a |
| 1842 // WebViewImpl::resize since the top controls shown state may not have | 1842 // WebViewImpl::resize since the top controls shown state may not have |
| 1843 // changed. | 1843 // changed. |
| 1844 if ((old_permitted_state == kWebBrowserControlsHidden && | 1844 if ((old_permitted_state == kWebBrowserControlsHidden && |
| 1845 constraint == kWebBrowserControlsBoth) || | 1845 constraint == kWebBrowserControlsBoth) || |
| 1846 (old_permitted_state == kWebBrowserControlsBoth && | 1846 (old_permitted_state == kWebBrowserControlsBoth && |
| 1847 constraint == kWebBrowserControlsHidden)) { | 1847 constraint == kWebBrowserControlsHidden)) { |
| 1848 PerformResize(); | 1848 UpdateICBAndResizeViewport(); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 if (layer_tree_view_) | 1851 if (layer_tree_view_) |
| 1852 layer_tree_view_->UpdateBrowserControlsState(constraint, current, animate); | 1852 layer_tree_view_->UpdateBrowserControlsState(constraint, current, animate); |
| 1853 } | 1853 } |
| 1854 | 1854 |
| 1855 void WebViewImpl::DidUpdateBrowserControls() { | 1855 void WebViewImpl::DidUpdateBrowserControls() { |
| 1856 if (layer_tree_view_) { | 1856 if (layer_tree_view_) { |
| 1857 layer_tree_view_->SetBrowserControlsShownRatio( | 1857 layer_tree_view_->SetBrowserControlsShownRatio( |
| 1858 GetBrowserControls().ShownRatio()); | 1858 GetBrowserControls().ShownRatio()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 bool browser_controls_shrink_layout) { | 1894 bool browser_controls_shrink_layout) { |
| 1895 DCHECK(MainFrameImpl()); | 1895 DCHECK(MainFrameImpl()); |
| 1896 | 1896 |
| 1897 GetBrowserControls().SetHeight(browser_controls_height, | 1897 GetBrowserControls().SetHeight(browser_controls_height, |
| 1898 browser_controls_shrink_layout); | 1898 browser_controls_shrink_layout); |
| 1899 | 1899 |
| 1900 { | 1900 { |
| 1901 // Avoids unnecessary invalidations while various bits of state in | 1901 // Avoids unnecessary invalidations while various bits of state in |
| 1902 // TextAutosizer are updated. | 1902 // TextAutosizer are updated. |
| 1903 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); | 1903 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); |
| 1904 PerformResize(); | 1904 UpdateICBAndResizeViewport(); |
| 1905 } | 1905 } |
| 1906 | 1906 |
| 1907 fullscreen_controller_->UpdateSize(); | 1907 fullscreen_controller_->UpdateSize(); |
| 1908 | 1908 |
| 1909 // Update lifecyle phases immediately to recalculate the minimum scale limit | 1909 // Update lifecyle phases immediately to recalculate the minimum scale limit |
| 1910 // for rotation anchoring, and to make sure that no lifecycle states are | 1910 // for rotation anchoring, and to make sure that no lifecycle states are |
| 1911 // stale if this WebView is embedded in another one. | 1911 // stale if this WebView is embedded in another one. |
| 1912 UpdateAllLifecyclePhases(); | 1912 UpdateAllLifecyclePhases(); |
| 1913 } | 1913 } |
| 1914 | 1914 |
| (...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3650 } | 3650 } |
| 3651 | 3651 |
| 3652 // Give the visual viewport's scroll layer its initial size. | 3652 // Give the visual viewport's scroll layer its initial size. |
| 3653 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); | 3653 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); |
| 3654 | 3654 |
| 3655 // Make sure link highlight from previous page is cleared. | 3655 // Make sure link highlight from previous page is cleared. |
| 3656 link_highlights_.clear(); | 3656 link_highlights_.clear(); |
| 3657 EndActiveFlingAnimation(); | 3657 EndActiveFlingAnimation(); |
| 3658 } | 3658 } |
| 3659 | 3659 |
| 3660 void WebViewImpl::PostLayoutResize(WebLocalFrameImpl* webframe) { | 3660 void WebViewImpl::ResizeFrameView(WebLocalFrameImpl* webframe) { |
| 3661 FrameView* view = webframe->GetFrame()->View(); | 3661 FrameView* view = webframe->GetFrame()->View(); |
| 3662 if (webframe == MainFrame()) | 3662 if (webframe == MainFrame()) |
| 3663 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); | 3663 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); |
| 3664 else | 3664 else |
| 3665 view->Resize(webframe->GetFrameView()->Size()); | 3665 view->Resize(webframe->GetFrameView()->Size()); |
| 3666 } | 3666 } |
| 3667 | 3667 |
| 3668 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { | 3668 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { |
| 3669 LocalFrame* frame = webframe->GetFrame(); | 3669 LocalFrame* frame = webframe->GetFrame(); |
| 3670 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3670 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) |
| 3671 return; | 3671 return; |
| 3672 | 3672 |
| 3673 if (should_auto_resize_) { | 3673 if (should_auto_resize_) { |
| 3674 WebSize frame_size = frame->View()->FrameRect().Size(); | 3674 WebSize frame_size = frame->View()->FrameRect().Size(); |
| 3675 if (frame_size != size_) { | 3675 if (frame_size != size_) { |
| 3676 size_ = frame_size; | 3676 size_ = frame_size; |
| 3677 | 3677 |
| 3678 GetPage()->GetVisualViewport().SetSize(size_); | 3678 GetPage()->GetVisualViewport().SetSize(size_); |
| 3679 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); | 3679 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); |
| 3680 frame->View()->SetInitialViewportSize(size_); | 3680 frame->View()->SetInitialViewportSize(size_); |
| 3681 | 3681 |
| 3682 client_->DidAutoResize(size_); | 3682 client_->DidAutoResize(size_); |
| 3683 SendResizeEventAndRepaint(); | 3683 SendResizeEventAndRepaint(); |
| 3684 } | 3684 } |
| 3685 } | 3685 } |
| 3686 | 3686 |
| 3687 if (GetPageScaleConstraintsSet().ConstraintsDirty()) | 3687 if (GetPageScaleConstraintsSet().ConstraintsDirty()) |
| 3688 RefreshPageScaleFactorAfterLayout(); | 3688 RefreshPageScaleFactorAfterLayout(); |
| 3689 | 3689 |
| 3690 FrameView* view = webframe->GetFrame()->View(); | 3690 UpdateICBAndResizeViewport(); |
| 3691 } |
| 3691 | 3692 |
| 3692 PostLayoutResize(webframe); | 3693 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { |
| 3694 LocalFrame* frame = webframe->GetFrame(); |
| 3695 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) |
| 3696 return; |
| 3697 |
| 3698 ResizeAfterLayout(webframe); |
| 3693 | 3699 |
| 3694 // Relayout immediately to avoid violating the rule that needsLayout() | 3700 // Relayout immediately to avoid violating the rule that needsLayout() |
| 3695 // isn't set at the end of a layout. | 3701 // isn't set at the end of a layout. |
| 3702 FrameView* view = frame->View(); |
| 3696 if (view->NeedsLayout()) | 3703 if (view->NeedsLayout()) |
| 3697 view->UpdateLayout(); | 3704 view->UpdateLayout(); |
| 3698 | 3705 |
| 3699 UpdatePageOverlays(); | 3706 UpdatePageOverlays(); |
| 3700 | 3707 |
| 3701 fullscreen_controller_->DidUpdateLayout(); | 3708 fullscreen_controller_->DidUpdateLayout(); |
| 3702 client_->DidUpdateLayout(); | 3709 client_->DidUpdateLayout(); |
| 3703 } | 3710 } |
| 3704 | 3711 |
| 3705 void WebViewImpl::DidChangeContentsSize() { | 3712 void WebViewImpl::DidChangeContentsSize() { |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4165 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) | 4172 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) |
| 4166 return nullptr; | 4173 return nullptr; |
| 4167 return focused_frame; | 4174 return focused_frame; |
| 4168 } | 4175 } |
| 4169 | 4176 |
| 4170 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { | 4177 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { |
| 4171 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; | 4178 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; |
| 4172 } | 4179 } |
| 4173 | 4180 |
| 4174 } // namespace blink | 4181 } // namespace blink |
| OLD | NEW |