Title: [179976] branches/safari-600.5-branch

Diff

Modified: branches/safari-600.5-branch/LayoutTests/ChangeLog (179975 => 179976)


--- branches/safari-600.5-branch/LayoutTests/ChangeLog	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog	2015-02-12 01:46:51 UTC (rev 179976)
@@ -1,5 +1,21 @@
 2015-02-11  Lucas Forschler  <lforsch...@apple.com>
 
+        Merge r177377
+
+    2014-12-16  Myles C. Maxfield  <lithe...@gmail.com>
+
+            Ruby does not preserve expansion opportunities from enclosing context
+            https://bugs.webkit.org/show_bug.cgi?id=139618
+
+            Updating test for new expansion logic.
+
+            Reviewed by David Hyatt.
+
+            * fast/ruby/ruby-justification-expected.html:
+            * fast/ruby/ruby-justification.html:
+
+2015-02-11  Lucas Forschler  <lforsch...@apple.com>
+
         Merge r179706
 
     2015-02-05  Maciej Stachowiak  <m...@apple.com>

Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html (179975 => 179976)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html	2015-02-12 01:46:51 UTC (rev 179976)
@@ -9,7 +9,13 @@
 <div>
 abcdefg <ruby>abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 </div>
+<div>
+abcdefg <ruby>a<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 </div>
+<div>
+a<span style="background: green;">&#x685c;</span>b mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+</div>
 <div style="font-family: Ahem; font-size: 16px;">
 <ruby>abcdefg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 </div>

Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html (179975 => 179976)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html	2015-02-12 01:46:51 UTC (rev 179976)
@@ -9,6 +9,12 @@
 <div>
 <ruby>abcdefg abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 </div>
+<div>
+abcdefg <ruby>a<rt><span style="color: transparent;">aaaaaaaaaaaaaaaaaaaaaaa</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+a<ruby><rb style="background: green;">&#x685c;</rb><rt> </ruby>b mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
 <div style="font-family: Ahem;">
 <ruby>abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 </div>

Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/ChangeLog	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog	2015-02-12 01:46:51 UTC (rev 179976)
@@ -1,5 +1,66 @@
 2015-02-11  Lucas Forschler  <lforsch...@apple.com>
 
