https://bugs.webkit.org/show_bug.cgi?id=141732
Reviewed by David Hyatt.
Source/WebCore:
After we re-layout RenderRubyRuns, this can change the environment upon which
ruby's overhang calculation is sensitive to. Before this patch, we would recalculate
the overhang after the RenderRubyRun gets relaid out. However, doing such causes the
effective width of the RenderRubyRun to change, which causes out subsequent
justification calculations to be off.
Therefore, we have a cycle; the amount of ruby overhang can change the justification
in a line, and the layout of the line affects the ruby overhang calculation. Instead
of performing a layout in a loop until it converges, this patch simply observes that
having a flush right edge is more valuable than having a perfectly correct overhang.
It therefore simply removes the secondary overhang calculation.
Test: fast/text/ruby-justification-flush.html
* rendering/RenderBlockFlow.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::updateRubyForJustifiedText):
(WebCore::RenderBlockFlow::computeExpansionForJustifiedText):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
LayoutTests:
Make sure that the right edge of a justified ruby line matches up with
the same line without ruby.
* fast/text/ruby-justification-flush-expected.html: Added.
* fast/text/ruby-justification-flush.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180278
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-02-18 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Justified ruby can cause lines to grow beyond their container
+ https://bugs.webkit.org/show_bug.cgi?id=141732
+
+ Reviewed by David Hyatt.
+
+ Make sure that the right edge of a justified ruby line matches up with
+ the same line without ruby.
+
+ * fast/text/ruby-justification-flush-expected.html: Added.
+ * fast/text/ruby-justification-flush.html: Added.
+
2015-02-18 Eric Carlson <eric.carlson@apple.com>
[iOS] pause video when a tab moves to the background on some devices
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<style>
+#outer {
+ position: absolute;
+ width: 500px;
+ height: 500px;
+ overflow: hidden;
+}
+
+#inner {
+ font-size: 127px;
+ text-align: justify;
+ position: absolute;
+ bottom: 0px;
+ left: 73px;
+ width: 1200px;
+ font-family: Ahem;
+}
+</style>
+</head>
+<body>
+This test makes sure that ruby overhangs don't make text grow beyond the bound of the enclosing box.
+At the bottom left of this page, there are two black squares on top of each other. This test passes if the two squares are exactly vertically aligned.
+<div id="outer"><div id="inner">a<br>a<br> </div></div>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<style>
+#outer {
+ position: absolute;
+ width: 500px;
+ height: 500px;
+ overflow: hidden;
+}
+
+#inner {
+ font-size: 127px;
+ text-align: justify;
+ position: absolute;
+ bottom: 0px;
+ left: -1000px;
+ width: 1200px;
+ font-family: Ahem;
+}
+</style>
+</head>
+<body>
+This test makes sure that ruby overhangs don't make text grow beyond the bound of the enclosing box.
+At the bottom left of this page, there are two black squares on top of each other. This test passes if the two squares are exactly vertically aligned.
+<div id="outer"><div id="inner">a<ruby> a <rt>aaaa</rt> a <rt>aaaa</rt></ruby>a a a a a a a a</div></div>
+</body>
+</html>
+2015-02-18 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Justified ruby can cause lines to grow beyond their container
+ https://bugs.webkit.org/show_bug.cgi?id=141732
+
+ Reviewed by David Hyatt.
+
+ After we re-layout RenderRubyRuns, this can change the environment upon which
+ ruby's overhang calculation is sensitive to. Before this patch, we would recalculate
+ the overhang after the RenderRubyRun gets relaid out. However, doing such causes the
+ effective width of the RenderRubyRun to change, which causes out subsequent
+ justification calculations to be off.
+
+ Therefore, we have a cycle; the amount of ruby overhang can change the justification
+ in a line, and the layout of the line affects the ruby overhang calculation. Instead
+ of performing a layout in a loop until it converges, this patch simply observes that
+ having a flush right edge is more valuable than having a perfectly correct overhang.
+ It therefore simply removes the secondary overhang calculation.
+
+ Test: fast/text/ruby-justification-flush.html
+
+ * rendering/RenderBlockFlow.h:
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::updateRubyForJustifiedText):
+ (WebCore::RenderBlockFlow::computeExpansionForJustifiedText):
+ (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+
2015-02-18 Chris Dumez <cdumez@apple.com>
Evict dead resources in MemoryCache in MemoryPressureHandler::releaseNoncriticalMemory()
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&);
+ void updateRubyForJustifiedText(RenderRubyRun&, BidiRun&, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t& expansionIndex);
+ void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth);
BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const LineInfo&, ETextAlign, float& logicalLeft,
float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache&, WordMeasurements&);
void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
}
}
-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)
+void RenderBlockFlow::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;
}
rubyRun.layoutBlock(true);
rubyRun.clearOverrideLogicalContentWidth();
- 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
}
}
-void RenderBlockFlow::computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth, const LineInfo& lineInfo)
+void RenderBlockFlow::computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth)
{
if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth)
return;
- RenderObject* previousObject = nullptr;
-
size_t i = 0;
for (BidiRun* run = firstRun; run; run = run->next()) {
- if (!run->box() || run == trailingSpaceRun) {
- previousObject = &run->renderer();
+ if (!run->box() || run == trailingSpaceRun)
continue;
- }
if (is<RenderText>(run->renderer())) {
unsigned opportunitiesInRun = expansionOpportunities[i++];
}
expansionOpportunityCount -= opportunitiesInRun;
} else if (is<RenderRubyRun>(run->renderer()))
- updateRubyForJustifiedText(downcast<RenderRubyRun>(run->renderer()), *run, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, previousObject, lineInfo, i);
-
- previousObject = &run->renderer();
+ updateRubyForJustifiedText(downcast<RenderRubyRun>(run->renderer()), *run, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
if (!expansionOpportunityCount)
break;
updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
- computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, lineInfo);
+ computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
return run;
}