Changeset 85695 in webkit


Ignore:
Timestamp:
May 3, 2011 5:38:05 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-05-03 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

findNextLineBreak splits InlineIterator into 3 pieces
https://bugs.webkit.org/show_bug.cgi?id=60082

Avoid splitting InlineIterator into 3 variables with inter-dependencies.

  • rendering/InlineIterator.h: (WebCore::InlineIterator::fastIncrementInTextNode): Added. (WebCore::InlineIterator::previousInSameNode): Added.
  • rendering/RenderBlockLineLayout.cpp: (WebCore::RenderBlock::findNextLineBreak):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85693 r85695  
     12011-05-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        findNextLineBreak splits InlineIterator into 3 pieces
     6        https://bugs.webkit.org/show_bug.cgi?id=60082
     7
     8        Avoid splitting InlineIterator into 3 variables with inter-dependencies.
     9
     10        * rendering/InlineIterator.h:
     11        (WebCore::InlineIterator::fastIncrementInTextNode): Added.
     12        (WebCore::InlineIterator::previousInSameNode): Added.
     13        * rendering/RenderBlockLineLayout.cpp:
     14        (WebCore::RenderBlock::findNextLineBreak):
     15
    1162011-05-03  Dean Jackson  <dino@apple.com>
    217
  • trunk/Source/WebCore/rendering/InlineIterator.h

    r84450 r85695  
    6666    RenderObject* root() const { return m_root; }
    6767
     68    void fastIncrementInTextNode();
    6869    void increment(InlineBidiResolver* = 0);
    6970    bool atEnd() const;
     
    8182
    8283    UChar current() const;
     84    UChar previousInSameNode() const;
    8385    ALWAYS_INLINE WTF::Unicode::Direction direction() const;
    8486
     
    237239}
    238240
     241inline void InlineIterator::fastIncrementInTextNode()
     242{
     243    ASSERT(m_obj);
     244    ASSERT(m_obj->isText());
     245    ASSERT(m_pos <= toRenderText(m_obj)->textLength());
     246    m_pos++;
     247}
     248
    239249inline void InlineIterator::increment(InlineBidiResolver* resolver)
    240250{
     
    242252        return;
    243253    if (m_obj->isText()) {
    244         m_pos++;
     254        fastIncrementInTextNode();
    245255        if (m_pos < toRenderText(m_obj)->textLength())
    246256            return;
     
    265275
    266276    return text->characters()[m_pos];
     277}
     278
     279inline UChar InlineIterator::previousInSameNode() const
     280{
     281    if (!m_obj || !m_obj->isText() || !m_pos)
     282        return 0;
     283
     284    RenderText* text = toRenderText(m_obj);
     285    return text->characters()[m_pos - 1];
    267286}
    268287
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r85685 r85695  
    18201820    // FIXME: It is error-prone to split the position object out like this.
    18211821    // Teach this code to work with objects instead of this split tuple.
    1822     RenderObject* o = resolver.position().m_obj;
    1823     RenderObject* last = o;
    1824     unsigned pos = resolver.position().m_pos;
    1825     int nextBreakable = resolver.position().m_nextBreakablePosition;
     1822    InlineIterator current = resolver.position();
     1823    RenderObject* last = current.m_obj;
    18261824    bool atStart = true;
    18271825
     
    18411839    EWhiteSpace currWS = style()->whiteSpace();
    18421840    EWhiteSpace lastWS = currWS;
    1843     while (o) {
    1844         RenderObject* next = bidiNext(this, o);
    1845 
    1846         currWS = o->isReplaced() ? o->parent()->style()->whiteSpace() : o->style()->whiteSpace();
     1841    while (current.m_obj) {
     1842        RenderObject* next = bidiNext(this, current.m_obj);
     1843
     1844        currWS = current.m_obj->isReplaced() ? current.m_obj->parent()->style()->whiteSpace() : current.m_obj->style()->whiteSpace();
    18471845        lastWS = last->isReplaced() ? last->parent()->style()->whiteSpace() : last->style()->whiteSpace();
    18481846
     
    18511849
    18521850#if ENABLE(SVG)
    1853         bool preserveNewline = o->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS);
     1851        bool preserveNewline = current.m_obj->isSVGInlineText() ? false : RenderStyle::preserveNewline(currWS);
    18541852#else
    18551853        bool preserveNewline = RenderStyle::preserveNewline(currWS);
     
    18581856        bool collapseWhiteSpace = RenderStyle::collapseWhiteSpace(currWS);
    18591857
    1860         if (o->isBR()) {
     1858        if (current.m_obj->isBR()) {
    18611859            if (width.fitsOnLine()) {
    1862                 lBreak.moveToStartOf(o);
     1860                lBreak.moveToStartOf(current.m_obj);
    18631861                lBreak.increment();
    18641862
     
    18741872
    18751873                if (!lineInfo.isEmpty() && clear)
    1876                     *clear = o->style()->clear();
     1874                    *clear = current.m_obj->style()->clear();
    18771875            }
    18781876            goto end;
    18791877        }
    18801878
    1881         if (o->isFloatingOrPositioned()) {
     1879        if (current.m_obj->isFloatingOrPositioned()) {
    18821880            // add to special objects...
    1883             if (o->isFloating()) {
    1884                 RenderBox* floatBox = toRenderBox(o);
     1881            if (current.m_obj->isFloating()) {
     1882                RenderBox* floatBox = toRenderBox(current.m_obj);
    18851883                FloatingObject* f = insertFloatingObject(floatBox);
    18861884                // check if it fits in the current line.
     
    18891887                if (floatsFitOnLine && width.fitsOnLine(logicalWidthForFloat(f))) {
    18901888                    positionNewFloatOnLine(f, lastFloatFromPreviousLine, width);
    1891                     if (lBreak.m_obj == o) {
     1889                    if (lBreak.m_obj == current.m_obj) {
    18921890                        ASSERT(!lBreak.m_pos);
    18931891                        lBreak.increment();
     
    18951893                } else
    18961894                    floatsFitOnLine = false;
    1897             } else if (o->isPositioned()) {
     1895            } else if (current.m_obj->isPositioned()) {
    18981896                // If our original display wasn't an inline type, then we can
    18991897                // go ahead and determine our static inline position now.
    1900                 RenderBox* box = toRenderBox(o);
     1898                RenderBox* box = toRenderBox(current.m_obj);
    19011899                bool isInlineType = box->style()->isOriginalDisplayInlineType();
    19021900                if (!isInlineType)
     
    19101908                // If we're ignoring spaces, we have to stop and include this object and
    19111909                // then start ignoring spaces again.
    1912                 if (isInlineType || o->container()->isRenderInline()) {
     1910                if (isInlineType || current.m_obj->container()->isRenderInline()) {
    19131911                    if (ignoringSpaces) {
    1914                         ignoreStart.m_obj = o;
     1912                        ignoreStart.m_obj = current.m_obj;
    19151913                        ignoreStart.m_pos = 0;
    19161914                        addMidpoint(lineMidpointState, ignoreStart); // Stop ignoring spaces.
     
    19211919                    positionedBoxes.append(box);
    19221920            }
    1923         } else if (o->isRenderInline()) {
     1921        } else if (current.m_obj->isRenderInline()) {
    19241922            // Right now, we should only encounter empty inlines here.
    1925             ASSERT(!o->firstChild());
    1926 
    1927             RenderInline* flowBox = toRenderInline(o);
     1923            ASSERT(!current.m_obj->firstChild());
     1924
     1925            RenderInline* flowBox = toRenderInline(current.m_obj);
    19281926
    19291927            // Now that some inline flows have line boxes, if we are already ignoring spaces, we need
     
    19351933                if (ignoringSpaces) {
    19361934                    trailingObjects.clear();
    1937                     addMidpoint(lineMidpointState, InlineIterator(0, o, 0)); // Stop ignoring spaces.
    1938                     addMidpoint(lineMidpointState, InlineIterator(0, o, 0)); // Start ignoring again.
    1939                 } else if (style()->collapseWhiteSpace() && resolver.position().m_obj == o
    1940                     && shouldSkipWhitespaceAfterStartObject(this, o, lineMidpointState)) {
     1935                    addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0)); // Stop ignoring spaces.
     1936                    addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0)); // Start ignoring again.
     1937                } else if (style()->collapseWhiteSpace() && resolver.position().m_obj == current.m_obj
     1938                    && shouldSkipWhitespaceAfterStartObject(this, current.m_obj, lineMidpointState)) {
    19411939                    // Like with list markers, we start ignoring spaces to make sure that any
    19421940                    // additional spaces we see will be discarded.
     
    19481946
    19491947            width.addUncommittedWidth(borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox));
    1950         } else if (o->isReplaced()) {
    1951             RenderBox* replacedBox = toRenderBox(o);
     1948        } else if (current.m_obj->isReplaced()) {
     1949            RenderBox* replacedBox = toRenderBox(current.m_obj);
    19521950
    19531951            // Break on replaced elements if either has normal white-space.
    1954             if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (!o->isImage() || allowImagesToBreak)) {
     1952            if ((autoWrap || RenderStyle::autoWrap(lastWS)) && (!current.m_obj->isImage() || allowImagesToBreak)) {
    19551953                width.commit();
    1956                 lBreak.moveToStartOf(o);
     1954                lBreak.moveToStartOf(current.m_obj);
    19571955            }
    19581956
    19591957            if (ignoringSpaces)
    1960                 addMidpoint(lineMidpointState, InlineIterator(0, o, 0));
     1958                addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, 0));
    19611959
    19621960            lineInfo.setEmpty(false);
     
    19681966            // Optimize for a common case. If we can't find whitespace after the list
    19691967            // item, then this is all moot.
    1970             int replacedLogicalWidth = logicalWidthForChild(replacedBox) + marginStartForChild(replacedBox) + marginEndForChild(replacedBox) + inlineLogicalWidth(o);
    1971             if (o->isListMarker()) {
    1972                 if (style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(this, o, lineMidpointState)) {
     1968            int replacedLogicalWidth = logicalWidthForChild(replacedBox) + marginStartForChild(replacedBox) + marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj);
     1969            if (current.m_obj->isListMarker()) {
     1970                if (style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(this, current.m_obj, lineMidpointState)) {
    19731971                    // Like with inline flows, we start ignoring spaces to make sure that any
    19741972                    // additional spaces we see will be discarded.
     
    19771975                    ignoringSpaces = true;
    19781976                }
    1979                 if (toRenderListMarker(o)->isInside())
     1977                if (toRenderListMarker(current.m_obj)->isInside())
    19801978                    width.addUncommittedWidth(replacedLogicalWidth);
    19811979            } else
    19821980                width.addUncommittedWidth(replacedLogicalWidth);
    1983             if (o->isRubyRun())
    1984                 width.applyOverhang(toRenderRubyRun(o), last, next);
    1985         } else if (o->isText()) {
    1986             if (!pos)
     1981            if (current.m_obj->isRubyRun())
     1982                width.applyOverhang(toRenderRubyRun(current.m_obj), last, next);
     1983        } else if (current.m_obj->isText()) {
     1984            if (!current.m_pos)
    19871985                appliedStartWidth = false;
    19881986
    1989             RenderText* t = toRenderText(o);
     1987            RenderText* t = toRenderText(current.m_obj);
    19901988
    19911989#if ENABLE(SVG)
     
    19941992
    19951993            RenderStyle* style = t->style(lineInfo.isFirstLine());
    1996             if (style->hasTextCombine() && o->isCombineText())
    1997                 toRenderCombineText(o)->combineText();
    1998 
    1999             int strlen = t->textLength();
    2000             int len = strlen - pos;
    2001             const UChar* str = t->characters();
     1994            if (style->hasTextCombine() && current.m_obj->isCombineText())
     1995                toRenderCombineText(current.m_obj)->combineText();
    20021996
    20031997            const Font& f = style->font();
     
    20051999            bool canHyphenate = style->hyphens() == HyphensAuto && WebCore::canHyphenate(style->locale());
    20062000
    2007             int lastSpace = pos;
    2008             float wordSpacing = o->style()->wordSpacing();
     2001            int lastSpace = current.m_pos;
     2002            float wordSpacing = current.m_obj->style()->wordSpacing();
    20092003            float lastSpaceWordSpacing = 0;
    20102004
     
    20132007            float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(TextRun(&space, 1)) + wordSpacing : 0;
    20142008
    2015             float wrapW = width.uncommittedWidth() + inlineLogicalWidth(o, !appliedStartWidth, true);
     2009            float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true);
    20162010            float charWidth = 0;
    2017             bool breakNBSP = autoWrap && o->style()->nbspMode() == SPACE;
     2011            bool breakNBSP = autoWrap && current.m_obj->style()->nbspMode() == SPACE;
    20182012            // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word,
    20192013            // which is only possible if the word is the first thing on the line, that is, if |w| is zero.
    2020             bool breakWords = o->style()->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE);
     2014            bool breakWords = current.m_obj->style()->breakWords() && ((autoWrap && !width.committedWidth()) || currWS == PRE);
    20212015            bool midWordBreak = false;
    2022             bool breakAll = o->style()->wordBreak() == BreakAllWordBreak && autoWrap;
     2016            bool breakAll = current.m_obj->style()->wordBreak() == BreakAllWordBreak && autoWrap;
    20232017            float hyphenWidth = 0;
    20242018
    20252019            if (t->isWordBreak()) {
    20262020                width.commit();
    2027                 lBreak.moveToStartOf(o);
    2028                 ASSERT(!len);
    2029             }
    2030 
    2031             while (len) {
     2021                lBreak.moveToStartOf(current.m_obj);
     2022                ASSERT(current.m_pos == t->textLength());
     2023            }
     2024
     2025            for (; current.m_pos < t->textLength(); current.fastIncrementInTextNode()) {
    20322026                bool previousCharacterIsSpace = currentCharacterIsSpace;
    20332027                bool previousCharacterIsWS = currentCharacterIsWS;
    2034                 UChar c = str[pos];
     2028                UChar c = current.current();
    20352029                currentCharacterIsSpace = c == ' ' || c == '\t' || (!preserveNewline && (c == '\n'));
    20362030
     
    20502044                if ((breakAll || breakWords) && !midWordBreak) {
    20512045                    wrapW += charWidth;
    2052                     charWidth = textWidth(t, pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
     2046                    charWidth = textWidth(t, current.m_pos, 1, f, width.committedWidth() + wrapW, isFixedPitch, collapseWhiteSpace);
    20532047                    midWordBreak = width.committedWidth() + wrapW + charWidth > width.availableWidth();
    20542048                }
     
    20562050                if (lineBreakIteratorInfo.first != t) {
    20572051                    lineBreakIteratorInfo.first = t;
    2058                     lineBreakIteratorInfo.second.reset(str, strlen);
     2052                    lineBreakIteratorInfo.second.reset(t->characters(), t->textLength());
    20592053                }
    20602054
    2061                 bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(lineBreakIteratorInfo.second, pos, nextBreakable, breakNBSP) && (style->hyphens() != HyphensNone || (pos && str[pos - 1] != softHyphen)));
     2055                bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(lineBreakIteratorInfo.second, current.m_pos, current.m_nextBreakablePosition, breakNBSP)
     2056                    && (style->hyphens() != HyphensNone || (current.previousInSameNode() != softHyphen)));
    20622057
    20632058                if (betweenWords || midWordBreak) {
     
    20692064                            ignoringSpaces = false;
    20702065                            lastSpaceWordSpacing = 0;
    2071                             lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
    2072                             addMidpoint(lineMidpointState, InlineIterator(0, o, pos));
     2066                            lastSpace = current.m_pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
     2067                            addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos));
    20732068                            stoppedIgnoringSpaces = true;
    20742069                        } else {
    20752070                            // Just keep ignoring these spaces.
    2076                             pos++;
    2077                             len--;
    20782071                            continue;
    20792072                        }
     
    20822075                    float additionalTmpW;
    20832076                    if (wordTrailingSpaceWidth && currentCharacterIsSpace)
    2084                         additionalTmpW = textWidth(t, lastSpace, pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) - wordTrailingSpaceWidth + lastSpaceWordSpacing;
     2077                        additionalTmpW = textWidth(t, lastSpace, current.m_pos + 1 - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) - wordTrailingSpaceWidth + lastSpaceWordSpacing;
    20852078                    else
    2086                         additionalTmpW = textWidth(t, lastSpace, pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
     2079                        additionalTmpW = textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
    20872080                    width.addUncommittedWidth(additionalTmpW);
    20882081                    if (!appliedStartWidth) {
    2089                         width.addUncommittedWidth(inlineLogicalWidth(o, true, false));
     2082                        width.addUncommittedWidth(inlineLogicalWidth(current.m_obj, true, false));
    20902083                        appliedStartWidth = true;
    20912084                    }
     
    21002093                        // as candidate width for this line.
    21012094                        bool lineWasTooWide = false;
    2102                         if (width.fitsOnLine() && currentCharacterIsWS && o->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) {
    2103                             float charWidth = textWidth(t, pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + (applyWordSpacing ? wordSpacing : 0);
     2095                        if (width.fitsOnLine() && currentCharacterIsWS && current.m_obj->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) {
     2096                            float charWidth = textWidth(t, current.m_pos, 1, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + (applyWordSpacing ? wordSpacing : 0);
    21042097                            // Check if line is too big even without the extra space
    21052098                            // at the end of the line. If it is not, do nothing.
     
    21092102                            if (!width.fitsOnLine(charWidth)) {
    21102103                                lineWasTooWide = true;
    2111                                 lBreak.moveTo(o, pos, nextBreakable);
     2104                                lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    21122105                                skipTrailingWhitespace(lBreak, lineInfo);
    21132106                            }
     
    21152108                        if (lineWasTooWide || !width.fitsOnLine()) {
    21162109                            if (canHyphenate && !width.fitsOnLine()) {
    2117                                 tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     2110                                tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, hyphenated);
    21182111                                if (hyphenated)
    21192112                                    goto end;
    21202113                            }
    21212114                            if (lBreak.atTextParagraphSeparator()) {
    2122                                 if (!stoppedIgnoringSpaces && pos > 0) {
     2115                                if (!stoppedIgnoringSpaces && current.m_pos > 0) {
    21232116                                    // We need to stop right before the newline and then start up again.
    2124                                     addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1)); // Stop
    2125                                     addMidpoint(lineMidpointState, InlineIterator(0, o, pos)); // Start
     2117                                    addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1)); // Stop
     2118                                    addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); // Start
    21262119                                }
    21272120                                lBreak.increment();
     
    21432136
    21442137                    if (c == '\n' && preserveNewline) {
    2145                         if (!stoppedIgnoringSpaces && pos > 0) {
     2138                        if (!stoppedIgnoringSpaces && current.m_pos > 0) {
    21462139                            // We need to stop right before the newline and then start up again.
    2147                             addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1)); // Stop
    2148                             addMidpoint(lineMidpointState, InlineIterator(0, o, pos)); // Start
     2140                            addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1)); // Stop
     2141                            addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos)); // Start
    21492142                        }
    2150                         lBreak.moveTo(o, pos, nextBreakable);
     2143                        lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    21512144                        lBreak.increment();
    21522145                        lineInfo.setPreviousLineBrokeCleanly(true);
     
    21572150                        width.commit();
    21582151                        wrapW = 0;
    2159                         lBreak.moveTo(o, pos, nextBreakable);
     2152                        lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    21602153                        // Auto-wrapping text should not wrap in the middle of a word once it has had an
    21612154                        // opportunity to break after a word.
     
    21662159                        // Remember this as a breakable position in case
    21672160                        // adding the end width forces a break.
    2168                         lBreak.moveTo(o, pos, nextBreakable);
     2161                        lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    21692162                        midWordBreak &= (breakWords || breakAll);
    21702163                    }
     
    21722165                    if (betweenWords) {
    21732166                        lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
    2174                         lastSpace = pos;
     2167                        lastSpace = current.m_pos;
    21752168                    }
    21762169
    2177                     if (!ignoringSpaces && o->style()->collapseWhiteSpace()) {
     2170                    if (!ignoringSpaces && current.m_obj->style()->collapseWhiteSpace()) {
    21782171                        // If we encounter a newline, or if we encounter a
    21792172                        // second space, we need to go ahead and break up this
     
    21932186                    ignoringSpaces = false;
    21942187                    lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
    2195                     lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
    2196                     addMidpoint(lineMidpointState, InlineIterator(0, o, pos));
     2188                    lastSpace = current.m_pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
     2189                    addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos));
    21972190                }
    21982191
    21992192#if ENABLE(SVG)
    2200                 if (isSVGText && pos > 0) {
     2193                if (isSVGText && current.m_pos > 0) {
    22012194                    // Force creation of new InlineBoxes for each absolute positioned character (those that start new text chunks).
    2202                     if (static_cast<RenderSVGInlineText*>(t)->characterStartsNewTextChunk(pos)) {
    2203                         addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1));
    2204                         addMidpoint(lineMidpointState, InlineIterator(0, o, pos));
     2195                    if (static_cast<RenderSVGInlineText*>(t)->characterStartsNewTextChunk(current.m_pos)) {
     2196                        addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1));
     2197                        addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos));
    22052198                    }
    22062199                }
     
    22082201
    22092202                if (currentCharacterIsSpace && !previousCharacterIsSpace) {
    2210                     ignoreStart.m_obj = o;
    2211                     ignoreStart.m_pos = pos;
     2203                    ignoreStart.m_obj = current.m_obj;
     2204                    ignoreStart.m_pos = current.m_pos;
    22122205                }
    22132206
    22142207                if (!currentCharacterIsWS && previousCharacterIsWS) {
    2215                     if (autoWrap && o->style()->breakOnlyAfterWhiteSpace())
    2216                         lBreak.moveTo(o, pos, nextBreakable);
     2208                    if (autoWrap && current.m_obj->style()->breakOnlyAfterWhiteSpace())
     2209                        lBreak.moveTo(current.m_obj, current.m_pos, current.m_nextBreakablePosition);
    22172210                }
    22182211
    22192212                if (collapseWhiteSpace && currentCharacterIsSpace && !ignoringSpaces)
    2220                     trailingObjects.setTrailingWhitespace(static_cast<RenderText*>(o));
    2221                 else if (!o->style()->collapseWhiteSpace() || !currentCharacterIsSpace)
     2213                    trailingObjects.setTrailingWhitespace(static_cast<RenderText*>(current.m_obj));
     2214                else if (!current.m_obj->style()->collapseWhiteSpace() || !currentCharacterIsSpace)
    22222215                    trailingObjects.clear();
    22232216
    2224                 pos++;
    2225                 len--;
    22262217                atStart = false;
    22272218            }
    22282219
    2229             // IMPORTANT: pos is > length here!
    2230             float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
    2231             width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(o, !appliedStartWidth, true));
     2220            // IMPORTANT: current.m_pos is > length here!
     2221            float additionalTmpW = ignoringSpaces ? 0 : textWidth(t, lastSpace, current.m_pos - lastSpace, f, width.currentWidth(), isFixedPitch, collapseWhiteSpace) + lastSpaceWordSpacing;
     2222            width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true));
    22322223
    22332224            if (!width.fitsOnLine()) {
    22342225                if (canHyphenate)
    2235                     tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, nextBreakable, hyphenated);
     2226                    tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, hyphenated);
    22362227
    22372228                if (!hyphenated && 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)
     
    22472238        if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && currWS == NOWRAP)
    22482239            checkForBreak = true;
    2249         else if (next && o->isText() && next->isText() && !next->isBR()) {
     2240        else if (next && current.m_obj->isText() && next->isText() && !next->isBR()) {
    22502241            if (autoWrap || (next->style()->autoWrap())) {
    22512242                if (currentCharacterIsSpace)
     
    22782269        if (checkForBreak && !width.fitsOnLine()) {
    22792270            // if we have floats, try to get below them.
    2280             if (currentCharacterIsSpace && !ignoringSpaces && o->style()->collapseWhiteSpace())
     2271            if (currentCharacterIsSpace && !ignoringSpaces && current.m_obj->style()->collapseWhiteSpace())
    22812272                trailingObjects.clear();
    22822273
     
    22932284        }
    22942285
    2295         if (!o->isFloatingOrPositioned()) {
    2296             last = o;
     2286        if (!current.m_obj->isFloatingOrPositioned()) {
     2287            last = current.m_obj;
    22972288            if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside())) {
    22982289                width.commit();
     
    23002291            }
    23012292        }
    2302 
    2303         o = next;
    2304         nextBreakable = -1;
    23052293
    23062294        // Clear out our character space bool, since inline <pre>s don't collapse whitespace
     
    23092297            currentCharacterIsSpace = false;
    23102298
    2311         pos = 0;
     2299        current.moveToStartOf(next);
    23122300        atStart = false;
    23132301    }
     
    23212309        if (style()->whiteSpace() == PRE) {
    23222310            // FIXME: Don't really understand this case.
    2323             if (pos != 0) {
     2311            if (current.m_pos) {
    23242312                // FIXME: This should call moveTo which would clear m_nextBreakablePosition
    23252313                // this code as-is is likely wrong.
    2326                 lBreak.m_obj = o;
    2327                 lBreak.m_pos = pos - 1;
     2314                lBreak.m_obj = current.m_obj;
     2315                lBreak.m_pos = current.m_pos - 1;
    23282316            } else
    23292317                lBreak.moveTo(last, last->isText() ? last->length() : 0);
     
    23322320            // There's no room at all. We just have to be on this line,
    23332321            // even though we'll spill out.
    2334             lBreak.moveTo(o, pos);
     2322            lBreak.moveTo(current.m_obj, current.m_pos);
    23352323        }
    23362324    }
Note: See TracChangeset for help on using the changeset viewer.