Changeset 85652 in webkit


Ignore:
Timestamp:
May 3, 2011 1:49:15 PM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-05-03 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Extract LineInfo class
https://bugs.webkit.org/show_bug.cgi?id=60044

Created a LineInfo class in RenderBlockLineLayout.cpp that brings together the relevant
layout information about a line. This simplifies function signatures and clears up initialization.

No new tests as this is refactoring.

  • rendering/RenderBlock.h: Updated internal layout function signatures to use LineInfo.
  • rendering/RenderBlockLineLayout.cpp: (WebCore::LineInfo::LineInfo): (WebCore::LineInfo::isFirstLine): (WebCore::LineInfo::isLastLine): (WebCore::LineInfo::isEmpty): (WebCore::LineInfo::previousLineBrokeCleanly): (WebCore::LineInfo::setFirstLine): (WebCore::LineInfo::setLastLine): (WebCore::LineInfo::setEmpty): (WebCore::LineInfo::setPreviousLineBrokeCleanly): (WebCore::RenderBlock::createLineBoxes): (WebCore::RenderBlock::constructLine): (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): (WebCore::RenderBlock::layoutInlineChildren): (WebCore::RenderBlock::determineStartPosition): (WebCore::skipNonBreakingSpace): (WebCore::shouldCollapseWhiteSpace): (WebCore::requiresLineBox): Moved from RenderBlock.h and made it locally scoped to RenderBlockLineLayout.cpp (WebCore::RenderBlock::generatesLineBoxesForInlineChild): (WebCore::RenderBlock::skipTrailingWhitespace): (WebCore::RenderBlock::skipLeadingWhitespace): (WebCore::RenderBlock::findNextLineBreak):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85650 r85652  
     12011-05-03  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Extract LineInfo class
     6        https://bugs.webkit.org/show_bug.cgi?id=60044
     7
     8        Created a LineInfo class in RenderBlockLineLayout.cpp that brings together the relevant
     9        layout information about a line. This simplifies function signatures and clears up initialization.
     10
     11        No new tests as this is refactoring.
     12
     13        * rendering/RenderBlock.h: Updated internal layout function signatures to use LineInfo.
     14        * rendering/RenderBlockLineLayout.cpp:
     15        (WebCore::LineInfo::LineInfo):
     16        (WebCore::LineInfo::isFirstLine):
     17        (WebCore::LineInfo::isLastLine):
     18        (WebCore::LineInfo::isEmpty):
     19        (WebCore::LineInfo::previousLineBrokeCleanly):
     20        (WebCore::LineInfo::setFirstLine):
     21        (WebCore::LineInfo::setLastLine):
     22        (WebCore::LineInfo::setEmpty):
     23        (WebCore::LineInfo::setPreviousLineBrokeCleanly):
     24        (WebCore::RenderBlock::createLineBoxes):
     25        (WebCore::RenderBlock::constructLine):
     26        (WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
     27        (WebCore::RenderBlock::layoutInlineChildren):
     28        (WebCore::RenderBlock::determineStartPosition):
     29        (WebCore::skipNonBreakingSpace):
     30        (WebCore::shouldCollapseWhiteSpace):
     31        (WebCore::requiresLineBox): Moved from RenderBlock.h and made it locally scoped to RenderBlockLineLayout.cpp
     32        (WebCore::RenderBlock::generatesLineBoxesForInlineChild):
     33        (WebCore::RenderBlock::skipTrailingWhitespace):
     34        (WebCore::RenderBlock::skipLeadingWhitespace):
     35        (WebCore::RenderBlock::findNextLineBreak):
     36
    1372011-05-03  Roland Steiner  <rolandsteiner@chromium.org>
    238
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r85512 r85652  
    4444struct BidiRun;
    4545struct PaintInfo;
     46class LineInfo;
    4647
    4748template <class Iterator, class Run> class BidiResolver;
     
    9495    RootInlineBox* createAndAppendRootInlineBox();
    9596
    96     bool generatesLineBoxesForInlineChild(RenderObject*, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);
     97    bool generatesLineBoxesForInlineChild(RenderObject*);
    9798
    9899    void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true);
     
    157158   
    158159    static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&);
    159     static bool requiresLineBox(const InlineIterator&, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);
    160160
    161161    ColumnInfo* columnInfo() const;
     
    492492    // The following functions' implementations are in RenderBlockLineLayout.cpp.
    493493    void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat);
    494     RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly,
    495                                           InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats,
     494    RootInlineBox* determineStartPosition(LineInfo&, bool& fullLayout, InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats,
    496495                                          bool& useRepaintBounds, int& repaintTop, int& repaintBottom);
    497496    RootInlineBox* determineEndPosition(RootInlineBox* startBox, Vector<FloatWithRect>& floats, size_t floatIndex, InlineIterator& cleanLineStart,
     
    500499                        RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop);
    501500
    502     void skipTrailingWhitespace(InlineIterator&, bool isLineEmpty, bool previousLineBrokeCleanly);
    503     void skipLeadingWhitespace(InlineBidiResolver&, bool isLineEmpty, bool previousLineBrokeCleanly, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
     501    void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
     502    void skipLeadingWhitespace(InlineBidiResolver&, const LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
    504503    typedef std::pair<RenderText*, LazyLineBreakIterator> LineBreakIteratorInfo;
    505     InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, LineBreakIteratorInfo&, bool& previousLineBrokeCleanly, bool& hyphenated,
     504    InlineIterator findNextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, bool& hyphenated,
    506505                                     EClear*, FloatingObject* lastFloatFromPreviousLine, Vector<RenderBox*>& positionedObjects);
    507     RootInlineBox* constructLine(BidiRunList<BidiRun>&, bool firstLine, bool lastLine);
    508     InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine, InlineBox* childBox);
    509 
    510     void computeInlineDirectionPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
     506    RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
     507    InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* childBox);
     508
     509    void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
    511510    void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
    512511    void deleteEllipsisLineBoxes();
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r85649 r85652  
    6060// We don't let our line box tree for a single line get any deeper than this.
    6161const unsigned cMaxLineDepth = 200;
     62   
     63class LineInfo {
     64public:
     65    LineInfo()
     66        : m_isFirstLine(true)
     67        , m_isLastLine(false)
     68        , m_isEmpty(true)
     69        , m_previousLineBrokeCleanly(true)
     70    { }
     71
     72    bool isFirstLine() const { return m_isFirstLine; }
     73    bool isLastLine() const { return m_isLastLine; }
     74    bool isEmpty() const { return m_isEmpty; }
     75    bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; }
     76
     77    void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; }
     78    void setLastLine(bool lastLine) { m_isLastLine = lastLine; }
     79    void setEmpty(bool empty) { m_isEmpty = empty; }
     80    void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }
     81
     82private:
     83    bool m_isFirstLine;
     84    bool m_isLastLine;
     85    bool m_isEmpty;
     86    bool m_previousLineBrokeCleanly;
     87};
    6288
    6389static inline int borderPaddingMarginStart(RenderInline* child)
     
    205231}
    206232
    207 InlineFlowBox* RenderBlock::createLineBoxes(RenderObject* obj, bool firstLine, InlineBox* childBox)
     233InlineFlowBox* RenderBlock::createLineBoxes(RenderObject* obj, const LineInfo& lineInfo, InlineBox* childBox)
    208234{
    209235    // See if we have an unconstructed line box for this object that is also
     
    235261            ASSERT(newBox->isInlineFlowBox());
    236262            parentBox = static_cast<InlineFlowBox*>(newBox);
    237             parentBox->setFirstLineStyleBit(firstLine);
     263            parentBox->setFirstLineStyleBit(lineInfo.isFirstLine());
    238264            parentBox->setIsHorizontal(isHorizontalWritingMode());
    239265            if (!hasDefaultLineBoxContain)
     
    288314}
    289315
    290 RootInlineBox* RenderBlock::constructLine(BidiRunList<BidiRun>& bidiRuns, bool firstLine, bool lastLine)
     316RootInlineBox* RenderBlock::constructLine(BidiRunList<BidiRun>& bidiRuns, const LineInfo& lineInfo)
    291317{
    292318    ASSERT(bidiRuns.firstRun());
     
    315341        if (!parentBox || parentBox->renderer() != r->m_object->parent())
    316342            // Create new inline boxes all the way back to the appropriate insertion point.
    317             parentBox = createLineBoxes(r->m_object->parent(), firstLine, box);
     343            parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box);
    318344        else {
    319345            // Append the inline box to this line.
     
    348374    // the line.
    349375    bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->m_object && bidiRuns.logicallyLastRun()->m_object->isText() ? !reachedEndOfTextRenderer(bidiRuns) : true;
    350     lastLineBox()->determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object);
     376    lastLineBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogicallyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object);
    351377
    352378    // Now mark the line boxes as being constructed.
     
    418444}
    419445
    420 void RenderBlock::computeInlineDirectionPositionsForLine(RootInlineBox* lineBox, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd,
     446void RenderBlock::computeInlineDirectionPositionsForLine(RootInlineBox* lineBox, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd,
    421447                                                         GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache)
    422448{
    423449    ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWithBreak());
    424     float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), firstLine);
    425     float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), firstLine) - logicalLeft;
     450    float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), lineInfo.isFirstLine());
     451    float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), lineInfo.isFirstLine()) - logicalLeft;
    426452
    427453    bool needsWordSpacing = false;
     
    450476            if (int length = rt->textLength()) {
    451477                if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt->characters()[r->m_start]))
    452                     totalLogicalWidth += rt->style(firstLine)->font().wordSpacing();
     478                    totalLogicalWidth += rt->style(lineInfo.isFirstLine())->font().wordSpacing();
    453479                needsWordSpacing = !isSpaceOrNewline(rt->characters()[r->m_stop - 1]) && r->m_stop == length;         
    454480            }
     
    462488                bool includeRootLine = lineBox->includesRootLineBoxFontOrLeading();
    463489                int baselineShift = lineBox->verticalPositionForBox(r->m_box, verticalPositionCache);
    464                 int rootDescent = includeRootLine ? lineBox->renderer()->style(firstLine)->font().fontMetrics().descent() : 0;
    465                 int rootAscent = includeRootLine ? lineBox->renderer()->style(firstLine)->font().fontMetrics().ascent() : 0;
    466                 int boxAscent = rt->style(firstLine)->font().fontMetrics().ascent() - baselineShift;
    467                 int boxDescent = rt->style(firstLine)->font().fontMetrics().descent() + baselineShift;
     490                int rootDescent = includeRootLine ? lineBox->renderer()->style(lineInfo.isFirstLine())->font().fontMetrics().descent() : 0;
     491                int rootAscent = includeRootLine ? lineBox->renderer()->style(lineInfo.isFirstLine())->font().fontMetrics().ascent() : 0;
     492                int boxAscent = rt->style(lineInfo.isFirstLine())->font().fontMetrics().ascent() - baselineShift;
     493                int boxDescent = rt->style(lineInfo.isFirstLine())->font().fontMetrics().descent() + baselineShift;
    468494                if (boxAscent > rootDescent ||  boxDescent > rootAscent)
    469495                    glyphOverflow.computeBounds = true;
     
    473499            if (static_cast<InlineTextBox*>(r->m_box)->hasHyphen()) {
    474500                const AtomicString& hyphenString = rt->style()->hyphenString();
    475                 hyphenWidth = rt->style(firstLine)->font().width(TextRun(hyphenString.characters(), hyphenString.length()));
    476             }
    477             r->m_box->setLogicalWidth(rt->width(r->m_start, r->m_stop - r->m_start, totalLogicalWidth, firstLine, &fallbackFonts, &glyphOverflow) + hyphenWidth);
     501                hyphenWidth = rt->style(lineInfo.isFirstLine())->font().width(TextRun(hyphenString.characters(), hyphenString.length()));
     502            }
     503            r->m_box->setLogicalWidth(rt->width(r->m_start, r->m_stop - r->m_start, totalLogicalWidth, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow) + hyphenWidth);
    478504            if (!fallbackFonts.isEmpty()) {
    479505                ASSERT(r->m_box->isText());
     
    503529                        }
    504530                    }
    505                     toRenderRubyRun(renderBox)->getOverhang(firstLine, renderBox->style()->isLeftToRightDirection() ? previousObject : nextObject, renderBox->style()->isLeftToRightDirection() ? nextObject : previousObject, startOverhang, endOverhang);
     531                    toRenderRubyRun(renderBox)->getOverhang(lineInfo.isFirstLine(), renderBox->style()->isLeftToRightDirection() ? previousObject : nextObject, renderBox->style()->isLeftToRightDirection() ? nextObject : previousObject, startOverhang, endOverhang);
    506532                    setMarginStartForChild(renderBox, -startOverhang);
    507533                    setMarginEndForChild(renderBox, -endOverhang);
     
    793819        InlineBidiResolver resolver;
    794820        unsigned floatIndex;
    795         bool firstLine = true;
    796         bool previousLineBrokeCleanly = true;
    797         RootInlineBox* startLine = determineStartPosition(firstLine, fullLayout, previousLineBrokeCleanly, resolver, floats, floatIndex,
     821        LineInfo lineInfo;
     822        RootInlineBox* startLine = determineStartPosition(lineInfo, fullLayout, resolver, floats, floatIndex,
    798823                                                          useRepaintBounds, repaintLogicalTop, repaintLogicalBottom);
    799824
     
    862887        bool checkForFloatsFromLastLine = false;
    863888
    864         bool isLineEmpty = true;
    865889        bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();
    866890
     
    875899            lineMidpointState.reset();
    876900           
    877             isLineEmpty = true;
     901            lineInfo.setEmpty(true);
    878902           
    879903            EClear clear = CNONE;
     
    883907            InlineIterator oldEnd = end;
    884908            FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
    885             end = findNextLineBreak(resolver, firstLine, isLineEmpty, lineBreakIteratorInfo, previousLineBrokeCleanly, hyphenated, &clear, lastFloatFromPreviousLine, positionedObjects);
     909            end = findNextLineBreak(resolver, lineInfo, lineBreakIteratorInfo, hyphenated, &clear, lastFloatFromPreviousLine, positionedObjects);
    886910            if (resolver.position().atEnd()) {
    887911                // FIXME: We shouldn't be creating any runs in findNextLineBreak to begin with!
     
    894918            ASSERT(end != resolver.position());
    895919
    896             if (isLineEmpty) {
     920            if (lineInfo.isEmpty()) {
    897921                if (lastRootBox())
    898922                    lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.status());
     
    901925                // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine.
    902926                BidiRunList<BidiRun>& bidiRuns = resolver.runs();
    903                 resolver.createBidiRunsForLine(end, override, previousLineBrokeCleanly);
     927                resolver.createBidiRunsForLine(end, override, lineInfo.previousLineBrokeCleanly());
    904928                ASSERT(resolver.position() == end);
    905929
    906                 BidiRun* trailingSpaceRun = !previousLineBrokeCleanly ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0;
     930                BidiRun* trailingSpaceRun = !lineInfo.previousLineBrokeCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0;
    907931
    908932                // Now that the runs have been ordered, we create the line boxes.
     
    915939                    if (hyphenated)
    916940                        bidiRuns.logicallyLastRun()->m_hasHyphen = true;
    917                     lineBox = constructLine(bidiRuns, firstLine, !end.m_obj);
     941                    lineInfo.setLastLine(!end.m_obj);
     942                    lineBox = constructLine(bidiRuns, lineInfo);
    918943                    if (lineBox) {
    919                         lineBox->setEndsWithBreak(previousLineBrokeCleanly);
     944                        lineBox->setEndsWithBreak(lineInfo.previousLineBrokeCleanly());
    920945
    921946#if ENABLE(SVG)
     
    929954                        // Now we position all of our text runs horizontally.
    930955                        if (!isSVGRootInlineBox)
    931                             computeInlineDirectionPositionsForLine(lineBox, firstLine, bidiRuns.firstRun(), trailingSpaceRun, end.atEnd(), textBoxDataMap, verticalPositionCache);
     956                            computeInlineDirectionPositionsForLine(lineBox, lineInfo, bidiRuns.firstRun(), trailingSpaceRun, end.atEnd(), textBoxDataMap, verticalPositionCache);
    932957
    933958                        // Now position our text runs vertically.
     
    971996                        adjustLinePositionForPagination(lineBox, adjustment);
    972997                        if (adjustment) {
    973                             int oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, firstLine);
     998                            int oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, lineInfo.isFirstLine());
    974999                            lineBox->adjustBlockDirectionPosition(adjustment);
    9751000                            if (useRepaintBounds) // This can only be a positive adjustment, so no need to update repaintTop.
    9761001                                repaintLogicalBottom = max(repaintLogicalBottom, lineBox->logicalBottomVisualOverflow());
    9771002                               
    978                             if (availableLogicalWidthForLine(oldLogicalHeight + adjustment, firstLine) != oldLineWidth) {
     1003                            if (availableLogicalWidthForLine(oldLogicalHeight + adjustment, lineInfo.isFirstLine()) != oldLineWidth) {
    9791004                                // We have to delete this line, remove all floats that got added, and let line layout re-run.
    9801005                                lineBox->deleteLine(renderArena());
     
    9941019                    setStaticPositions(this, positionedObjects[i]);
    9951020
    996                 firstLine = false;
     1021                lineInfo.setFirstLine(false);
    9971022                newLine(clear);
    9981023            }
     
    11601185}
    11611186
    1162 RootInlineBox* RenderBlock::determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly,
    1163                                                    InlineBidiResolver& resolver, Vector<FloatWithRect>& floats, unsigned& numCleanFloats,
    1164                                                    bool& useRepaintBounds, int& repaintLogicalTop, int& repaintLogicalBottom)
     1187RootInlineBox* RenderBlock::determineStartPosition(LineInfo& lineInfo, bool& fullLayout, InlineBidiResolver& resolver, Vector<FloatWithRect>& floats,
     1188                                                   unsigned& numCleanFloats, bool& useRepaintBounds, int& repaintLogicalTop, int& repaintLogicalBottom)
    11651189{
    11661190    RootInlineBox* curr = 0;
     
    12571281    }
    12581282
    1259     firstLine = !last;
    1260     previousLineBrokeCleanly = !last || last->endsWithBreak();
     1283    lineInfo.setFirstLine(!last);
     1284    lineInfo.setPreviousLineBrokeCleanly(!last || last->endsWithBreak());
    12611285
    12621286    if (last) {
     
    13911415}
    13921416
    1393 static inline bool skipNonBreakingSpace(const InlineIterator& it, bool isLineEmpty, bool previousLineBrokeCleanly)
     1417static inline bool skipNonBreakingSpace(const InlineIterator& it, const LineInfo& lineInfo)
    13941418{
    13951419    if (it.m_obj->style()->nbspMode() != SPACE || it.current() != noBreakSpace)
     
    14011425    // on a line after a clean line break (or on the first line, since previousLineBrokeCleanly starts off
    14021426    // |true|).
    1403     if (isLineEmpty && previousLineBrokeCleanly)
     1427    if (lineInfo.isEmpty() && lineInfo.previousLineBrokeCleanly())
    14041428        return false;
    14051429
     
    14071431}
    14081432
    1409 static inline bool shouldCollapseWhiteSpace(const RenderStyle* style, bool isLineEmpty, bool previousLineBrokeCleanly)
    1410 {
    1411     return style->collapseWhiteSpace() || (style->whiteSpace() == PRE_WRAP && (!isLineEmpty || !previousLineBrokeCleanly));
     1433static inline bool shouldCollapseWhiteSpace(const RenderStyle* style, const LineInfo& lineInfo)
     1434{
     1435    return style->collapseWhiteSpace() || (style->whiteSpace() == PRE_WRAP && (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly()));
    14121436}
    14131437
     
    14201444}
    14211445
    1422 bool RenderBlock::requiresLineBox(const InlineIterator& it, bool isLineEmpty, bool previousLineBrokeCleanly)
     1446static bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo = LineInfo())
    14231447{
    14241448    if (it.m_obj->isFloatingOrPositioned())
     
    14281452        return false;
    14291453
    1430     if (!shouldCollapseWhiteSpace(it.m_obj->style(), isLineEmpty, previousLineBrokeCleanly) || it.m_obj->isBR())
     1454    if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo) || it.m_obj->isBR())
    14311455        return true;
    14321456
    14331457    UChar current = it.current();
    14341458    return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline())
    1435             && !skipNonBreakingSpace(it, isLineEmpty, previousLineBrokeCleanly);
    1436 }
    1437 
    1438 bool RenderBlock::generatesLineBoxesForInlineChild(RenderObject* inlineObj, bool isLineEmpty, bool previousLineBrokeCleanly)
     1459    && !skipNonBreakingSpace(it, lineInfo);
     1460}
     1461
     1462bool RenderBlock::generatesLineBoxesForInlineChild(RenderObject* inlineObj)
    14391463{
    14401464    ASSERT(inlineObj->parent() == this);
    14411465
    14421466    InlineIterator it(this, inlineObj, 0);
    1443     while (!it.atEnd() && !requiresLineBox(it, isLineEmpty, previousLineBrokeCleanly))
     1467    while (!it.atEnd() && !requiresLineBox(it))
    14441468        it.increment();
    14451469
     
    14531477// NB. this function will insert any floating elements that would otherwise
    14541478// be skipped but it will not position them.
    1455 void RenderBlock::skipTrailingWhitespace(InlineIterator& iterator, bool isLineEmpty, bool previousLineBrokeCleanly)
    1456 {
    1457     while (!iterator.atEnd() && !requiresLineBox(iterator, isLineEmpty, previousLineBrokeCleanly)) {
     1479void RenderBlock::skipTrailingWhitespace(InlineIterator& iterator, const LineInfo& lineInfo)
     1480{
     1481    while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo)) {
    14581482        RenderObject* object = iterator.m_obj;
    14591483        if (object->isFloating()) {
     
    14651489}
    14661490
    1467 void RenderBlock::skipLeadingWhitespace(InlineBidiResolver& resolver, bool isLineEmpty, bool previousLineBrokeCleanly,
     1491void RenderBlock::skipLeadingWhitespace(InlineBidiResolver& resolver, const LineInfo& lineInfo,
    14681492    FloatingObject* lastFloatFromPreviousLine, LineWidth& width)
    14691493{
    1470     while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), isLineEmpty, previousLineBrokeCleanly)) {
     1494    while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), lineInfo)) {
    14711495        RenderObject* object = resolver.position().m_obj;
    14721496        if (object->isFloating())
     
    17421766}
    17431767
    1744 InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool firstLine, bool& isLineEmpty, LineBreakIteratorInfo& lineBreakIteratorInfo, bool& previousLineBrokeCleanly,
     1768InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, LineBreakIteratorInfo& lineBreakIteratorInfo,
    17451769                                              bool& hyphenated, EClear* clear, FloatingObject* lastFloatFromPreviousLine, Vector<RenderBox*>& positionedBoxes)
    17461770{
     
    17501774    LineMidpointState& lineMidpointState = resolver.midpointState();
    17511775
    1752     LineWidth width(this, firstLine);
    1753 
    1754     skipLeadingWhitespace(resolver, isLineEmpty, previousLineBrokeCleanly, lastFloatFromPreviousLine, width);
     1776    LineWidth width(this, lineInfo.isFirstLine());
     1777
     1778    skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width);
    17551779
    17561780    if (resolver.position().atEnd())
     
    17791803    bool atStart = true;
    17801804
    1781     bool prevLineBrokeCleanly = previousLineBrokeCleanly;
    1782     previousLineBrokeCleanly = false;
     1805    bool startingNewParagraph = lineInfo.previousLineBrokeCleanly();
     1806    lineInfo.setPreviousLineBrokeCleanly(false);
    17831807
    17841808    hyphenated = false;
     
    18211845                // cleanly.  Otherwise the <br> has no effect on whether the line is
    18221846                // empty or not.
    1823                 if (prevLineBrokeCleanly)
    1824                     isLineEmpty = false;
     1847                if (startingNewParagraph)
     1848                    lineInfo.setEmpty(false);
    18251849                trailingObjects.clear();
    1826                 previousLineBrokeCleanly = true;
    1827 
    1828                 if (!isLineEmpty && clear)
     1850                lineInfo.setPreviousLineBrokeCleanly(true);
     1851
     1852                if (!lineInfo.isEmpty() && clear)
    18291853                    *clear = o->style()->clear();
    18301854            }
     
    18851909            // start ignoring spaces.
    18861910            if (inlineFlowRequiresLineBox(flowBox)) {
    1887                 isLineEmpty = false;
     1911                lineInfo.setEmpty(false);
    18881912                if (ignoringSpaces) {
    18891913                    trailingObjects.clear();
     
    19131937                addMidpoint(lineMidpointState, InlineIterator(0, o, 0));
    19141938
    1915             isLineEmpty = false;
     1939            lineInfo.setEmpty(false);
    19161940            ignoringSpaces = false;
    19171941            currentCharacterIsSpace = false;
     
    19461970#endif
    19471971
    1948             RenderStyle* style = t->style(firstLine);
     1972            RenderStyle* style = t->style(lineInfo.isFirstLine());
    19491973            if (style->hasTextCombine() && o->isCombineText())
    19501974                toRenderCombineText(o)->combineText();
     
    19892013
    19902014                if (!collapseWhiteSpace || !currentCharacterIsSpace)
    1991                     isLineEmpty = false;
     2015                    lineInfo.setEmpty(false);
    19922016
    19932017                if (c == softHyphen && autoWrap && !hyphenWidth && style->hyphens() != HyphensNone) {
     
    20632087                                lineWasTooWide = true;
    20642088                                lBreak.moveTo(o, pos, nextBreakable);
    2065                                 skipTrailingWhitespace(lBreak, isLineEmpty, previousLineBrokeCleanly);
     2089                                skipTrailingWhitespace(lBreak, lineInfo);
    20662090                            }
    20672091                        }
     
    20792103                                }
    20802104                                lBreak.increment();
    2081                                 previousLineBrokeCleanly = true;
     2105                                lineInfo.setPreviousLineBrokeCleanly(true);
    20822106                            }
    20832107                            if (lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)->characters()[lBreak.m_pos - 1] == softHyphen && style->hyphens() != HyphensNone)
     
    21032127                        lBreak.moveTo(o, pos, nextBreakable);
    21042128                        lBreak.increment();
    2105                         previousLineBrokeCleanly = true;
     2129                        lineInfo.setPreviousLineBrokeCleanly(true);
    21062130                        return lBreak;
    21072131                    }
Note: See TracChangeset for help on using the changeset viewer.