Title: [158834] trunk/Source/WebCore
Revision
158834
Author
[email protected]
Date
2013-11-07 02:12:36 -0800 (Thu, 07 Nov 2013)

Log Message

Clean up BidiRun a little bit.
<https://webkit.org/b/123964>

Make BidiRun's member variables private and add accessors for them.
In doing so, codify the following:

    - BidiRun always has a corresponding RenderObject.
    - The inline box is never cleared after being set.

Reviewed by Antti Koivisto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158833 => 158834)


--- trunk/Source/WebCore/ChangeLog	2013-11-07 10:11:43 UTC (rev 158833)
+++ trunk/Source/WebCore/ChangeLog	2013-11-07 10:12:36 UTC (rev 158834)
@@ -1,5 +1,18 @@
 2013-11-07  Andreas Kling  <[email protected]>
 
+        Clean up BidiRun a little bit.
+        <https://webkit.org/b/123964>
+
+        Make BidiRun's member variables private and add accessors for them.
+        In doing so, codify the following:
+
+            - BidiRun always has a corresponding RenderObject.
+            - The inline box is never cleared after being set.
+
+        Reviewed by Antti Koivisto.
+
+2013-11-07  Andreas Kling  <[email protected]>
+
         More CSSPrimitiveValue constructors should return PassRef.
         <https://webkit.org/b/123953>
 

Modified: trunk/Source/WebCore/rendering/BidiRun.cpp (158833 => 158834)


--- trunk/Source/WebCore/rendering/BidiRun.cpp	2013-11-07 10:11:43 UTC (rev 158833)
+++ trunk/Source/WebCore/rendering/BidiRun.cpp	2013-11-07 10:12:36 UTC (rev 158834)
@@ -33,15 +33,15 @@
 
 DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, bidiRunCounter, ("BidiRun"));
 
-BidiRun::BidiRun(int start, int stop, RenderObject* object, BidiContext* context, UCharDirection dir)
+BidiRun::BidiRun(int start, int stop, RenderObject& renderer, BidiContext* context, UCharDirection dir)
     : BidiCharacterRun(start, stop, context, dir)
