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

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

Powered by Google App Engine
This is Rietveld 408576698