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

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

Issue 2816873002: Update PaintLayer size during layout, not after.
Patch Set: s/UpdateICBAndViewportSize/ResizeFrameView/ Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 542638cc60e7f3ee01de268029f41c582d0ef704..b0eedfba2bb662687d7e770e13ff5d2094654d90 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -547,26 +547,36 @@ void FrameView::InvalidateRect(const IntRect& rect) {
}
void FrameView::SetFrameRect(const IntRect& frame_rect) {
- if (frame_rect == frame_rect_)
+ bool root_layer_scrolls = RuntimeEnabledFeatures::rootLayerScrollingEnabled();
+ IntRect old_rect = FrameRect();
+ if (frame_rect == old_rect)
return;
const bool width_changed = frame_rect_.Width() != frame_rect.Width();
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_ |= old_rect.Size() != frame_rect.Size();
+
+ // If this is not the main frame, then we got here via
+ // LayoutPart::UpdateGeometryInternal. In that case, we can't clamp the
+ // scroll offset yet, because we still need to run UpdateLayout(), so our
+ // clamping boundaries may yet change.
+ if (GetFrame().IsMainFrame()) {
+ if (root_layer_scrolls) {
+ if (LayoutView* lv = GetLayoutView())
+ lv->GetScrollableArea()->ClampScrollOffsetAfterOverflowChange();
+ } else {
+ AdjustScrollOffsetFromUpdateScrollbars();
+ }
+ }
FrameRectsChanged();
UpdateParentScrollableAreaSet();
if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
- !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
+ !root_layer_scrolls) {
// The overflow clip property depends on the frame size and the pre
// translation property depends on the frame location.
SetNeedsPaintPropertyUpdate();
@@ -710,15 +720,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
@@ -742,12 +750,7 @@ void FrameView::AdjustViewSize() {
const IntPoint origin(-rect.X(), -rect.Y());
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();
+ ScrollableArea::SetScrollOrigin(origin);
}
SetContentsSize(size);
@@ -885,6 +888,7 @@ void FrameView::RecalcOverflowAfterStyleChange() {
AdjustViewSize();
UpdateScrollbarGeometry();
+ SetNeedsPaintPropertyUpdate();
if (ScrollOriginChanged())
SetNeedsLayout();
@@ -1308,10 +1312,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();
+ }
ASSERT(layout_subtree_root_list_.IsEmpty());
} // Reset m_layoutSchedulingEnabled to its previous value.
@@ -1671,18 +1690,6 @@ void FrameView::ViewportSizeChanged(bool width_changed, bool height_changed) {
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()) {
@@ -1694,13 +1701,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
@@ -2171,9 +2178,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();
@@ -3604,6 +3608,8 @@ void FrameView::ForceLayoutForPagination(const FloatSize& page_size,
}
}
+ if (TextAutosizer* text_autosizer = frame_->GetDocument()->GetTextAutosizer())
+ text_autosizer->UpdatePageInfo();
AdjustViewSizeAndLayout();
}
@@ -4324,7 +4330,7 @@ bool FrameView::AdjustScrollbarExistence(
return true;
if (!HasOverlayScrollbars())
- ContentsResized();
+ SetNeedsLayout();
ScrollbarExistenceDidChange();
return true;
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698