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

Side by Side Diff: Source/core/rendering/RenderView.cpp

Issue 196533012: Make LayoutState always be RAII (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix FlexBox LayoutState scoping Created 6 years, 9 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (!positionedDescendants) 155 if (!positionedDescendants)
156 return; 156 return;
157 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 157 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
158 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 158 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
159 RenderBox* box = *it; 159 RenderBox* box = *it;
160 if (box->node() && box->node()->hasTagName(HTMLNames::dialogTag)) 160 if (box->node() && box->node()->hasTagName(HTMLNames::dialogTag))
161 positionDialog(box); 161 positionDialog(box);
162 } 162 }
163 } 163 }
164 164
165 void RenderView::layoutContent(const LayoutState& state) 165 void RenderView::layoutContent()
166 { 166 {
167 ASSERT(needsLayout()); 167 ASSERT(needsLayout());
168 168
169 LayoutRectRecorder recorder(*this); 169 LayoutRectRecorder recorder(*this);
170 RenderBlockFlow::layout(); 170 RenderBlockFlow::layout();
171 171
172 if (RuntimeEnabledFeatures::dialogElementEnabled()) 172 if (RuntimeEnabledFeatures::dialogElementEnabled())
173 positionDialogs(); 173 positionDialogs();
174 174
175 #ifndef NDEBUG 175 #ifndef NDEBUG
176 checkLayoutState(state); 176 checkLayoutState();
177 #endif 177 #endif
178 } 178 }
179 179
180 #ifndef NDEBUG 180 #ifndef NDEBUG
181 void RenderView::checkLayoutState(const LayoutState& state) 181 void RenderView::checkLayoutState()
182 { 182 {
183 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { 183 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
184 ASSERT(layoutDeltaMatches(LayoutSize())); 184 ASSERT(layoutDeltaMatches(LayoutSize()));
185 } 185 }
186 ASSERT(!m_layoutStateDisableCount); 186 ASSERT(!m_layoutStateDisableCount);
187 ASSERT(m_layoutState == &state); 187 ASSERT(!m_layoutState->m_next);
188 } 188 }
189 #endif 189 #endif
190 190
191 void RenderView::initializeLayoutState(LayoutState& state) 191 void RootLayoutStateScope::initializeLayoutState()
192 { 192 {
193 state.m_clipped = false; 193 m_rootLayoutState.m_clipped = false;
194 state.m_pageLogicalHeight = m_pageLogicalHeight; 194 m_rootLayoutState.m_pageLogicalHeight = m_view.m_pageLogicalHeight;
195 state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; 195 m_rootLayoutState.m_pageLogicalHeightChanged = m_view.m_pageLogicalHeightCha nged;
196 state.m_isPaginated = state.m_pageLogicalHeight; 196 m_rootLayoutState.m_isPaginated = m_rootLayoutState.m_pageLogicalHeight;
197 } 197 }
198 198
199 void RenderView::layout() 199 void RenderView::layout()
200 { 200 {
201 if (!document().paginated()) 201 if (!document().paginated())
202 setPageLogicalHeight(0); 202 setPageLogicalHeight(0);
203 203
204 if (shouldUsePrintingLayout()) 204 if (shouldUsePrintingLayout())
205 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ; 205 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ;
206 206
(...skipping 15 matching lines...) Expand all
222 } 222 }
223 223
224 if (document().svgExtensions()) 224 if (document().svgExtensions())
225 document().accessSVGExtensions().invalidateSVGRootsWithRelativeLengt hDescendents(&layoutScope); 225 document().accessSVGExtensions().invalidateSVGRootsWithRelativeLengt hDescendents(&layoutScope);
226 } 226 }
227 227
228 ASSERT(!m_layoutState); 228 ASSERT(!m_layoutState);
229 if (!needsLayout()) 229 if (!needsLayout())
230 return; 230 return;
231 231
232 LayoutState state; 232 RootLayoutStateScope rootLayoutStateScope(*this);
233 initializeLayoutState(state);
234 233
235 m_pageLogicalHeightChanged = false; 234 m_pageLogicalHeightChanged = false;
236 m_layoutState = &state;
237 235
238 layoutContent(state); 236 layoutContent();
239 237
240 #ifndef NDEBUG 238 #ifndef NDEBUG
241 checkLayoutState(state); 239 checkLayoutState();
242 #endif 240 #endif
243 m_layoutState = 0;
244 clearNeedsLayout(); 241 clearNeedsLayout();
245 } 242 }
246 243
247 void RenderView::mapLocalToContainer(const RenderLayerModelObject* repaintContai ner, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) c onst 244 void RenderView::mapLocalToContainer(const RenderLayerModelObject* repaintContai ner, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) c onst
248 { 245 {
249 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed)); 246 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed));
250 247
251 if (!repaintContainer && mode & UseTransforms && shouldUseTransformFromConta iner(0)) { 248 if (!repaintContainer && mode & UseTransforms && shouldUseTransformFromConta iner(0)) {
252 TransformationMatrix t; 249 TransformationMatrix t;
253 getTransformFromContainer(0, LayoutSize(), t); 250 getTransformFromContainer(0, LayoutSize(), t);
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 return viewWidth(IncludeScrollbars) / scale; 980 return viewWidth(IncludeScrollbars) / scale;
984 } 981 }
985 982
986 double RenderView::layoutViewportHeight() const 983 double RenderView::layoutViewportHeight() const
987 { 984 {
988 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 985 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
989 return viewHeight(IncludeScrollbars) / scale; 986 return viewHeight(IncludeScrollbars) / scale;
990 } 987 }
991 988
992 } // namespace WebCore 989 } // namespace WebCore
OLDNEW
« Source/core/rendering/RenderTable.cpp ('K') | « Source/core/rendering/RenderView.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698