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

Side by Side 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 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
561 // subframes after changing the zoom level. For now always calling
562 // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to
563 // discover the deeper cause of this. http://crbug.com/607987.
564 UpdateScrollbarsIfNeeded();
565 560
566 FrameRectsChanged(); 561 FrameRectsChanged();
567 562
568 UpdateParentScrollableAreaSet(); 563 UpdateParentScrollableAreaSet();
569 564
570 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 565 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
571 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 566 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
572 // The overflow clip property depends on the frame size and the pre 567 // The overflow clip property depends on the frame size and the pre
573 // translation property depends on the frame location. 568 // translation property depends on the frame location.
574 SetNeedsPaintPropertyUpdate(); 569 SetNeedsPaintPropertyUpdate();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 700
706 Scrollbar* FrameView::CreateScrollbar(ScrollbarOrientation orientation) { 701 Scrollbar* FrameView::CreateScrollbar(ScrollbarOrientation orientation) {
707 return scrollbar_manager_.CreateScrollbar(orientation); 702 return scrollbar_manager_.CreateScrollbar(orientation);
708 } 703 }
709 704
710 void FrameView::SetContentsSize(const IntSize& size) { 705 void FrameView::SetContentsSize(const IntSize& size) {
711 if (size == ContentsSize()) 706 if (size == ContentsSize())
712 return; 707 return;
713 708
714 contents_size_ = size; 709 contents_size_ = size;
715 UpdateScrollbars(); 710 needs_scrollbars_update_ = true;
716 ScrollableArea::ContentsResized(); 711 ScrollableArea::ContentsResized();
717 712
718 Page* page = GetFrame().GetPage(); 713 Page* page = GetFrame().GetPage();
719 if (!page) 714 if (!page)
720 return; 715 return;
721 716
722 UpdateParentScrollableAreaSet();
723
724 page->GetChromeClient().ContentsSizeChanged(frame_.Get(), size); 717 page->GetChromeClient().ContentsSizeChanged(frame_.Get(), size);
725 718
726 // Ensure the scrollToFragmentAnchor is called before 719 // Ensure the scrollToFragmentAnchor is called before
727 // restoreScrollPositionAndViewState when reload 720 // restoreScrollPositionAndViewState when reload
728 ScrollToFragmentAnchor(); 721 ScrollToFragmentAnchor();
729 GetFrame().Loader().RestoreScrollPositionAndViewState(); 722 GetFrame().Loader().RestoreScrollPositionAndViewState();
730 } 723 }
731 724
732 void FrameView::AdjustViewSize() { 725 void FrameView::AdjustViewSize() {
733 if (suppress_adjust_view_size_) 726 if (suppress_adjust_view_size_)
734 return; 727 return;
735 728
736 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 729 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
737 if (layout_view_item.IsNull()) 730 if (layout_view_item.IsNull())
738 return; 731 return;
739 732
740 ASSERT(frame_->View() == this); 733 ASSERT(frame_->View() == this);
741 734
742 const IntRect rect = layout_view_item.DocumentRect(); 735 const IntRect rect = layout_view_item.DocumentRect();
743 const IntSize& size = rect.Size(); 736 const IntSize& size = rect.Size();
744 737
745 const IntPoint origin(-rect.X(), -rect.Y()); 738 const IntPoint origin(-rect.X(), -rect.Y());
746 if (ScrollOrigin() != origin) { 739 if (ScrollOrigin() != origin)
747 SetScrollOrigin(origin); 740 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 741
755 SetContentsSize(size); 742 SetContentsSize(size);
756 } 743 }
757 744
758 void FrameView::AdjustViewSizeAndLayout() { 745 void FrameView::AdjustViewSizeAndLayout() {
759 AdjustViewSize(); 746 AdjustViewSize();
760 if (NeedsLayout()) { 747 if (NeedsLayout()) {
761 AutoReset<bool> suppress_adjust_view_size(&suppress_adjust_view_size_, 748 AutoReset<bool> suppress_adjust_view_size(&suppress_adjust_view_size_,
762 true); 749 true);
763 UpdateLayout(); 750 UpdateLayout();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 bool has_horizontal_scrollbar = HorizontalScrollbar(); 867 bool has_horizontal_scrollbar = HorizontalScrollbar();
881 bool has_vertical_scrollbar = VerticalScrollbar(); 868 bool has_vertical_scrollbar = VerticalScrollbar();
882 if (has_horizontal_scrollbar != should_have_horizontal_scrollbar || 869 if (has_horizontal_scrollbar != should_have_horizontal_scrollbar ||
883 has_vertical_scrollbar != should_have_vertical_scrollbar) { 870 has_vertical_scrollbar != should_have_vertical_scrollbar) {
884 SetNeedsLayout(); 871 SetNeedsLayout();
885 return; 872 return;
886 } 873 }
887 874
888 AdjustViewSize(); 875 AdjustViewSize();
889 UpdateScrollbarGeometry(); 876 UpdateScrollbarGeometry();
877 SetNeedsPaintPropertyUpdate();
890 878
891 if (ScrollOriginChanged()) 879 if (ScrollOriginChanged())
892 SetNeedsLayout(); 880 SetNeedsLayout();
893 } 881 }
894 882
895 bool FrameView::UsesCompositedScrolling() const { 883 bool FrameView::UsesCompositedScrolling() const {
896 LayoutViewItem layout_view = this->GetLayoutViewItem(); 884 LayoutViewItem layout_view = this->GetLayoutViewItem();
897 if (layout_view.IsNull()) 885 if (layout_view.IsNull())
898 return false; 886 return false;
899 if (frame_->GetSettings() && 887 if (frame_->GetSettings() &&
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 else if (root_layout_object && 1291 else if (root_layout_object &&
1304 root_layout_object->StretchesToViewport()) 1292 root_layout_object->StretchesToViewport())
1305 root_layout_object->SetChildNeedsLayout(); 1293 root_layout_object->SetChildNeedsLayout();
1306 } 1294 }
1307 } 1295 }
1308 1296
1309 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 1297 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
1310 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree", 1298 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree",
1311 this, TracedLayoutObject::Create(*GetLayoutView(), false)); 1299 this, TracedLayoutObject::Create(*GetLayoutView(), false));
1312 1300
1301 IntSize old_size(Size());
1302
1313 PerformLayout(in_subtree_layout); 1303 PerformLayout(in_subtree_layout);
1304 UpdateScrollbars();
1305 UpdateParentScrollableAreaSet();
1314 1306
1315 if (!in_subtree_layout && !document->Printing()) 1307 IntSize new_size(Size());
1316 AdjustViewSizeAndLayout(); 1308 if (old_size != new_size) {
1309 needs_scrollbars_update_ = true;
1310 SetNeedsLayout();
1311 MarkViewportConstrainedObjectsForLayout(
1312 old_size.Width() != new_size.Width(),
1313 old_size.Height() != new_size.Height());
1314 }
1315
1316 if (NeedsLayout()) {
1317 AutoReset<bool> suppress(&suppress_adjust_view_size_, true);
1318 UpdateLayout();
1319 }
1317 1320
1318 DCHECK(layout_subtree_root_list_.IsEmpty()); 1321 DCHECK(layout_subtree_root_list_.IsEmpty());
1319 } // Reset m_layoutSchedulingEnabled to its previous value. 1322 } // Reset m_layoutSchedulingEnabled to its previous value.
1320 CheckDoesNotNeedLayout(); 1323 CheckDoesNotNeedLayout();
1321 1324
1322 frame_timing_requests_dirty_ = true; 1325 frame_timing_requests_dirty_ = true;
1323 1326
1324 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark 1327 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark
1325 // from there. crbug.com/462719 1328 // from there. crbug.com/462719
1326 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout(); 1329 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1655 }
1653 } 1656 }
1654 1657
1655 void FrameView::ViewportSizeChanged(bool width_changed, bool height_changed) { 1658 void FrameView::ViewportSizeChanged(bool width_changed, bool height_changed) {
1656 DCHECK(width_changed || height_changed); 1659 DCHECK(width_changed || height_changed);
1657 DCHECK(frame_->GetPage()); 1660 DCHECK(frame_->GetPage());
1658 1661
1659 bool root_layer_scrolling_enabled = 1662 bool root_layer_scrolling_enabled =
1660 RuntimeEnabledFeatures::rootLayerScrollingEnabled(); 1663 RuntimeEnabledFeatures::rootLayerScrollingEnabled();
1661 1664
1662 if (LayoutViewItem layout_view = this->GetLayoutViewItem()) { 1665 if (LayoutView* layout_view = this->GetLayoutView()) {
1663 if (layout_view.UsesCompositing()) { 1666 // If this is the main frame, we might have got here by hiding/showing the
1667 // top controls. In that case, layout won't be triggered, so we need to
1668 // clamp the scroll offset here.
1669 if (GetFrame().IsMainFrame()) {
1664 if (root_layer_scrolling_enabled) { 1670 if (root_layer_scrolling_enabled) {
1665 layout_view.Layer()->SetNeedsCompositingInputsUpdate(); 1671 layout_view->GetScrollableArea()
1672 ->ClampScrollOffsetAfterOverflowChange();
1673 } else {
1674 AdjustScrollOffsetFromUpdateScrollbars();
1675 }
1676 }
1677
1678 if (layout_view->UsesCompositing()) {
1679 if (root_layer_scrolling_enabled) {
1680 layout_view->Layer()->SetNeedsCompositingInputsUpdate();
1666 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 1681 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
1667 SetNeedsPaintPropertyUpdate(); 1682 SetNeedsPaintPropertyUpdate();
1668 } else { 1683 } else {
1669 layout_view.Compositor()->FrameViewDidChangeSize(); 1684 layout_view->Compositor()->FrameViewDidChangeSize();
1670 } 1685 }
1671 } 1686 }
1672 } 1687 }
1673 1688
1674 ShowOverlayScrollbars(); 1689 ShowOverlayScrollbars();
1675 1690
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() && 1691 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && GetLayoutView() &&
1689 frame_->IsMainFrame() && 1692 frame_->IsMainFrame() &&
1690 frame_->GetPage()->GetBrowserControls().Height()) { 1693 frame_->GetPage()->GetBrowserControls().Height()) {
1691 if (GetLayoutView()->Style()->HasFixedBackgroundImage()) { 1694 if (GetLayoutView()->Style()->HasFixedBackgroundImage()) {
1692 // In the case where we don't change layout size from top control resizes, 1695 // 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, 1696 // 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 1697 // the background layer needs to get resized so we should request a layout
1695 // explicitly. 1698 // explicitly.
1696 PaintLayer* layer = GetLayoutView()->Layer(); 1699 PaintLayer* layer = GetLayoutView()->Layer();
1697 if (GetLayoutView()->Compositor()->NeedsFixedRootBackgroundLayer(layer)) { 1700 if (GetLayoutView()->Compositor()->NeedsFixedRootBackgroundLayer(layer)) {
1698 SetNeedsLayout(); 1701 SetNeedsLayout();
1699 } else if (!root_layer_scrolling_enabled) { 1702 } else {
1700 // If root layer scrolls is on, we've already issued a full invalidation 1703 // If root layer scrolls is on, we've already issued a full invalidation
1701 // above. 1704 // above.
1702 GetLayoutView()->SetShouldDoFullPaintInvalidationOnResizeIfNeeded( 1705 GetLayoutView()->SetShouldDoFullPaintInvalidationOnResizeIfNeeded(
1703 width_changed, height_changed); 1706 width_changed, height_changed);
1704 } 1707 }
1705 } else if (height_changed && !root_layer_scrolling_enabled) { 1708 } else if (height_changed) {
1706 // If the document rect doesn't fill the full view height, hiding the 1709 // 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 1710 // 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 1711 // paint additional background. If RLS is on, we've already invalidated
1709 // above. 1712 // above.
1710 LayoutViewItem lvi = GetLayoutViewItem(); 1713 LayoutViewItem lvi = GetLayoutViewItem();
1711 DCHECK(!lvi.IsNull()); 1714 DCHECK(!lvi.IsNull());
1712 if (lvi.DocumentRect().Height() < lvi.ViewRect().Height()) 1715 if (lvi.DocumentRect().Height() < lvi.ViewRect().Height())
1713 lvi.SetShouldDoFullPaintInvalidation(); 1716 lvi.SetShouldDoFullPaintInvalidation();
1714 } 1717 }
1715 } 1718 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 // frame(). 2169 // frame().
2167 if (!GetFrame().View()) 2170 if (!GetFrame().View())
2168 return; 2171 return;
2169 2172
2170 Element* custom_scrollbar_element = nullptr; 2173 Element* custom_scrollbar_element = nullptr;
2171 2174
2172 bool uses_overlay_scrollbars = 2175 bool uses_overlay_scrollbars =
2173 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && 2176 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() &&
2174 !ShouldUseCustomScrollbars(custom_scrollbar_element); 2177 !ShouldUseCustomScrollbars(custom_scrollbar_element);
2175 2178
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()) 2179 if (!uses_overlay_scrollbars && NeedsLayout())
2180 UpdateLayout(); 2180 UpdateLayout();
2181 2181
2182 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) { 2182 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) {
2183 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange(); 2183 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange();
2184 2184
2185 if (!uses_overlay_scrollbars) 2185 if (!uses_overlay_scrollbars)
2186 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize(); 2186 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize();
2187 } 2187 }
2188 } 2188 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 if (!horizontal_writing_mode) 3594 if (!horizontal_writing_mode)
3595 overflow = overflow.TransposedRect(); 3595 overflow = overflow.TransposedRect();
3596 AdjustViewSizeAndLayout(); 3596 AdjustViewSizeAndLayout();
3597 // This is how we clip in case we overflow again. 3597 // This is how we clip in case we overflow again.
3598 layout_view->ClearLayoutOverflow(); 3598 layout_view->ClearLayoutOverflow();
3599 layout_view->AddLayoutOverflow(overflow); 3599 layout_view->AddLayoutOverflow(overflow);
3600 return; 3600 return;
3601 } 3601 }
3602 } 3602 }
3603 3603
3604 if (TextAutosizer* text_autosizer = frame_->GetDocument()->GetTextAutosizer())
3605 text_autosizer->UpdatePageInfo();
3604 AdjustViewSizeAndLayout(); 3606 AdjustViewSizeAndLayout();
3605 } 3607 }
3606 3608
3607 IntRect FrameView::ConvertFromLayoutItem( 3609 IntRect FrameView::ConvertFromLayoutItem(
3608 const LayoutItem& layout_item, 3610 const LayoutItem& layout_item,
3609 const IntRect& layout_object_rect) const { 3611 const IntRect& layout_object_rect) const {
3610 // Convert from page ("absolute") to FrameView coordinates. 3612 // Convert from page ("absolute") to FrameView coordinates.
3611 LayoutRect rect = EnclosingLayoutRect( 3613 LayoutRect rect = EnclosingLayoutRect(
3612 layout_item.LocalToAbsoluteQuad(FloatRect(layout_object_rect)) 3614 layout_item.LocalToAbsoluteQuad(FloatRect(layout_object_rect))
3613 .BoundingBox()); 3615 .BoundingBox());
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 if (!scrollbar_existence_changed) 4309 if (!scrollbar_existence_changed)
4308 return false; 4310 return false;
4309 4311
4310 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar); 4312 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar);
4311 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar); 4313 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar);
4312 4314
4313 if (scrollbars_suppressed_) 4315 if (scrollbars_suppressed_)
4314 return true; 4316 return true;
4315 4317
4316 if (!HasOverlayScrollbars()) 4318 if (!HasOverlayScrollbars())
4317 ContentsResized(); 4319 SetNeedsLayout();
4318 ScrollbarExistenceDidChange(); 4320 ScrollbarExistenceDidChange();
4319 return true; 4321 return true;
4320 } 4322 }
4321 4323
4322 bool FrameView::NeedsScrollbarReconstruction() const { 4324 bool FrameView::NeedsScrollbarReconstruction() const {
4323 Scrollbar* scrollbar = HorizontalScrollbar(); 4325 Scrollbar* scrollbar = HorizontalScrollbar();
4324 if (!scrollbar) 4326 if (!scrollbar)
4325 scrollbar = VerticalScrollbar(); 4327 scrollbar = VerticalScrollbar();
4326 if (!scrollbar) { 4328 if (!scrollbar) {
4327 // We have no scrollbar to reconstruct. 4329 // We have no scrollbar to reconstruct.
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 void FrameView::SetAnimationHost( 5390 void FrameView::SetAnimationHost(
5389 std::unique_ptr<CompositorAnimationHost> host) { 5391 std::unique_ptr<CompositorAnimationHost> host) {
5390 animation_host_ = std::move(host); 5392 animation_host_ = std::move(host);
5391 } 5393 }
5392 5394
5393 LayoutUnit FrameView::CaretWidth() const { 5395 LayoutUnit FrameView::CaretWidth() const {
5394 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5396 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5395 } 5397 }
5396 5398
5397 } // namespace blink 5399 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698