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 1879 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) { | 3649 void WebViewImpl::ResizeFrameView(WebLocalFrameImpl* webframe) { |
3652 FrameView* view = webframe->GetFrame()->View(); | |
3653 if (webframe == MainFrame()) | 3650 if (webframe == MainFrame()) |
3654 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); | 3651 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); |
3655 else | |
3656 view->Resize(webframe->GetFrameView()->Size()); | |
3657 } | 3652 } |
3658 | 3653 |
3659 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { | 3654 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { |
3660 LocalFrame* frame = webframe->GetFrame(); | 3655 LocalFrame* frame = webframe->GetFrame(); |
3661 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3656 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) |
3662 return; | 3657 return; |
3663 | 3658 |
3664 if (should_auto_resize_) { | 3659 if (should_auto_resize_) { |
3665 WebSize frame_size = frame->View()->FrameRect().Size(); | 3660 WebSize frame_size = frame->View()->FrameRect().Size(); |
3666 if (frame_size != size_) { | 3661 if (frame_size != size_) { |
3667 size_ = frame_size; | 3662 size_ = frame_size; |
3668 | 3663 |
3669 GetPage()->GetVisualViewport().SetSize(size_); | 3664 GetPage()->GetVisualViewport().SetSize(size_); |
3670 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); | 3665 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); |
3671 frame->View()->SetInitialViewportSize(size_); | 3666 frame->View()->SetInitialViewportSize(size_); |
3672 | 3667 |
3673 client_->DidAutoResize(size_); | 3668 client_->DidAutoResize(size_); |
3674 SendResizeEventAndRepaint(); | 3669 SendResizeEventAndRepaint(); |
3675 } | 3670 } |
3676 } | 3671 } |
3677 | 3672 |
3678 if (GetPageScaleConstraintsSet().ConstraintsDirty()) | 3673 if (GetPageScaleConstraintsSet().ConstraintsDirty()) |
3679 RefreshPageScaleFactorAfterLayout(); | 3674 RefreshPageScaleFactorAfterLayout(); |
3680 | 3675 |
3681 ResizeFrameView(webframe); | 3676 ResizeFrameView(webframe); |
3682 } | 3677 } |
3683 | 3678 |
3684 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { | 3679 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { |
3685 LocalFrame* frame = webframe->GetFrame(); | 3680 LocalFrame* frame = webframe->GetFrame(); |
3686 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3681 if (!client_ || !frame->IsLocalRoot()) |
cbiesinger
2017/05/05 18:20:01
I don't understand this change?
You're still call
szager1
2017/05/08 16:27:06
I asked bokan and dcheng about this: IsMainFrame()
| |
3687 return; | 3682 return; |
3688 | |
3689 ResizeAfterLayout(webframe); | |
3690 | |
3691 // Relayout immediately to avoid violating the rule that needsLayout() | 3683 // Relayout immediately to avoid violating the rule that needsLayout() |
3692 // isn't set at the end of a layout. | 3684 // isn't set at the end of a layout. |
3693 FrameView* view = frame->View(); | 3685 FrameView* view = frame->View(); |
3694 if (view->NeedsLayout()) | 3686 if (view->NeedsLayout()) |
3695 view->UpdateLayout(); | 3687 view->UpdateLayout(); |
3696 | 3688 |
3697 UpdatePageOverlays(); | 3689 UpdatePageOverlays(); |
3698 | 3690 |
3699 fullscreen_controller_->DidUpdateLayout(); | 3691 fullscreen_controller_->DidUpdateLayout(); |
3700 client_->DidUpdateLayout(); | 3692 client_->DidUpdateLayout(); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4169 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) | 4161 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) |
4170 return nullptr; | 4162 return nullptr; |
4171 return focused_frame; | 4163 return focused_frame; |
4172 } | 4164 } |
4173 | 4165 |
4174 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { | 4166 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { |
4175 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; | 4167 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; |
4176 } | 4168 } |
4177 | 4169 |
4178 } // namespace blink | 4170 } // namespace blink |
OLD | NEW |