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

Diff

Modified: branches/safari-600.5-branch/LayoutTests/ChangeLog (179028 => 179029)


--- branches/safari-600.5-branch/LayoutTests/ChangeLog	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog	2015-01-23 23:04:58 UTC (rev 179029)
@@ -1,3 +1,27 @@
+2015-01-23  Dana Burkart  <dburk...@apple.com>
+
+        Merged r174489. <rdar://problem/19452129>
+
+    2014-10-08  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+            Inline ruby does not get justified correctly
+            https://bugs.webkit.org/show_bug.cgi?id=137421
+
+            Reviewed by Dave Hyatt.
+
+            Test that ruby gets spaces inside the ruby base, and that hit testing the
+            ruby base gives us correct answers.
+
+            * fast/ruby/ruby-justification-expected.html: Added.
+            * fast/ruby/ruby-justification-hittest-expected.txt: Added.
+            * fast/ruby/ruby-justification-hittest.html: Added.
+            * fast/ruby/ruby-justification.html: Added.
+            * platform/mac/fast/ruby/bopomofo-rl-expected.txt: Ruby text gets the CSS
+            property text-align: justify, which worked prior to this patch. However, this
+            patch now justifies ruby bases, so now if there is text that is both a ruby
+            base and ruby text (such as ruby in ruby) it correctly gets justified. This
+            test does such, and therefore needs to be rebaselined.
+
 2015-01-22  Matthew Hanson  <matthew_han...@apple.com>
 
         Merge r175264. rdar://problem/19451378

Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-expected.html) (0 => 179029)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html	                        (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html	2015-01-23 23:04:58 UTC (rev 179029)
@@ -0,0 +1,21 @@
+This test makes sure that ruby inside text-align: justify has its contents justified.
+<div style="text-align: justify; font-size: 16px;">
+<div>
+abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+abcdefg abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+abcdefg <ruby>abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg 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>
+<div style="text-align: right;">
+a
+</div>
+<div style="text-align: justify;">
+abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>

Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt) (0 => 179029)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt	                        (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt	2015-01-23 23:04:58 UTC (rev 179029)
@@ -0,0 +1,11 @@
+This test makes sure that hit testing works with ruby inside text-align: justify.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS right is 792
+PASS document.elementFromPoint(right - 1, bottom - 1).id is "ruby"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+abcdefg abcdefga mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-hittest.html) (0 => 179029)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html	                        (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html	2015-01-23 23:04:58 UTC (rev 179029)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div style="text-align: justify; font-family: Ahem;">
+<ruby id="ruby">abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<script>
+description("This test makes sure that hit testing works with ruby inside text-align: justify.");
+var ruby = document.getElementById("ruby");
+var boundingRect = ruby.getBoundingClientRect();
+var right = boundingRect.right;
+var bottom = boundingRect.bottom;
+shouldBe("right", "792");
+shouldBeEqualToString("document.elementFromPoint(right - 1, bottom - 1).id", "ruby");
+</script>
+<script src=""
+</body>
+</html>

Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification.html) (0 => 179029)


