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

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

Issue 18601002: Add infrastructure for partial layouts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: If text autosizing is enabled, only partial layout for the second of two layouts Created 7 years, 4 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 | Annotate | Revision Log
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 , m_isTrackingRepaints(false) 172 , m_isTrackingRepaints(false)
173 , m_shouldUpdateWhileOffscreen(true) 173 , m_shouldUpdateWhileOffscreen(true)
174 , m_deferSetNeedsLayouts(0) 174 , m_deferSetNeedsLayouts(0)
175 , m_setNeedsLayoutWasDeferred(false) 175 , m_setNeedsLayoutWasDeferred(false)
176 , m_scrollCorner(0) 176 , m_scrollCorner(0)
177 , m_shouldAutoSize(false) 177 , m_shouldAutoSize(false)
178 , m_inAutoSize(false) 178 , m_inAutoSize(false)
179 , m_didRunAutosize(false) 179 , m_didRunAutosize(false)
180 , m_hasSoftwareFilters(false) 180 , m_hasSoftwareFilters(false)
181 , m_visibleContentScaleFactor(1) 181 , m_visibleContentScaleFactor(1)
182 , m_shouldStopPartialLayout(false)
183 , m_stopLayoutAtRenderer(0)
182 { 184 {
183 init(); 185 init();
184 186
185 // FIXME: Can m_frame ever be null here? 187 // FIXME: Can m_frame ever be null here?
186 if (!m_frame) 188 if (!m_frame)
187 return; 189 return;
188 190
189 Page* page = m_frame->page(); 191 Page* page = m_frame->page();
190 if (!page) 192 if (!page)
191 return; 193 return;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 void FrameView::layout(bool allowSubtree) 841 void FrameView::layout(bool allowSubtree)
840 { 842 {
841 // We should never layout a Document which is not in a Frame. 843 // We should never layout a Document which is not in a Frame.
842 ASSERT(m_frame); 844 ASSERT(m_frame);
843 ASSERT(m_frame->view() == this); 845 ASSERT(m_frame->view() == this);
844 ASSERT(m_frame->page()); 846 ASSERT(m_frame->page());
845 847
846 if (m_inLayout) 848 if (m_inLayout)
847 return; 849 return;
848 850
851 ASSERT(!shouldStopPartialLayout());
852
849 TRACE_EVENT0("webkit", "FrameView::layout"); 853 TRACE_EVENT0("webkit", "FrameView::layout");
850 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout"); 854 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout");
851 855
852 // Protect the view from being deleted during layout (in recalcStyle) 856 // Protect the view from being deleted during layout (in recalcStyle)
853 RefPtr<FrameView> protector(this); 857 RefPtr<FrameView> protector(this);
854 858
855 // Every scroll that happens during layout is programmatic. 859 // Every scroll that happens during layout is programmatic.
856 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru e); 860 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru e);
857 861
858 m_layoutTimer.stop(); 862 m_layoutTimer.stop();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 else if (rootRenderer && rootRenderer->stretchesToViewport() ) 980 else if (rootRenderer && rootRenderer->stretchesToViewport() )
977 rootRenderer->setChildNeedsLayout(); 981 rootRenderer->setChildNeedsLayout();
978 } 982 }
979 } 983 }
980 } 984 }
981 985
982 layer = rootForThisLayout->enclosingLayer(); 986 layer = rootForThisLayout->enclosingLayer();
983 987
984 m_actionScheduler->pause(); 988 m_actionScheduler->pause();
985 989
990 // Text Autosizing requires two-pass layout which is incompatible with p artial layout. If
esprehn 2013/08/18 03:43:15 This should be a FIXME for text autosizing not to
pdr. 2013/08/20 06:19:10 Added fixme and a reference to crbug.com/256657.
991 // enabled, only do partial layout for the second layout.
992 RenderObject* delayPartialLayoutForRenderer = 0;
993 if (m_frame && m_frame->settings() && m_frame->settings()->textAutosizin gEnabled()) {
esprehn 2013/08/18 03:43:15 m_frame cannot be null here. I'm pretty sure that'
pdr. 2013/08/20 06:19:10 Done.
994 delayPartialLayoutForRenderer = m_stopLayoutAtRenderer;
995 m_stopLayoutAtRenderer = 0;
996 }
997
986 { 998 {
987 bool disableLayoutState = false; 999 bool disableLayoutState = false;
988 if (inSubtreeLayout) { 1000 if (inSubtreeLayout) {
989 RenderView* view = rootForThisLayout->view(); 1001 RenderView* view = rootForThisLayout->view();
990 disableLayoutState = view->shouldDisableLayoutStateForSubtree(ro otForThisLayout); 1002 disableLayoutState = view->shouldDisableLayoutStateForSubtree(ro otForThisLayout);
991 view->pushLayoutState(rootForThisLayout); 1003 view->pushLayoutState(rootForThisLayout);
992 } 1004 }
993 LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootFor ThisLayout->view() : 0); 1005 LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootFor ThisLayout->view() : 0);
994 1006
995 m_inLayout = true; 1007 m_inLayout = true;
996 beginDeferredRepaints(); 1008 beginDeferredRepaints();
997 forceLayoutParentViewIfNeeded(); 1009 forceLayoutParentViewIfNeeded();
998 rootForThisLayout->layout(); 1010 rootForThisLayout->layout();
999 1011
1012 // If text autosizing is enabled, do a partial layout for the second layout.
1013 if (delayPartialLayoutForRenderer) {
1014 ASSERT(!shouldStopPartialLayout());
1015 m_stopLayoutAtRenderer = delayPartialLayoutForRenderer;
1016 }
1000 bool autosized = document->textAutosizer()->processSubtree(rootForTh isLayout); 1017 bool autosized = document->textAutosizer()->processSubtree(rootForTh isLayout);
1001 if (autosized && rootForThisLayout->needsLayout()) { 1018 if (autosized && rootForThisLayout->needsLayout()) {
1002 TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing"); 1019 TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing");
1003 rootForThisLayout->layout(); 1020 rootForThisLayout->layout();
1004 } 1021 }
1005 1022
1006 endDeferredRepaints(); 1023 endDeferredRepaints();
1007 m_inLayout = false; 1024 m_inLayout = false;
1008 1025
1009 if (inSubtreeLayout) 1026 if (inSubtreeLayout)
1010 rootForThisLayout->view()->popLayoutState(rootForThisLayout); 1027 rootForThisLayout->view()->popLayoutState(rootForThisLayout);
1011 } 1028 }
1012 m_layoutRoot = 0; 1029 m_layoutRoot = 0;
1013 } // Reset m_layoutSchedulingEnabled to its previous value. 1030 } // Reset m_layoutSchedulingEnabled to its previous value.
1014 1031
1032 // Reset partial layout state post-layout and exit here if a partial layout was done.
1033 if (shouldStopPartialLayout()) {
1034 resetPartialLayoutState();
1035 return;
1036 }
1037 resetPartialLayoutState();
1038
1015 bool neededFullRepaint = m_doFullRepaint; 1039 bool neededFullRepaint = m_doFullRepaint;
1016 1040
1017 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->printing()) 1041 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->printing())
1018 adjustViewSize(); 1042 adjustViewSize();
1019 1043
1020 m_doFullRepaint = neededFullRepaint; 1044 m_doFullRepaint = neededFullRepaint;
1021 1045
1022 // Now update the positions of all layers. 1046 // Now update the positions of all layers.
1023 beginDeferredRepaints(); 1047 beginDeferredRepaints();
1024 if (m_doFullRepaint) 1048 if (m_doFullRepaint)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 // however m_inLayout is not set for most of this function, so none of our R ELEASE_ASSERTS 1112 // however m_inLayout is not set for most of this function, so none of our R ELEASE_ASSERTS
1089 // in Frame/Page will fire. One of the post-layout tasks is disconnecting th e Frame from 1113 // in Frame/Page will fire. One of the post-layout tasks is disconnecting th e Frame from
1090 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml 1114 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml
1091 // necessitating this check here. 1115 // necessitating this check here.
1092 ASSERT(frame()); 1116 ASSERT(frame());
1093 // ASSERT(frame()->page()); 1117 // ASSERT(frame()->page());
1094 if (frame() && frame()->page()) 1118 if (frame() && frame()->page())
1095 frame()->page()->chrome().client()->layoutUpdated(frame()); 1119 frame()->page()->chrome().client()->layoutUpdated(frame());
1096 } 1120 }
1097 1121
1122 void FrameView::checkPartialLayoutComplete(RenderObject* renderer)
esprehn 2013/08/18 03:43:15 This check should be inline.
pdr. 2013/08/20 06:19:10 Done.
1123 {
1124 ASSERT(renderer);
1125 if (renderer == m_stopLayoutAtRenderer) {
1126 // Make sure a partial layout was allowed.
1127 do {
1128 ASSERT(renderer->supportsPartialLayout());
1129 } while ((renderer = renderer->parent()));
esprehn 2013/08/18 03:43:15 Why do you need to check this twice? Doing it eith
pdr. 2013/08/20 06:19:10 The supportsPartialLayout loop was intended to jus
1130
1131 m_shouldStopPartialLayout = true;
1132 }
1133 }
1134
1098 RenderBox* FrameView::embeddedContentBox() const 1135 RenderBox* FrameView::embeddedContentBox() const
1099 { 1136 {
1100 RenderView* renderView = this->renderView(); 1137 RenderView* renderView = this->renderView();
1101 if (!renderView) 1138 if (!renderView)
1102 return 0; 1139 return 0;
1103 1140
1104 RenderObject* firstChild = renderView->firstChild(); 1141 RenderObject* firstChild = renderView->firstChild();
1105 if (!firstChild || !firstChild->isBox()) 1142 if (!firstChild || !firstChild->isBox())
1106 return 0; 1143 return 0;
1107 1144
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 } 3366 }
3330 3367
3331 AXObjectCache* FrameView::axObjectCache() const 3368 AXObjectCache* FrameView::axObjectCache() const
3332 { 3369 {
3333 if (frame() && frame()->document()) 3370 if (frame() && frame()->document())
3334 return frame()->document()->existingAXObjectCache(); 3371 return frame()->document()->existingAXObjectCache();
3335 return 0; 3372 return 0;
3336 } 3373 }
3337 3374
3338 } // namespace WebCore 3375 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698