-    , m_object(object)
-    , m_box(0)
+    , m_renderer(renderer)
+    , m_box(nullptr)
 {
 #ifndef NDEBUG
     bidiRunCounter.increment();
 #endif
-    ASSERT(!object->isText() || static_cast<unsigned>(stop) <= toRenderText(object)->textLength());
+    ASSERT(!m_renderer.isText() || static_cast<unsigned>(stop) <= toRenderText(m_renderer).textLength());
     // Stored in base class to save space.
     m_hasHyphen = false;
 #if ENABLE(CSS_SHAPES)

Modified: trunk/Source/WebCore/rendering/BidiRun.h (158833 => 158834)


--- trunk/Source/WebCore/rendering/BidiRun.h	2013-11-07 10:11:43 UTC (rev 158833)
+++ trunk/Source/WebCore/rendering/BidiRun.h	2013-11-07 10:12:36 UTC (rev 158834)
@@ -34,14 +34,16 @@
 class InlineBox;
 
 struct BidiRun : BidiCharacterRun {
-    BidiRun(int start, int stop, RenderObject*, BidiContext*, UCharDirection);
+    BidiRun(int start, int stop, RenderObject&, BidiContext*, UCharDirection);
     ~BidiRun();
 
     BidiRun* next() { return static_cast<BidiRun*>(m_next); }
-    RenderObject* object() { return m_object; }
+    RenderObject& renderer() { return m_renderer; }
+    InlineBox* box() { return m_box; }
+    void setBox(InlineBox& box) { m_box = &box; }
 
-public:
-    RenderObject* m_object;
+private:
+    RenderObject& m_renderer;
     InlineBox* m_box;
 };
 

Modified: trunk/Source/WebCore/rendering/InlineIterator.h (158833 => 158834)


--- trunk/Source/WebCore/rendering/InlineIterator.h	2013-11-07 10:11:43 UTC (rev 158833)
+++ trunk/Source/WebCore/rendering/InlineIterator.h	2013-11-07 10:12:36 UTC (rev 158834)
@@ -448,9 +448,8 @@
 
 // FIXME: This belongs on InlineBidiResolver, except it's a template specialization
 // of BidiResolver which knows nothing about RenderObjects.
-static inline void addPlaceholderRunForIsolatedInline(InlineBidiResolver& resolver, RenderObject* obj, unsigned pos)
+static inline void addPlaceholderRunForIsolatedInline(InlineBidiResolver& resolver, RenderObject& obj, unsigned pos)
 {
-    ASSERT(obj);
     BidiRun* isolatedRun = new BidiRun(pos, 0, obj, resolver.context(), resolver.dir());
     resolver.runs().addRun(isolatedRun);
     // FIXME: isolatedRuns() could be a hash of object->run and then we could cheaply
@@ -480,12 +479,12 @@
     void embed(UCharDirection, BidiEmbeddingSource) { }
     void commitExplicitEmbedding() { }
 
-    void addFakeRunIfNecessary(RenderObject* obj, unsigned pos, InlineBidiResolver& resolver)
+    void addFakeRunIfNecessary(RenderObject& obj, unsigned pos, InlineBidiResolver& resolver)
     {
         // We only need to add a fake run for a given isolated span once during each call to createBidiRunsForLine.
         // We'll be called for every span inside the isolated span so we just ignore subsequent calls.
         // We also avoid creating a fake run until we hit a child that warrants one, e.g. we skip floats.
-        if (m_haveAddedFakeRunForRootIsolate || RenderBlock::shouldSkipCreatingRunsForObject(obj))
+        if (m_haveAddedFakeRunForRootIsolate || RenderBlock::shouldSkipCreatingRunsForObject(&obj))
             return;
         m_haveAddedFakeRunForRootIsolate = true;
         // obj and pos together denote a single position in the inline, from which the parsing of the isolate will start.
@@ -496,7 +495,7 @@
         // For now, if we enter an isolate between midpoints, we increment our current midpoint or else
         // we'll leave the isolate and ignore the content that follows.
         MidpointState<InlineIterator>& midpointState = resolver.midpointState();
-        if (midpointState.betweenMidpoints && midpointState.midpoints[midpointState.currentMidpoint].object() == obj) {
+        if (midpointState.betweenMidpoints && midpointState.midpoints[midpointState.currentMidpoint].object() == &obj) {
             midpointState.betweenMidpoints = false;
             ++midpointState.currentMidpoint;
         }
@@ -519,7 +518,7 @@
         RenderObject* obj = m_sor.m_obj;
         while (obj && obj != m_eor.m_obj && obj != endOfLine.m_obj) {
             if (isolateTracker.inIsolate())
-                isolateTracker.addFakeRunIfNecessary(obj, start, *this);
+                isolateTracker.addFakeRunIfNecessary(*obj, start, *this);
             else
                 RenderBlockFlow::appendRunsForObject(m_runs, start, obj->length(), obj, *this);
             // FIXME: start/obj should be an InlineIterator instead of two separate variables.
@@ -535,7 +534,7 @@
             // It's OK to add runs for zero-length RenderObjects, just don't make the run larger than it should be
             int end = obj->length() ? pos + 1 : 0;
             if (isolateTracker.inIsolate())
-                isolateTracker.addFakeRunIfNecessary(obj, start, *this);
+                isolateTracker.addFakeRunIfNecessary(*obj, start, *this);
             else
                 RenderBlockFlow::appendRunsForObject(m_runs, start, end, obj, *this);
         }

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (158833 => 158834)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-07 10:11:43 UTC (rev 158833)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-07 10:12:36 UTC (rev 158834)
@@ -240,7 +240,8 @@
 
 static inline BidiRun* createRun(int start, int end, RenderObject* obj, InlineBidiResolver& resolver)
 {
-    return new BidiRun(start, end, obj, resolver.context(), resolver.dir());
+    ASSERT(obj);
+    return new BidiRun(start, end, *obj, resolver.context(), resolver.dir());
 }
 
 void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>& runs, int start, int end, RenderObject* obj, InlineBidiResolver& resolver)
@@ -440,17 +441,17 @@
     if (!run)
         return true;
     unsigned pos = run->stop();
-    RenderObject* r = run->m_object;
-    if (!r->isText())
+    const RenderObject& r = run->renderer();
+    if (!r.isText())
         return false;
-    RenderText* renderText = toRenderText(r);
-    unsigned length = renderText->textLength();
+    const RenderText& renderText = toRenderText(r);
+    unsigned length = renderText.textLength();
     if (pos >= length)
         return true;
 
-    if (renderText->is8Bit())
-        return endsWithASCIISpaces(renderText->characters8(), pos, length);
-    return endsWithASCIISpaces(renderText->characters16(), pos, length);
+    if (renderText.is8Bit())
+        return endsWithASCIISpaces(renderText.characters8(), pos, length);
+    return endsWithASCIISpaces(renderText.characters16(), pos, length);
 }
 
 RootInlineBox* RenderBlockFlow::constructLine(BidiRunList<BidiRun>& bidiRuns, const LineInfo& lineInfo)
@@ -463,19 +464,15 @@
     for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) {
         // Create a box for our object.
         bool isOnlyRun = (runCount == 1);
-        if (runCount == 2 && !r->m_object->isListMarker())
-            isOnlyRun = (!style().isLeftToRightDirection() ? bidiRuns.lastRun() : bidiRuns.firstRun())->m_object->isListMarker();
+        if (runCount == 2 && !r->renderer().isListMarker())
+            isOnlyRun = (!style().isLeftToRightDirection() ? bidiRuns.lastRun() : bidiRuns.firstRun())->renderer().isListMarker();
 
         if (lineInfo.isEmpty())
             continue;
 
-        InlineBox* box = createInlineBoxForRenderer(r->m_object, false, isOnlyRun);
-        r->m_box = box;
+        InlineBox* box = createInlineBoxForRenderer(&r->renderer(), false, isOnlyRun);
+        r->setBox(*box);
 
-        ASSERT(box);
-        if (!box)
-            continue;
-
         if (!rootHasSelectedChildren && box->renderer().selectionState() != RenderObject::SelectionNone)
             rootHasSelectedChildren = true;
 
@@ -488,15 +485,15 @@
 #else
         bool runStartsSegment = false;
 #endif
-        if (!parentBox || &parentBox->renderer() != r->m_object->parent() || runStartsSegment)
+        if (!parentBox || &parentBox->renderer() != r->renderer().parent() || runStartsSegment)
             // Create new inline boxes all the way back to the appropriate insertion point.
-            parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box, runStartsSegment);
+            parentBox = createLineBoxes(r->renderer().parent(), lineInfo, box, runStartsSegment);
         else {
             // Append the inline box to this line.
             parentBox->addToLine(box);
         }
 
-        bool visuallyOrdered = r->m_object->style().rtlOrdering() == VisualOrder;
+        bool visuallyOrdered = r->renderer().style().rtlOrdering() == VisualOrder;
         box->setBidiLevel(r->level());
 
         if (box->isInlineTextBox()) {
@@ -522,8 +519,8 @@
     // paint borders/margins/padding.  This knowledge will ultimately be used when
     // we determine the horizontal positions and widths of all the inline boxes on
     // the line.
-    bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->m_object && bidiRuns.logicallyLastRun()->m_object->isText() ? !reachedEndOfTextRenderer(bidiRuns) : true;
-    lastRootBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogicallyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object);
+    bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->renderer().isText() ? !reachedEndOfTextRenderer(bidiRuns) : true;
+    lastRootBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogicallyLastRunWrapped, &bidiRuns.logicallyLastRun()->renderer());
 
     // Now mark the line boxes as being constructed.
     lastRootBox()->setConstructed();
