Diff
Modified: trunk/Source/WebCore/ChangeLog (222636 => 222637)
--- trunk/Source/WebCore/ChangeLog 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/ChangeLog 2017-09-28 23:08:27 UTC (rev 222637)
@@ -1,3 +1,48 @@
+2017-09-28 Daniel Bates <[email protected]>
+
+ Remove TextRun::setCharactersLength() and TextRun::charactersLength()
+ https://bugs.webkit.org/show_bug.cgi?id=177620
+
+ Reviewed by Zalan Bujtas.
+
+ The purpose of TextRun::setCharactersLength() and TextRun::charactersLength() predate the
+ use of WidthIterator to safely iterate over characters in a TextRun that may contain
+ surrogate halves due to how it was created (without thought of surrogate pairs). Historically
+ TextRun::charactersLength() complemented TextRun::length() and represented the length of the
+ text to render ignoring and respecting truncation, respectively. We not longer need either
+ of these member functions with the advent of WidthIterator.
+
+ No functionality changed. So, no new tests.
+
+ * platform/graphics/ComplexTextController.cpp:
+ (WebCore::TextLayout::constructTextRun):
+ * platform/graphics/TextRun.cpp: Remove one unsigned field from ExpectedTextRunSize as we
+ reduced the size of TextRun with the removal of TextRun::m_charactersLength.
+ * platform/graphics/TextRun.h:
+ (WebCore::TextRun::TextRun):
+ (WebCore::TextRun::charactersLength const): Deleted.
+ (WebCore::TextRun::setCharactersLength): Deleted.
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::constructTextRun const):
+ * rendering/InlineTextBox.h:
+ (WebCore::InlineTextBox::constructTextRun): Deleted overload that took const RenderStyle& style
+ and StringView.
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::widthFromCache const):
+ (WebCore::maxWordFragmentWidth):
+ (WebCore::RenderText::computePreferredLogicalWidths):
+ (WebCore::RenderText::width const):
+ * rendering/line/BreakingContext.h:
+ (WebCore::textWidth):
+ (WebCore::tryHyphenating):
+ * rendering/svg/SVGInlineTextBox.cpp:
+ (WebCore::SVGInlineTextBox::constructTextRun const):
+ * rendering/svg/SVGTextMetrics.cpp:
+ (WebCore::SVGTextMetrics::constructTextRun):
+ * rendering/svg/SVGTextMetricsBuilder.cpp:
+ (WebCore::SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair const): Use TextRun::length().
+ (WebCore::SVGTextMetricsBuilder::advance): Ditto.
+
2017-09-28 Tim Horton <[email protected]>
Remove constant() in favor of env()
Modified: trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp (222636 => 222637)
--- trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -78,8 +78,6 @@
static TextRun constructTextRun(RenderText& text, float xPos)
{
TextRun run = RenderBlock::constructTextRun(text, text.style());
- run.setCharactersLength(text.textLength());
- ASSERT(run.charactersLength() >= run.length());
run.setXPos(xPos);
return run;
}
Modified: trunk/Source/WebCore/platform/graphics/TextRun.cpp (222636 => 222637)
--- trunk/Source/WebCore/platform/graphics/TextRun.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/platform/graphics/TextRun.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -31,7 +31,6 @@
struct ExpectedTextRunSize {
StringView text;
unsigned integer1;
- unsigned integer2;
float float1;
float float2;
float float3;
Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (222636 => 222637)
--- trunk/Source/WebCore/platform/graphics/TextRun.h 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h 2017-09-28 23:08:27 UTC (rev 222637)
@@ -46,7 +46,6 @@
public:
explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = DefaultExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_text(text)
- , m_charactersLength(text.length())
, m_tabSize(0)
, m_xpos(xpos)
, m_horizontalGlyphStretch(1)
@@ -83,13 +82,11 @@
bool is8Bit() const { return m_text.is8Bit(); }
unsigned length() const { return m_text.length(); }
- unsigned charactersLength() const { return m_charactersLength; }
String string() const { return m_text.toString(); }
void setText(const LChar* c, unsigned len) { m_text = StringView(c, len); }
void setText(const UChar* c, unsigned len) { m_text = StringView(c, len); }
void setText(StringView stringView) { m_text = stringView; }
- void setCharactersLength(unsigned charactersLength) { m_charactersLength = charactersLength; }
float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; }
void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = scale; }
@@ -117,7 +114,6 @@
private:
StringView m_text;
- unsigned m_charactersLength; // Marks the end of the characters buffer. Default equals to length of m_text.
unsigned m_tabSize;
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (222636 => 222637)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -1091,24 +1091,16 @@
TextRun InlineTextBox::constructTextRun(const RenderStyle& style, StringView alternateStringToRender, std::optional<unsigned> alternateLength) const
{
+ auto actuallyConstructTextRun = [&] (StringView string) {
+ TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
+ run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
+ return run;
+ };
if (alternateStringToRender.isNull())
- return constructTextRun(style, substringToRender(alternateLength), renderer().textLength() - start());
- return constructTextRun(style, alternateStringToRender, alternateStringToRender.length());
+ return actuallyConstructTextRun(substringToRender(alternateLength));
+ return actuallyConstructTextRun(alternateStringToRender);
}
-TextRun InlineTextBox::constructTextRun(const RenderStyle& style, StringView string, unsigned maximumLength) const
-{
- ASSERT(maximumLength >= string.length());
-
- TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
- run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
-
- // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
- run.setCharactersLength(maximumLength);
- ASSERT(run.charactersLength() >= run.length());
- return run;
-}
-
inline const RenderCombineText* InlineTextBox::combinedText() const
{
return lineStyle().hasTextCombine() && is<RenderCombineText>(renderer()) && downcast<RenderCombineText>(renderer()).isCombined() ? &downcast<RenderCombineText>(renderer()) : nullptr;
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (222636 => 222637)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2017-09-28 23:08:27 UTC (rev 222637)
@@ -110,7 +110,6 @@
StringView substringToRender(std::optional<unsigned> overridingLength = { }) const;
String hyphenatedStringForTextRun(const RenderStyle&, std::optional<unsigned> alternateLength = { }) const;
TextRun constructTextRun(const RenderStyle&, StringView alternateStringToRender = { }, std::optional<unsigned> alternateLength = { }) const;
- TextRun constructTextRun(const RenderStyle&, StringView, unsigned maximumLength) const;
public:
FloatRect calculateBoundaries() const override { return FloatRect(x(), y(), width(), height()); }
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (222636 => 222637)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -514,9 +514,6 @@
}
TextRun run = RenderBlock::constructTextRun(*this, start, len, style);
- run.setCharactersLength(textLength() - start);
- ASSERT(run.charactersLength() >= run.length());
-
run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(xPos);
@@ -781,7 +778,6 @@
fragmentWithHyphen.append(style.hyphenString());
TextRun run = RenderBlock::constructTextRun(fragmentWithHyphen.toString(), style);
- run.setCharactersLength(fragmentWithHyphen.length());
run.setCharacterScanForCodePath(!renderer.canUseSimpleFontCodePath());
float fragmentWidth = font.width(run, &fallbackFonts, &glyphOverflow);
@@ -1007,8 +1003,6 @@
currMaxWidth = 0;
} else {
TextRun run = RenderBlock::constructTextRun(*this, i, 1, style);
- run.setCharactersLength(len - i);
- ASSERT(run.charactersLength() >= run.length());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(leadWidth + currMaxWidth);
@@ -1395,12 +1389,10 @@
w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow, style);
} else {
TextRun run = RenderBlock::constructTextRun(*this, from, len, style);
- run.setCharactersLength(textLength() - from);
- ASSERT(run.charactersLength() >= run.length());
-
run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(xPos);
+
w = f.width(run, fallbackFonts, glyphOverflow);
}
Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (222636 => 222637)
--- trunk/Source/WebCore/rendering/line/BreakingContext.h 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h 2017-09-28 23:08:27 UTC (rev 222637)
@@ -628,9 +628,6 @@
return FontCascade::width(*layout, from, len, &fallbackFonts);
TextRun run = RenderBlock::constructTextRun(text, from, len, style);
- run.setCharactersLength(text.textLength() - from);
- ASSERT(run.charactersLength() >= run.length());
-
run.setCharacterScanForCodePath(!text.canUseSimpleFontCodePath());
run.setTabSize(!collapseWhiteSpace, style.tabSize());
run.setXPos(xPos);
@@ -675,9 +672,6 @@
const RenderStyle& style = text.style();
TextRun run = RenderBlock::constructTextRun(text, lastSpace, pos - lastSpace, style);
- run.setCharactersLength(text.textLength() - lastSpace);
- ASSERT(run.charactersLength() >= run.length());
-
run.setTabSize(!collapseWhiteSpace, style.tabSize());
run.setXPos(xPos + lastSpaceWordSpacing);
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (222636 => 222637)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -396,10 +396,6 @@
// We handle letter & word spacing ourselves.
run.disableSpacing();
-
- // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
- run.setCharactersLength(renderer().textLength() - fragment.characterOffset);
- ASSERT(run.charactersLength() >= run.length());
return run;
}
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp (222636 => 222637)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -73,10 +73,6 @@
// We handle letter & word spacing ourselves.
run.disableSpacing();
-
- // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
- run.setCharactersLength(text.textLength() - position);
- ASSERT(run.charactersLength() >= run.length());
return run;
}
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp (222636 => 222637)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2017-09-28 23:04:05 UTC (rev 222636)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2017-09-28 23:08:27 UTC (rev 222637)
@@ -38,13 +38,13 @@
inline bool SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair() const
{
- return U16_IS_LEAD(m_run[m_textPosition]) && (m_textPosition + 1) < m_run.charactersLength() && U16_IS_TRAIL(m_run[m_textPosition + 1]);
+ return U16_IS_LEAD(m_run[m_textPosition]) && (m_textPosition + 1) < m_run.length() && U16_IS_TRAIL(m_run[m_textPosition + 1]);
}
bool SVGTextMetricsBuilder::advance()
{
m_textPosition += m_currentMetrics.length();
- if (m_textPosition >= m_run.charactersLength())
+ if (m_textPosition >= m_run.length())
return false;
if (m_isComplexText)