Changeset 38227 in webkit
- Timestamp:
- Nov 7, 2008 11:17:08 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r38224 r38227 1 2008-11-07 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Dan Bernstein 4 5 https://bugs.webkit.org/show_bug.cgi?id=22122 6 7 Use a stack-based object to simplify the pushLayoutState/popLayoutState 8 code. LayoutStateMaintainer either pushes in the constructor, or allows 9 an explicit push() later. Both cases require an explicit pop(). 10 11 * rendering/RenderBlock.cpp: 12 (WebCore::RenderBlock::layoutBlock): 13 (WebCore::RenderBlock::layoutOnlyPositionedObjects): 14 * rendering/RenderContainer.cpp: 15 (WebCore::RenderContainer::layout): 16 * rendering/RenderFlexibleBox.cpp: 17 (WebCore::RenderFlexibleBox::layoutBlock): 18 * rendering/RenderTable.cpp: 19 (WebCore::RenderTable::layout): 20 * rendering/RenderTableRow.cpp: 21 (WebCore::RenderTableRow::layout): 22 * rendering/RenderTableSection.cpp: 23 (WebCore::RenderTableSection::setCellWidths): 24 (WebCore::RenderTableSection::calcRowHeight): 25 (WebCore::RenderTableSection::layoutRows): 26 * rendering/RenderView.h: 27 (WebCore::LayoutStateMaintainer::LayoutStateMaintainer): 28 (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer): 29 (WebCore::LayoutStateMaintainer::pop): 30 (WebCore::LayoutStateMaintainer::push): 31 (WebCore::LayoutStateMaintainer::didPush): 32 1 33 2008-11-07 Tor Arne Vestbø <tavestbo@trolltech.com> 2 34 -
trunk/WebCore/rendering/RenderBlock.cpp
r38207 r38227 593 593 } 594 594 595 bool hadColumns = m_hasColumns; 596 if (!hadColumns && !hasReflection()) 597 view()->pushLayoutState(this, IntSize(xPos(), yPos())); 598 else 599 view()->disableLayoutState(); 595 LayoutStateMaintainer statePusher(view(), this, IntSize(xPos(), yPos()), !m_hasColumns && !hasReflection()); 600 596 601 597 int oldWidth = m_width; … … 726 722 } 727 723 728 if (!hadColumns && !hasReflection()) 729 view()->popLayoutState(); 730 else 731 view()->enableLayoutState(); 724 statePusher.pop(); 732 725 733 726 // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if … … 1395 1388 return false; 1396 1389 1397 if (!m_hasColumns) 1398 view()->pushLayoutState(this, IntSize(xPos(), yPos())); 1399 else 1400 view()->disableLayoutState(); 1390 LayoutStateMaintainer statePusher(view(), this, IntSize(xPos(), yPos()), !m_hasColumns); 1401 1391 1402 1392 if (needsPositionedMovementLayout()) { … … 1409 1399 layoutPositionedObjects(false); 1410 1400 1411 if (!m_hasColumns) 1412 view()->popLayoutState(); 1413 else 1414 view()->enableLayoutState(); 1401 statePusher.pop(); 1415 1402 1416 1403 if (hasOverflowClip()) -
trunk/WebCore/rendering/RenderContainer.cpp
r38098 r38227 521 521 ASSERT(needsLayout()); 522 522 523 view()->pushLayoutState(this, IntSize(m_x, m_y));523 LayoutStateMaintainer statePusher(view(), this, IntSize(m_x, m_y)); 524 524 525 525 RenderObject* child = m_firstChild; … … 530 530 } 531 531 532 view()->popLayoutState();532 statePusher.pop(); 533 533 setNeedsLayout(false); 534 534 } -
trunk/WebCore/rendering/RenderFlexibleBox.cpp
r38207 r38227 220 220 } 221 221 222 if (!hasReflection()) 223 view()->pushLayoutState(this, IntSize(m_x, m_y)); 224 else 225 view()->disableLayoutState(); 222 LayoutStateMaintainer statePusher(view(), this, IntSize(m_x, m_y), !hasReflection()); 226 223 227 224 int previousWidth = m_width; … … 309 306 } 310 307 311 if (!hasReflection()) 312 view()->popLayoutState(); 313 else 314 view()->enableLayoutState(); 308 statePusher.pop(); 315 309 316 310 // Update our scrollbars if we're overflow:auto/scroll/hidden now that we know if -
trunk/WebCore/rendering/RenderTable.cpp
r37637 r38227 266 266 } 267 267 268 view()->pushLayoutState(this, IntSize(m_x, m_y));268 LayoutStateMaintainer statePusher(view(), this, IntSize(m_x, m_y)); 269 269 270 270 m_height = 0; … … 426 426 } 427 427 428 view()->popLayoutState();428 statePusher.pop(); 429 429 430 430 bool didFullRepaint = true; -
trunk/WebCore/rendering/RenderTableRow.cpp
r37637 r38227 125 125 126 126 // Table rows do not add translation. 127 view()->pushLayoutState(this, IntSize());127 LayoutStateMaintainer statePusher(view(), this, IntSize()); 128 128 129 129 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { … … 149 149 } 150 150 151 view()->popLayoutState();151 statePusher.pop(); 152 152 setNeedsLayout(false); 153 153 } -
trunk/WebCore/rendering/RenderTableSection.cpp
r37637 r38227 258 258 { 259 259 Vector<int>& columnPos = table()->columnPositions(); 260 bool pushedLayoutState = false; 261 260 261 LayoutStateMaintainer statePusher(view()); 262 262 263 for (int i = 0; i < m_gridRows; i++) { 263 264 Row& row = *m_grid[i].row; … … 280 281 cell->setNeedsLayout(true); 281 282 if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout()) { 282 if (! pushedLayoutState) {283 if (!statePusher.didPush()) { 283 284 // Technically, we should also push state for the row, but since 284 285 // rows don't push a coordinate transform, that's not necessary. 285 view()->pushLayoutState(this, IntSize(m_x, m_y)); 286 pushedLayoutState = true; 286 statePusher.push(this, IntSize(m_x, m_y)); 287 287 } 288 288 cell->repaint(); … … 293 293 } 294 294 295 if (pushedLayoutState) 296 view()->popLayoutState(); 295 statePusher.pop(); // only pops if we pushed 297 296 } 298 297 … … 302 301 303 302 int spacing = table()->vBorderSpacing(); 304 bool pushedLayoutState = false; 303 304 LayoutStateMaintainer statePusher(view()); 305 305 306 306 m_rowPos.resize(m_gridRows + 1); … … 331 331 332 332 if (cell->overrideSize() != -1) { 333 if (! pushedLayoutState) {333 if (!statePusher.didPush()) { 334 334 // Technically, we should also push state for the row, but since 335 335 // rows don't push a coordinate transform, that's not necessary. 336 view()->pushLayoutState(this, IntSize(m_x, m_y)); 337 pushedLayoutState = true; 336 statePusher.push(this, IntSize(m_x, m_y)); 338 337 } 339 338 cell->setOverrideSize(-1); … … 374 373 } 375 374 376 if (pushedLayoutState) 377 view()->popLayoutState(); 375 statePusher.pop(); 378 376 379 377 return m_rowPos[m_gridRows]; … … 457 455 int nEffCols = table()->numEffCols(); 458 456 459 view()->pushLayoutState(this, IntSize(m_x, m_y));457 LayoutStateMaintainer statePusher(view(), this, IntSize(m_x, m_y)); 460 458 461 459 for (int r = 0; r < totalRows; r++) { … … 576 574 } 577 575 578 view()->popLayoutState();576 statePusher.pop(); 579 577 580 578 m_height = m_rowPos[totalRows]; -
trunk/WebCore/rendering/RenderView.h
r38186 r38227 158 158 }; 159 159 160 // Stack-based class to assist with LayoutState push/pop 161 class LayoutStateMaintainer : Noncopyable { 162 public: 163 // ctor to push now 164 LayoutStateMaintainer(RenderView* view, RenderBox* root, IntSize offset, bool shouldPush = true) 165 : m_view(view) 166 , m_shouldPushPop(shouldPush) 167 , m_didStart(false) 168 , m_didEnd(false) 169 { 170 push(root, offset); 171 } 172 173 // ctor to maybe push later 174 LayoutStateMaintainer(RenderView* view) 175 : m_view(view) 176 , m_shouldPushPop(true) 177 , m_didStart(false) 178 , m_didEnd(false) 179 { 180 } 181 182 ~LayoutStateMaintainer() 183 { 184 ASSERT(m_didStart == m_didEnd); // if this fires, it means that someone did a push(), but forgot to pop(). 185 } 186 187 void pop() 188 { 189 if (m_didStart) { 190 ASSERT(!m_didEnd); 191 if (m_shouldPushPop) 192 m_view->popLayoutState(); 193 else 194 m_view->enableLayoutState(); 195 m_didEnd = true; 196 } 197 } 198 199 void push(RenderBox* root, IntSize offset) 200 { 201 ASSERT(!m_didStart); 202 if (m_shouldPushPop) 203 m_view->pushLayoutState(root, offset); 204 else 205 m_view->disableLayoutState(); 206 m_didStart = true; 207 } 208 209 bool didPush() const { return m_didStart; } 210 211 private: 212 RenderView* m_view; 213 bool m_shouldPushPop : 1; // true if we should push/pop, rather than disable/enable 214 bool m_didStart : 1; // true if we did a push or disable 215 bool m_didEnd : 1; // true if we popped or re-enabled 216 }; 217 160 218 } // namespace WebCore 161 219
Note: See TracChangeset
for help on using the changeset viewer.