@@ -547,12 +544,12 @@
     // In particular with RTL blocks, wide lines should still spill out to the left.
     if (isLeftToRightDirection) {
         if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun)
-            trailingSpaceRun->m_box->setLogicalWidth(max<float>(0, trailingSpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth));
+            trailingSpaceRun->box()->setLogicalWidth(max<float>(0, trailingSpaceRun->box()->logicalWidth() - totalLogicalWidth + availableLogicalWidth));
         return;
     }
 
     if (trailingSpaceRun)
-        trailingSpaceRun->m_box->setLogicalWidth(0);
+        trailingSpaceRun->box()->setLogicalWidth(0);
     else if (totalLogicalWidth > availableLogicalWidth)
         logicalLeft -= (totalLogicalWidth - availableLogicalWidth);
 }
@@ -564,8 +561,8 @@
     // side of the block.
     if (isLeftToRightDirection) {
         if (trailingSpaceRun) {
-            totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
-            trailingSpaceRun->m_box->setLogicalWidth(0);
+            totalLogicalWidth -= trailingSpaceRun->box()->logicalWidth();
+            trailingSpaceRun->box()->setLogicalWidth(0);
         }
         if (totalLogicalWidth < availableLogicalWidth)
             logicalLeft += availableLogicalWidth - totalLogicalWidth;
@@ -573,8 +570,8 @@
     }
 
     if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) {
-        trailingSpaceRun->m_box->setLogicalWidth(max<float>(0, trailingSpaceRun->m_box->logicalWidth() - totalLogicalWidth + availableLogicalWidth));
-        totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
+        trailingSpaceRun->box()->setLogicalWidth(max<float>(0, trailingSpaceRun->box()->logicalWidth() - totalLogicalWidth + availableLogicalWidth));
+        totalLogicalWidth -= trailingSpaceRun->box()->logicalWidth();
     } else
         logicalLeft += availableLogicalWidth - totalLogicalWidth;
 }
