Changeset 83076 in webkit
- Timestamp:
- Apr 6, 2011 11:34:11 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83075 r83076 1 2011-04-06 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Bundle lineLeftOffset and lineRightOffset as a class 6 https://bugs.webkit.org/show_bug.cgi?id=57851 7 8 Added a new class LineOffsets that encapsulates lineLeftOffset and lineRightOffset. 9 The patch makes clear that lineLeftOffset and lineRightOffset are never read individually 10 and only the difference is used to compute the width. 11 12 * rendering/RenderBlock.h: 13 * rendering/RenderBlockLineLayout.cpp: 14 (WebCore::RenderBlock::skipLeadingWhitespace): Takes LineOffsets instead of two integers. 15 (WebCore::LineOffsets::LineOffsets): Added. 16 (WebCore::LineOffsets::width): Added. 17 (WebCore::LineOffsets::setLeft): Added. 18 (WebCore::LineOffsets::setRight): Added. 19 (WebCore::RenderBlock::findNextLineBreak): Calls skipLeadingWhitespace and positionNewFloatOnLine. 20 (WebCore::RenderBlock::positionNewFloatOnLine): Takes LineOffsets instead of two integers. 21 1 22 2011-04-06 David Hyatt <hyatt@apple.com> 2 23 -
trunk/Source/WebCore/rendering/RenderBlock.h
r83052 r83076 37 37 class LayoutStateMaintainer; 38 38 class LazyLineBreakIterator; 39 class LineOffsets; 39 40 class RenderInline; 40 41 … … 494 495 495 496 void skipTrailingWhitespace(InlineIterator&, bool isLineEmpty, bool previousLineBrokeCleanly); 496 void skipLeadingWhitespace(InlineBidiResolver&, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly, FloatingObject* lastFloatFromPreviousLine, int& lineLeftOffset, int& lineRightOffset);497 void skipLeadingWhitespace(InlineBidiResolver&, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly, FloatingObject* lastFloatFromPreviousLine, LineOffsets&); 497 498 void fitBelowFloats(float widthToFit, float totalOverhangWidth, bool firstLine, float& availableWidth); 498 499 typedef std::pair<RenderText*, LazyLineBreakIterator> LineBreakIteratorInfo; … … 509 510 // Positions new floats and also adjust all floats encountered on the line if any of them 510 511 // have to move to the next page/column. 511 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, bool firstLine, int& lineLeftOffset, int& lineRightOffset);512 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, bool firstLine, LineOffsets&); 512 513 513 514 // End of functions defined in RenderBlockLineLayout.cpp. -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r83075 r83076 1457 1457 1458 1458 void RenderBlock::skipLeadingWhitespace(InlineBidiResolver& resolver, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly, 1459 FloatingObject* lastFloatFromPreviousLine, int& lineLeftOffset, int& lineRightOffset)1459 FloatingObject* lastFloatFromPreviousLine, LineOffsets& lineOffsets) 1460 1460 { 1461 1461 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), isLineEmpty, previousLineBrokeCleanly)) { 1462 1462 RenderObject* object = resolver.position().m_obj; 1463 1463 if (object->isFloating()) 1464 positionNewFloatOnLine(insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, firstLine, line LeftOffset, lineRightOffset);1464 positionNewFloatOnLine(insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, firstLine, lineOffsets); 1465 1465 else if (object->isPositioned()) 1466 1466 setStaticPositions(this, toRenderBox(object)); … … 1563 1563 } 1564 1564 1565 class LineOffsets { 1566 public: 1567 LineOffsets(int leftOffset, int rightOffset) 1568 : m_left(leftOffset) 1569 , m_right(rightOffset) 1570 { 1571 } 1572 int width() const { return max(0, m_right - m_left); } 1573 void setLeft(int left) { m_left = left; } 1574 void setRight(int right) { m_right = right; } 1575 private: 1576 int m_left; 1577 int m_right; 1578 }; 1579 1565 1580 InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool firstLine, bool& isLineEmpty, LineBreakIteratorInfo& lineBreakIteratorInfo, bool& previousLineBrokeCleanly, 1566 1581 bool& hyphenated, EClear* clear, FloatingObject* lastFloatFromPreviousLine, Vector<RenderBox*>& positionedBoxes) … … 1572 1587 1573 1588 int blockOffset = logicalHeight(); 1574 int lineLeftOffset = logicalLeftOffsetForLine(blockOffset, firstLine); 1575 int lineRightOffset = logicalRightOffsetForLine(blockOffset, firstLine); 1576 1577 skipLeadingWhitespace(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, lastFloatFromPreviousLine, lineLeftOffset, lineRightOffset); 1578 1579 float width = max(0, lineRightOffset - lineLeftOffset); 1589 LineOffsets lineOffsets(logicalLeftOffsetForLine(blockOffset, firstLine), logicalRightOffsetForLine(blockOffset, firstLine)); 1590 1591 skipLeadingWhitespace(resolver, firstLine, isLineEmpty, previousLineBrokeCleanly, lastFloatFromPreviousLine, lineOffsets); 1592 1593 float width = lineOffsets.width(); 1580 1594 float w = 0; 1581 1595 float tmpW = 0; … … 1671 1685 // it after moving to next line (in newLine() func) 1672 1686 if (floatsFitOnLine && logicalWidthForFloat(f) + w + tmpW <= width) { 1673 positionNewFloatOnLine(f, lastFloatFromPreviousLine, firstLine, line LeftOffset, lineRightOffset);1674 width = max(0, lineRightOffset - lineLeftOffset) + totalOverhangWidth;1687 positionNewFloatOnLine(f, lastFloatFromPreviousLine, firstLine, lineOffsets); 1688 width = lineOffsets.width() + totalOverhangWidth; 1675 1689 if (lBreak.m_obj == o) { 1676 1690 ASSERT(!lBreak.m_pos); … … 2258 2272 } 2259 2273 2260 bool RenderBlock::positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, bool firstLine, int& lineLeftOffset, int& lineRightOffset)2274 bool RenderBlock::positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, bool firstLine, LineOffsets& lineOffsets) 2261 2275 { 2262 2276 bool didPosition = positionNewFloats(); … … 2267 2281 if (blockOffset >= logicalTopForFloat(newFloat) && blockOffset < logicalBottomForFloat(newFloat)) { 2268 2282 if (newFloat->type() == FloatingObject::FloatLeft) 2269 line LeftOffset = logicalRightForFloat(newFloat);2283 lineOffsets.setLeft(logicalRightForFloat(newFloat)); 2270 2284 else 2271 line RightOffset = logicalLeftForFloat(newFloat);2285 lineOffsets.setRight(logicalLeftForFloat(newFloat)); 2272 2286 } 2273 2287 … … 2305 2319 2306 2320 setLogicalHeight(blockOffset + paginationStrut); 2307 line LeftOffset = logicalLeftOffsetForLine(logicalHeight(), firstLine);2308 line RightOffset = logicalRightOffsetForLine(logicalHeight(), firstLine);2321 lineOffsets.setLeft(logicalLeftOffsetForLine(logicalHeight(), firstLine)); 2322 lineOffsets.setRight(logicalRightOffsetForLine(logicalHeight(), firstLine)); 2309 2323 2310 2324 return didPosition;
Note: See TracChangeset
for help on using the changeset viewer.