--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html	                        (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html	2015-01-23 23:04:58 UTC (rev 179029)
@@ -0,0 +1,18 @@
+This test makes sure that ruby inside text-align: justify has its contents justified.
+<div style="text-align: justify; font-size: 16px;">
+<div>
+<ruby>abcdefg abcdefg<rt> </ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt> </ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div style="font-family: Ahem;">
+<ruby>abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt style="text-align: right; font-size: 16px;">a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+</div>

Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (179028 => 179029)


--- branches/safari-600.5-branch/Source/WebCore/ChangeLog	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog	2015-01-23 23:04:58 UTC (rev 179029)
@@ -1,3 +1,38 @@
+2015-01-23  Dana Burkart  <dburk...@apple.com>
+
+        Merged r174489. <rdar://problem/19452129>
+
+    2014-10-08  Myles C. Maxfield  <lithe...@gmail.com>
+
+            Inline ruby does not get justified correctly
+            https://bugs.webkit.org/show_bug.cgi?id=137421
+
+            Reviewed by Dave Hyatt.
+
+            We justify text in two passes: one counts expansion opportunities within a line,
+            and the other doles out widths and expansion amounts to constituent inline boxes.
+            This patch simply modifies both passes to descend into ruby bases. Once it has
+            done so, we then re-layout the ruby run with the newly found width.
+
+            Tests: fast/ruby/ruby-justification-hittest.html
+                   fast/ruby/ruby-justification.html
+
+            * rendering/InlineBox.h:
+            (WebCore::InlineBox::setExpansion): updateRubyForJustifiedText() has to set the
+            expansion for an inline box, so make setExpansion() public.
+            * rendering/RenderBlockLineLayout.cpp:
+            (WebCore::updateRubyForJustifiedText): Given values that have already been
+            computed in computeInlineDirectionPositionsForSegment(), adjust the widths and
+            expansion values for all the various pieces of ruby.
+            (WebCore::computeExpansionForJustifiedText): Call updateRubyForJustifiedText() if
+            necessary.
+            (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment): When
+            counting expansion opportunities in a line, include ruby bases.
+            * rendering/RenderRubyRun.h: Fix grammar in comment.
+            * rendering/RenderText.cpp:
+            (WebCore::RenderText::stringView): Give default arguments to function.
+            * rendering/RenderText.h: Ditto.
+
 2015-01-22  Dana Burkart  <dburk...@apple.com>
 
         Merged r178967. <rdar://problem/19572776>

Modified: branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h (179028 => 179029)


--- branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h	2015-01-23 23:04:58 UTC (rev 179029)
@@ -201,6 +201,9 @@
     static bool isCJKIdeograph(UChar32);
     static bool isCJKIdeographOrSymbol(UChar32);
 
+    // BEWARE: If isAfterExpansion is true after this function call, then the returned value includes a trailing opportunity
+    // which may or may not actually be present. RenderBlockFlow::computeInlineDirectionPositionsForSegment() compensates
+    // for this by decrementing the returned value if isAfterExpansion is true at the end of a line.
     static unsigned expansionOpportunityCount(const LChar*, size_t length, TextDirection, bool& isAfterExpansion);
     static unsigned expansionOpportunityCount(const UChar*, size_t length, TextDirection, bool& isAfterExpansion);
 

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


--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h	2015-01-23 23:04:58 UTC (rev 179029)
@@ -271,6 +271,13 @@
     bool dirOverride() const { return m_bitfields.dirOverride(); }
     void setDirOverride(bool dirOverride) { m_bitfields.setDirOverride(dirOverride); }
 
+    void setExpansion(float newExpansion)
+    {
+        m_logicalWidth -= m_bitfields.expansion();
+        m_bitfields.setExpansion(newExpansion);
+        m_logicalWidth += m_bitfields.expansion();
+    }
+
 private:
     InlineBox* m_next; // The next element on the same line as us.
     InlineBox* m_prev; // The previous element on the same line as us.
@@ -408,7 +415,6 @@
     bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeadingExpansion(); }
     void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); }
     int expansion() { return m_bitfields.expansion(); }
-    void setExpansion(int expansion) { m_bitfields.setExpansion(expansion); }
     
     // For InlineFlowBox and InlineTextBox
     bool extracted() const { return m_bitfields.extracted(); }

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


--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h	2015-01-23 23:04:58 UTC (rev 179029)
@@ -133,13 +133,6 @@
 public:
     virtual bool isLineBreak() const override final;
 
-    void setExpansion(int newExpansion)
-    {
-        m_logicalWidth -= expansion();
-        InlineBox::setExpansion(newExpansion);
-        m_logicalWidth += newExpansion;
-    }
-
 private:
     virtual bool isInlineTextBox() const override final { return true; }
 

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


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2015-01-23 23:04:58 UTC (rev 179029)
@@ -38,6 +38,8 @@
 #include "RenderFlowThread.h"
 #include "RenderLineBreak.h"
 #include "RenderRegion.h"
+#include "RenderRubyBase.h"
+#include "RenderRubyText.h"
 #include "RenderView.h"
 #include "SVGRootInlineBox.h"
 #include "Settings.h"
@@ -538,8 +540,42 @@
     }
 }
 
