Changeset 100048 in webkit
- Timestamp:
- Nov 11, 2011 5:12:58 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r100047 r100048 1 2011-11-11 Emil A Eklund <eae@chromium.org> 2 3 Switch remaining RenderBlock/Box methods to to new layout types 4 https://bugs.webkit.org/show_bug.cgi?id=72075 5 6 Reviewed by Eric Seidel. 7 8 Move margins, floats and line layout block logic to layout abstraction. 9 10 No new tests. 11 12 * rendering/RenderBlockLineLayout.cpp: 13 (WebCore::borderPaddingMarginStart): 14 (WebCore::borderPaddingMarginEnd): 15 (WebCore::inlineLogicalWidth): 16 (WebCore::setStaticPositions): 17 (WebCore::LineLayoutState::LineLayoutState): 18 (WebCore::LineLayoutState::setRepaintRange): 19 (WebCore::LineLayoutState::updateRepaintRangeFromBox): 20 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): 21 (WebCore::RenderBlock::linkToEndLineIfNeeded): 22 (WebCore::RenderBlock::layoutInlineChildren): 23 (WebCore::RenderBlock::checkFloatsInCleanLine): 24 (WebCore::RenderBlock::determineStartPosition): 25 (WebCore::RenderBlock::checkPaginationAndFloatsAtEndLine): 26 (WebCore::RenderBlock::LineBreaker::nextLineBreak): 27 (WebCore::RenderBlock::addOverflowFromInlineChildren): 28 (WebCore::RenderBlock::checkLinesForTextOverflow): 29 (WebCore::RenderBlock::positionNewFloatOnLine): 30 * rendering/RenderBox.cpp: 31 (WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion): 32 (WebCore::RenderBox::offsetFromContainer): 33 (WebCore::RenderBox::positionLineBox): 34 (WebCore::RenderBox::computeInlineDirectionMargins): 35 (WebCore::RenderBox::containingBlockLogicalWidthForPositioned): 36 (WebCore::RenderBox::containingBlockLogicalHeightForPositioned): 37 * rendering/RenderBox.h: 38 (WebCore::RenderBox::tryLayoutDoingPositionedMovementOnly): 39 1 40 2011-11-11 Antoine Labour <piman@chromium.org> 2 41 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r97282 r100048 227 227 }; 228 228 229 static inline int borderPaddingMarginStart(RenderInline* child)229 static inline LayoutUnit borderPaddingMarginStart(RenderInline* child) 230 230 { 231 231 return child->marginStart() + child->paddingStart() + child->borderStart(); 232 232 } 233 233 234 static inline int borderPaddingMarginEnd(RenderInline* child)234 static inline LayoutUnit borderPaddingMarginEnd(RenderInline* child) 235 235 { 236 236 return child->marginEnd() + child->paddingEnd() + child->borderEnd(); 237 237 } 238 238 239 static int inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true)239 static LayoutUnit inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true) 240 240 { 241 241 unsigned lineDepth = 1; 242 int extraWidth = 0;242 LayoutUnit extraWidth = 0; 243 243 RenderObject* parent = child->parent(); 244 244 while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) { … … 858 858 // will work for the common cases 859 859 RenderObject* containerBlock = child->container(); 860 int blockHeight = block->logicalHeight();860 LayoutUnit blockHeight = block->logicalHeight(); 861 861 if (containerBlock->isRenderInline()) { 862 862 // A relative positioned inline encloses us. In this case, we also have to determine our … … 1041 1041 class LineLayoutState { 1042 1042 public: 1043 LineLayoutState(bool fullLayout, int& repaintLogicalTop, int& repaintLogicalBottom)1043 LineLayoutState(bool fullLayout, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom) 1044 1044 : m_lastFloat(0) 1045 1045 , m_endLine(0) … … 1059 1059 bool usesRepaintBounds() const { return m_usesRepaintBounds; } 1060 1060 1061 void setRepaintRange( int logicalHeight)1061 void setRepaintRange(LayoutUnit logicalHeight) 1062 1062 { 1063 1063 m_usesRepaintBounds = true; … … 1065 1065 } 1066 1066 1067 void updateRepaintRangeFromBox(RootInlineBox* box, int paginationDelta = 0)1067 void updateRepaintRangeFromBox(RootInlineBox* box, LayoutUnit paginationDelta = 0) 1068 1068 { 1069 1069 m_usesRepaintBounds = true; … … 1108 1108 1109 1109 // FIXME: Should this be a range object instead of two ints? 1110 int& m_repaintLogicalTop;1111 int& m_repaintLogicalBottom;1112 1110 LayoutUnit& m_repaintLogicalTop; 1111 LayoutUnit& m_repaintLogicalBottom; 1112 1113 1113 bool m_usesRepaintBounds; 1114 1114 }; … … 1258 1258 // inline flow boxes. 1259 1259 1260 int oldLogicalHeight = logicalHeight();1260 LayoutUnit oldLogicalHeight = logicalHeight(); 1261 1261 RootInlineBox* lineBox = createLineBoxesFromBidiRuns(bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun); 1262 1262 … … 1270 1270 1271 1271 if (paginated) { 1272 int adjustment = 0;1272 LayoutUnit adjustment = 0; 1273 1273 adjustLinePositionForPagination(lineBox, adjustment); 1274 1274 if (adjustment) { 1275 int oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());1275 LayoutUnit oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine()); 1276 1276 lineBox->adjustBlockDirectionPosition(adjustment); 1277 1277 if (layoutState.usesRepaintBounds()) … … 1333 1333 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated(); 1334 1334 // Attach all the remaining lines, and then adjust their y-positions as needed. 1335 int delta = logicalHeight() - layoutState.endLineLogicalTop();1335 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop(); 1336 1336 for (RootInlineBox* line = layoutState.endLine(); line; line = line->nextRootBox()) { 1337 1337 line->attachLine(); … … 1413 1413 } 1414 1414 1415 void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom)1415 void RenderBlock::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom) 1416 1416 { 1417 1417 m_overflow.clear(); … … 1509 1509 RenderBox* floatingBox = *it; 1510 1510 floatingBox->layoutIfNeeded(); 1511 IntSize newSize(floatingBox->width() + floatingBox->marginLeft() + floatingBox->marginRight(), floatingBox->height() + floatingBox->marginTop() + floatingBox->marginBottom());1511 LayoutSize newSize(floatingBox->width() + floatingBox->marginLeft() + floatingBox->marginRight(), floatingBox->height() + floatingBox->marginTop() + floatingBox->marginBottom()); 1512 1512 ASSERT(floatIndex < floats.size()); 1513 1513 if (floats[floatIndex].object != floatingBox) { … … 1517 1517 1518 1518 if (floats[floatIndex].rect.size() != newSize) { 1519 int floatTop = isHorizontalWritingMode() ? floats[floatIndex].rect.y() : floats[floatIndex].rect.x();1520 int floatHeight = isHorizontalWritingMode() ? max(floats[floatIndex].rect.height(), newSize.height())1519 LayoutUnit floatTop = isHorizontalWritingMode() ? floats[floatIndex].rect.y() : floats[floatIndex].rect.x(); 1520 LayoutUnit floatHeight = isHorizontalWritingMode() ? max(floats[floatIndex].rect.height(), newSize.height()) 1521 1521 : max(floats[floatIndex].rect.width(), newSize.width()); 1522 floatHeight = min(floatHeight, numeric_limits< int>::max() - floatTop);1522 floatHeight = min(floatHeight, numeric_limits<LayoutUnit>::max() - floatTop); 1523 1523 line->markDirty(); 1524 1524 markLinesDirtyInBlockRange(line->lineBottomWithLeading(), floatTop + floatHeight, line); … … 1540 1540 // Paginate all of the clean lines. 1541 1541 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated(); 1542 int paginationDelta = 0;1542 LayoutUnit paginationDelta = 0; 1543 1543 size_t floatIndex = 0; 1544 1544 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextRootBox()) { … … 1611 1611 unsigned numCleanFloats = 0; 1612 1612 if (!layoutState.floats().isEmpty()) { 1613 int savedLogicalHeight = logicalHeight();1613 LayoutUnit savedLogicalHeight = logicalHeight(); 1614 1614 // Restore floats from clean lines. 1615 1615 RootInlineBox* line = firstRootBox(); … … 1715 1715 1716 1716 // See if any floats end in the range along which we want to shift the lines vertically. 1717 int logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop());1717 LayoutUnit logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop()); 1718 1718 1719 1719 RootInlineBox* lastLine = layoutState.endLine(); … … 1721 1721 lastLine = nextLine; 1722 1722 1723 int logicalBottom = lastLine->lineBottomWithLeading() + abs(lineDelta);1723 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + abs(lineDelta); 1724 1724 1725 1725 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); … … 2219 2219 // Optimize for a common case. If we can't find whitespace after the list 2220 2220 // item, then this is all moot. 2221 int replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj);2221 LayoutUnit replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj); 2222 2222 if (current.m_obj->isListMarker()) { 2223 2223 if (m_block->style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) { … … 2598 2598 void RenderBlock::addOverflowFromInlineChildren() 2599 2599 { 2600 int endPadding = hasOverflowClip() ? paddingEnd() : 0;2600 LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : 0; 2601 2601 // FIXME: Need to find another way to do this, since scrollbars could show when we don't want them to. 2602 2602 if (hasOverflowClip() && !endPadding && node() && node()->rendererIsEditable() && node() == node()->rootEditableElement() && style()->isLeftToRightDirection()) … … 2622 2622 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); 2623 2623 const Font& firstLineFont = firstLineStyle()->font(); 2624 int firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsis, 1, firstLineStyle()));2625 int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style()));2624 LayoutUnit firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsis, 1, firstLineStyle())); 2625 LayoutUnit ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style())); 2626 2626 2627 2627 // For LTR text truncation, we want to get the right edge of our padding box, and then we want to see … … 2631 2631 bool ltr = style()->isLeftToRightDirection(); 2632 2632 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 2633 int blockRightEdge = logicalRightOffsetForLine(curr->y(), curr == firstRootBox());2634 int blockLeftEdge = logicalLeftOffsetForLine(curr->y(), curr == firstRootBox());2635 int lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x();2633 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->y(), curr == firstRootBox()); 2634 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->y(), curr == firstRootBox()); 2635 LayoutUnit lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x(); 2636 2636 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < blockLeftEdge)) { 2637 2637 // This line spills out of our box in the appropriate direction. Now we need to see if the line … … 2639 2639 // accommodate our truncation string, and no replaced elements (images, tables) can overlap the ellipsis 2640 2640 // space. 2641 int width = curr == firstRootBox() ? firstLineEllipsisWidth : ellipsisWidth;2642 int blockEdge = ltr ? blockRightEdge : blockLeftEdge;2641 LayoutUnit width = curr == firstRootBox() ? firstLineEllipsisWidth : ellipsisWidth; 2642 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 2643 2643 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, width)) 2644 2644 curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width); … … 2663 2663 ASSERT(floatingObjectSet.last() == newFloat); 2664 2664 2665 int floatLogicalTop = logicalTopForFloat(newFloat);2665 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); 2666 2666 int paginationStrut = newFloat->m_paginationStrut; 2667 2667 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r99630 r100048 1298 1298 if (!boxInfo) 1299 1299 return result; 1300 return max (0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));1300 return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWidth())); 1301 1301 } 1302 1302 … … 1426 1426 block->adjustStartEdgeForWritingModeIncludingColumns(columnRect); 1427 1427 offset += toSize(columnRect.location()); 1428 IntPoint columnPoint = block->flipForWritingModeIncludingColumns(point + offset);1429 offset = to Size(block->flipForWritingModeIncludingColumns(LayoutPoint(offset)));1428 LayoutPoint columnPoint = block->flipForWritingModeIncludingColumns(point + offset); 1429 offset = toLayoutSize(block->flipForWritingModeIncludingColumns(toLayoutPoint(offset))); 1430 1430 o->adjustForColumns(offset, columnPoint); 1431 1431 offset = block->flipForWritingMode(offset); … … 1486 1486 box->destroy(renderArena()); 1487 1487 } else if (isReplaced()) { 1488 setLocation(roundedLayoutPoint( FloatPoint(box->x(), box->y())));1488 setLocation(roundedLayoutPoint(box->topLeft())); 1489 1489 ASSERT(!m_inlineBoxWrapper); 1490 1490 m_inlineBoxWrapper = box; … … 1824 1824 } 1825 1825 1826 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth)1826 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth) 1827 1827 { 1828 1828 const RenderStyle* containingBlockStyle = containingBlock->style(); … … 2323 2323 } 2324 2324 2325 int RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,2325 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region, 2326 2326 LayoutUnit offsetFromLogicalTopOfFirstPage, bool checkForPerpendicularWritingMode) const 2327 2327 { … … 2348 2348 } 2349 2349 if (boxInfo) 2350 return max (0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));2350 return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWidth())); 2351 2351 } 2352 2352 return result; … … 2376 2376 } 2377 2377 2378 int RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const2378 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const 2379 2379 { 2380 2380 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode()) -
trunk/Source/WebCore/rendering/RenderBox.h
r98021 r100048 235 235 virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); } 236 236 237 virtual void absoluteRects(Vector< IntRect>&, const LayoutPoint& accumulatedOffset) const;237 virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset) const; 238 238 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const; 239 239 240 IntRect reflectionBox() const;240 LayoutRect reflectionBox() const; 241 241 int reflectionOffset() const; 242 242 // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection. … … 269 269 // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end 270 270 // of the containing block. 271 void computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth);271 void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth); 272 272 273 273 // Used to resolve margins in the containing block's block-flow direction. … … 378 378 bool tryLayoutDoingPositionedMovementOnly() 379 379 { 380 int oldWidth = width();380 LayoutUnit oldWidth = width(); 381 381 computeLogicalWidth(); 382 382 // If we shrink to fit our width may have changed, so we still need full layout. … … 469 469 bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground); 470 470 471 int containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,471 LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0, 472 472 LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const; 473 int containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;473 LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const; 474 474 475 475 void computePositionedLogicalHeight();
Note: See TracChangeset
for help on using the changeset viewer.