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

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2860433002: Update WebView/FrameView size from LayoutView::UpdateAfterLayout (Closed)
Patch Set: s/IsLocalRoot/IsMainFrame/ 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index ae3818d3c8d36c02f6bc7066a16ebf685155cf5d..094c7f96ad2ce150e1c5150028e3aab1468a8d90 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -556,12 +556,7 @@ void FrameView::SetFrameRect(const IntRect& frame_rect) {
const bool height_changed = frame_rect_.Height() != frame_rect.Height();
frame_rect_ = frame_rect;
- needs_scrollbars_update_ = width_changed || height_changed;
- // TODO(wjmaclean): find out why scrollbars fail to resize for complex
- // subframes after changing the zoom level. For now always calling
- // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to
- // discover the deeper cause of this. http://crbug.com/607987.
- UpdateScrollbarsIfNeeded();
+ needs_scrollbars_update_ |= width_changed || height_changed;
FrameRectsChanged();
@@ -712,15 +707,13 @@ void FrameView::SetContentsSize(const IntSize& size) {
return;
contents_size_ = size;
- UpdateScrollbars();
+ needs_scrollbars_update_ = true;
ScrollableArea::ContentsResized();
Page* page = GetFrame().GetPage();
if (!page)
return;
- UpdateParentScrollableAreaSet();
-
page->GetChromeClient().ContentsSizeChanged(frame_.Get(), size);
// Ensure the scrollToFragmentAnchor is called before
@@ -743,14 +736,8 @@ void FrameView::AdjustViewSize() {
const IntSize& size = rect.Size();
const IntPoint origin(-rect.X(), -rect.Y());
- if (ScrollOrigin() != origin) {
+ if (ScrollOrigin() != origin)
SetScrollOrigin(origin);
- // setContentSize (below) also calls updateScrollbars so we can avoid
- // updating scrollbars twice by skipping the call here when the content
- // size does not change.
- if (!frame_->GetDocument()->Printing() && size == ContentsSize())
- UpdateScrollbars();
- }
SetContentsSize(size);
}
@@ -887,6 +874,7 @@ void FrameView::RecalcOverflowAfterStyleChange() {
AdjustViewSize();
UpdateScrollbarGeometry();
+ SetNeedsPaintPropertyUpdate();
if (ScrollOriginChanged())
SetNeedsLayout();
@@ -1310,10 +1298,25 @@ void FrameView::UpdateLayout() {
TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree",
this, TracedLayoutObject::Create(*GetLayoutView(), false));
+ IntSize old_size(Size());
+
PerformLayout(in_subtree_layout);
+ UpdateScrollbars();
+ UpdateParentScrollableAreaSet();
- if (!in_subtree_layout && !document->Printing())
- AdjustViewSizeAndLayout();
+ IntSize new_size(Size());
+ if (old_size != new_size) {
+ needs_scrollbars_update_ = true;
+ SetNeedsLayout();
+ MarkViewportConstrainedObjectsForLayout(
+ old_size.Width() != new_size.Width(),
+ old_size.Height() != new_size.Height());
+ }
+
+ if (NeedsLayout()) {
+ AutoReset<bool> suppress(&suppress_adjust_view_size_, true);
+ UpdateLayout();
+ }
DCHECK(layout_subtree_root_list_.IsEmpty());
} // Reset m_layoutSchedulingEnabled to its previous value.
@@ -1659,32 +1662,32 @@ void FrameView::ViewportSizeChanged(bool width_changed, bool height_changed) {
bool root_layer_scrolling_enabled =
RuntimeEnabledFeatures::rootLayerScrollingEnabled();
- if (LayoutViewItem layout_view = this->GetLayoutViewItem()) {
- if (layout_view.UsesCompositing()) {
+ if (LayoutView* layout_view = this->GetLayoutView()) {
+ // If this is the main frame, we might have got here by hiding/showing the
+ // top controls. In that case, layout won't be triggered, so we need to
+ // clamp the scroll offset here.
+ if (GetFrame().IsMainFrame()) {
if (root_layer_scrolling_enabled) {
- layout_view.Layer()->SetNeedsCompositingInputsUpdate();
+ layout_view->GetScrollableArea()
+ ->ClampScrollOffsetAfterOverflowChange();
+ } else {
+ AdjustScrollOffsetFromUpdateScrollbars();
+ }
+ }
+
+ if (layout_view->UsesCompositing()) {
+ if (root_layer_scrolling_enabled) {
+ layout_view->Layer()->SetNeedsCompositingInputsUpdate();
if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
SetNeedsPaintPropertyUpdate();
} else {
- layout_view.Compositor()->FrameViewDidChangeSize();
+ layout_view->Compositor()->FrameViewDidChangeSize();
}
}
}
ShowOverlayScrollbars();
- if (root_layer_scrolling_enabled) {
- // The background must be repainted when the FrameView is resized, even if
- // the initial containing block does not change (so we can't rely on layout
- // to issue the invalidation). This is because the background fills the
- // main GraphicsLayer, which takes the size of the layout viewport.
- // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents
- // layer and avoid this invalidation (http://crbug.com/568847).
- LayoutViewItem lvi = GetLayoutViewItem();
- if (!lvi.IsNull())
- lvi.SetShouldDoFullPaintInvalidation();
- }
-
if (RuntimeEnabledFeatures::inertTopControlsEnabled() && GetLayoutView() &&
frame_->IsMainFrame() &&
frame_->GetPage()->GetBrowserControls().Height()) {
@@ -1696,13 +1699,13 @@ void FrameView::ViewportSizeChanged(bool width_changed, bool height_changed) {
PaintLayer* layer = GetLayoutView()->Layer();
if (GetLayoutView()->Compositor()->NeedsFixedRootBackgroundLayer(layer)) {
SetNeedsLayout();
- } else if (!root_layer_scrolling_enabled) {
+ } else {
// If root layer scrolls is on, we've already issued a full invalidation
// above.
GetLayoutView()->SetShouldDoFullPaintInvalidationOnResizeIfNeeded(
width_changed, height_changed);
}
- } else if (height_changed && !root_layer_scrolling_enabled) {
+ } else if (height_changed) {
// If the document rect doesn't fill the full view height, hiding the
// URL bar will expose area outside the current LayoutView so we need to
// paint additional background. If RLS is on, we've already invalidated
@@ -2173,9 +2176,6 @@ void FrameView::ScrollbarExistenceDidChange() {
ScrollbarTheme::GetTheme().UsesOverlayScrollbars() &&
!ShouldUseCustomScrollbars(custom_scrollbar_element);
- // FIXME: this call to layout() could be called within FrameView::layout(),
- // but before performLayout(), causing double-layout. See also
- // crbug.com/429242.
if (!uses_overlay_scrollbars && NeedsLayout())
UpdateLayout();
@@ -3601,6 +3601,8 @@ void FrameView::ForceLayoutForPagination(const FloatSize& page_size,
}
}
+ if (TextAutosizer* text_autosizer = frame_->GetDocument()->GetTextAutosizer())
+ text_autosizer->UpdatePageInfo();
AdjustViewSizeAndLayout();
}
@@ -4314,7 +4316,7 @@ bool FrameView::AdjustScrollbarExistence(
return true;
if (!HasOverlayScrollbars())
- ContentsResized();
+ SetNeedsLayout();
ScrollbarExistenceDidChange();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698