-static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth)
+static inline void updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t& i)
 {
+    if (!rubyRun.rubyBase() || !rubyRun.rubyBase()->firstRootBox() || rubyRun.rubyBase()->firstRootBox()->nextRootBox() || !r.renderer().style().collapseWhiteSpace())
+        return;
+
+    auto& rubyBase = *rubyRun.rubyBase();
+    auto& rootBox = *rubyBase.firstRootBox();
+
+    float totalExpansion = 0;
+    unsigned totalOpportunitiesInRun = 0;
+    for (auto* leafChild = rootBox.firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
+        if (!leafChild->isInlineTextBox())
+            continue;
+
+        unsigned opportunitiesInRun = expansionOpportunities[i++];
+        ASSERT(opportunitiesInRun <= expansionOpportunityCount);
+        auto expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / expansionOpportunityCount;
+        totalExpansion += expansion;
+        totalOpportunitiesInRun += opportunitiesInRun;
+    }
+
+    if (totalOpportunitiesInRun) {
+        ASSERT(!rubyRun.hasOverrideWidth());
+        rubyRun.setOverrideLogicalContentWidth(rubyRun.logicalWidth() + totalExpansion);
+        rubyRun.setNeedsLayout(MarkOnlyThis);
+        rubyRun.layoutBlock(true);
+        rubyRun.clearOverrideLogicalContentWidth();
+        r.box()->setExpansion(totalExpansion);
+
+        totalLogicalWidth += totalExpansion;
+        expansionOpportunityCount -= totalOpportunitiesInRun;
+    }
+}
+
+static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth)
+{
     if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth)
         return;
 
@@ -561,9 +597,11 @@
                 totalLogicalWidth += expansion;
             }
             expansionOpportunityCount -= opportunitiesInRun;
-            if (!expansionOpportunityCount)
-                break;
-        }
+        } else if (r->renderer().isRubyRun())
+            updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
+
+        if (!expansionOpportunityCount)
+            break;
     }
 }
 
@@ -693,7 +731,33 @@
 
             setLogicalWidthForTextRun(lineBox, r, &rt, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
         } else {
-            isAfterExpansion = false;
+            bool encounteredJustifiedRuby = false;
+            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()) {
+                    for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
+                        if (!leafChild->isInlineTextBox())
+                            continue;
+                        if (!isAfterExpansion)
+                            toInlineTextBox(leafChild)->setCanHaveLeadingExpansion(true);
+                        encounteredJustifiedRuby = true;
+                        RenderText& renderText = toRenderText(leafChild->renderer());
+
+                        unsigned opportunitiesInRun;
+                        if (renderText.is8Bit())
+                            opportunitiesInRun = Font::expansionOpportunityCount(renderText.characters8() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
+                        else
+                            opportunitiesInRun = Font::expansionOpportunityCount(renderText.characters16() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
+
+                        expansionOpportunities.append(opportunitiesInRun);
+                        expansionOpportunityCount += opportunitiesInRun;
+                    }
+                }
+            }
+
+            if (!encounteredJustifiedRuby)
+                isAfterExpansion = false;
+
             if (!r->renderer().isRenderInline()) {
                 RenderBox& renderBox = toRenderBox(r->renderer());
                 if (renderBox.isRubyRun())

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp (179028 => 179029)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp	2015-01-23 23:04:58 UTC (rev 179029)
@@ -2283,7 +2283,7 @@
     // width.  Use the width from the style context.
     // FIXME: Account for block-flow in flexible boxes.
     // https://bugs.webkit.org/show_bug.cgi?id=46418
-    if (hasOverrideWidth() && (style().borderFit() == BorderFitLines || parent()->isFlexibleBoxIncludingDeprecated())) {
+    if (hasOverrideWidth() && (isRubyRun() || style().borderFit() == BorderFitLines || parent()->isFlexibleBoxIncludingDeprecated())) {
         computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddingLogicalWidth();
         return;
     }

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


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp	2015-01-23 23:04:58 UTC (rev 179029)
@@ -143,7 +143,7 @@
 
 void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
 {
-    int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth();
+    LayoutUnit maxPreferredLogicalWidth = rubyRun() && rubyRun()->hasOverrideWidth() ? rubyRun()->overrideLogicalContentWidth() : this->maxPreferredLogicalWidth();
     if (maxPreferredLogicalWidth >= logicalWidth)
         return;
 

Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h (179028 => 179029)


--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h	2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h	2015-01-23 23:04:58 UTC (rev 179029)
@@ -38,7 +38,7 @@
 class RenderRubyBase;
 class RenderRubyText;
 
-// RenderRubyRun are 'inline-block/table' like objects,and wrap a single pairing of a ruby base with its ruby text(s).
+// RenderRubyRuns are 'inline-block/table' like objects, and wrap a single pairing of a ruby base with its ruby text(s).
 // See RenderRuby.h for further comments on the structure
 
 class RenderRubyRun final : public RenderBlockFlow {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to