+        Merge r177377
+
+    2014-12-16  Myles C. Maxfield  <lithe...@gmail.com>
+
+            Ruby does not preserve expansion opportunities from enclosing context
+            https://bugs.webkit.org/show_bug.cgi?id=139618
+
+            Reviewed by David Hyatt.
+
+            There is currently no sharing of expansion opportunity information between
+            ruby bases and the text surrounding the ruby. This patch adds a bit on
+            RenderText, m_contentIsKnownToFollow, which affects how expansion
+            opportunities are handled at paint-time, as well as a bit on RenderRubyBase,
+            m_isAfterExpansion, which affects how expansions are calculated when laying
+            out a line. This patch also adds a field to RenderRubyBase which represents
+            the base's starting position within a ruby. This field is necessary because
+            an expansion from a line might occur at the very beginning of a ruby base,
+            so we have to remember some state from expansion time to RenderRubyBase
+            layout time.
+
+            Added more tests to fast/ruby/ruby-justification.html.
+
+            * rendering/InlineBox.h:
+            (WebCore::InlineBox::setExpansionWithoutGrowing):
+            (WebCore::InlineBox::expansion):
+            * rendering/InlineFlowBox.cpp:
+            (WebCore::InlineFlowBox::removeChild): Keep the bit on InlineTextBox up to
+            date.
+            (WebCore::InlineFlowBox::placeBoxRangeInInlineDirection): Set expansion
+            information in InlineFlowBoxes so the total expansion for a whole line
+            is held in the RootInlineBox's expansion.
+            * rendering/InlineTextBox.h:
+            (WebCore::InlineTextBox::expansionBehavior):
+            * rendering/RenderBlockFlow.h:
+            * rendering/RenderBlockLineLayout.cpp:
+            (WebCore::RenderBlockFlow::updateRubyForJustifiedText):
+            updateRubyForJustifiedText() had a bunch of problems with it. First of all,
+            it didn't actually set the InlineBoxes as dirty, so the second layout pass
+            sometimes wouldn't perform any updates. Secondarily, it didn't take
+            overhangs into account. Thirdly, it didn't mark the ruby base and text as
+            needing layout so that subsequent layouts would actually traverse into them.
+            (WebCore::RenderBlockFlow::computeExpansionForJustifiedText):
+            (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+            This nested if triangle is super nasty, but I'm not sure of a better way to
+            write it.
+            (WebCore::updateRubyForJustifiedText): Deleted.
+            (WebCore::computeExpansionForJustifiedText): Deleted.
+            * rendering/RenderRubyBase.cpp:
+            (WebCore::RenderRubyBase::RenderRubyBase):
+            (WebCore::RenderRubyBase::adjustInlineDirectionLineBounds):
+            * rendering/RenderRubyBase.h:
+            * rendering/RenderRubyRun.cpp:
+            (WebCore::RenderRubyRun::layout):
+            * rendering/RenderText.cpp:
+            (WebCore::RenderText::RenderText):
+            * rendering/RenderText.h:
+            (WebCore::RenderText::contentIsKnownToFollow):
+            (WebCore::RenderText::setContentIsKnownToFollow):
+
+2015-02-11  Lucas Forschler  <lforsch...@apple.com>
+
         Merge r179750
 
     2015-02-06  Maciej Stachowiak  <m...@apple.com>

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h	2015-02-12 01:46:51 UTC (rev 179976)
@@ -245,7 +245,7 @@
     void invalidateParentChildList();
 #endif
 
-    int expansion() const { return m_bitfields.expansion(); }
+    //int expansion() const { return m_bitfields.expansion(); }
 
     bool visibleToHitTesting() const { return renderer().style().visibility() == VISIBLE && renderer().style().pointerEvents() != PE_NONE; }
 
@@ -279,6 +279,12 @@
         m_bitfields.setExpansion(newExpansion);
         m_logicalWidth += m_bitfields.expansion();
     }
+    void setExpansionWithoutGrowing(float newExpansion)
+    {
+        ASSERT(!m_bitfields.expansion());
+        m_bitfields.setExpansion(newExpansion);
+    }
+    float expansion() const { return m_bitfields.expansion(); }
 
 private:
     InlineBox* m_next; // The next element on the same line as us.
@@ -416,7 +422,6 @@
     void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(hasHyphen); }    
     bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeadingExpansion(); }
     void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); }
-    int expansion() { return m_bitfields.expansion(); }
     
     // For InlineFlowBox and InlineTextBox
     bool extracted() const { return m_bitfields.extracted(); }

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp	2015-02-12 01:46:51 UTC (rev 179976)
@@ -179,6 +179,14 @@
     if (!isDirty())
         dirtyLineBoxes();
 
+    if (child->prevLeafChild() && child->prevLeafChild()->isInlineTextBox()) {
+        if (child->isInlineTextBox()) 
+            toInlineTextBox(child->prevLeafChild())->renderer().setContentIsKnownToFollow(toInlineTextBox(child)->renderer().contentIsKnownToFollow());
+        // FIXME: Handle the case where we remove the last inline box, and it's not a text box. If we're trying to share
+        // expansion opportunites both inside and outside a replaced element (such as for ruby bases), we need to search
+        // outside the current inline box tree to determine if there is content that follows the new last inline item.
+    }
+
     root().childRemoved(child);
 
     if (child == m_firstChild)
