Diff
Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (205587 => 205588)
--- releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog 2016-09-08 06:33:09 UTC (rev 205587)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog 2016-09-08 06:42:02 UTC (rev 205588)
@@ -1,3 +1,14 @@
+2016-08-30 Zalan Bujtas <[email protected]>
+
+ ASSERTION FAILED: opportunitiesInRun <= expansionOpportunityCount in WebCore::computeExpansionForJustifiedText
+ https://bugs.webkit.org/show_bug.cgi?id=139393
+ <rdar://problem/27704243>
+
+ Reviewed by Myles C. Maxfield.
+
+ * fast/text/assert-on-expansion-opportunity-expected.txt: Added.
+ * fast/text/assert-on-expansion-opportunity.html: Added.
+
2016-08-29 Chris Dumez <[email protected]>
We should throw a SecurityError when denying setting a cross-origin Location property
Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity-expected.txt (0 => 205588)
--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity-expected.txt 2016-09-08 06:42:02 UTC (rev 205588)
@@ -0,0 +1,9 @@
+
+
+Pass if no assert in Debug.
+aa
+
+
+
+
+
Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity.html (0 => 205588)
--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity.html (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/text/assert-on-expansion-opportunity.html 2016-09-08 06:42:02 UTC (rev 205588)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we compute expansion opportunities properly.</title>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<style>
+:first-letter, * {
+ white-space: pre-wrap;
+}
+
+</style>
+</head>
+<body>
+Pass if no assert in Debug.
+<ruby>aa
+ <rt> </rt>
+</ruby>
+</body>
+</html>
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (205587 => 205588)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog 2016-09-08 06:33:09 UTC (rev 205587)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog 2016-09-08 06:42:02 UTC (rev 205588)
@@ -1,3 +1,19 @@
+2016-08-30 Zalan Bujtas <[email protected]>
+
+ ASSERTION FAILED: opportunitiesInRun <= expansionOpportunityCount in WebCore::computeExpansionForJustifiedText
+ https://bugs.webkit.org/show_bug.cgi?id=139393
+ <rdar://problem/27704243>
+
+ Reviewed by Myles C. Maxfield.
+
+ This patch ensures that we always remove a valid 'after expansion' opportunity (even when the last entry
+ in the opportunities list is 0).
+
+ Test: fast/text/assert-on-expansion-opportunity.html
+
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+
2016-08-30 Antti Koivisto <[email protected]>
Remove StylePendingImage
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.cpp (205587 => 205588)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.cpp 2016-09-08 06:33:09 UTC (rev 205587)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.cpp 2016-09-08 06:42:02 UTC (rev 205588)
@@ -958,7 +958,7 @@
return isCJKIdeograph(c);
}
-std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const LChar* characters, size_t length, TextDirection direction, ExpansionBehavior expansionBehavior)
+std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const LChar* characters, unsigned length, TextDirection direction, ExpansionBehavior expansionBehavior)
{
unsigned count = 0;
bool isAfterExpansion = (expansionBehavior & LeadingExpansionMask) == ForbidLeadingExpansion;
@@ -967,7 +967,7 @@
isAfterExpansion = true;
}
if (direction == LTR) {
- for (size_t i = 0; i < length; ++i) {
+ for (unsigned i = 0; i < length; ++i) {
if (treatAsSpace(characters[i])) {
count++;
isAfterExpansion = true;
@@ -975,7 +975,7 @@
isAfterExpansion = false;
}
} else {
- for (size_t i = length; i > 0; --i) {
+ for (unsigned i = length; i > 0; --i) {
if (treatAsSpace(characters[i - 1])) {
count++;
isAfterExpansion = true;
@@ -987,6 +987,7 @@
++count;
isAfterExpansion = true;
} else if (isAfterExpansion && (expansionBehavior & TrailingExpansionMask) == ForbidTrailingExpansion) {
+ ASSERT(count);
--count;
isAfterExpansion = false;
}
@@ -993,7 +994,7 @@
return std::make_pair(count, isAfterExpansion);
}
-std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const UChar* characters, size_t length, TextDirection direction, ExpansionBehavior expansionBehavior)
+std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const UChar* characters, unsigned length, TextDirection direction, ExpansionBehavior expansionBehavior)
{
static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText();
unsigned count = 0;
@@ -1003,7 +1004,7 @@
isAfterExpansion = true;
}
if (direction == LTR) {
- for (size_t i = 0; i < length; ++i) {
+ for (unsigned i = 0; i < length; ++i) {
UChar32 character = characters[i];
if (treatAsSpace(character)) {
count++;
@@ -1024,7 +1025,7 @@
isAfterExpansion = false;
}
} else {
- for (size_t i = length; i > 0; --i) {
+ for (unsigned i = length; i > 0; --i) {
UChar32 character = characters[i - 1];
if (treatAsSpace(character)) {
count++;
@@ -1049,6 +1050,7 @@
++count;
isAfterExpansion = true;
} else if (isAfterExpansion && (expansionBehavior & TrailingExpansionMask) == ForbidTrailingExpansion) {
+ ASSERT(count);
--count;
isAfterExpansion = false;
}
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.h (205587 => 205588)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.h 2016-09-08 06:33:09 UTC (rev 205587)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/FontCascade.h 2016-09-08 06:42:02 UTC (rev 205588)
@@ -239,8 +239,8 @@
int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const;
void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const;
- static std::pair<unsigned, bool> expansionOpportunityCountInternal(const LChar*, size_t length, TextDirection, ExpansionBehavior);
- static std::pair<unsigned, bool> expansionOpportunityCountInternal(const UChar*, size_t length, TextDirection, ExpansionBehavior);
+ static std::pair<unsigned, bool> expansionOpportunityCountInternal(const LChar*, unsigned length, TextDirection, ExpansionBehavior);
+ static std::pair<unsigned, bool> expansionOpportunityCountInternal(const UChar*, unsigned length, TextDirection, ExpansionBehavior);
friend struct WidthIterator;
Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBlockLineLayout.cpp (205587 => 205588)
--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2016-09-08 06:33:09 UTC (rev 205587)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2016-09-08 06:42:02 UTC (rev 205588)
@@ -853,6 +853,21 @@
BidiRun* run = firstRun;
BidiRun* previousRun = nullptr;
for (; run; run = run->next()) {
+ auto computeExpansionOpportunities = [&expansionOpportunities, &expansionOpportunityCount, textAlign, &isAfterExpansion] (RenderBlockFlow& block,
+ InlineTextBox& textBox, BidiRun* previousRun, BidiRun* nextRun, const StringView& stringView, TextDirection direction)
+ {
+ if (stringView.isEmpty()) {
+ // Empty runs should still produce an entry in expansionOpportunities list so that the number of items matches the number of runs.
+ expansionOpportunities.append(0);
+ return;
+ }
+ ExpansionBehavior expansionBehavior = expansionBehaviorForInlineTextBox(block, textBox, previousRun, nextRun, textAlign, isAfterExpansion);
+ applyExpansionBehavior(textBox, expansionBehavior);
+ unsigned opportunitiesInRun;
+ std::tie(opportunitiesInRun, isAfterExpansion) = FontCascade::expansionOpportunityCount(stringView, direction, expansionBehavior);
+ expansionOpportunities.append(opportunitiesInRun);
+ expansionOpportunityCount += opportunitiesInRun;
+ };
if (!run->box() || run->renderer().isOutOfFlowPositioned() || run->box()->isLineBreak()) {
continue; // Positioned objects are only participating to figure out their
// correct static x position. They have no effect on the width.
@@ -879,14 +894,8 @@
canHangPunctuationAtEnd = false;
}
- if (textAlign == JUSTIFY && run != trailingSpaceRun) {
- ExpansionBehavior expansionBehavior = expansionBehaviorForInlineTextBox(*this, textBox, previousRun, run->next(), textAlign, isAfterExpansion);
- applyExpansionBehavior(textBox, expansionBehavior);
- unsigned opportunitiesInRun;
- std::tie(opportunitiesInRun, isAfterExpansion) = FontCascade::expansionOpportunityCount(renderText.stringView(run->m_start, run->m_stop), run->box()->direction(), expansionBehavior);
- expansionOpportunities.append(opportunitiesInRun);
- expansionOpportunityCount += opportunitiesInRun;
- }
+ if (textAlign == JUSTIFY && run != trailingSpaceRun)
+ computeExpansionOpportunities(*this, textBox, previousRun, run->next(), renderText.stringView(run->m_start, run->m_stop), run->box()->direction());
if (unsigned length = renderText.textLength()) {
if (!run->m_start && needsWordSpacing && isSpaceOrNewline(renderText.characterAt(run->m_start)))
@@ -906,15 +915,9 @@
for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
if (!is<InlineTextBox>(*leafChild))
continue;
- auto& textBox = downcast<InlineTextBox>(*leafChild);
encounteredJustifiedRuby = true;
- auto& renderText = downcast<RenderText>(leafChild->renderer());
- ExpansionBehavior expansionBehavior = expansionBehaviorForInlineTextBox(*rubyBase, textBox, nullptr, nullptr, textAlign, isAfterExpansion);
- applyExpansionBehavior(textBox, expansionBehavior);
- unsigned opportunitiesInRun;
- std::tie(opportunitiesInRun, isAfterExpansion) = FontCascade::expansionOpportunityCount(renderText.stringView(), leafChild->direction(), expansionBehavior);
- expansionOpportunities.append(opportunitiesInRun);
- expansionOpportunityCount += opportunitiesInRun;
+ computeExpansionOpportunities(*rubyBase, downcast<InlineTextBox>(*leafChild), nullptr, nullptr,
+ downcast<RenderText>(leafChild->renderer()).stringView(), leafChild->direction());
}
}
}
@@ -936,8 +939,15 @@
}
if (isAfterExpansion && !expansionOpportunities.isEmpty()) {
- expansionOpportunities.last()--;
- expansionOpportunityCount--;
+ // FIXME: see <webkit.org/b/139393#c11>
+ int lastValidExpansionOpportunitiesIndex = expansionOpportunities.size() - 1;
+ while (lastValidExpansionOpportunitiesIndex >= 0 && !expansionOpportunities.at(lastValidExpansionOpportunitiesIndex))
+ --lastValidExpansionOpportunitiesIndex;
+ if (lastValidExpansionOpportunitiesIndex >= 0) {
+ ASSERT(expansionOpportunities.at(lastValidExpansionOpportunitiesIndex));
+ expansionOpportunities.at(lastValidExpansionOpportunitiesIndex)--;
+ expansionOpportunityCount--;
+ }
}
if (is<RenderRubyBase>(*this) && !expansionOpportunityCount)