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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2860433002: Update WebView/FrameView size from LayoutView::UpdateAfterLayout (Closed)
Patch Set: nits 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 549 }
550 550
551 void FrameView::SetFrameRect(const IntRect& frame_rect) { 551 void FrameView::SetFrameRect(const IntRect& frame_rect) {
552 if (frame_rect == frame_rect_) 552 if (frame_rect == frame_rect_)
553 return; 553 return;
554 554
555 const bool width_changed = frame_rect_.Width() != frame_rect.Width(); 555 const bool width_changed = frame_rect_.Width() != frame_rect.Width();
556 const bool height_changed = frame_rect_.Height() != frame_rect.Height(); 556 const bool height_changed = frame_rect_.Height() != frame_rect.Height();
557 frame_rect_ = frame_rect; 557 frame_rect_ = frame_rect;
558 558
559 needs_scrollbars_update_ = width_changed || height_changed; 559 needs_scrollbars_update_ |= width_changed || height_changed;
560 // TODO(wjmaclean): find out why scrollbars fail to resize for complex 560
561 // subframes after changing the zoom level. For now always calling 561 // If this is not the main frame, then we got here via
562 // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to 562 // LayoutPart::UpdateGeometryInternal. In that case, we can't clamp the
563 // discover the deeper cause of this. http://crbug.com/607987. 563 // scroll offset yet, because we still need to run UpdateLayout(), so our
564 UpdateScrollbarsIfNeeded(); 564 // clamping boundaries may yet change.
565 if (GetFrame().IsMainFrame()) {
566 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
567 if (LayoutView* lv = GetLayoutView())
568 lv->GetScrollableArea()->ClampScrollOffsetAfterOverflowChange();
569 } else {
570 AdjustScrollOffsetFromUpdateScrollbars();
571 }
572 }
565 573
566 FrameRectsChanged(); 574 FrameRectsChanged();
567 575
568 UpdateParentScrollableAreaSet(); 576 UpdateParentScrollableAreaSet();
569 577
570 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 578 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
571 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 579 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
572 // The overflow clip property depends on the frame size and the pre 580 // The overflow clip property depends on the frame size and the pre
573 // translation property depends on the frame location. 581 // translation property depends on the frame location.
574 SetNeedsPaintPropertyUpdate(); 582 SetNeedsPaintPropertyUpdate();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 713
706 Scrollbar* FrameView::CreateScrollbar(ScrollbarOrientation orientation) { 714 Scrollbar* FrameView::CreateScrollbar(ScrollbarOrientation orientation) {
707 return scrollbar_manager_.CreateScrollbar(orientation); 715 return scrollbar_manager_.CreateScrollbar(orientation);
708 } 716 }
709 717
710 void FrameView::SetContentsSize(const IntSize& size) { 718 void FrameView::SetContentsSize(const IntSize& size) {
711 if (size == ContentsSize()) 719 if (size == ContentsSize())
712 return; 720 return;
713 721
714 contents_size_ = size; 722 contents_size_ = size;
715 UpdateScrollbars(); 723 needs_scrollbars_update_ = true;
716 ScrollableArea::ContentsResized(); 724 ScrollableArea::ContentsResized();
717 725
718 Page* page = GetFrame().GetPage(); 726 Page* page = GetFrame().GetPage();
719 if (!page) 727 if (!page)
720 return; 728 return;
721 729
722 UpdateParentScrollableAreaSet();
723
724 page->GetChromeClient().ContentsSizeChanged(frame_.Get(), size); 730 page->GetChromeClient().ContentsSizeChanged(frame_.Get(), size);
725 731
726 // Ensure the scrollToFragmentAnchor is called before 732 // Ensure the scrollToFragmentAnchor is called before
727 // restoreScrollPositionAndViewState when reload 733 // restoreScrollPositionAndViewState when reload
728 ScrollToFragmentAnchor(); 734 ScrollToFragmentAnchor();
729 GetFrame().Loader().RestoreScrollPositionAndViewState(); 735 GetFrame().Loader().RestoreScrollPositionAndViewState();
730 } 736 }
731 737
732 void FrameView::AdjustViewSize() { 738 void FrameView::AdjustViewSize() {
733 if (suppress_adjust_view_size_) 739 if (suppress_adjust_view_size_)
734 return; 740 return;
735 741
736 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 742 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
737 if (layout_view_item.IsNull()) 743 if (layout_view_item.IsNull())
738 return; 744 return;
739 745
740 ASSERT(frame_->View() == this); 746 ASSERT(frame_->View() == this);
741 747
742 const IntRect rect = layout_view_item.DocumentRect(); 748 const IntRect rect = layout_view_item.DocumentRect();
743 const IntSize& size = rect.Size(); 749 const IntSize& size = rect.Size();
744 750
745 const IntPoint origin(-rect.X(), -rect.Y()); 751 const IntPoint origin(-rect.X(), -rect.Y());
746 if (ScrollOrigin() != origin) { 752 if (ScrollOrigin() != origin)
747 SetScrollOrigin(origin); 753 SetScrollOrigin(origin);
748 // setContentSize (below) also calls updateScrollbars so we can avoid
749 // updating scrollbars twice by skipping the call here when the content
750 // size does not change.
751 if (!frame_->GetDocument()->Printing() && size == ContentsSize())
752 UpdateScrollbars();
753 }
754 754
755 SetContentsSize(size); 755 SetContentsSize(size);
756 } 756 }
757 757
758 void FrameView::AdjustViewSizeAndLayout() { 758 void FrameView::AdjustViewSizeAndLayout() {
759 AdjustViewSize(); 759 AdjustViewSize();
760 if (NeedsLayout()) { 760 if (NeedsLayout()) {
761 AutoReset<bool> suppress_adjust_view_size(&suppress_adjust_view_size_, 761 AutoReset<bool> suppress_adjust_view_size(&suppress_adjust_view_size_,
762 true); 762 true);
763 UpdateLayout(); 763 UpdateLayout();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 bool has_horizontal_scrollbar = HorizontalScrollbar(); 880 bool has_horizontal_scrollbar = HorizontalScrollbar();
881 bool has_vertical_scrollbar = VerticalScrollbar(); 881 bool has_vertical_scrollbar = VerticalScrollbar();
882 if (has_horizontal_scrollbar != should_have_horizontal_scrollbar || 882 if (has_horizontal_scrollbar != should_have_horizontal_scrollbar ||
883 has_vertical_scrollbar != should_have_vertical_scrollbar) { 883 has_vertical_scrollbar != should_have_vertical_scrollbar) {
884 SetNeedsLayout(); 884 SetNeedsLayout();
885 return; 885 return;
886 } 886 }
887 887
888 AdjustViewSize(); 888 AdjustViewSize();
889 UpdateScrollbarGeometry(); 889 UpdateScrollbarGeometry();
890 SetNeedsPaintPropertyUpdate();
890 891
891 if (ScrollOriginChanged()) 892 if (ScrollOriginChanged())
892 SetNeedsLayout(); 893 SetNeedsLayout();
893 } 894 }
894 895
895 bool FrameView::UsesCompositedScrolling() const { 896 bool FrameView::UsesCompositedScrolling() const {
896 LayoutViewItem layout_view = this->GetLayoutViewItem(); 897 LayoutViewItem layout_view = this->GetLayoutViewItem();
897 if (layout_view.IsNull()) 898 if (layout_view.IsNull())
898 return false; 899 return false;
899 if (frame_->GetSettings() && 900 if (frame_->GetSettings() &&
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 else if (root_layout_object && 1304 else if (root_layout_object &&
1304 root_layout_object->StretchesToViewport()) 1305 root_layout_object->StretchesToViewport())
1305 root_layout_object->SetChildNeedsLayout(); 1306 root_layout_object->SetChildNeedsLayout();
1306 } 1307 }
1307 } 1308 }
1308 1309
1309 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 1310 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
1310 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree", 1311 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree",
1311 this, TracedLayoutObject::Create(*GetLayoutView(), false)); 1312 this, TracedLayoutObject::Create(*GetLayoutView(), false));
1312 1313
1314 IntSize old_size(Size());
1315
1313 PerformLayout(in_subtree_layout); 1316 PerformLayout(in_subtree_layout);
1317 UpdateScrollbars();
1318 UpdateParentScrollableAreaSet();
1314 1319
1315 if (!in_subtree_layout && !document->Printing()) 1320 IntSize new_size(Size());
1316 AdjustViewSizeAndLayout(); 1321 if (old_size != new_size) {
1322 needs_scrollbars_update_ = true;
1323 SetNeedsLayout();
1324 MarkViewportConstrainedObjectsForLayout(
1325 old_size.Width() != new_size.Width(),
1326 old_size.Height() != new_size.Height());
1327 }
1328
1329 if (NeedsLayout()) {
1330 AutoReset<bool> suppress(&suppress_adjust_view_size_, true);
1331 UpdateLayout();
1332 }
1317 1333
1318 DCHECK(layout_subtree_root_list_.IsEmpty()); 1334 DCHECK(layout_subtree_root_list_.IsEmpty());
1319 } // Reset m_layoutSchedulingEnabled to its previous value. 1335 } // Reset m_layoutSchedulingEnabled to its previous value.
1320 CheckDoesNotNeedLayout(); 1336 CheckDoesNotNeedLayout();
1321 1337
1322 frame_timing_requests_dirty_ = true; 1338 frame_timing_requests_dirty_ = true;
1323 1339
1324 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark 1340 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark
1325 // from there. crbug.com/462719 1341 // from there. crbug.com/462719
1326 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout(); 1342 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 1682 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
1667 SetNeedsPaintPropertyUpdate(); 1683 SetNeedsPaintPropertyUpdate();
1668 } else { 1684 } else {
1669 layout_view.Compositor()->FrameViewDidChangeSize(); 1685 layout_view.Compositor()->FrameViewDidChangeSize();
1670 } 1686 }
1671 } 1687 }
1672 } 1688 }
1673 1689
1674 ShowOverlayScrollbars(); 1690 ShowOverlayScrollbars();
1675 1691
1676 if (root_layer_scrolling_enabled) {
1677 // The background must be repainted when the FrameView is resized, even if
1678 // the initial containing block does not change (so we can't rely on layout
1679 // to issue the invalidation). This is because the background fills the
1680 // main GraphicsLayer, which takes the size of the layout viewport.
1681 // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents
1682 // layer and avoid this invalidation (http://crbug.com/568847).
1683 LayoutViewItem lvi = GetLayoutViewItem();
1684 if (!lvi.IsNull())
1685 lvi.SetShouldDoFullPaintInvalidation();
1686 }
1687
1688 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && GetLayoutView() && 1692 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && GetLayoutView() &&
1689 frame_->IsMainFrame() && 1693 frame_->IsMainFrame() &&
1690 frame_->GetPage()->GetBrowserControls().Height()) { 1694 frame_->GetPage()->GetBrowserControls().Height()) {
1691 if (GetLayoutView()->Style()->HasFixedBackgroundImage()) { 1695 if (GetLayoutView()->Style()->HasFixedBackgroundImage()) {
1692 // In the case where we don't change layout size from top control resizes, 1696 // In the case where we don't change layout size from top control resizes,
1693 // we wont perform a layout. If we have a fixed background image however, 1697 // we wont perform a layout. If we have a fixed background image however,
1694 // the background layer needs to get resized so we should request a layout 1698 // the background layer needs to get resized so we should request a layout
1695 // explicitly. 1699 // explicitly.
1696 PaintLayer* layer = GetLayoutView()->Layer(); 1700 PaintLayer* layer = GetLayoutView()->Layer();
1697 if (GetLayoutView()->Compositor()->NeedsFixedRootBackgroundLayer(layer)) { 1701 if (GetLayoutView()->Compositor()->NeedsFixedRootBackgroundLayer(layer)) {
1698 SetNeedsLayout(); 1702 SetNeedsLayout();
1699 } else if (!root_layer_scrolling_enabled) { 1703 } else {
1700 // If root layer scrolls is on, we've already issued a full invalidation 1704 // If root layer scrolls is on, we've already issued a full invalidation
1701 // above. 1705 // above.
1702 GetLayoutView()->SetShouldDoFullPaintInvalidationOnResizeIfNeeded( 1706 GetLayoutView()->SetShouldDoFullPaintInvalidationOnResizeIfNeeded(
1703 width_changed, height_changed); 1707 width_changed, height_changed);
1704 } 1708 }
1705 } else if (height_changed && !root_layer_scrolling_enabled) { 1709 } else if (height_changed) {
1706 // If the document rect doesn't fill the full view height, hiding the 1710 // If the document rect doesn't fill the full view height, hiding the
1707 // URL bar will expose area outside the current LayoutView so we need to 1711 // URL bar will expose area outside the current LayoutView so we need to
1708 // paint additional background. If RLS is on, we've already invalidated 1712 // paint additional background. If RLS is on, we've already invalidated
1709 // above. 1713 // above.
1710 LayoutViewItem lvi = GetLayoutViewItem(); 1714 LayoutViewItem lvi = GetLayoutViewItem();
1711 DCHECK(!lvi.IsNull()); 1715 DCHECK(!lvi.IsNull());
1712 if (lvi.DocumentRect().Height() < lvi.ViewRect().Height()) 1716 if (lvi.DocumentRect().Height() < lvi.ViewRect().Height())
1713 lvi.SetShouldDoFullPaintInvalidation(); 1717 lvi.SetShouldDoFullPaintInvalidation();
1714 } 1718 }
1715 } 1719 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 // frame(). 2170 // frame().
2167 if (!GetFrame().View()) 2171 if (!GetFrame().View())
2168 return; 2172 return;
2169 2173
2170 Element* custom_scrollbar_element = nullptr; 2174 Element* custom_scrollbar_element = nullptr;
2171 2175
2172 bool uses_overlay_scrollbars = 2176 bool uses_overlay_scrollbars =
2173 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && 2177 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() &&
2174 !ShouldUseCustomScrollbars(custom_scrollbar_element); 2178 !ShouldUseCustomScrollbars(custom_scrollbar_element);
2175 2179
2176 // FIXME: this call to layout() could be called within FrameView::layout(),
2177 // but before performLayout(), causing double-layout. See also
2178 // crbug.com/429242.
2179 if (!uses_overlay_scrollbars && NeedsLayout()) 2180 if (!uses_overlay_scrollbars && NeedsLayout())
2180 UpdateLayout(); 2181 UpdateLayout();
2181 2182
2182 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) { 2183 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) {
2183 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange(); 2184 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange();
2184 2185
2185 if (!uses_overlay_scrollbars) 2186 if (!uses_overlay_scrollbars)
2186 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize(); 2187 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize();
2187 } 2188 }
2188 } 2189 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 if (!horizontal_writing_mode) 3595 if (!horizontal_writing_mode)
3595 overflow = overflow.TransposedRect(); 3596 overflow = overflow.TransposedRect();
3596 AdjustViewSizeAndLayout(); 3597 AdjustViewSizeAndLayout();
3597 // This is how we clip in case we overflow again. 3598 // This is how we clip in case we overflow again.
3598 layout_view->ClearLayoutOverflow(); 3599 layout_view->ClearLayoutOverflow();
3599 layout_view->AddLayoutOverflow(overflow); 3600 layout_view->AddLayoutOverflow(overflow);
3600 return; 3601 return;
3601 } 3602 }
3602 } 3603 }
3603 3604
3605 if (TextAutosizer* text_autosizer = frame_->GetDocument()->GetTextAutosizer())
3606 text_autosizer->UpdatePageInfo();
3604 AdjustViewSizeAndLayout(); 3607 AdjustViewSizeAndLayout();
3605 } 3608 }
3606 3609
3607 IntRect FrameView::ConvertFromLayoutItem( 3610 IntRect FrameView::ConvertFromLayoutItem(
3608 const LayoutItem& layout_item, 3611 const LayoutItem& layout_item,
3609 const IntRect& layout_object_rect) const { 3612 const IntRect& layout_object_rect) const {
3610 // Convert from page ("absolute") to FrameView coordinates. 3613 // Convert from page ("absolute") to FrameView coordinates.
3611 LayoutRect rect = EnclosingLayoutRect( 3614 LayoutRect rect = EnclosingLayoutRect(
3612 layout_item.LocalToAbsoluteQuad(FloatRect(layout_object_rect)) 3615 layout_item.LocalToAbsoluteQuad(FloatRect(layout_object_rect))
3613 .BoundingBox()); 3616 .BoundingBox());
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 if (!scrollbar_existence_changed) 4310 if (!scrollbar_existence_changed)
4308 return false; 4311 return false;
4309 4312
4310 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar); 4313 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar);
4311 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar); 4314 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar);
4312 4315
4313 if (scrollbars_suppressed_) 4316 if (scrollbars_suppressed_)
4314 return true; 4317 return true;
4315 4318
4316 if (!HasOverlayScrollbars()) 4319 if (!HasOverlayScrollbars())
4317 ContentsResized(); 4320 SetNeedsLayout();
4318 ScrollbarExistenceDidChange(); 4321 ScrollbarExistenceDidChange();
4319 return true; 4322 return true;
4320 } 4323 }
4321 4324
4322 bool FrameView::NeedsScrollbarReconstruction() const { 4325 bool FrameView::NeedsScrollbarReconstruction() const {
4323 Scrollbar* scrollbar = HorizontalScrollbar(); 4326 Scrollbar* scrollbar = HorizontalScrollbar();
4324 if (!scrollbar) 4327 if (!scrollbar)
4325 scrollbar = VerticalScrollbar(); 4328 scrollbar = VerticalScrollbar();
4326 if (!scrollbar) { 4329 if (!scrollbar) {
4327 // We have no scrollbar to reconstruct. 4330 // We have no scrollbar to reconstruct.
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 void FrameView::SetAnimationHost( 5391 void FrameView::SetAnimationHost(
5389 std::unique_ptr<CompositorAnimationHost> host) { 5392 std::unique_ptr<CompositorAnimationHost> host) {
5390 animation_host_ = std::move(host); 5393 animation_host_ = std::move(host);
5391 } 5394 }
5392 5395
5393 LayoutUnit FrameView::CaretWidth() const { 5396 LayoutUnit FrameView::CaretWidth() const {
5394 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5397 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5395 } 5398 }
5396 5399
5397 } // namespace blink 5400 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698