@@ -375,6 +383,7 @@
 
 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing)
 {
+    float totalExpansion = 0;
     for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
         if (curr->renderer().isText()) {
             InlineTextBox* text = toInlineTextBox(curr);
@@ -388,6 +397,7 @@
             if (knownToHaveNoOverflow())
                 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
             logicalLeft += text->logicalWidth();
+            totalExpansion += text->expansion();
             if (knownToHaveNoOverflow())
                 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
         } else {
@@ -407,6 +417,7 @@
                 if (knownToHaveNoOverflow())
                     minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
                 logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, needsWordSpacing);
+                totalExpansion += flow->expansion();
                 if (knownToHaveNoOverflow())
                     maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
                 logicalLeft += flow->marginLogicalRight();
@@ -429,6 +440,7 @@
             }
         }
     }
+    setExpansionWithoutGrowing(totalExpansion);
     return logicalLeft;
 }
 

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h	2015-02-12 01:46:51 UTC (rev 179976)
@@ -166,7 +166,7 @@
     TextRun::ExpansionBehavior expansionBehavior() const
     {
         return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : TextRun::ForbidLeadingExpansion)
-            | (expansion() && nextLeafChild() && !nextLeafChild()->isLineBreak() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
+            | (renderer().contentIsKnownToFollow() || (expansion() && nextLeafChild() && !nextLeafChild()->isLineBreak()) ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
     }
 
     void behavesLikeText() const = delete;

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h	2015-02-12 01:46:51 UTC (rev 179976)
@@ -552,6 +552,8 @@
     RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
     void setMarginsForRubyRun(BidiRun*, RenderRubyRun&, RenderObject*, const LineInfo&);
     void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&, WordMeasurements&);
+    void updateRubyForJustifiedText(RenderRubyRun&, BidiRun&, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, RenderObject* previousObject, const LineInfo&, size_t& expansionIndex);
+    void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth, const LineInfo&);
     BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const LineInfo&, ETextAlign, float& logicalLeft,
         float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache&, WordMeasurements&);
     void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-02-12 01:46:51 UTC (rev 179976)
@@ -540,7 +540,7 @@
     }
 }
 
-static inline void updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t& i)
+void RenderBlockFlow::updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, RenderObject* previousObject, const LineInfo& lineInfo, size_t& i)
 {
     if (!rubyRun.rubyBase() || !rubyRun.rubyBase()->firstRootBox() || rubyRun.rubyBase()->firstRootBox()->nextRootBox() || !r.renderer().style().collapseWhiteSpace())
         return;
@@ -563,26 +563,47 @@
 
     if (totalOpportunitiesInRun) {
         ASSERT(!rubyRun.hasOverrideWidth());
-        rubyRun.setOverrideLogicalContentWidth(rubyRun.logicalWidth() + totalExpansion);
+        float newBaseWidth = rubyRun.logicalWidth() + totalExpansion + marginStartForChild(rubyRun) + marginEndForChild(rubyRun);
+        float newRubyRunWidth = rubyRun.logicalWidth() + totalExpansion;
+        rubyBase.setInitialOffset((newRubyRunWidth - newBaseWidth) / 2);
+        rubyRun.setOverrideLogicalContentWidth(newRubyRunWidth);
         rubyRun.setNeedsLayout(MarkOnlyThis);
+        rootBox.markDirty();
+        if (RenderRubyText* rubyText = rubyRun.rubyText()) {
+            if (RootInlineBox* textRootBox = rubyText->firstRootBox())
+                textRootBox->markDirty();
+        }
         rubyRun.layoutBlock(true);
         rubyRun.clearOverrideLogicalContentWidth();
-        r.box()->setExpansion(totalExpansion);
+        setMarginsForRubyRun(&r, rubyRun, previousObject, lineInfo); // Expanding the base might mean there's less of a need for overhang
+        r.box()->setExpansion(newRubyRunWidth - r.box()->logicalWidth());
 
+        // This relayout caused the size of the RenderRubyText and the RenderRubyBase to change, dependent on the line's current expansion. Next time we relayout the
+        // RenderRubyRun, make sure that we relayout the RenderRubyBase and RenderRubyText as well.
+        rubyBase.setNeedsLayout(MarkOnlyThis);
+        if (RenderRubyText* rubyText = rubyRun.rubyText())
+            rubyText->setNeedsLayout(MarkOnlyThis);
+        if (rubyBase.lastLeafChild() && rubyBase.lastLeafChild()->isText() && r.box() && r.box()->nextLeafChild() && !r.box()->nextLeafChild()->isLineBreak())
+            toRenderText(rubyBase.lastLeafChild())->setContentIsKnownToFollow(true);
+
         totalLogicalWidth += totalExpansion;
         expansionOpportunityCount -= totalOpportunitiesInRun;
     }
 }
 
