Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2816873002: Update PaintLayer size during layout, not after.
Patch Set: Speculatively remove call to UpdateScrollbars() Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 bool browser_controls_shrink_layout) { 1886 bool browser_controls_shrink_layout) {
1887 DCHECK(MainFrameImpl()); 1887 DCHECK(MainFrameImpl());
1888 1888
1889 GetBrowserControls().SetHeight(browser_controls_height, 1889 GetBrowserControls().SetHeight(browser_controls_height,
1890 browser_controls_shrink_layout); 1890 browser_controls_shrink_layout);
1891 1891
1892 { 1892 {
1893 // Avoids unnecessary invalidations while various bits of state in 1893 // Avoids unnecessary invalidations while various bits of state in
1894 // TextAutosizer are updated. 1894 // TextAutosizer are updated.
1895 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage()); 1895 TextAutosizer::DeferUpdatePageInfo defer_update_page_info(GetPage());
1896 FrameView* frame_view = MainFrameImpl()->GetFrameView();
1897 IntRect old_rect = frame_view->FrameRect();
1896 PerformResize(); 1898 PerformResize();
1899 IntRect new_rect = frame_view->FrameRect();
1900 frame_view->MarkViewportConstrainedObjectsForLayout(
1901 old_rect.Width() != new_rect.Width(),
1902 old_rect.Height() != new_rect.Height());
1897 } 1903 }
1898 1904
1899 fullscreen_controller_->UpdateSize(); 1905 fullscreen_controller_->UpdateSize();
1900 1906
1901 // Update lifecyle phases immediately to recalculate the minimum scale limit 1907 // Update lifecyle phases immediately to recalculate the minimum scale limit
1902 // for rotation anchoring, and to make sure that no lifecycle states are 1908 // for rotation anchoring, and to make sure that no lifecycle states are
1903 // stale if this WebView is embedded in another one. 1909 // stale if this WebView is embedded in another one.
1904 UpdateAllLifecyclePhases(); 1910 UpdateAllLifecyclePhases();
1905 } 1911 }
1906 1912
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 float new_page_scale_factor = PageScaleFactor(); 3153 float new_page_scale_factor = PageScaleFactor();
3148 if (GetPageScaleConstraintsSet().NeedsReset() && 3154 if (GetPageScaleConstraintsSet().NeedsReset() &&
3149 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) { 3155 GetPageScaleConstraintsSet().FinalConstraints().initial_scale != -1) {
3150 new_page_scale_factor = 3156 new_page_scale_factor =
3151 GetPageScaleConstraintsSet().FinalConstraints().initial_scale; 3157 GetPageScaleConstraintsSet().FinalConstraints().initial_scale;
3152 GetPageScaleConstraintsSet().SetNeedsReset(false); 3158 GetPageScaleConstraintsSet().SetNeedsReset(false);
3153 } 3159 }
3154 SetPageScaleFactor(new_page_scale_factor); 3160 SetPageScaleFactor(new_page_scale_factor);
3155 3161
3156 UpdateLayerTreeViewport(); 3162 UpdateLayerTreeViewport();
3157
3158 // Changes to page-scale during layout may require an additional frame.
3159 // We can't update the lifecycle here because we may be in the middle of
3160 // layout in the caller of this method.
3161 // TODO(chrishtr): clean all this up. All layout should happen in one
3162 // lifecycle run (crbug.com/578239).
3163 if (MainFrameImpl()->GetFrameView()->NeedsLayout())
3164 MainFrameImpl()->FrameWidget()->ScheduleAnimation();
3165 } 3163 }
3166 3164
3167 void WebViewImpl::UpdatePageDefinedViewportConstraints( 3165 void WebViewImpl::UpdatePageDefinedViewportConstraints(
3168 const ViewportDescription& description) { 3166 const ViewportDescription& description) {
3169 if (!GetPage() || (!size_.width && !size_.height) || 3167 if (!GetPage() || (!size_.width && !size_.height) ||
3170 !GetPage()->MainFrame()->IsLocalFrame()) 3168 !GetPage()->MainFrame()->IsLocalFrame())
3171 return; 3169 return;
3172 3170
3173 if (!GetSettings()->ViewportEnabled()) { 3171 if (!GetSettings()->ViewportEnabled()) {
3174 GetPageScaleConstraintsSet().ClearPageDefinedConstraints(); 3172 GetPageScaleConstraintsSet().ClearPageDefinedConstraints();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 3641
3644 // Give the visual viewport's scroll layer its initial size. 3642 // Give the visual viewport's scroll layer its initial size.
3645 GetPage()->GetVisualViewport().MainFrameDidChangeSize(); 3643 GetPage()->GetVisualViewport().MainFrameDidChangeSize();
3646 3644
3647 // Make sure link highlight from previous page is cleared. 3645 // Make sure link highlight from previous page is cleared.
3648 link_highlights_.clear(); 3646 link_highlights_.clear();
3649 EndActiveFlingAnimation(); 3647 EndActiveFlingAnimation();
3650 } 3648 }
3651 3649
3652 void WebViewImpl::PostLayoutResize(WebLocalFrameImpl* webframe) { 3650 void WebViewImpl::PostLayoutResize(WebLocalFrameImpl* webframe) {
3653 FrameView* view = webframe->GetFrame()->View();
3654 if (webframe == MainFrame()) 3651 if (webframe == MainFrame())
3655 resize_viewport_anchor_->ResizeFrameView(MainFrameSize()); 3652 resize_viewport_anchor_->ResizeFrameView(MainFrameSize());
3656 else
3657 view->Resize(webframe->GetFrameView()->Size());
3658 } 3653 }
3659 3654
3660 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) { 3655 void WebViewImpl::ResizeAfterLayout(WebLocalFrameImpl* webframe) {
3661 LocalFrame* frame = webframe->GetFrame(); 3656 LocalFrame* frame = webframe->GetFrame();
3662 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame()) 3657 if (!client_ || !client_->CanUpdateLayout() || !frame->IsMainFrame())
3663 return; 3658 return;
3664 3659
3665 if (should_auto_resize_) { 3660 if (should_auto_resize_) {
3666 WebSize frame_size = frame->View()->FrameRect().Size(); 3661 WebSize frame_size = frame->View()->FrameRect().Size();
3667 if (frame_size != size_) { 3662 if (frame_size != size_) {
3668 size_ = frame_size; 3663 size_ = frame_size;
3669 3664
3670 GetPage()->GetVisualViewport().SetSize(size_); 3665 GetPage()->GetVisualViewport().SetSize(size_);
3671 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_); 3666 GetPageScaleConstraintsSet().DidChangeInitialContainingBlockSize(size_);
3672 frame->View()->SetInitialViewportSize(size_); 3667 frame->View()->SetInitialViewportSize(size_);
3673 3668
3674 client_->DidAutoResize(size_); 3669 client_->DidAutoResize(size_);
3675 SendResizeEventAndRepaint(); 3670 SendResizeEventAndRepaint();
3676 } 3671 }
3677 } 3672 }
3678 3673
3679 if (GetPageScaleConstraintsSet().ConstraintsDirty()) 3674 if (GetPageScaleConstraintsSet().ConstraintsDirty())
3680 RefreshPageScaleFactorAfterLayout(); 3675 RefreshPageScaleFactorAfterLayout();
3681 3676
3682 FrameView* view = webframe->GetFrame()->View(); 3677 PostLayoutResize(webframe);
3678 }
3683 3679
3684 PostLayoutResize(webframe); 3680 void WebViewImpl::LayoutUpdated(WebLocalFrameImpl* webframe) {
3685 3681 LocalFrame* frame = webframe->GetFrame();
3682 if (!client_ || !frame->IsLocalRoot())
3683 return;
3686 // Relayout immediately to avoid violating the rule that needsLayout() 3684 // Relayout immediately to avoid violating the rule that needsLayout()
3687 // isn't set at the end of a layout. 3685 // isn't set at the end of a layout.
3686 FrameView* view = webframe->GetFrame()->View();
3688 if (view->NeedsLayout()) 3687 if (view->NeedsLayout())
3689 view->UpdateLayout(); 3688 view->UpdateLayout();
3690 3689
3691 UpdatePageOverlays(); 3690 UpdatePageOverlays();
3692 3691
3693 fullscreen_controller_->DidUpdateLayout(); 3692 fullscreen_controller_->DidUpdateLayout();
3694 client_->DidUpdateLayout(); 3693 client_->DidUpdateLayout();
3695 } 3694 }
3696 3695
3697 void WebViewImpl::DidChangeContentsSize() { 3696 void WebViewImpl::DidChangeContentsSize() {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4157 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) 4156 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame())
4158 return nullptr; 4157 return nullptr;
4159 return focused_frame; 4158 return focused_frame;
4160 } 4159 }
4161 4160
4162 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { 4161 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const {
4163 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; 4162 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr;
4164 } 4163 }
4165 4164
4166 } // namespace blink 4165 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698