@@ -583,9 +580,9 @@
 {
     float trailingSpaceWidth = 0;
     if (trailingSpaceRun) {
-        totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
-        trailingSpaceWidth = min(trailingSpaceRun->m_box->logicalWidth(), (availableLogicalWidth - totalLogicalWidth + 1) / 2);
-        trailingSpaceRun->m_box->setLogicalWidth(max<float>(0, trailingSpaceWidth));
+        totalLogicalWidth -= trailingSpaceRun->box()->logicalWidth();
+        trailingSpaceWidth = min(trailingSpaceRun->box()->logicalWidth(), (availableLogicalWidth - totalLogicalWidth + 1) / 2);
+        trailingSpaceRun->box()->setLogicalWidth(max<float>(0, trailingSpaceWidth));
     }
     if (isLeftToRightDirection)
         logicalLeft += max<float>((availableLogicalWidth - totalLogicalWidth) / 2, 0);
@@ -599,8 +596,8 @@
     int endOverhang;
     RenderObject* nextObject = 0;
     for (BidiRun* runWithNextObject = run->next(); runWithNextObject; runWithNextObject = runWithNextObject->next()) {
-        if (!runWithNextObject->m_object->isOutOfFlowPositioned() && !runWithNextObject->m_box->isLineBreak()) {
-            nextObject = runWithNextObject->m_object;
+        if (!runWithNextObject->renderer().isOutOfFlowPositioned() && !runWithNextObject->box()->isLineBreak()) {
+            nextObject = &runWithNextObject->renderer();
             break;
         }
     }
@@ -649,7 +646,7 @@
         // If we don't stick out of the root line's font box, then don't bother computing our glyph overflow. This optimization
         // will keep us from computing glyph bounds in nearly all cases.
         bool includeRootLine = lineBox->includesRootLineBoxFontOrLeading();
-        int baselineShift = lineBox->verticalPositionForBox(run->m_box, verticalPositionCache);
+        int baselineShift = lineBox->verticalPositionForBox(run->box(), verticalPositionCache);
         int rootDescent = includeRootLine ? font.fontMetrics().descent() : 0;
         int rootAscent = includeRootLine ? font.fontMetrics().ascent() : 0;
         int boxAscent = font.fontMetrics().ascent() - baselineShift;
@@ -659,7 +656,7 @@
     }
     
     LayoutUnit hyphenWidth = 0;
-    if (toInlineTextBox(run->m_box)->hasHyphen())
+    if (toInlineTextBox(run->box())->hasHyphen())
         hyphenWidth = measureHyphenWidth(renderer, font, &fallbackFonts);
 
     float measuredWidth = 0;
@@ -706,19 +703,19 @@
     if (!measuredWidth)
         measuredWidth = renderer->width(run->m_start, run->m_stop - run->m_start, xPos, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow);
 
-    run->m_box->setLogicalWidth(measuredWidth + hyphenWidth);
+    run->box()->setLogicalWidth(measuredWidth + hyphenWidth);
     if (!fallbackFonts.isEmpty()) {
-        ASSERT(run->m_box->behavesLikeText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
+        ASSERT(run->box()->behavesLikeText());
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->box()), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         ASSERT(it->value.first.isEmpty());
         copyToVector(fallbackFonts, it->value.first);
-        run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
+        run->box()->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
     }
     if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
-        ASSERT(run->m_box->behavesLikeText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
+        ASSERT(run->box()->behavesLikeText());
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->box()), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         it->value.second = glyphOverflow;
-        run->m_box->clearKnownToHaveNoOverflow();
+        run->box()->clearKnownToHaveNoOverflow();
     }
 }
 
