Changeset 68957 in webkit
- Timestamp:
- Oct 1, 2010 5:13:00 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r68954 r68957 1 2010-10-01 David Hyatt <hyatt@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 https://bugs.webkit.org/show_bug.cgi?id=47021 6 7 Patch the floatBottom function and its friends. Rename them and consolidate them to be block-flow-aware. 8 9 Nothing testable yet, since most of the float code is still unpatched. 10 11 * rendering/RenderBlock.cpp: 12 (WebCore::RenderBlock::layoutBlock): 13 (WebCore::RenderBlock::layoutBlockChildren): 14 (WebCore::RenderBlock::layoutBlockChild): 15 (WebCore::RenderBlock::positionNewFloats): 16 (WebCore::RenderBlock::newLine): 17 (WebCore::RenderBlock::nextFloatLogicalBottomBelow): 18 (WebCore::RenderBlock::lowestFloatLogicalBottom): 19 (WebCore::RenderBlock::clearFloats): 20 (WebCore::RenderBlock::addOverhangingFloats): 21 (WebCore::RenderBlock::getClearDelta): 22 * rendering/RenderBlock.h: 23 (WebCore::RenderBlock::logicalBottomForFloat): 24 (WebCore::RenderBlock::hasOverhangingFloats): 25 * rendering/RenderBlockLineLayout.cpp: 26 (WebCore::RenderBlock::fitBelowFloats): 27 1 28 2010-10-01 Anders Carlsson <andersca@apple.com> 2 29 -
trunk/WebCore/rendering/RenderBlock.cpp
r68926 r68957 1199 1199 int repaintTop = 0; 1200 1200 int repaintBottom = 0; 1201 int maxFloat Bottom = 0;1201 int maxFloatLogicalBottom = 0; 1202 1202 if (!firstChild() && !isAnonymousBlock()) 1203 1203 setChildrenInline(true); … … 1205 1205 layoutInlineChildren(relayoutChildren, repaintTop, repaintBottom); 1206 1206 else 1207 layoutBlockChildren(relayoutChildren, maxFloat Bottom);1207 layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom); 1208 1208 1209 1209 // Expand our intrinsic height to encompass floats. 1210 1210 int toAdd = borderAfter() + paddingAfter() + scrollbarLogicalHeight(); 1211 if ( floatBottom() > (logicalHeight() - toAdd) && expandsToEncloseOverhangingFloats())1212 setLogicalHeight( floatBottom() + toAdd);1211 if (lowestFloatLogicalBottom() > (logicalHeight() - toAdd) && expandsToEncloseOverhangingFloats()) 1212 setLogicalHeight(lowestFloatLogicalBottom() + toAdd); 1213 1213 1214 1214 if (layoutColumns(hasSpecifiedPageHeight, pageHeight, statePusher)) … … 1220 1220 int newHeight = logicalHeight(); 1221 1221 if (oldHeight != newHeight) { 1222 if (oldHeight > newHeight && maxFloat Bottom > newHeight && !childrenInline()) {1222 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) { 1223 1223 // One of our children's floats may have become an overhanging float for us. We need to look for it. 1224 1224 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 1225 1225 if (child->isBlockFlow() && !child->isFloatingOrPositioned()) { 1226 1226 RenderBlock* block = toRenderBlock(child); 1227 if (block-> floatBottom() + block->logicalTop() > newHeight)1227 if (block->lowestFloatLogicalBottom() + block->logicalTop() > newHeight) 1228 1228 addOverhangingFloats(block, -block->x(), -block->y(), false); 1229 1229 } … … 1740 1740 } 1741 1741 1742 void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloat Bottom)1742 void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom) 1743 1743 { 1744 1744 if (gPercentHeightDescendantsMap) { … … 1774 1774 RenderObject* legend = layoutLegend(relayoutChildren); 1775 1775 1776 int previousFloat Bottom = 0;1777 maxFloat Bottom = 0;1776 int previousFloatLogicalBottom = 0; 1777 maxFloatLogicalBottom = 0; 1778 1778 1779 1779 RenderBox* next = firstChildBox(); … … 1802 1802 1803 1803 // Lay out the child. 1804 layoutBlockChild(child, marginInfo, previousFloat Bottom, maxFloatBottom);1804 layoutBlockChild(child, marginInfo, previousFloatLogicalBottom, maxFloatLogicalBottom); 1805 1805 } 1806 1806 … … 1810 1810 } 1811 1811 1812 void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int& previousFloat Bottom, int& maxFloatBottom)1812 void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom) 1813 1813 { 1814 1814 int oldPosMarginBefore = maxPositiveMarginBefore(); … … 1846 1846 // If an element might be affected by the presence of floats, then always mark it for 1847 1847 // layout. 1848 int fb = max(previousFloat Bottom, floatBottom());1848 int fb = max(previousFloatLogicalBottom, lowestFloatLogicalBottom()); 1849 1849 if (fb > logicalTopEstimate) 1850 1850 markDescendantsWithFloats = true; … … 1855 1855 childRenderBlock->markAllDescendantsWithFloatsForLayout(); 1856 1856 if (!child->isBlockFlowRoot()) 1857 previousFloat Bottom = max(previousFloatBottom, oldLogicalTop + childRenderBlock->floatBottom());1857 previousFloatLogicalBottom = max(previousFloatLogicalBottom, oldLogicalTop + childRenderBlock->lowestFloatLogicalBottom()); 1858 1858 } 1859 1859 … … 1951 1951 // of this block), then the parent gets notified of the floats now. 1952 1952 if (childRenderBlock && childRenderBlock->containsFloats()) 1953 maxFloat Bottom = max(maxFloatBottom, addOverhangingFloats(toRenderBlock(child), -child->x(), -child->y(), !childNeededLayout));1953 maxFloatLogicalBottom = max(maxFloatLogicalBottom, addOverhangingFloats(toRenderBlock(child), -child->x(), -child->y(), !childNeededLayout)); 1954 1954 1955 1955 IntSize childOffset(child->x() - oldRect.x(), child->y() - oldRect.y()); … … 3030 3030 3031 3031 if (o->style()->clear() & CLEFT) 3032 y = max(l eftBottom(), y);3032 y = max(lowestFloatLogicalBottom(FloatingObject::FloatLeft), y); 3033 3033 if (o->style()->clear() & CRIGHT) 3034 y = max( rightBottom(), y);3034 y = max(lowestFloatLogicalBottom(FloatingObject::FloatRight), y); 3035 3035 3036 3036 if (o->style()->floating() == FLEFT) { … … 3139 3139 { 3140 3140 case CLEFT: 3141 newY = l eftBottom();3141 newY = lowestFloatLogicalBottom(FloatingObject::FloatLeft); 3142 3142 break; 3143 3143 case CRIGHT: 3144 newY = rightBottom();3144 newY = lowestFloatLogicalBottom(FloatingObject::FloatRight); 3145 3145 break; 3146 3146 case CBOTH: 3147 newY = floatBottom();3147 newY = lowestFloatLogicalBottom(); 3148 3148 default: 3149 3149 break; … … 3277 3277 } 3278 3278 3279 int RenderBlock::nextFloat BottomBelow(int height) const3279 int RenderBlock::nextFloatLogicalBottomBelow(int logicalHeight) const 3280 3280 { 3281 3281 if (!m_floatingObjects) … … 3286 3286 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects); 3287 3287 for ( ; (r = it.current()); ++it) { 3288 if (r->bottom() > height) 3289 bottom = min(r->bottom(), bottom); 3288 int floatBottom = logicalBottomForFloat(r); 3289 if (floatBottom > logicalHeight) 3290 bottom = min(floatBottom, bottom); 3290 3291 } 3291 3292 … … 3293 3294 } 3294 3295 3295 int 3296 RenderBlock::floatBottom() const 3297 { 3298 if (!m_floatingObjects)return 0;3299 int bottom = 0;3296 int RenderBlock::lowestFloatLogicalBottom(FloatingObject::Type floatType) const 3297 { 3298 if (!m_floatingObjects) 3299 return 0; 3300 int lowestFloatBottom = 0; 3300 3301 FloatingObject* r; 3301 3302 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects); 3302 for ( ; (r = it.current()); ++it ) 3303 if (r->bottom() > bottom) 3304 bottom = r->bottom(); 3305 return bottom; 3303 for ( ; (r = it.current()); ++it) { 3304 if (r->type() & floatType) 3305 lowestFloatBottom = max(lowestFloatBottom, logicalBottomForFloat(r)); 3306 } 3307 return lowestFloatBottom; 3306 3308 } 3307 3309 … … 3584 3586 } 3585 3587 3586 int RenderBlock::leftBottom()3587 {3588 if (!m_floatingObjects) return 0;3589 int bottom = 0;3590 FloatingObject* r;3591 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);3592 for ( ; (r = it.current()); ++it)3593 if (r->bottom() > bottom && r->type() == FloatingObject::FloatLeft)3594 bottom = r->bottom();3595 3596 return bottom;3597 }3598 3599 int RenderBlock::rightBottom()3600 {3601 if (!m_floatingObjects) return 0;3602 int bottom = 0;3603 FloatingObject* r;3604 DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);3605 for ( ; (r = it.current()); ++it)3606 if (r->bottom() > bottom && r->type() == FloatingObject::FloatRight)3607 bottom = r->bottom();3608 3609 return bottom;3610 }3611 3612 3588 void RenderBlock::markLinesDirtyInVerticalRange(int top, int bottom, RootInlineBox* highest) 3613 3589 { … … 3686 3662 3687 3663 RenderBlock* block = toRenderBlock(prev); 3688 if (block->m_floatingObjects && block-> floatBottom() > offset)3664 if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > offset) 3689 3665 addIntrudingFloats(block, xoffset, offset); 3690 3666 … … 3733 3709 return 0; 3734 3710 3735 int lowestFloat Bottom = 0;3711 int lowestFloatLogicalBottom = 0; 3736 3712 3737 3713 // Floats that will remain the child's responsibility to paint should factor into its … … 3740 3716 for (FloatingObject* r; (r = it.current()); ++it) { 3741 3717 int bottom = child->y() + r->bottom(); 3742 lowestFloat Bottom = max(lowestFloatBottom, bottom);3718 lowestFloatLogicalBottom = max(lowestFloatLogicalBottom, bottom); 3743 3719 3744 3720 if (bottom > height()) { … … 3776 3752 child->addOverflowFromChild(r->m_renderer, IntSize(r->left() + r->m_renderer->marginLeft(), r->top() + r->m_renderer->marginTop())); 3777 3753 } 3778 return lowestFloat Bottom;3754 return lowestFloatLogicalBottom; 3779 3755 } 3780 3756 … … 3912 3888 break; 3913 3889 case CLEFT: 3914 bottom = l eftBottom();3890 bottom = lowestFloatLogicalBottom(FloatingObject::FloatLeft); 3915 3891 break; 3916 3892 case CRIGHT: 3917 bottom = rightBottom();3893 bottom = lowestFloatLogicalBottom(FloatingObject::FloatRight); 3918 3894 break; 3919 3895 case CBOTH: 3920 bottom = floatBottom();3896 bottom = lowestFloatLogicalBottom(); 3921 3897 break; 3922 3898 } … … 3946 3922 return y - yPos; 3947 3923 3948 y = nextFloat BottomBelow(y);3924 y = nextFloatLogicalBottomBelow(y); 3949 3925 ASSERT(y >= yPos); 3950 3926 if (y < yPos) -
trunk/WebCore/rendering/RenderBlock.h
r68926 r68957 186 186 int collapsedMarginBeforeForChild(RenderBox* child) const; 187 187 int collapsedMarginAfterForChild(RenderBox* child) const; 188 188 189 189 class MarginValues { 190 190 public: … … 332 332 virtual void repaintOverhangingFloats(bool paintAllDescendants); 333 333 334 void layoutBlockChildren(bool relayoutChildren, int& maxFloat Bottom);334 void layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom); 335 335 void layoutInlineChildren(bool relayoutChildren, int& repaintTop, int& repaintBottom); 336 336 … … 360 360 361 361 struct FloatingObject : Noncopyable { 362 enum Type { 363 FloatLeft, 364 FloatRight 365 }; 366 362 // Note that Type uses bits so you can use FloatBoth as a mask to query for both left and right. 363 enum Type { FloatLeft = 1, FloatRight = 2, FloatBoth = 3 }; 364 367 365 FloatingObject(Type type, const IntRect& frameRect = IntRect()) 368 366 : m_renderer(0) … … 395 393 IntRect m_frameRect; 396 394 int m_paginationStrut; 397 unsigned m_type : 1; // Type (left or right aligned)395 unsigned m_type : 2; // Type (left or right aligned) 398 396 bool m_shouldPaint : 1; 399 397 bool m_isDescendant : 1; 400 398 }; 401 399 400 int logicalBottomForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->bottom() : child->right(); } 401 402 402 // The following functions' implementations are in RenderBlockLineLayout.cpp. 403 403 RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly, … … 452 452 virtual bool avoidsFloats() const; 453 453 454 bool hasOverhangingFloats() { return parent() && !hasColumns() && floatBottom() > height(); }454 bool hasOverhangingFloats() { return parent() && !hasColumns() && lowestFloatLogicalBottom() > logicalHeight(); } 455 455 void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset); 456 456 int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats); 457 457 458 int nextFloatBottomBelow(int) const; 459 int floatBottom() const; 460 inline int leftBottom(); 461 inline int rightBottom(); 462 458 int lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatBoth) const; 459 int nextFloatLogicalBottomBelow(int) const; 460 463 461 virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); 464 462 virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); … … 603 601 }; 604 602 605 void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloat Bottom, int& maxFloatBottom);603 void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom); 606 604 void adjustPositionedBlock(RenderBox* child, const MarginInfo&); 607 605 void adjustFloatingBlock(const MarginInfo&); -
trunk/WebCore/rendering/RenderBlockLineLayout.cpp
r68926 r68957 1331 1331 ASSERT(widthToFit > availableWidth); 1332 1332 1333 int float Bottom;1334 int lastFloat Bottom = height();1333 int floatLogicalBottom; 1334 int lastFloatLogicalBottom = height(); 1335 1335 int newLineWidth = availableWidth; 1336 1336 while (true) { 1337 float Bottom = nextFloatBottomBelow(lastFloatBottom);1338 if (!float Bottom)1337 floatLogicalBottom = nextFloatLogicalBottomBelow(lastFloatLogicalBottom); 1338 if (!floatLogicalBottom) 1339 1339 break; 1340 1340 1341 newLineWidth = availableLogicalWidthForLine(float Bottom, firstLine);1342 lastFloat Bottom = floatBottom;1341 newLineWidth = availableLogicalWidthForLine(floatLogicalBottom, firstLine); 1342 lastFloatLogicalBottom = floatLogicalBottom; 1343 1343 if (newLineWidth >= widthToFit) 1344 1344 break; … … 1346 1346 1347 1347 if (newLineWidth > availableWidth) { 1348 setLogicalHeight(lastFloat Bottom);1348 setLogicalHeight(lastFloatLogicalBottom); 1349 1349 availableWidth = newLineWidth; 1350 1350 }
Note: See TracChangeset
for help on using the changeset viewer.