-static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth)
+void RenderBlockFlow::computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth, const LineInfo& lineInfo)
 {
     if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth)
         return;
 
+    RenderObject* previousObject = nullptr;
+
     size_t i = 0;
     for (BidiRun* r = firstRun; r; r = r->next()) {
-        if (!r->box() || r == trailingSpaceRun)
+        if (!r->box() || r == trailingSpaceRun) {
+            previousObject = &r->renderer();
             continue;
+        }
         
         if (r->renderer().isText()) {
             unsigned opportunitiesInRun = expansionOpportunities[i++];
@@ -598,8 +619,10 @@
             }
             expansionOpportunityCount -= opportunitiesInRun;
         } else if (r->renderer().isRubyRun())
-            updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
+            updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, previousObject, lineInfo, i);
 
+        previousObject = &r->renderer();
+
         if (!expansionOpportunityCount)
             break;
     }
@@ -699,7 +722,7 @@
     bool needsWordSpacing = false;
     float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth();
     unsigned expansionOpportunityCount = 0;
-    bool isAfterExpansion = true;
+    bool isAfterExpansion = this->isRubyBase() ? toRenderRubyBase(*this).isAfterExpansion() : true;
     Vector<unsigned, 16> expansionOpportunities;
     RenderObject* previousObject = 0;
 
@@ -735,6 +758,7 @@
             if (r->renderer().isRubyRun() && textAlign == JUSTIFY && r != trailingSpaceRun && toRenderRubyRun(r->renderer()).rubyBase()) {
                 auto* rubyBase = toRenderRubyRun(r->renderer()).rubyBase();
                 if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && r->renderer().style().collapseWhiteSpace()) {
+                    rubyBase->setIsAfterExpansion(isAfterExpansion);
                     for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
                         if (!leafChild->isInlineTextBox())
                             continue;
@@ -772,13 +796,28 @@
     }
 
     if (isAfterExpansion && !expansionOpportunities.isEmpty()) {
-        expansionOpportunities.last()--;
-        expansionOpportunityCount--;
+        bool shouldShareExpansionsWithContainingLine = true;
+        if (this->isRubyBase()) {
+            if (RenderRubyRun* rubyRun = toRenderRubyBase(*this).rubyRun()) {
+                if (RenderElement* rubyElement = rubyRun->parent()) {
+                    if (rubyElement->style().display() == INLINE) {
+                        if (RenderBlock* containingBlock = rubyElement->containingBlock()) {
+                            if (containingBlock->style().textAlign() == JUSTIFY)
+                                shouldShareExpansionsWithContainingLine = false;
+                        }
+                    }
+                }
+            }
+        }
+        if (shouldShareExpansionsWithContainingLine) {
+            expansionOpportunities.last()--;
+            expansionOpportunityCount--;
+        }
     }
 
     updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
 
-    computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
+    computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, lineInfo);
 
     return r;
 }

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp	2015-02-12 01:46:51 UTC (rev 179976)
@@ -38,6 +38,8 @@
 
 RenderRubyBase::RenderRubyBase(Document& document, PassRef<RenderStyle> style)
     : RenderBlockFlow(document, WTF::move(style))
+    , m_initialOffset(0)
+    , m_isAfterExpansion(true)
 {
     setInline(false);
 }