@@ -734,17 +731,17 @@
         if (r->m_startsSegment)
             break;
 #endif
-        if (!r->m_box || r == trailingSpaceRun)
+        if (!r->box() || r == trailingSpaceRun)
             continue;
         
-        if (r->m_object->isText()) {
+        if (r->renderer().isText()) {
             unsigned opportunitiesInRun = expansionOpportunities[i++];
             
             ASSERT(opportunitiesInRun <= expansionOpportunityCount);
             
             // Only justify text if whitespace is collapsed.
-            if (r->m_object->style().collapseWhiteSpace()) {
-                InlineTextBox* textBox = toInlineTextBox(r->m_box);
+            if (r->renderer().style().collapseWhiteSpace()) {
+                InlineTextBox* textBox = toInlineTextBox(r->box());
                 int expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / expansionOpportunityCount;
                 textBox->setExpansion(expansion);
                 totalLogicalWidth += expansion;
@@ -779,8 +776,8 @@
         adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth);
         if (expansionOpportunityCount) {
             if (trailingSpaceRun) {
-                totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
-                trailingSpaceRun->m_box->setLogicalWidth(0);
+                totalLogicalWidth -= trailingSpaceRun->box()->logicalWidth();
+                trailingSpaceRun->box()->setLogicalWidth(0);
             }
             break;
         }
@@ -863,7 +860,7 @@
             availableLogicalWidth = logicalRight - logicalLeft;
             BidiRun* newSegmentStart = computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, logicalLeft, availableLogicalWidth, segmentStart, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements);
             needsWordSpacing = false;
-            endLogicalRight = lineBox->placeBoxRangeInInlineDirection(segmentStart->m_box, newSegmentStart ? newSegmentStart->m_box : 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing, textBoxDataMap);
+            endLogicalRight = lineBox->placeBoxRangeInInlineDirection(segmentStart->box(), newSegmentStart ? newSegmentStart->box() : 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing, textBoxDataMap);
             if (!newSegmentStart || !newSegmentStart->next())
                 break;
             ASSERT(newSegmentStart->m_startsSegment);
@@ -875,9 +872,9 @@
     }
 #endif
 
-    if (firstRun && firstRun->m_object->isReplaced()) {
-        RenderBox* renderBox = toRenderBox(firstRun->m_object);
-        updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, renderBox->logicalHeight());
+    if (firstRun && firstRun->renderer().isReplaced()) {
+        RenderBox& renderBox = toRenderBox(firstRun->renderer());
+        updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, renderBox.logicalHeight());
     }
 
     computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, lineLogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements);
@@ -906,44 +903,44 @@
         if (r->m_startsSegment)
             break;
 #endif
-        if (!r->m_box || r->m_object->isOutOfFlowPositioned() || r->m_box->isLineBreak())
+        if (!r->box() || r->renderer().isOutOfFlowPositioned() || r->box()->isLineBreak())
             continue; // Positioned objects are only participating to figure out their
                       // correct static x position.  They have no effect on the width.
                       // Similarly, line break boxes have no effect on the width.
-        if (r->m_object->isText()) {
-            RenderText* rt = toRenderText(r->m_object);
+        if (r->renderer().isText()) {
+            RenderText& rt = toRenderText(r->renderer());
             if (textAlign == JUSTIFY && r != trailingSpaceRun) {
                 if (!isAfterExpansion)
-                    toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true);
+                    toInlineTextBox(r->box())->setCanHaveLeadingExpansion(true);
                 unsigned opportunitiesInRun;
-                if (rt->is8Bit())
-                    opportunitiesInRun = Font::expansionOpportunityCount(rt->characters8() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), isAfterExpansion);
+                if (rt.is8Bit())
+                    opportunitiesInRun = Font::expansionOpportunityCount(rt.characters8() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
                 else
-                    opportunitiesInRun = Font::expansionOpportunityCount(rt->characters16() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), isAfterExpansion);
+                    opportunitiesInRun = Font::expansionOpportunityCount(rt.characters16() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
                 expansionOpportunities.append(opportunitiesInRun);
                 expansionOpportunityCount += opportunitiesInRun;
             }
 
-            if (int length = rt->textLength()) {
-                if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt->characterAt(r->m_start)))
-                    totalLogicalWidth += lineStyle(*rt->parent(), lineInfo).font().wordSpacing();
-                needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop - 1)) && r->m_stop == length;
+            if (int length = rt.textLength()) {
+                if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt.characterAt(r->m_start)))
+                    totalLogicalWidth += lineStyle(*rt.parent(), lineInfo).font().wordSpacing();
+                needsWordSpacing = !isSpaceOrNewline(rt.characterAt(r->m_stop - 1)) && r->m_stop == length;
             }
 
