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 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 | 1814 |
1815 UpdatePageDefinedViewportConstraints( | 1815 UpdatePageDefinedViewportConstraints( |
1816 MainFrameImpl()->GetFrame()->GetDocument()->GetViewportDescription()); | 1816 MainFrameImpl()->GetFrame()->GetDocument()->GetViewportDescription()); |
1817 UpdateMainFrameLayoutSize(); | 1817 UpdateMainFrameLayoutSize(); |
1818 | 1818 |
1819 GetPage()->GetVisualViewport().SetSize(size_); | 1819 GetPage()->GetVisualViewport().SetSize(size_); |
1820 | 1820 |
1821 if (MainFrameImpl()->GetFrameView()) { | 1821 if (MainFrameImpl()->GetFrameView()) { |
1822 MainFrameImpl()->GetFrameView()->SetInitialViewportSize(icb_size); | 1822 MainFrameImpl()->GetFrameView()->SetInitialViewportSize(icb_size); |
1823 if (!MainFrameImpl()->GetFrameView()->NeedsLayout()) | 1823 if (!MainFrameImpl()->GetFrameView()->NeedsLayout()) |
1824 ResizeFrameView(MainFrameImpl()); | 1824 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); |
1825 } | 1825 } |
1826 } | 1826 } |
1827 | 1827 |
1828 void WebViewImpl::UpdateBrowserControlsState(WebBrowserControlsState constraint, | 1828 void WebViewImpl::UpdateBrowserControlsState(WebBrowserControlsState constraint, |
1829 WebBrowserControlsState current, | 1829 WebBrowserControlsState current, |
1830 bool animate) { | 1830 bool animate) { |
1831 WebBrowserControlsState old_permitted_state = | 1831 WebBrowserControlsState old_permitted_state = |
1832 GetBrowserControls().PermittedState(); | 1832 GetBrowserControls().PermittedState(); |
1833 | 1833 |
1834 GetBrowserControls().UpdateConstraintsAndState(constraint, current, animate); | 1834 GetBrowserControls().UpdateConstraintsAndState(constraint, current, animate); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 bool browser_controls_shrink_layout) { | 1890 bool browser_controls_shrink_layout) { |
1891 DCHECK(MainFrameImpl()); | 1891 DCHECK(MainFrameImpl()); |
1892 | 1892 |
1893 GetBrowserControls().SetHeight(browser_controls_height, | 1893 GetBrowserControls().SetHeight(browser_controls_height, |
1894 browser_controls_shrink_layout); | 1894 browser_controls_shrink_layout); |
1895 | 1895 |
1896 { | 1896 { |
1897 // Avoids unnecessary invalidations while various bits of state in | 1897 // Avoids unnecessary invalidations while various bits of state in |
1898 // TextAutosizer are updated. | 1898 // TextAutosizer are updated. |
1899 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); | 1899 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); |
| 1900 FrameView* frame_view = MainFrameImpl()->GetFrameView(); |
| 1901 IntRect old_rect = frame_view->FrameRect(); |
1900 UpdateICBAndResizeViewport(); | 1902 UpdateICBAndResizeViewport(); |
| 1903 IntRect new_rect = frame_view->FrameRect(); |
| 1904 frame_view->MarkViewportConstrainedObjectsForLayout( |
| 1905 old_rect.Width() != new_rect.Width(), |
| 1906 old_rect.Height() != new_rect.Height()); |
1901 } | 1907 } |
1902 | 1908 |
1903 fullscreen_controller_->UpdateSize(); | 1909 fullscreen_controller_->UpdateSize(); |
1904 | 1910 |
1905 // Update lifecyle phases immediately to recalculate the minimum scale limit | 1911 // Update lifecyle phases immediately to recalculate the minimum scale limit |
1906 // for rotation anchoring, and to make sure that no lifecycle states are | 1912 // for rotation anchoring, and to make sure that no lifecycle states are |
1907 // stale if this WebView is embedded in another one. | 1913 // stale if this WebView is embedded in another one. |
1908 UpdateAllLifecyclePhases(); | 1914 UpdateAllLifecyclePhases(); |
1909 } | 1915 } |
1910 | 1916 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3146 float new_page_scale_factor = PageScaleFactor(); | 3152 float new_page_scale_factor = PageScaleFactor(); |
3147 if (GetPageScaleConstraintsSet().NeedsReset() && | 3153 if (GetPageScaleConstraintsSet().NeedsReset() && |
3148 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) { | 3154 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) { |
3149 new_page_scale_factor = | 3155 new_page_scale_factor = |
3150 GetPageScaleConstraintsSet().FinalConstraints().initial_scale; | 3156 GetPageScaleConstraintsSet().FinalConstraints().initial_scale; |
3151 GetPageScaleConstraintsSet().SetNeedsReset(false); | 3157 GetPageScaleConstraintsSet().SetNeedsReset(false); |
3152 } | 3158 } |
3153 SetPageScaleFactor(new_page_scale_factor); | 3159 SetPageScaleFactor(new_page_scale_factor); |
3154 | 3160 |
3155 UpdateLayerTreeViewport(); | 3161 UpdateLayerTreeViewport(); |
3156 | |
3157 // Changes to page-scale during layout may require an additional frame. | |
3158 // We can't update the lifecycle here because we may be in the middle of | |
3159 // layout in the caller of this method. | |
3160 // TODO(chrishtr): clean all this up. All layout should happen in one | |
3161 // lifecycle run (crbug.com/578239). | |
3162 if (MainFrameImpl()->GetFrameView()->NeedsLayout()) | |
3163 MainFrameImpl()->FrameWidget()->ScheduleAnimation(); | |
3164 } | 3162 } |
3165 | 3163 |
3166 void WebViewImpl::UpdatePageDefinedViewportConstraints( | 3164 void WebViewImpl::UpdatePageDefinedViewportConstraints( |
3167 const ViewportDescription& description) { | 3165 const ViewportDescription& description) { |
3168 if (!GetPage() || (!size_.width && !size_.height) || | 3166 if (!GetPage() || (!size_.width && !size_.height) || |
3169 !GetPage()->MainFrame()->IsLocalFrame()) | 3167 !GetPage()->MainFrame()->IsLocalFrame()) |
3170 return; | 3168 return; |
3171 | 3169 |
3172 if (!GetSettings()->ViewportEnabled()) { | 3170 if (!GetSettings()->ViewportEnabled()) { |
3173 GetPageScaleConstraintsSet().ClearPageDefinedConstraints(); | 3171 GetPageScaleConstraintsSet().ClearPageDefinedConstraints(); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 } | 3639 } |
3642 | 3640 |
3643 // Give the visual viewport's scroll layer its initial size. | 3641 // Give the visual viewport's scroll layer its initial size. |
3644 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); | 3642 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); |
3645 | 3643 |
3646 // Make sure link highlight from previous page is cleared. | 3644 // Make sure link highlight from previous page is cleared. |
3647 link_highlights_.clear(); | 3645 link_highlights_.clear(); |
3648 EndActiveFlingAnimation(); | 3646 EndActiveFlingAnimation(); |
3649 } | 3647 } |
3650 | 3648 |
3651 void WebViewImpl::ResizeFrameView(WebLocalFrameImpl* webframe) { | |
3652 FrameView* view = webframe->GetFrame()->View(); | |
3653 if (webframe == MainFrame()) | |
3654 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); | |
3655 else | |
3656 view->Resize(webframe->GetFrameView()->Size()); | |
3657 } | |
3658 | |
3659 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { | 3649 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { |
3660 LocalFrame* frame = webframe->GetFrame(); | 3650 LocalFrame* frame = webframe->GetFrame(); |
3661 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3651 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) |
3662 return; | 3652 return; |
3663 | 3653 |
3664 if (should_auto_resize_) { | 3654 if (should_auto_resize_) { |
3665 WebSize frame_size = frame->View()->FrameRect().Size(); | 3655 WebSize frame_size = frame->View()->FrameRect().Size(); |
3666 if (frame_size != size_) { | 3656 if (frame_size != size_) { |
3667 size_ = frame_size; | 3657 size_ = frame_size; |
3668 | 3658 |
3669 GetPage()->GetVisualViewport().SetSize(size_); | 3659 GetPage()->GetVisualViewport().SetSize(size_); |
3670 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); | 3660 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); |
3671 frame->View()->SetInitialViewportSize(size_); | 3661 frame->View()->SetInitialViewportSize(size_); |
3672 | 3662 |
3673 client_->DidAutoResize(size_); | 3663 client_->DidAutoResize(size_); |
3674 SendResizeEventAndRepaint(); | 3664 SendResizeEventAndRepaint(); |
3675 } | 3665 } |
3676 } | 3666 } |
3677 | 3667 |
3678 if (GetPageScaleConstraintsSet().ConstraintsDirty()) | 3668 if (GetPageScaleConstraintsSet().ConstraintsDirty()) |
3679 RefreshPageScaleFactorAfterLayout(); | 3669 RefreshPageScaleFactorAfterLayout(); |
3680 | 3670 |
3681 ResizeFrameView(webframe); | 3671 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); |
3682 } | 3672 } |
3683 | 3673 |
3684 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { | 3674 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { |
3685 LocalFrame* frame = webframe->GetFrame(); | 3675 LocalFrame* frame = webframe->GetFrame(); |
3686 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3676 if (!client_ || !frame->IsMainFrame()) |
3687 return; | 3677 return; |
3688 | 3678 |
3689 ResizeAfterLayout(webframe); | |
3690 | |
3691 // Relayout immediately to avoid violating the rule that needsLayout() | |
3692 // isn't set at the end of a layout. | |
3693 FrameView* view = frame->View(); | |
3694 if (view->NeedsLayout()) | |
3695 view->UpdateLayout(); | |
3696 | |
3697 UpdatePageOverlays(); | 3679 UpdatePageOverlays(); |
3698 | 3680 |
3699 fullscreen_controller_->DidUpdateLayout(); | 3681 fullscreen_controller_->DidUpdateLayout(); |
3700 client_->DidUpdateLayout(); | 3682 client_->DidUpdateLayout(); |
3701 } | 3683 } |
3702 | 3684 |
3703 void WebViewImpl::DidChangeContentsSize() { | 3685 void WebViewImpl::DidChangeContentsSize() { |
3704 GetPageScaleConstraintsSet().DidChangeContentsSize(ContentsSize(), | 3686 GetPageScaleConstraintsSet().DidChangeContentsSize(ContentsSize(), |
3705 PageScaleFactor()); | 3687 PageScaleFactor()); |
3706 } | 3688 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4169 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) | 4151 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) |
4170 return nullptr; | 4152 return nullptr; |
4171 return focused_frame; | 4153 return focused_frame; |
4172 } | 4154 } |
4173 | 4155 |
4174 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { | 4156 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { |
4175 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; | 4157 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; |
4176 } | 4158 } |
4177 | 4159 |
4178 } // namespace blink | 4160 } // namespace blink |
OLD | NEW |