| 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 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 bool browser_controls_shrink_layout) { | 1898 bool browser_controls_shrink_layout) { |
| 1899 DCHECK(MainFrameImpl()); | 1899 DCHECK(MainFrameImpl()); |
| 1900 | 1900 |
| 1901 GetBrowserControls().SetHeight(browser_controls_height, | 1901 GetBrowserControls().SetHeight(browser_controls_height, |
| 1902 browser_controls_shrink_layout); | 1902 browser_controls_shrink_layout); |
| 1903 | 1903 |
| 1904 { | 1904 { |
| 1905 // Avoids unnecessary invalidations while various bits of state in | 1905 // Avoids unnecessary invalidations while various bits of state in |
| 1906 // TextAutosizer are updated. | 1906 // TextAutosizer are updated. |
| 1907 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); | 1907 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); |
| 1908 FrameView* frame_view = MainFrameImpl()->GetFrameView(); |
| 1909 IntRect old_rect = frame_view->FrameRect(); |
| 1908 UpdateICBAndResizeViewport(); | 1910 UpdateICBAndResizeViewport(); |
| 1911 IntRect new_rect = frame_view->FrameRect(); |
| 1912 frame_view->MarkViewportConstrainedObjectsForLayout( |
| 1913 old_rect.Width() != new_rect.Width(), |
| 1914 old_rect.Height() != new_rect.Height()); |
| 1909 } | 1915 } |
| 1910 | 1916 |
| 1911 fullscreen_controller_->UpdateSize(); | 1917 fullscreen_controller_->UpdateSize(); |
| 1912 | 1918 |
| 1913 // Update lifecyle phases immediately to recalculate the minimum scale limit | 1919 // Update lifecyle phases immediately to recalculate the minimum scale limit |
| 1914 // for rotation anchoring, and to make sure that no lifecycle states are | 1920 // for rotation anchoring, and to make sure that no lifecycle states are |
| 1915 // stale if this WebView is embedded in another one. | 1921 // stale if this WebView is embedded in another one. |
| 1916 UpdateAllLifecyclePhases(); | 1922 UpdateAllLifecyclePhases(); |
| 1917 } | 1923 } |
| 1918 | 1924 |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3159 float new_page_scale_factor = PageScaleFactor(); | 3165 float new_page_scale_factor = PageScaleFactor(); |
| 3160 if (GetPageScaleConstraintsSet().NeedsReset() && | 3166 if (GetPageScaleConstraintsSet().NeedsReset() && |
| 3161 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) { | 3167 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) { |
| 3162 new_page_scale_factor = | 3168 new_page_scale_factor = |
| 3163 GetPageScaleConstraintsSet().FinalConstraints().initial_scale; | 3169 GetPageScaleConstraintsSet().FinalConstraints().initial_scale; |
| 3164 GetPageScaleConstraintsSet().SetNeedsReset(false); | 3170 GetPageScaleConstraintsSet().SetNeedsReset(false); |
| 3165 } | 3171 } |
| 3166 SetPageScaleFactor(new_page_scale_factor); | 3172 SetPageScaleFactor(new_page_scale_factor); |
| 3167 | 3173 |
| 3168 UpdateLayerTreeViewport(); | 3174 UpdateLayerTreeViewport(); |
| 3169 | |
| 3170 // Changes to page-scale during layout may require an additional frame. | |
| 3171 // We can't update the lifecycle here because we may be in the middle of | |
| 3172 // layout in the caller of this method. | |
| 3173 // TODO(chrishtr): clean all this up. All layout should happen in one | |
| 3174 // lifecycle run (crbug.com/578239). | |
| 3175 if (MainFrameImpl()->GetFrameView()->NeedsLayout()) | |
| 3176 MainFrameImpl()->FrameWidget()->ScheduleAnimation(); | |
| 3177 } | 3175 } |
| 3178 | 3176 |
| 3179 void WebViewImpl::UpdatePageDefinedViewportConstraints( | 3177 void WebViewImpl::UpdatePageDefinedViewportConstraints( |
| 3180 const ViewportDescription& description) { | 3178 const ViewportDescription& description) { |
| 3181 if (!GetPage() || (!size_.width && !size_.height) || | 3179 if (!GetPage() || (!size_.width && !size_.height) || |
| 3182 !GetPage()->MainFrame()->IsLocalFrame()) | 3180 !GetPage()->MainFrame()->IsLocalFrame()) |
| 3183 return; | 3181 return; |
| 3184 | 3182 |
| 3185 if (!GetSettings()->ViewportEnabled()) { | 3183 if (!GetSettings()->ViewportEnabled()) { |
| 3186 GetPageScaleConstraintsSet().ClearPageDefinedConstraints(); | 3184 GetPageScaleConstraintsSet().ClearPageDefinedConstraints(); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3655 | 3653 |
| 3656 // Give the visual viewport's scroll layer its initial size. | 3654 // Give the visual viewport's scroll layer its initial size. |
| 3657 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); | 3655 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); |
| 3658 | 3656 |
| 3659 // Make sure link highlight from previous page is cleared. | 3657 // Make sure link highlight from previous page is cleared. |
| 3660 link_highlights_.clear(); | 3658 link_highlights_.clear(); |
| 3661 EndActiveFlingAnimation(); | 3659 EndActiveFlingAnimation(); |
| 3662 } | 3660 } |
| 3663 | 3661 |
| 3664 void WebViewImpl::ResizeFrameView(WebLocalFrameImpl* webframe) { | 3662 void WebViewImpl::ResizeFrameView(WebLocalFrameImpl* webframe) { |
| 3665 FrameView* view = webframe->GetFrame()->View(); | |
| 3666 if (webframe == MainFrame()) | 3663 if (webframe == MainFrame()) |
| 3667 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); | 3664 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); |
| 3668 else | |
| 3669 view->Resize(webframe->GetFrameView()->Size()); | |
| 3670 } | 3665 } |
| 3671 | 3666 |
| 3672 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { | 3667 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) { |
| 3673 LocalFrame* frame = webframe->GetFrame(); | 3668 LocalFrame* frame = webframe->GetFrame(); |
| 3674 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3669 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) |
| 3675 return; | 3670 return; |
| 3676 | 3671 |
| 3677 if (should_auto_resize_) { | 3672 if (should_auto_resize_) { |
| 3678 WebSize frame_size = frame->View()->FrameRect().Size(); | 3673 WebSize frame_size = frame->View()->FrameRect().Size(); |
| 3679 if (frame_size != size_) { | 3674 if (frame_size != size_) { |
| 3680 size_ = frame_size; | 3675 size_ = frame_size; |
| 3681 | 3676 |
| 3682 GetPage()->GetVisualViewport().SetSize(size_); | 3677 GetPage()->GetVisualViewport().SetSize(size_); |
| 3683 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); | 3678 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); |
| 3684 frame->View()->SetInitialViewportSize(size_); | 3679 frame->View()->SetInitialViewportSize(size_); |
| 3685 | 3680 |
| 3686 client_->DidAutoResize(size_); | 3681 client_->DidAutoResize(size_); |
| 3687 SendResizeEventAndRepaint(); | 3682 SendResizeEventAndRepaint(); |
| 3688 } | 3683 } |
| 3689 } | 3684 } |
| 3690 | 3685 |
| 3691 if (GetPageScaleConstraintsSet().ConstraintsDirty()) | 3686 if (GetPageScaleConstraintsSet().ConstraintsDirty()) |
| 3692 RefreshPageScaleFactorAfterLayout(); | 3687 RefreshPageScaleFactorAfterLayout(); |
| 3693 | 3688 |
| 3694 UpdateICBAndResizeViewport(); | 3689 ResizeFrameView(webframe); |
| 3695 } | 3690 } |
| 3696 | 3691 |
| 3697 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { | 3692 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { |
| 3698 LocalFrame* frame = webframe->GetFrame(); | 3693 LocalFrame* frame = webframe->GetFrame(); |
| 3699 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) | 3694 if (!client_ || !frame->IsLocalRoot()) |
| 3700 return; | 3695 return; |
| 3701 | |
| 3702 ResizeAfterLayout(webframe); | |
| 3703 | |
| 3704 // Relayout immediately to avoid violating the rule that needsLayout() | 3696 // Relayout immediately to avoid violating the rule that needsLayout() |
| 3705 // isn't set at the end of a layout. | 3697 // isn't set at the end of a layout. |
| 3706 FrameView* view = frame->View(); | 3698 FrameView* view = frame->View(); |
| 3707 if (view->NeedsLayout()) | 3699 if (view->NeedsLayout()) |
| 3708 view->UpdateLayout(); | 3700 view->UpdateLayout(); |
| 3709 | 3701 |
| 3710 UpdatePageOverlays(); | 3702 UpdatePageOverlays(); |
| 3711 | 3703 |
| 3712 fullscreen_controller_->DidUpdateLayout(); | 3704 fullscreen_controller_->DidUpdateLayout(); |
| 3713 client_->DidUpdateLayout(); | 3705 client_->DidUpdateLayout(); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4180 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) | 4172 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) |
| 4181 return nullptr; | 4173 return nullptr; |
| 4182 return focused_frame; | 4174 return focused_frame; |
| 4183 } | 4175 } |
| 4184 | 4176 |
| 4185 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { | 4177 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { |
| 4186 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; | 4178 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; |
| 4187 } | 4179 } |
| 4188 | 4180 |
| 4189 } // namespace blink | 4181 } // namespace blink |
| OLD | NEW |