-            setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
+            setLogicalWidthForTextRun(lineBox, r, &rt, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
         } else {
             isAfterExpansion = false;
-            if (!r->m_object->isRenderInline()) {
-                RenderBox& renderBox = toRenderBox(*r->m_object);
+            if (!r->renderer().isRenderInline()) {
+                RenderBox& renderBox = toRenderBox(r->renderer());
                 if (renderBox.isRubyRun())
                     setMarginsForRubyRun(r, toRenderRubyRun(renderBox), previousObject, lineInfo);
-                r->m_box->setLogicalWidth(logicalWidthForChild(renderBox));
+                r->box()->setLogicalWidth(logicalWidthForChild(renderBox));
                 totalLogicalWidth += marginStartForChild(renderBox) + marginEndForChild(renderBox);
             }
         }
 
-        totalLogicalWidth += r->m_box->logicalWidth();
-        previousObject = r->m_object;
+        totalLogicalWidth += r->box()->logicalWidth();
+        previousObject = &r->renderer();
     }
 
     if (isAfterExpansion && !expansionOpportunities.isEmpty()) {
@@ -965,37 +962,37 @@
 
     // Now make sure we place replaced render objects correctly.
     for (BidiRun* r = firstRun; r; r = r->next()) {
-        ASSERT(r->m_box);
-        if (!r->m_box)
+        ASSERT(r->box());
+        if (!r->box())
             continue; // Skip runs with no line boxes.
 
         // Align positioned boxes with the top of the line box.  This is
         // a reasonable approximation of an appropriate y position.
-        if (r->m_object->isOutOfFlowPositioned())
-            r->m_box->setLogicalTop(logicalHeight());
+        if (r->renderer().isOutOfFlowPositioned())
+            r->box()->setLogicalTop(logicalHeight());
 
         // Position is used to properly position both replaced elements and
         // to update the static normal flow x/y of positioned elements.
-        if (r->m_object->isText())
-            toRenderText(r->m_object)->positionLineBox(r->m_box);
-        else if (r->m_object->isBox())
-            toRenderBox(r->m_object)->positionLineBox(r->m_box);
-        else if (r->m_object->isLineBreak())
-            toRenderLineBreak(r->m_object)->replaceInlineBoxWrapper(r->m_box);
+        if (r->renderer().isText())
+            toRenderText(r->renderer()).positionLineBox(r->box());
+        else if (r->renderer().isBox())
+            toRenderBox(r->renderer()).positionLineBox(r->box());
+        else if (r->renderer().isLineBreak())
+            toRenderLineBreak(r->renderer()).replaceInlineBoxWrapper(r->box());
     }
     // Positioned objects and zero-length text nodes destroy their boxes in
     // position(), which unnecessarily dirties the line.
     lineBox->markDirty(false);
 }
 
-static inline bool isCollapsibleSpace(UChar character, RenderText* renderer)
+static inline bool isCollapsibleSpace(UChar character, const RenderText& renderer)
 {
     if (character == ' ' || character == '\t' || character == softHyphen)
         return true;
     if (character == '\n')
-        return !renderer->style().preserveNewline();
+        return !renderer.style().preserveNewline();
     if (character == noBreakSpace)
-        return renderer->style().nbspMode() == SPACE;
+        return renderer.style().nbspMode() == SPACE;
     return false;
 }
 
@@ -1018,7 +1015,7 @@
 }
 
 template <typename CharacterType>