@@ -143,6 +145,12 @@
 
 void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
 {
+    if (rubyRun()->hasOverrideWidth() && firstRootBox() && !firstRootBox()->nextRootBox()) {
+        logicalLeft += m_initialOffset;
+        logicalWidth -= 2 * m_initialOffset;
+        return;
+    }
+
     LayoutUnit maxPreferredLogicalWidth = rubyRun() && rubyRun()->hasOverrideWidth() ? rubyRun()->overrideLogicalContentWidth() : this->maxPreferredLogicalWidth();
     if (maxPreferredLogicalWidth >= logicalWidth)
         return;

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h	2015-02-12 01:46:51 UTC (rev 179976)
@@ -50,6 +50,17 @@
 
     virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
 
+    void setIsAfterExpansion(bool isAfterExpansion) { m_isAfterExpansion = isAfterExpansion; }
+    bool isAfterExpansion() { return m_isAfterExpansion; }
+
+    void setInitialOffset(float initialOffset) { m_initialOffset = initialOffset; }
+
+    void reset()
+    {
+        m_initialOffset = 0;
+        m_isAfterExpansion = true;
+    }
+
 private:
     virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
     virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
@@ -62,6 +73,9 @@
 
     // Allow RenderRubyRun to manipulate the children within ruby bases.
     friend class RenderRubyRun;
+
+    float m_initialOffset;
+    unsigned m_isAfterExpansion : 1;
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderRubyBase, isRubyBase())

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp	2015-02-12 01:46:51 UTC (rev 179976)
@@ -233,6 +233,9 @@
 
 void RenderRubyRun::layout()
 {
+    if (RenderRubyBase* base = rubyBase())
+        base->reset();
+
     RenderBlockFlow::layout();
     
     RenderRubyText* rt = rubyText();

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp	2015-02-12 01:46:51 UTC (rev 179976)
@@ -163,6 +163,7 @@
     , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
     , m_useBackslashAsYenSymbol(false)
     , m_originalTextDiffersFromRendered(false)
+    , m_contentIsKnownToFollow(false)
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     , m_candidateComputedTextSize(0)
 #endif

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h (179975 => 179976)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h	2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h	2015-02-12 01:46:51 UTC (rev 179976)
@@ -156,6 +156,9 @@
     void deleteLineBoxesBeforeSimpleLineLayout();
     const SimpleLineLayout::Layout* simpleLineLayout() const;
 
+    bool contentIsKnownToFollow() { return m_contentIsKnownToFollow; }
+    void setContentIsKnownToFollow(bool contentIsKnownToFollow) { m_contentIsKnownToFollow = contentIsKnownToFollow; }
+
 protected:
     virtual void computePreferredLogicalWidths(float leadWidth);
     virtual void willBeDestroyed() override;
@@ -191,21 +194,22 @@
     void node() const = delete;
 
     // We put the bitfield first to minimize padding on 64-bit.
-    bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
-    bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
-    bool m_hasTab : 1; // Whether or not we have a variable width tab character (e.g., <pre> with '\t').
-    bool m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre)
-    bool m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre)
-    bool m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific
+    unsigned m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
+    unsigned m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
+    unsigned m_hasTab : 1; // Whether or not we have a variable width tab character (e.g., <pre> with '\t').
+    unsigned m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre)
+    unsigned m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre)
+    unsigned m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific
                            // line boxes, and this hint will enable layoutInlineChildren to avoid
                            // just dirtying everything when character data is modified (e.g., appended/inserted
                            // or removed).
-    bool m_containsReversedText : 1;
-    bool m_isAllASCII : 1;
-    bool m_canUseSimpleFontCodePath : 1;
-    mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
-    bool m_useBackslashAsYenSymbol : 1;
-    bool m_originalTextDiffersFromRendered : 1;
+    unsigned m_containsReversedText : 1;
+    unsigned m_isAllASCII : 1;
+    unsigned m_canUseSimpleFontCodePath : 1;
+    mutable unsigned m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
+    unsigned m_useBackslashAsYenSymbol : 1;
+    unsigned m_originalTextDiffersFromRendered : 1;
+    unsigned m_contentIsKnownToFollow : 1;
 
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     // FIXME: This should probably be part of the text sizing structures in Document instead. That would save some memory.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to