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

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

Issue 927773002: Keep track of multiple layout roots (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address concerns. Created 5 years, 10 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // The maximum number of updateWidgets iterations that should be done before ret urning. 101 // The maximum number of updateWidgets iterations that should be done before ret urning.
102 static const unsigned maxUpdateWidgetsIterations = 2; 102 static const unsigned maxUpdateWidgetsIterations = 2;
103 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; 103 static const double resourcePriorityUpdateDelayAfterScroll = 0.250;
104 104
105 FrameView::FrameView(LocalFrame* frame) 105 FrameView::FrameView(LocalFrame* frame)
106 : m_frame(frame) 106 : m_frame(frame)
107 , m_displayMode(WebDisplayModeBrowser) 107 , m_displayMode(WebDisplayModeBrowser)
108 , m_canHaveScrollbars(true) 108 , m_canHaveScrollbars(true)
109 , m_slowRepaintObjectCount(0) 109 , m_slowRepaintObjectCount(0)
110 , m_hasPendingLayout(false) 110 , m_hasPendingLayout(false)
111 , m_layoutSubtreeRoot(0) 111 , m_isSubtreeLayout(false)
112 , m_inSynchronousPostLayout(false) 112 , m_inSynchronousPostLayout(false)
113 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) 113 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
114 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired) 114 , m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
115 , m_isTransparent(false) 115 , m_isTransparent(false)
116 , m_baseBackgroundColor(Color::white) 116 , m_baseBackgroundColor(Color::white)
117 , m_mediaType(MediaTypeNames::screen) 117 , m_mediaType(MediaTypeNames::screen)
118 , m_overflowStatusDirty(true) 118 , m_overflowStatusDirty(true)
119 , m_viewportRenderer(0) 119 , m_viewportRenderer(0)
120 , m_wasScrolledByUser(false) 120 , m_wasScrolledByUser(false)
121 , m_inProgrammaticScroll(false) 121 , m_inProgrammaticScroll(false)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 visitor->trace(m_horizontalScrollbar); 220 visitor->trace(m_horizontalScrollbar);
221 visitor->trace(m_verticalScrollbar); 221 visitor->trace(m_verticalScrollbar);
222 visitor->trace(m_children); 222 visitor->trace(m_children);
223 #endif 223 #endif
224 Widget::trace(visitor); 224 Widget::trace(visitor);
225 } 225 }
226 226
227 void FrameView::reset() 227 void FrameView::reset()
228 { 228 {
229 m_hasPendingLayout = false; 229 m_hasPendingLayout = false;
230 m_layoutSubtreeRoot = nullptr; 230 m_isSubtreeLayout = false;
231 m_doFullPaintInvalidation = false; 231 m_doFullPaintInvalidation = false;
232 m_layoutSchedulingEnabled = true; 232 m_layoutSchedulingEnabled = true;
233 m_inPerformLayout = false; 233 m_inPerformLayout = false;
234 m_inSynchronousPostLayout = false; 234 m_inSynchronousPostLayout = false;
235 m_layoutCount = 0; 235 m_layoutCount = 0;
236 m_nestedLayoutCount = 0; 236 m_nestedLayoutCount = 0;
237 m_postLayoutTasksTimer.stop(); 237 m_postLayoutTasksTimer.stop();
238 m_updateWidgetsTimer.stop(); 238 m_updateWidgetsTimer.stop();
239 m_firstLayout = true; 239 m_firstLayout = true;
240 m_firstLayoutCallbackPending = false; 240 m_firstLayoutCallbackPending = false;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 757
758 bool FrameView::isEnclosedInCompositingLayer() const 758 bool FrameView::isEnclosedInCompositingLayer() const
759 { 759 {
760 // FIXME: It's a bug that compositing state isn't always up to date when thi s is called. crbug.com/366314 760 // FIXME: It's a bug that compositing state isn't always up to date when thi s is called. crbug.com/366314
761 DisableCompositingQueryAsserts disabler; 761 DisableCompositingQueryAsserts disabler;
762 762
763 LayoutObject* frameOwnerRenderer = m_frame->ownerRenderer(); 763 LayoutObject* frameOwnerRenderer = m_frame->ownerRenderer();
764 return frameOwnerRenderer && frameOwnerRenderer->enclosingLayer()->enclosing LayerForPaintInvalidationCrossingFrameBoundaries(); 764 return frameOwnerRenderer && frameOwnerRenderer->enclosingLayer()->enclosing LayerForPaintInvalidationCrossingFrameBoundaries();
765 } 765 }
766 766
767 LayoutObject* FrameView::layoutRoot(bool onlyDuringLayout) const 767 static inline void countObjectsNeedingLayoutInRoot(const LayoutObject* root, uns igned& needsLayoutObjects, unsigned& totalObjects)
768 { 768 {
769 return onlyDuringLayout && layoutPending() ? nullptr : m_layoutSubtreeRoot; 769 for (const LayoutObject* o = root; o; o = o->nextInPreOrder(root)) {
770 ++totalObjects;
771 if (o->needsLayout())
772 ++needsLayoutObjects;
773 }
774 }
775
776 void FrameView::countObjectsNeedingLayout(unsigned& needsLayoutObjects, unsigned & totalObjects, bool& isSubtree)
777 {
778 needsLayoutObjects = 0;
779 totalObjects = 0;
780 if (isSubtreeLayout()) {
781 isSubtree = true;
782 for (auto& subtreeRoot : m_layoutSubtreeRoots)
783 countObjectsNeedingLayoutInRoot(subtreeRoot, needsLayoutObjects, tot alObjects);
784 } else {
785 isSubtree = false;
786 countObjectsNeedingLayoutInRoot(m_frame->document()->renderView(), needs LayoutObjects, totalObjects);
787 }
788 }
789
790 bool FrameView::isLayoutRoot(const LayoutObject* object) const
791 {
792 return m_layoutSubtreeRoots.contains(const_cast<LayoutObject*>(object));
770 } 793 }
771 794
772 inline void FrameView::forceLayoutParentViewIfNeeded() 795 inline void FrameView::forceLayoutParentViewIfNeeded()
773 { 796 {
774 LayoutPart* ownerRenderer = m_frame->ownerRenderer(); 797 LayoutPart* ownerRenderer = m_frame->ownerRenderer();
775 if (!ownerRenderer || !ownerRenderer->frame()) 798 if (!ownerRenderer || !ownerRenderer->frame())
776 return; 799 return;
777 800
778 RenderBox* contentBox = embeddedContentBox(); 801 RenderBox* contentBox = embeddedContentBox();
779 if (!contentBox) 802 if (!contentBox)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 851
829 document->updateRenderTreeIfNeeded(); 852 document->updateRenderTreeIfNeeded();
830 lifecycle().advanceTo(DocumentLifecycle::StyleClean); 853 lifecycle().advanceTo(DocumentLifecycle::StyleClean);
831 } 854 }
832 855
833 void FrameView::lineLayoutTime(double ms) 856 void FrameView::lineLayoutTime(double ms)
834 { 857 {
835 m_lineLayoutMs += ms; 858 m_lineLayoutMs += ms;
836 } 859 }
837 860
838 void FrameView::performLayout(LayoutObject* rootForThisLayout, bool inSubtreeLay out) 861 static void gatherDebugLayoutRects(LayoutObject& layoutRoot)
839 { 862 {
863 bool isTracing;
864 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.la yout"), &isTracing);
865 if (!isTracing)
866 return;
867 if (!layoutRoot.enclosingLayer()->hasCompositedLayerMapping())
868 return;
869 // For access to compositedLayerMapping().
870 DisableCompositingQueryAsserts disabler;
871 GraphicsLayer* graphicsLayer = layoutRoot.enclosingLayer()->compositedLayerM apping()->mainGraphicsLayer();
872 if (!graphicsLayer)
873 return;
874
875 GraphicsLayerDebugInfo& debugInfo = graphicsLayer->debugInfo();
876
877 debugInfo.currentLayoutRects().clear();
878 for (LayoutObject* renderer = &layoutRoot; renderer; renderer = renderer->ne xtInPreOrder()) {
879 if (renderer->layoutDidGetCalledSinceLastFrame()) {
880 FloatQuad quad = renderer->localToAbsoluteQuad(FloatQuad(renderer->p reviousPaintInvalidationRect()));
881 LayoutRect rect = quad.enclosingBoundingBox();
882 debugInfo.currentLayoutRects().append(rect);
883 }
884 }
885 }
886
887 static inline void layoutFromRootObject(LayoutObject& root)
888 {
889 LayoutState layoutState(root);
890 root.layout();
891 gatherDebugLayoutRects(root);
892 }
893
894 void FrameView::performLayout(bool inSubtreeLayout)
895 {
896 ASSERT(inSubtreeLayout || m_layoutSubtreeRoots.isEmpty());
897
840 m_lineLayoutMs = 0; 898 m_lineLayoutMs = 0;
841 TRACE_EVENT0("blink,benchmark", "FrameView::performLayout"); 899 TRACE_EVENT0("blink,benchmark", "FrameView::performLayout");
842 double start = WTF::currentTimeMS(); 900 double start = WTF::currentTimeMS();
843 901
844 ScriptForbiddenScope forbidScript; 902 ScriptForbiddenScope forbidScript;
845 903
846 ASSERT(!isInPerformLayout()); 904 ASSERT(!isInPerformLayout());
847 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); 905 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout);
848 906
849 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true); 907 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true);
850 908
851 // performLayout is the actual guts of layout(). 909 // performLayout is the actual guts of layout().
852 // FIXME: The 300 other lines in layout() probably belong in other helper fu nctions 910 // FIXME: The 300 other lines in layout() probably belong in other helper fu nctions
853 // so that a single human could understand what layout() is actually doing. 911 // so that a single human could understand what layout() is actually doing.
854 912
855 LayoutState layoutState(*rootForThisLayout);
856
857 forceLayoutParentViewIfNeeded(); 913 forceLayoutParentViewIfNeeded();
858 914
859 rootForThisLayout->layout(); 915 if (inSubtreeLayout) {
860 gatherDebugLayoutRects(rootForThisLayout); 916 while (m_layoutSubtreeRoots.size()) {
917 LayoutObject& root = *m_layoutSubtreeRoots.takeAny();
918 if (!root.needsLayout())
919 continue;
920 layoutFromRootObject(root);
921
922 // We need to ensure that we mark up all renderers up to the RenderV iew
923 // for paint invalidation. This simplifies our code as we just alway s
924 // do a full tree walk.
925 if (LayoutObject* container = root.container())
926 container->setMayNeedPaintInvalidation();
927 }
928 } else {
929 layoutFromRootObject(*m_frame->document()->renderView());
930 }
861 931
862 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllIma geResourcePriorities(); 932 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllIma geResourcePriorities();
863 933
864 lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout); 934 lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout);
865 int layoutMs = (WTF::currentTimeMS() - start); 935 int layoutMs = (WTF::currentTimeMS() - start);
866 Platform::current()->histogramCustomCounts("Renderer.LayoutMs", layoutMs, 0, 1000 * 60, 50); 936 Platform::current()->histogramCustomCounts("Renderer.LayoutMs", layoutMs, 0, 1000 * 60, 50);
867 // TODO(benjhayden): re-enable when safe 937 // TODO(benjhayden): re-enable when safe
868 // Platform::current()->histogramCustomCounts("Renderer.LineLayoutMs", m_lin eLayoutMs, 0, 1000 * 60, 50); 938 // Platform::current()->histogramCustomCounts("Renderer.LineLayoutMs", m_lin eLayoutMs, 0, 1000 * 60, 50);
869 } 939 }
870 940
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 996
927 #if !ENABLE(OILPAN) 997 #if !ENABLE(OILPAN)
928 // If there is only one ref to this view left, then its going to be destroye d as soon as we exit, 998 // If there is only one ref to this view left, then its going to be destroye d as soon as we exit,
929 // so there's no point to continuing to layout 999 // so there's no point to continuing to layout
930 if (protector->hasOneRef()) 1000 if (protector->hasOneRef())
931 return; 1001 return;
932 #endif 1002 #endif
933 1003
934 Document* document = m_frame->document(); 1004 Document* document = m_frame->document();
935 bool inSubtreeLayout = isSubtreeLayout(); 1005 bool inSubtreeLayout = isSubtreeLayout();
936 LayoutObject* rootForThisLayout = inSubtreeLayout ? m_layoutSubtreeRoot : do cument->renderView(); 1006
1007 // FIXME: The notion of a single root for layout is no longer applicable. Re move or update this code. crbug.com/460596
1008 LayoutObject* rootForThisLayout = inSubtreeLayout ? *(m_layoutSubtreeRoots.b egin()) : renderView();
937 if (!rootForThisLayout) { 1009 if (!rootForThisLayout) {
938 // FIXME: Do we need to set m_size here? 1010 // FIXME: Do we need to set m_size here?
939 ASSERT_NOT_REACHED(); 1011 ASSERT_NOT_REACHED();
940 return; 1012 return;
941 } 1013 }
942 1014
943 FontCachePurgePreventer fontCachePurgePreventer; 1015 FontCachePurgePreventer fontCachePurgePreventer;
944 Layer* layer;
945 { 1016 {
946 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false); 1017 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
947 1018
948 m_nestedLayoutCount++; 1019 m_nestedLayoutCount++;
949 if (!inSubtreeLayout) { 1020 if (!inSubtreeLayout) {
950 Document* document = m_frame->document(); 1021 clearLayoutSubtreeRootsAndMarkContainingBlocks();
951 Node* body = document->body(); 1022 Node* body = document->body();
952 if (body && body->renderer()) { 1023 if (body && body->renderer()) {
953 if (isHTMLFrameSetElement(*body)) { 1024 if (isHTMLFrameSetElement(*body)) {
954 body->renderer()->setChildNeedsLayout(); 1025 body->renderer()->setChildNeedsLayout();
955 } else if (isHTMLBodyElement(*body)) { 1026 } else if (isHTMLBodyElement(*body)) {
956 if (!m_firstLayout && m_size.height() != layoutSize().height () && body->renderer()->enclosingBox()->stretchesToViewport()) 1027 if (!m_firstLayout && m_size.height() != layoutSize().height () && body->renderer()->enclosingBox()->stretchesToViewport())
957 body->renderer()->setChildNeedsLayout(); 1028 body->renderer()->setChildNeedsLayout();
958 } 1029 }
959 } 1030 }
960 } 1031 }
961 updateCounters(); 1032 updateCounters();
962 1033
963 ScrollbarMode hMode; 1034 ScrollbarMode hMode;
964 ScrollbarMode vMode; 1035 ScrollbarMode vMode;
965 calculateScrollbarModesForLayoutAndSetViewportRenderer(hMode, vMode); 1036 calculateScrollbarModesForLayoutAndSetViewportRenderer(hMode, vMode);
966 1037
967 if (!inSubtreeLayout) { 1038 if (!inSubtreeLayout) {
968 // Now set our scrollbar state for the layout. 1039 // Now set our scrollbar state for the layout.
969 ScrollbarMode currentHMode = horizontalScrollbarMode(); 1040 ScrollbarMode currentHMode = horizontalScrollbarMode();
970 ScrollbarMode currentVMode = verticalScrollbarMode(); 1041 ScrollbarMode currentVMode = verticalScrollbarMode();
971 1042
972 if (m_firstLayout) { 1043 if (m_firstLayout) {
973 setScrollbarsSuppressed(true); 1044 setScrollbarsSuppressed(true);
974 1045
975 m_doFullPaintInvalidation = true; 1046 m_doFullPaintInvalidation = true;
976 m_firstLayout = false; 1047 m_firstLayout = false;
977 m_firstLayoutCallbackPending = true; 1048 m_firstLayoutCallbackPending = true;
978 m_lastViewportSize = layoutSize(IncludeScrollbars); 1049 m_lastViewportSize = layoutSize(IncludeScrollbars);
979 m_lastZoomFactor = rootForThisLayout->style()->zoom(); 1050 m_lastZoomFactor = renderView()->style()->zoom();
980 1051
981 // Set the initial vMode to AlwaysOn if we're auto. 1052 // Set the initial vMode to AlwaysOn if we're auto.
982 if (vMode == ScrollbarAuto) 1053 if (vMode == ScrollbarAuto)
983 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear. 1054 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear.
984 // Set the initial hMode to AlwaysOff if we're auto. 1055 // Set the initial hMode to AlwaysOff if we're auto.
985 if (hMode == ScrollbarAuto) 1056 if (hMode == ScrollbarAuto)
986 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This caus es a horizontal scrollbar to disappear. 1057 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This caus es a horizontal scrollbar to disappear.
987 1058
988 setScrollbarModes(hMode, vMode); 1059 setScrollbarModes(hMode, vMode);
989 setScrollbarsSuppressed(false, true); 1060 setScrollbarsSuppressed(false, true);
(...skipping 15 matching lines...) Expand all
1005 bodyRenderer->setChildNeedsLayout(); 1076 bodyRenderer->setChildNeedsLayout();
1006 else if (rootRenderer && rootRenderer->stretchesToViewport()) 1077 else if (rootRenderer && rootRenderer->stretchesToViewport())
1007 rootRenderer->setChildNeedsLayout(); 1078 rootRenderer->setChildNeedsLayout();
1008 } 1079 }
1009 1080
1010 // We need to set m_doFullPaintInvalidation before triggering layout as LayoutObject::checkForPaintInvalidation 1081 // We need to set m_doFullPaintInvalidation before triggering layout as LayoutObject::checkForPaintInvalidation
1011 // checks the boolean to disable local paint invalidations. 1082 // checks the boolean to disable local paint invalidations.
1012 m_doFullPaintInvalidation |= renderView()->shouldDoFullPaintInvalida tionForNextLayout(); 1083 m_doFullPaintInvalidation |= renderView()->shouldDoFullPaintInvalida tionForNextLayout();
1013 } 1084 }
1014 1085
1015 layer = rootForThisLayout->enclosingLayer(); 1086 performLayout(inSubtreeLayout);
1016 1087
1017 performLayout(rootForThisLayout, inSubtreeLayout); 1088 m_layoutSubtreeRoots.clear();
1018 1089 m_isSubtreeLayout = false;
1019 m_layoutSubtreeRoot = nullptr;
1020 // We need to ensure that we mark up all renderers up to the RenderView
1021 // for paint invalidation. This simplifies our code as we just always
1022 // do a full tree walk.
1023 if (LayoutObject* container = rootForThisLayout->container())
1024 container->setMayNeedPaintInvalidation();
1025 } // Reset m_layoutSchedulingEnabled to its previous value. 1090 } // Reset m_layoutSchedulingEnabled to its previous value.
1026 1091
1027 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->document().printin g()) 1092 if (!inSubtreeLayout && !document->printing())
1028 adjustViewSize(); 1093 adjustViewSize();
1029 1094
1030 layer->updateLayerPositionsAfterLayout(); 1095 // FIXME: Could find the common ancestor layer of all dirty subtrees and mar k from there.
1096 renderView()->enclosingLayer()->updateLayerPositionsAfterLayout();
1031 1097
1032 renderView()->compositor()->didLayout(); 1098 renderView()->compositor()->didLayout();
1033 1099
1034 m_layoutCount++; 1100 m_layoutCount++;
1035 1101
1036 if (AXObjectCache* cache = rootForThisLayout->document().axObjectCache()) { 1102 if (AXObjectCache* cache = document->axObjectCache()) {
1037 const KURL& url = rootForThisLayout->document().url(); 1103 const KURL& url = document->url();
1038 if (url.isValid() && !url.isAboutBlankURL()) 1104 if (url.isValid() && !url.isAboutBlankURL())
1039 cache->handleLayoutComplete(rootForThisLayout); 1105 cache->handleLayoutComplete(document);
1040 } 1106 }
1041 updateAnnotatedRegions(); 1107 updateAnnotatedRegions();
1042 1108
1043 ASSERT(!rootForThisLayout->needsLayout());
1044
1045 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) 1109 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
1046 updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize( ).height() < contentsHeight()); 1110 updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize( ).height() < contentsHeight());
1047 1111
1048 scheduleOrPerformPostLayoutTasks(); 1112 scheduleOrPerformPostLayoutTasks();
1049 1113
1114 // FIXME: The notion of a single root for layout is no longer applicable. Re move or update this code. crbug.com/460596
1050 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Layout", " endData", InspectorLayoutEvent::endData(rootForThisLayout)); 1115 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Layout", " endData", InspectorLayoutEvent::endData(rootForThisLayout));
1051 InspectorInstrumentation::didLayout(m_frame.get(), rootForThisLayout); 1116 InspectorInstrumentation::didLayout(m_frame.get());
1052 1117
1053 m_nestedLayoutCount--; 1118 m_nestedLayoutCount--;
1054 if (m_nestedLayoutCount) 1119 if (m_nestedLayoutCount)
1055 return; 1120 return;
1056 1121
1057 #if ENABLE(ASSERT) 1122 #if ENABLE(ASSERT)
1058 // Post-layout assert that nobody was re-marked as needing layout during lay out. 1123 // Post-layout assert that nobody was re-marked as needing layout during lay out.
1059 document->renderView()->assertSubtreeIsLaidOut(); 1124 renderView()->assertSubtreeIsLaidOut();
1060 #endif 1125 #endif
1061 1126
1062 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout 1127 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout
1063 // however m_inPerformLayout is not set for most of this function, so none o f our RELEASE_ASSERTS 1128 // however m_inPerformLayout is not set for most of this function, so none o f our RELEASE_ASSERTS
1064 // in LocalFrame/Page will fire. One of the post-layout tasks is disconnecti ng the LocalFrame from 1129 // in LocalFrame/Page will fire. One of the post-layout tasks is disconnecti ng the LocalFrame from
1065 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml 1130 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml
1066 // necessitating this check here. 1131 // necessitating this check here.
1067 // ASSERT(frame()->page()); 1132 // ASSERT(frame()->page());
1068 if (frame().page()) 1133 if (frame().page())
1069 frame().page()->chrome().client().layoutUpdated(m_frame.get()); 1134 frame().page()->chrome().client().layoutUpdated(m_frame.get());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1167
1103 if (m_frame->selection().isCaretBoundsDirty()) 1168 if (m_frame->selection().isCaretBoundsDirty())
1104 m_frame->selection().invalidateCaretRect(); 1169 m_frame->selection().invalidateCaretRect();
1105 } 1170 }
1106 1171
1107 DocumentLifecycle& FrameView::lifecycle() const 1172 DocumentLifecycle& FrameView::lifecycle() const
1108 { 1173 {
1109 return m_frame->document()->lifecycle(); 1174 return m_frame->document()->lifecycle();
1110 } 1175 }
1111 1176
1112 void FrameView::gatherDebugLayoutRects(LayoutObject* layoutRoot)
1113 {
1114 bool isTracing;
1115 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.la yout"), &isTracing);
1116 if (!isTracing)
1117 return;
1118 if (!layoutRoot->enclosingLayer()->hasCompositedLayerMapping())
1119 return;
1120 // For access to compositedLayerMapping().
1121 DisableCompositingQueryAsserts disabler;
1122 GraphicsLayer* graphicsLayer = layoutRoot->enclosingLayer()->compositedLayer Mapping()->mainGraphicsLayer();
1123 if (!graphicsLayer)
1124 return;
1125
1126 GraphicsLayerDebugInfo& debugInfo = graphicsLayer->debugInfo();
1127
1128 debugInfo.currentLayoutRects().clear();
1129 for (LayoutObject* renderer = layoutRoot; renderer; renderer = renderer->nex tInPreOrder()) {
1130 if (renderer->layoutDidGetCalledSinceLastFrame()) {
1131 FloatQuad quad = renderer->localToAbsoluteQuad(FloatQuad(renderer->p reviousPaintInvalidationRect()));
1132 LayoutRect rect = quad.enclosingBoundingBox();
1133 debugInfo.currentLayoutRects().append(rect);
1134 }
1135 }
1136 }
1137
1138 RenderBox* FrameView::embeddedContentBox() const 1177 RenderBox* FrameView::embeddedContentBox() const
1139 { 1178 {
1140 RenderView* renderView = this->renderView(); 1179 RenderView* renderView = this->renderView();
1141 if (!renderView) 1180 if (!renderView)
1142 return nullptr; 1181 return nullptr;
1143 1182
1144 LayoutObject* firstChild = renderView->firstChild(); 1183 LayoutObject* firstChild = renderView->firstChild();
1145 if (!firstChild || !firstChild->isBox()) 1184 if (!firstChild || !firstChild->isBox())
1146 return nullptr; 1185 return nullptr;
1147 1186
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 1843
1805 void FrameView::handleLoadCompleted() 1844 void FrameView::handleLoadCompleted()
1806 { 1845 {
1807 // Once loading has completed, allow autoSize one last opportunity to 1846 // Once loading has completed, allow autoSize one last opportunity to
1808 // reduce the size of the frame. 1847 // reduce the size of the frame.
1809 if (m_autoSizeInfo) 1848 if (m_autoSizeInfo)
1810 m_autoSizeInfo->autoSizeIfNeeded(); 1849 m_autoSizeInfo->autoSizeIfNeeded();
1811 maintainScrollPositionAtAnchor(0); 1850 maintainScrollPositionAtAnchor(0);
1812 } 1851 }
1813 1852
1853 void FrameView::clearLayoutSubtreeRoot(const LayoutObject* root)
1854 {
1855 m_layoutSubtreeRoots.remove(const_cast<LayoutObject*>(root));
1856 if (m_layoutSubtreeRoots.isEmpty())
1857 m_isSubtreeLayout = false;
1858 }
1859
1860 void FrameView::clearLayoutSubtreeRootsAndMarkContainingBlocks()
1861 {
1862 for (auto& iter : m_layoutSubtreeRoots)
1863 iter->markContainingBlocksForLayout(false);
1864 m_layoutSubtreeRoots.clear();
1865 }
1866
1814 void FrameView::scheduleRelayout() 1867 void FrameView::scheduleRelayout()
1815 { 1868 {
1816 ASSERT(m_frame->view() == this); 1869 ASSERT(m_frame->view() == this);
1817 1870
1818 if (isSubtreeLayout()) { 1871 m_isSubtreeLayout = false;
1819 m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
1820 m_layoutSubtreeRoot = nullptr;
1821 }
1822 if (!m_layoutSchedulingEnabled) 1872 if (!m_layoutSchedulingEnabled)
1823 return; 1873 return;
1824 if (!needsLayout()) 1874 if (!needsLayout())
1825 return; 1875 return;
1826 if (!m_frame->document()->shouldScheduleLayout()) 1876 if (!m_frame->document()->shouldScheduleLayout())
1827 return; 1877 return;
1828 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali dateLayout", "data", InspectorInvalidateLayoutEvent::data(m_frame.get())); 1878 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali dateLayout", "data", InspectorInvalidateLayoutEvent::data(m_frame.get()));
1829 1879
1830 if (m_hasPendingLayout) 1880 if (m_hasPendingLayout)
1831 return; 1881 return;
1882 clearLayoutSubtreeRootsAndMarkContainingBlocks();
1832 m_hasPendingLayout = true; 1883 m_hasPendingLayout = true;
1833 1884
1834 page()->animator().scheduleVisualUpdate(m_frame.get()); 1885 page()->animator().scheduleVisualUpdate(m_frame.get());
1835 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); 1886 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean);
1836 } 1887 }
1837 1888
1838 static bool isObjectAncestorContainerOf(LayoutObject* ancestor, LayoutObject* de scendant)
1839 {
1840 for (LayoutObject* r = descendant; r; r = r->container()) {
1841 if (r == ancestor)
1842 return true;
1843 }
1844 return false;
1845 }
1846
1847 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) 1889 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot)
1848 { 1890 {
1849 ASSERT(m_frame->view() == this); 1891 ASSERT(m_frame->view() == this);
1850 1892
1851 // FIXME: Should this call shouldScheduleLayout instead? 1893 // FIXME: Should this call shouldScheduleLayout instead?
1852 if (!m_frame->document()->isActive()) 1894 if (!m_frame->document()->isActive())
1853 return; 1895 return;
1854 1896
1855 RenderView* renderView = this->renderView(); 1897 RenderView* renderView = this->renderView();
1856 if (renderView && renderView->needsLayout()) { 1898 if (renderView && renderView->needsLayout()) {
1899 ASSERT(!m_isSubtreeLayout);
1857 if (relayoutRoot) 1900 if (relayoutRoot)
1858 relayoutRoot->markContainingBlocksForLayout(false); 1901 relayoutRoot->markContainingBlocksForLayout(false);
1859 return; 1902 return;
1860 } 1903 }
1861 1904
1862 if (layoutPending() || !m_layoutSchedulingEnabled) { 1905 if (relayoutRoot == renderView) {
1863 if (m_layoutSubtreeRoot != relayoutRoot) { 1906 m_isSubtreeLayout = false;
1864 if (isObjectAncestorContainerOf(m_layoutSubtreeRoot, relayoutRoot)) { 1907 clearLayoutSubtreeRootsAndMarkContainingBlocks();
1865 // Keep the current root 1908 } else {
1866 relayoutRoot->markContainingBlocksForLayout(false, m_layoutSubtr eeRoot); 1909 m_isSubtreeLayout = true;
1867 ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot ->container()->needsLayout()); 1910 m_layoutSubtreeRoots.add(relayoutRoot);
1868 } else if (isSubtreeLayout() && isObjectAncestorContainerOf(relayout Root, m_layoutSubtreeRoot)) { 1911 }
1869 // Re-root at relayoutRoot 1912 if (m_layoutSchedulingEnabled) {
1870 m_layoutSubtreeRoot->markContainingBlocksForLayout(false, relayo utRoot);
1871 m_layoutSubtreeRoot = relayoutRoot;
1872 ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot ->container()->needsLayout());
1873 } else {
1874 // Just do a full relayout
1875 if (isSubtreeLayout())
1876 m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
1877 m_layoutSubtreeRoot = nullptr;
1878 relayoutRoot->markContainingBlocksForLayout(false);
1879 }
1880 }
1881 } else if (m_layoutSchedulingEnabled) {
1882 m_layoutSubtreeRoot = relayoutRoot;
1883 ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->contai ner()->needsLayout());
1884 m_hasPendingLayout = true; 1913 m_hasPendingLayout = true;
1885 1914
1886 page()->animator().scheduleVisualUpdate(m_frame.get()); 1915 page()->animator().scheduleVisualUpdate(m_frame.get());
1887 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean); 1916 lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean);
1888 } 1917 }
1889 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali dateLayout", "data", InspectorInvalidateLayoutEvent::data(m_frame.get())); 1918 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali dateLayout", "data", InspectorInvalidateLayoutEvent::data(m_frame.get()));
1890 } 1919 }
1891 1920
1892 bool FrameView::layoutPending() const 1921 bool FrameView::layoutPending() const
1893 { 1922 {
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 { 4083 {
4055 Settings* settings = frame().settings(); 4084 Settings* settings = frame().settings();
4056 if (!settings || !settings->rootLayerScrolls()) 4085 if (!settings || !settings->rootLayerScrolls())
4057 return this; 4086 return this;
4058 4087
4059 RenderView* renderView = this->renderView(); 4088 RenderView* renderView = this->renderView();
4060 return renderView ? renderView->scrollableArea() : nullptr; 4089 return renderView ? renderView->scrollableArea() : nullptr;
4061 } 4090 }
4062 4091
4063 } // namespace blink 4092 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698