-static inline int findFirstTrailingSpace(RenderText* lastText, const CharacterType* characters, int start, int stop)
+static inline int findFirstTrailingSpace(const RenderText& lastText, const CharacterType* characters, int start, int stop)
 {
     int firstSpace = stop;
     while (firstSpace > start) {
@@ -1034,21 +1031,21 @@
 inline BidiRun* RenderBlockFlow::handleTrailingSpaces(BidiRunList<BidiRun>& bidiRuns, BidiContext* currentContext)
 {
     if (!bidiRuns.runCount()
-        || !bidiRuns.logicallyLastRun()->m_object->style().breakOnlyAfterWhiteSpace()
-        || !bidiRuns.logicallyLastRun()->m_object->style().autoWrap())
+        || !bidiRuns.logicallyLastRun()->renderer().style().breakOnlyAfterWhiteSpace()
+        || !bidiRuns.logicallyLastRun()->renderer().style().autoWrap())
         return 0;
 
     BidiRun* trailingSpaceRun = bidiRuns.logicallyLastRun();
-    RenderObject* lastObject = trailingSpaceRun->m_object;
-    if (!lastObject->isText())
+    const RenderObject& lastObject = trailingSpaceRun->renderer();
+    if (!lastObject.isText())
         return 0;
 
-    RenderText* lastText = toRenderText(lastObject);
+    const RenderText& lastText = toRenderText(lastObject);
     int firstSpace;
-    if (lastText->is8Bit())
-        firstSpace = findFirstTrailingSpace(lastText, lastText->characters8(), trailingSpaceRun->start(), trailingSpaceRun->stop());
+    if (lastText.is8Bit())
+        firstSpace = findFirstTrailingSpace(lastText, lastText.characters8(), trailingSpaceRun->start(), trailingSpaceRun->stop());
     else
-        firstSpace = findFirstTrailingSpace(lastText, lastText->characters16(), trailingSpaceRun->start(), trailingSpaceRun->stop());
+        firstSpace = findFirstTrailingSpace(lastText, lastText.characters16(), trailingSpaceRun->start(), trailingSpaceRun->stop());
 
     if (firstSpace == trailingSpaceRun->stop())
         return 0;
@@ -1060,7 +1057,7 @@
         while (BidiContext* parent = baseContext->parent())
             baseContext = parent;
 
-        BidiRun* newTrailingRun = new BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->m_object, baseContext, U_OTHER_NEUTRAL);
+        BidiRun* newTrailingRun = new BidiRun(firstSpace, trailingSpaceRun->m_stop, trailingSpaceRun->renderer(), baseContext, U_OTHER_NEUTRAL);
         trailingSpaceRun->m_stop = firstSpace;
         if (direction == LTR)
             bidiRuns.addRun(newTrailingRun);
@@ -1114,19 +1111,19 @@
         BidiRun* isolatedRun = topResolver.isolatedRuns().last();
         topResolver.isolatedRuns().removeLast();
 
-        RenderObject* startObj = isolatedRun->object();
+        RenderObject& startObj = isolatedRun->renderer();
 
         // Only inlines make sense with unicode-bidi: isolate (blocks are already isolated).
         // FIXME: Because enterIsolate is not passed a RenderObject, we have to crawl up the
         // tree to see which parent inline is the isolate. We could change enterIsolate
         // to take a RenderObject and do this logic there, but that would be a layering
         // violation for BidiResolver (which knows nothing about RenderObject).
-        RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj, currentRoot));
+        RenderInline* isolatedInline = toRenderInline(containingIsolate(&startObj, currentRoot));
         InlineBidiResolver isolatedResolver;
         EUnicodeBidi unicodeBidi = isolatedInline->style().unicodeBidi();
         TextDirection direction;
         if (unicodeBidi == Plaintext)
-            determineDirectionality(direction, InlineIterator(isolatedInline, isolatedRun->object(), 0));
+            determineDirectionality(direction, InlineIterator(isolatedInline, &isolatedRun->renderer(), 0));
         else {
             ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride);
             direction = isolatedInline->style().direction();
@@ -1141,7 +1138,7 @@
         // The starting position is the beginning of the first run within the isolate that was identified
         // during the earlier call to createBidiRunsForLine. This can be but is not necessarily the
         // first run within the isolate.
-        InlineIterator iter = InlineIterator(isolatedInline, startObj, isolatedRun->m_start);
+        InlineIterator iter = InlineIterator(isolatedInline, &startObj, isolatedRun->m_start);
         isolatedResolver.setPositionIgnoringNestedIsolates(iter);
 
         // We stop at the next end of line; we may re-enter this isolate in the next call to constructBidiRuns().
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to