Diff
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (294606 => 294607)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -207,7 +207,7 @@
const RenderStyle* computedStyle;
auto direction = toTextDirection(state().direction, &computedStyle);
bool override = computedStyle && isOverride(computedStyle->unicodeBidi());
- TextRun textRun(normalizedText, 0, 0, AllowRightExpansion, direction, override, true);
+ TextRun textRun(normalizedText, 0, 0, ExpansionBehavior::allowRightOnly(), direction, override, true);
return measureTextInternal(textRun);
}
@@ -240,7 +240,7 @@
const RenderStyle* computedStyle;
auto direction = toTextDirection(state().direction, &computedStyle);
bool override = computedStyle && isOverride(computedStyle->unicodeBidi());
- TextRun textRun(normalizedText, 0, 0, AllowRightExpansion, direction, override, true);
+ TextRun textRun(normalizedText, 0, 0, ExpansionBehavior::allowRightOnly(), direction, override, true);
drawTextUnchecked(textRun, x, y, fill, maxWidth);
}
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (294606 => 294607)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -2398,7 +2398,7 @@
String normalizedText = normalizeSpaces(text);
auto direction = (state().direction == Direction::Rtl) ? TextDirection::RTL : TextDirection::LTR;
- TextRun textRun(normalizedText, 0, 0, AllowRightExpansion, direction, false, true);
+ TextRun textRun(normalizedText, 0, 0, ExpansionBehavior::allowRightOnly(), direction, false, true);
drawTextUnchecked(textRun, x, y, fill, maxWidth);
}
@@ -2520,7 +2520,7 @@
{
String normalizedText = normalizeSpaces(text);
auto direction = (state().direction == Direction::Rtl) ? TextDirection::RTL : TextDirection::LTR;
- TextRun textRun(normalizedText, 0, 0, AllowRightExpansion, direction, false, true);
+ TextRun textRun(normalizedText, 0, 0, ExpansionBehavior::allowRightOnly(), direction, false, true);
return measureTextInternal(textRun);
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (294606 => 294607)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -115,15 +115,16 @@
auto hangingTrailingContentLength = m_hangingTrailingContent.length();
for (size_t runIndex = 0; runIndex < m_runs.size(); ++runIndex) {
auto& run = m_runs[runIndex];
- int expansionBehavior = DefaultExpansion;
+ auto expansionBehavior = ExpansionBehavior::defaultBehavior();
size_t expansionOpportunitiesInRun = 0;
// FIXME: Check why we don't apply expansion when whitespace is preserved.
if (run.isText() && (!TextUtil::shouldPreserveSpacesAndTabs(run.layoutBox()) || hangingTrailingContentLength)) {
if (run.hasTextCombine())
- expansionBehavior = ForbidLeftExpansion | ForbidRightExpansion;
+ expansionBehavior = ExpansionBehavior::forbidAll();
else {
- expansionBehavior = (runIsAfterExpansion ? ForbidLeftExpansion : AllowLeftExpansion) | AllowRightExpansion;
+ expansionBehavior.setLeft(runIsAfterExpansion ? ExpansionBehavior::Behavior::Forbid : ExpansionBehavior::Behavior::Allow);
+ expansionBehavior.setRight(ExpansionBehavior::Behavior::Allow);
auto& textContent = *run.textContent();
// Trailing hanging whitespace sequence is ignored when computing the expansion opportunities.
auto hangingTrailingContentInCurrentRun = std::min(textContent.length, hangingTrailingContentLength);
@@ -141,11 +142,9 @@
if (run.isText() || run.isBox())
lastRunIndexWithContent = runIndex;
}
- // Need to fix up the last run's trailing expansion.
+ // Forbid right expansion in the last run to prevent trailing expansion at the end of the line.
if (lastRunIndexWithContent && runsExpansionOpportunities[*lastRunIndexWithContent]) {
- // Turn off the trailing bits first and add the forbid trailing expansion.
- auto leadingExpansion = runsExpansionBehaviors[*lastRunIndexWithContent] & LeftExpansionMask;
- runsExpansionBehaviors[*lastRunIndexWithContent] = leadingExpansion | ForbidRightExpansion;
+ runsExpansionBehaviors[*lastRunIndexWithContent].setRight(ExpansionBehavior::Behavior::Forbid);
if (runIsAfterExpansion) {
// When the last run has an after expansion (e.g. CJK ideograph) we need to remove this trailing expansion opportunity.
// Note that this is not about trailing collapsible whitespace as at this point we trimmed them all.
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h (294606 => 294607)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2022-05-21 02:33:42 UTC (rev 294607)
@@ -156,7 +156,7 @@
const std::optional<Text>& text() const { return m_text; }
struct Expansion {
- ExpansionBehavior behavior { DefaultExpansion };
+ ExpansionBehavior behavior = ExpansionBehavior::defaultBehavior();
float horizontalExpansion { 0 };
};
Expansion expansion() const { return m_expansion; }
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp (294606 => 294607)
--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -161,8 +161,8 @@
};
if (includeHyphen == IncludeHyphen::Yes)
- collectFallbackFonts(TextRun { StringView(style.hyphenString().string()), { }, { }, DefaultExpansion, style.direction() });
- collectFallbackFonts(TextRun { textContent, { }, { }, DefaultExpansion, style.direction() });
+ collectFallbackFonts(TextRun { StringView(style.hyphenString().string()), { }, { }, ExpansionBehavior::defaultBehavior(), style.direction() });
+ collectFallbackFonts(TextRun { textContent, { }, { }, ExpansionBehavior::defaultBehavior(), style.direction() });
return fallbackFonts;
}
Modified: trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp (294606 => 294607)
--- trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -673,13 +673,13 @@
void ComplexTextController::adjustGlyphsAndAdvances()
{
- bool afterExpansion = (m_run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion;
+ bool afterExpansion = m_run.expansionBehavior().left() == ExpansionBehavior::Behavior::Forbid;
size_t runCount = m_complexTextRuns.size();
bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_expansion) && !m_run.spacingDisabled();
- bool runForcesLeftExpansion = (m_run.expansionBehavior() & LeftExpansionMask) == ForceLeftExpansion;
- bool runForcesRightExpansion = (m_run.expansionBehavior() & RightExpansionMask) == ForceRightExpansion;
- bool runForbidsLeftExpansion = (m_run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion;
- bool runForbidsRightExpansion = (m_run.expansionBehavior() & RightExpansionMask) == ForbidRightExpansion;
+ bool runForcesLeftExpansion = m_run.expansionBehavior().left() == ExpansionBehavior::Behavior::Force;
+ bool runForcesRightExpansion = m_run.expansionBehavior().right() == ExpansionBehavior::Behavior::Force;
+ bool runForbidsLeftExpansion = m_run.expansionBehavior().left() == ExpansionBehavior::Behavior::Forbid;
+ bool runForbidsRightExpansion = m_run.expansionBehavior().right() == ExpansionBehavior::Behavior::Forbid;
// We are iterating in glyph order, not string order. Compare this to WidthIterator::advanceInternal()
for (size_t runIndex = 0; runIndex < runCount; ++runIndex) {
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (294606 => 294607)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -962,8 +962,8 @@
std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const LChar* characters, unsigned length, TextDirection direction, ExpansionBehavior expansionBehavior)
{
unsigned count = 0;
- bool isAfterExpansion = (expansionBehavior & LeftExpansionMask) == ForbidLeftExpansion;
- if ((expansionBehavior & LeftExpansionMask) == ForceLeftExpansion) {
+ bool isAfterExpansion = expansionBehavior.left() == ExpansionBehavior::Behavior::Forbid;
+ if (expansionBehavior.left() == ExpansionBehavior::Behavior::Force) {
++count;
isAfterExpansion = true;
}
@@ -984,10 +984,10 @@
isAfterExpansion = false;
}
}
- if (!isAfterExpansion && (expansionBehavior & RightExpansionMask) == ForceRightExpansion) {
+ if (!isAfterExpansion && expansionBehavior.right() == ExpansionBehavior::Behavior::Force) {
++count;
isAfterExpansion = true;
- } else if (isAfterExpansion && (expansionBehavior & RightExpansionMask) == ForbidRightExpansion) {
+ } else if (isAfterExpansion && expansionBehavior.right() == ExpansionBehavior::Behavior::Forbid) {
ASSERT(count);
--count;
isAfterExpansion = false;
@@ -998,8 +998,8 @@
std::pair<unsigned, bool> FontCascade::expansionOpportunityCountInternal(const UChar* characters, unsigned length, TextDirection direction, ExpansionBehavior expansionBehavior)
{
unsigned count = 0;
- bool isAfterExpansion = (expansionBehavior & LeftExpansionMask) == ForbidLeftExpansion;
- if ((expansionBehavior & LeftExpansionMask) == ForceLeftExpansion) {
+ bool isAfterExpansion = expansionBehavior.left() == ExpansionBehavior::Behavior::Forbid;
+ if (expansionBehavior.left() == ExpansionBehavior::Behavior::Force) {
++count;
isAfterExpansion = true;
}
@@ -1046,10 +1046,10 @@
isAfterExpansion = false;
}
}
- if (!isAfterExpansion && (expansionBehavior & RightExpansionMask) == ForceRightExpansion) {
+ if (!isAfterExpansion && expansionBehavior.right() == ExpansionBehavior::Behavior::Force) {
++count;
isAfterExpansion = true;
- } else if (isAfterExpansion && (expansionBehavior & RightExpansionMask) == ForbidRightExpansion) {
+ } else if (isAfterExpansion && expansionBehavior.right() == ExpansionBehavior::Behavior::Forbid) {
ASSERT(count);
--count;
isAfterExpansion = false;
Modified: trunk/Source/WebCore/platform/graphics/TextRun.cpp (294606 => 294607)
--- trunk/Source/WebCore/platform/graphics/TextRun.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/graphics/TextRun.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -34,9 +34,10 @@
float float1;
float float2;
float float3;
- unsigned bitfields : 9;
+ ExpansionBehavior expansionBehavior;
+ unsigned bitfields : 5;
};
-static_assert(sizeof(TextRun) == sizeof(ExpectedTextRunSize), "TextRun is not of expected size");
+static_assert(sizeof(TextRun) == sizeof(ExpectedTextRunSize), "TextRun should be small");
}
Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (294606 => 294607)
--- trunk/Source/WebCore/platform/graphics/TextRun.h 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h 2022-05-21 02:33:42 UTC (rev 294607)
@@ -43,7 +43,7 @@
class TextRun {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit TextRun(const String& text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = DefaultExpansion, TextDirection direction = TextDirection::LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
+ explicit TextRun(const String& text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = ExpansionBehavior::defaultBehavior(), TextDirection direction = TextDirection::LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_text(text)
, m_tabSize(0)
, m_xpos(xpos)
@@ -59,7 +59,7 @@
ASSERT(!m_text.isNull());
}
- explicit TextRun(StringView stringView, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = DefaultExpansion, TextDirection direction = TextDirection::LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
+ explicit TextRun(StringView stringView, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = ExpansionBehavior::defaultBehavior(), TextDirection direction = TextDirection::LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: TextRun(stringView.toStringWithoutCopying(), xpos, expansion, expansionBehavior, direction, directionalOverride, characterScanForCodePath)
{
}
@@ -128,7 +128,7 @@
float m_horizontalGlyphStretch;
float m_expansion;
- unsigned m_expansionBehavior : 4;
+ ExpansionBehavior m_expansionBehavior;
unsigned m_allowTabs : 1;
unsigned m_direction : 1;
unsigned m_directionalOverride : 1; // Was this direction set by an override character.
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (294606 => 294607)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -41,7 +41,7 @@
, m_run(run)
, m_fallbackFonts(fallbackFonts)
, m_expansion(run.expansion())
- , m_isAfterExpansion((run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion)
+ , m_isAfterExpansion(run.expansionBehavior().left() == ExpansionBehavior::Behavior::Forbid)
, m_accountForGlyphBounds(accountForGlyphBounds)
, m_enableKerning(font.enableKerning())
, m_requiresShaping(font.requiresShaping())
@@ -381,10 +381,10 @@
if (!m_run.ltr())
std::swap(isLeftmostCharacter, isRightmostCharacter);
- bool forceLeftExpansion = isLeftmostCharacter && (m_run.expansionBehavior() & LeftExpansionMask) == ForceLeftExpansion;
- bool forceRightExpansion = isRightmostCharacter && (m_run.expansionBehavior() & RightExpansionMask) == ForceRightExpansion;
- bool forbidLeftExpansion = isLeftmostCharacter && (m_run.expansionBehavior() & LeftExpansionMask) == ForbidLeftExpansion;
- bool forbidRightExpansion = isRightmostCharacter && (m_run.expansionBehavior() & RightExpansionMask) == ForbidRightExpansion;
+ bool forceLeftExpansion = isLeftmostCharacter && m_run.expansionBehavior().left() == ExpansionBehavior::Behavior::Force;
+ bool forceRightExpansion = isRightmostCharacter && m_run.expansionBehavior().right() == ExpansionBehavior::Behavior::Force;
+ bool forbidLeftExpansion = isLeftmostCharacter && m_run.expansionBehavior().left() == ExpansionBehavior::Behavior::Forbid;
+ bool forbidRightExpansion = isRightmostCharacter && m_run.expansionBehavior().right() == ExpansionBehavior::Behavior::Forbid;
bool isIdeograph = FontCascade::canExpandAroundIdeographsInComplexText() && FontCascade::isCJKIdeographOrSymbol(character);
Modified: trunk/Source/WebCore/platform/text/TextFlags.h (294606 => 294607)
--- trunk/Source/WebCore/platform/text/TextFlags.h 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/text/TextFlags.h 2022-05-21 02:33:42 UTC (rev 294607)
@@ -58,20 +58,59 @@
Upright
};
-enum ExpansionBehaviorFlags {
- ForbidRightExpansion = 0 << 0,
- AllowRightExpansion = 1 << 0,
- ForceRightExpansion = 2 << 0,
- RightExpansionMask = 3 << 0,
+class ExpansionBehavior {
+public:
+ enum class Behavior : uint8_t {
+ Forbid,
+ Allow,
+ Force
+ };
- ForbidLeftExpansion = 0 << 2,
- AllowLeftExpansion = 1 << 2,
- ForceLeftExpansion = 2 << 2,
- LeftExpansionMask = 3 << 2,
+ ExpansionBehavior() = default;
- DefaultExpansion = AllowRightExpansion | ForbidLeftExpansion,
+ ExpansionBehavior(Behavior left, Behavior right)
+ : m_left(static_cast<uint8_t>(left))
+ , m_right(static_cast<uint8_t>(right))
+ {
+ }
+
+ static const ExpansionBehavior defaultBehavior()
+ {
+ return { };
+ }
+
+ static const ExpansionBehavior allowRightOnly()
+ {
+ return { Behavior::Forbid, Behavior::Allow };
+ }
+
+ static const ExpansionBehavior allowLeftOnly()
+ {
+ return { Behavior::Allow, Behavior::Forbid };
+ }
+
+ static const ExpansionBehavior forceLeftOnly()
+ {
+ return { Behavior::Force, Behavior::Forbid };
+ }
+
+ static const ExpansionBehavior forbidAll()
+ {
+ return { Behavior::Forbid, Behavior::Forbid };
+ }
+
+ Behavior left() const { return static_cast<Behavior>(m_left); }
+ void setLeft(Behavior behavior) { m_left = static_cast<uint8_t>(behavior); }
+
+ Behavior right() const { return static_cast<Behavior>(m_right); }
+ void setRight(Behavior behavior) { m_right = static_cast<uint8_t>(behavior); }
+
+private:
+ // Default behavior follows the previous implementation:
+ // forbids left and allows right expansions.
+ uint8_t m_left : 2 { static_cast<uint8_t>(Behavior::Forbid) };
+ uint8_t m_right : 2 { static_cast<uint8_t>(Behavior::Allow) };
};
-typedef unsigned ExpansionBehavior;
enum FontSynthesisValues {
FontSynthesisNone = 0x0,
Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.cpp (294606 => 294607)
--- trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -644,7 +644,7 @@
String itemText = client()->itemText(index);
- TextRun textRun(itemText, 0, 0, AllowLeftExpansion, itemStyle.textDirection(), itemStyle.hasTextDirectionOverride());
+ TextRun textRun(itemText, 0, 0, ExpansionBehavior::allowLeftOnly(), itemStyle.textDirection(), itemStyle.hasTextDirectionOverride());
context.setFillColor(optionTextColor);
FontCascade itemFont = m_font;
Modified: trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -70,7 +70,7 @@
}
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
- context.drawText(font, RenderBlock::constructTextRun(m_str, lineStyle, AllowRightExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.metricsOfPrimaryFont().ascent()));
+ context.drawText(font, RenderBlock::constructTextRun(m_str, lineStyle, ExpansionBehavior::allowRightOnly()), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.metricsOfPrimaryFont().ascent()));
// Restore the regular fill color.
if (textColor != context.fillColor())
@@ -119,7 +119,7 @@
const LegacyRootInlineBox& rootBox = root();
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
LayoutRect selectionRect { LayoutUnit(x()), LayoutUnit(y() + rootBox.selectionTopAdjustedForPrecedingBlock()), 0_lu, rootBox.selectionHeightAdjustedForPrecedingBlock() };
- font.adjustSelectionRectForText(RenderBlock::constructTextRun(m_str, lineStyle, AllowRightExpansion), selectionRect);
+ font.adjustSelectionRectForText(RenderBlock::constructTextRun(m_str, lineStyle, ExpansionBehavior::allowRightOnly()), selectionRect);
// FIXME: use directional pixel snapping instead.
return enclosingIntRect(selectionRect);
}
@@ -140,7 +140,7 @@
GraphicsContextStateSaver stateSaver(context);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
LayoutRect selectionRect { LayoutUnit(x() + paintOffset.x()), rootBox.selectionTop() + paintOffset.y(), 0_lu, rootBox.selectionHeight() };
- TextRun run = RenderBlock::constructTextRun(m_str, style, AllowRightExpansion);
+ TextRun run = RenderBlock::constructTextRun(m_str, style, ExpansionBehavior::allowRightOnly());
font.adjustSelectionRectForText(run, selectionRect);
context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c);
}
Modified: trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/LegacyInlineTextBox.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -488,23 +488,23 @@
ExpansionBehavior LegacyInlineTextBox::expansionBehavior() const
{
- ExpansionBehavior leftBehavior;
+ ExpansionBehavior behavior;
+
if (forceLeftExpansion())
- leftBehavior = ForceLeftExpansion;
+ behavior.setLeft(ExpansionBehavior::Behavior::Force);
else if (canHaveLeftExpansion())
- leftBehavior = AllowLeftExpansion;
+ behavior.setLeft(ExpansionBehavior::Behavior::Allow);
else
- leftBehavior = ForbidLeftExpansion;
+ behavior.setLeft(ExpansionBehavior::Behavior::Forbid);
- ExpansionBehavior rightBehavior;
if (forceRightExpansion())
- rightBehavior = ForceRightExpansion;
+ behavior.setRight(ExpansionBehavior::Behavior::Force);
else if (expansion() && nextLeafOnLine() && !nextLeafOnLine()->isLineBreak())
- rightBehavior = AllowRightExpansion;
+ behavior.setRight(ExpansionBehavior::Behavior::Allow);
else
- rightBehavior = ForbidRightExpansion;
+ behavior.setRight(ExpansionBehavior::Behavior::Forbid);
- return leftBehavior | rightBehavior;
+ return behavior;
}
#if ENABLE(TREE_DEBUGGING)
Modified: trunk/Source/WebCore/rendering/LegacyLineLayout.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -728,9 +728,9 @@
{
// Tatechuyoko is modeled as the Object Replacement Character (U+FFFC), which can never have expansion opportunities inside nor intrinsically adjacent to it.
if (textBox.renderer().style().textCombine() == TextCombine::All)
- return ForbidLeftExpansion | ForbidRightExpansion;
+ return ExpansionBehavior::forbidAll();
- ExpansionBehavior result = 0;
+ auto result = ExpansionBehavior::forbidAll();
bool setLeftExpansion = false;
bool setRightExpansion = false;
if (textAlign == TextAlignMode::Justify) {
@@ -743,7 +743,7 @@
// FIXME: This leftExpansionOpportunity doesn't actually work because it doesn't perform the UBA
if (FontCascade::leftExpansionOpportunity(downcast<RenderText>(leafChild->renderer()).stringView(), leafChild->direction())) {
setRightExpansion = true;
- result |= ForceRightExpansion;
+ result.setRight(ExpansionBehavior::Behavior::Force);
}
}
}
@@ -758,7 +758,7 @@
// FIXME: This leftExpansionOpportunity doesn't actually work because it doesn't perform the UBA
if (FontCascade::rightExpansionOpportunity(downcast<RenderText>(leafChild->renderer()).stringView(), leafChild->direction())) {
setLeftExpansion = true;
- result |= ForceLeftExpansion;
+ result.setLeft(ExpansionBehavior::Behavior::Force);
}
}
}
@@ -769,44 +769,45 @@
RenderRubyBase& rubyBase = downcast<RenderRubyBase>(block);
if (&textBox == rubyBase.firstRootBox()->firstLeafDescendant()) {
setLeftExpansion = true;
- result |= ForbidLeftExpansion;
+ result.setLeft(ExpansionBehavior::Behavior::Forbid);
} if (&textBox == rubyBase.firstRootBox()->lastLeafDescendant()) {
setRightExpansion = true;
- result |= ForbidRightExpansion;
+ result.setRight(ExpansionBehavior::Behavior::Forbid);
}
}
}
if (!setLeftExpansion)
- result |= isAfterExpansion ? ForbidLeftExpansion : AllowLeftExpansion;
+ result.setLeft(isAfterExpansion ? ExpansionBehavior::Behavior::Forbid : ExpansionBehavior::Behavior::Allow);
if (!setRightExpansion)
- result |= AllowRightExpansion;
+ result.setRight(ExpansionBehavior::Behavior::Allow);
return result;
}
static inline void applyExpansionBehavior(LegacyInlineTextBox& textBox, ExpansionBehavior expansionBehavior)
{
- switch (expansionBehavior & LeftExpansionMask) {
- case ForceLeftExpansion:
+ switch (expansionBehavior.left()) {
+ case ExpansionBehavior::Behavior::Force:
textBox.setForceLeftExpansion();
break;
- case ForbidLeftExpansion:
+ case ExpansionBehavior::Behavior::Forbid:
textBox.setCanHaveLeftExpansion(false);
break;
- case AllowLeftExpansion:
+ case ExpansionBehavior::Behavior::Allow:
textBox.setCanHaveLeftExpansion(true);
break;
default:
ASSERT_NOT_REACHED();
break;
- }
- switch (expansionBehavior & RightExpansionMask) {
- case ForceRightExpansion:
+ };
+
+ switch (expansionBehavior.right()) {
+ case ExpansionBehavior::Behavior::Force:
textBox.setForceRightExpansion();
break;
- case ForbidRightExpansion:
+ case ExpansionBehavior::Behavior::Forbid:
textBox.setCanHaveRightExpansion(false);
break;
- case AllowRightExpansion:
+ case ExpansionBehavior::Behavior::Allow:
textBox.setCanHaveRightExpansion(true);
break;
default:
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (294606 => 294607)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2022-05-21 02:33:42 UTC (rev 294607)
@@ -194,20 +194,20 @@
}
static TextRun constructTextRun(StringView, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior(), TextRunFlags = DefaultTextRunFlags);
static TextRun constructTextRun(const String&, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior(), TextRunFlags = DefaultTextRunFlags);
static TextRun constructTextRun(const AtomString&, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior(), TextRunFlags = DefaultTextRunFlags);
static TextRun constructTextRun(const RenderText&, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior());
static TextRun constructTextRun(const RenderText&, unsigned offset, unsigned length, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior());
static TextRun constructTextRun(const LChar* characters, unsigned length, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion);
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior());
static TextRun constructTextRun(const UChar* characters, unsigned length, const RenderStyle&,
- ExpansionBehavior = DefaultExpansion);
-
+ ExpansionBehavior = ExpansionBehavior::defaultBehavior());
+
LayoutUnit paginationStrut() const;
void setPaginationStrut(LayoutUnit);
Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -135,7 +135,7 @@
if (paintInfo.phase == PaintPhase::Foreground) {
const String& displayedFilename = fileTextValue();
const FontCascade& font = style().fontCascade();
- TextRun textRun = constructTextRun(displayedFilename, style(), AllowRightExpansion, RespectDirection | RespectDirectionOverride);
+ TextRun textRun = constructTextRun(displayedFilename, style(), ExpansionBehavior::allowRightOnly(), RespectDirection | RespectDirectionOverride);
#if PLATFORM(IOS_FAMILY)
int iconHeight = nodeHeight(uploadButton());
@@ -206,10 +206,10 @@
const String characterAsString = String(&character, 1);
const FontCascade& font = style().fontCascade();
// FIXME: Remove the need for this const_cast by making constructTextRun take a const RenderObject*.
- float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructTextRun(characterAsString, style(), AllowRightExpansion));
+ float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructTextRun(characterAsString, style(), ExpansionBehavior::allowRightOnly()));
const String label = theme().fileListDefaultLabel(inputElement().multiple());
- float defaultLabelWidth = font.width(constructTextRun(label, style(), AllowRightExpansion));
+ float defaultLabelWidth = font.width(constructTextRun(label, style(), ExpansionBehavior::allowRightOnly()));
if (HTMLInputElement* button = uploadButton())
if (RenderObject* buttonRenderer = button->renderer())
defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + afterButtonSpacing;
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -533,7 +533,7 @@
if (!m_altText.isEmpty()) {
auto& font = style().fontCascade();
auto& fontMetrics = font.metricsOfPrimaryFont();
- auto textRun = RenderBlock::constructTextRun(document().displayStringModifiedByEncoding(m_altText), style(), DefaultExpansion, RespectDirection | RespectDirectionOverride);
+ auto textRun = RenderBlock::constructTextRun(document().displayStringModifiedByEncoding(m_altText), style(), ExpansionBehavior::defaultBehavior(), RespectDirection | RespectDirectionOverride);
auto textWidth = LayoutUnit { font.width(textRun) };
auto hasRoomForAltText = [&] {
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -144,7 +144,7 @@
if (text.isEmpty())
continue;
text = applyTextTransform(style(), text, ' ');
- auto textRun = constructTextRun(text, style(), AllowRightExpansion);
+ auto textRun = constructTextRun(text, style(), ExpansionBehavior::allowRightOnly());
width = std::max(width, selectFont().width(textRun));
}
// FIXME: Is ceiling right here, or should we be doing some kind of rounding instead?
@@ -422,7 +422,7 @@
paintInfo.context().setFillColor(textColor);
- TextRun textRun(itemText, 0, 0, AllowRightExpansion, itemStyle.direction(), isOverride(itemStyle.unicodeBidi()), true);
+ TextRun textRun(itemText, 0, 0, ExpansionBehavior::allowRightOnly(), itemStyle.direction(), isOverride(itemStyle.unicodeBidi()), true);
FontCascade itemFont = style().fontCascade();
LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex);
r.move(itemOffsetForAlignment(textRun, &itemStyle, itemFont, r));
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -148,7 +148,7 @@
const UChar ch = '0';
const String str = String(&ch, 1);
const FontCascade& font = style().fontCascade();
- TextRun textRun = constructTextRun(str, style(), AllowRightExpansion);
+ TextRun textRun = constructTextRun(str, style(), ExpansionBehavior::allowRightOnly());
return font.width(textRun);
}
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -382,12 +382,12 @@
TextRun SVGInlineTextBox::constructTextRun(const RenderStyle& style, const SVGTextFragment& fragment) const
{
- TextRun run(StringView(renderer().text()).substring(fragment.characterOffset, fragment.length)
- , 0 /* xPos, only relevant with allowTabs=true */
- , 0 /* padding, only relevant for justified text, not relevant for SVG */
- , AllowRightExpansion
- , direction()
- , style.rtlOrdering() == Order::Visual /* directionalOverride */);
+ TextRun run(StringView(renderer().text()).substring(fragment.characterOffset, fragment.length),
+ 0, /* xPos, only relevant with allowTabs=true */
+ 0, /* padding, only relevant for justified text, not relevant for SVG */
+ ExpansionBehavior::allowRightOnly(),
+ direction(),
+ style.rtlOrdering() == Order::Visual /* directionalOverride */);
// We handle letter & word spacing ourselves.
run.disableSpacing();
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp (294606 => 294607)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -63,12 +63,12 @@
{
const RenderStyle& style = text.style();
- TextRun run(StringView(text.text()).substring(position, length)
- , 0 /* xPos, only relevant with allowTabs=true */
- , 0 /* padding, only relevant for justified text, not relevant for SVG */
- , AllowRightExpansion
- , style.direction()
- , isOverride(style.unicodeBidi()) /* directionalOverride */);
+ TextRun run(StringView(text.text()).substring(position, length),
+ 0, /* xPos, only relevant with allowTabs=true */
+ 0, /* padding, only relevant for justified text, not relevant for SVG */
+ ExpansionBehavior::allowRightOnly(),
+ style.direction(),
+ isOverride(style.unicodeBidi()) /* directionalOverride */);
// We handle letter & word spacing ourselves.
run.disableSpacing();
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp (294606 => 294607)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -111,7 +111,7 @@
String itemText = m_popupClient->itemText(index);
- TextRun textRun(itemText, 0, 0, AllowRightExpansion, itemStyle.textDirection(), itemStyle.hasTextDirectionOverride());
+ TextRun textRun(itemText, 0, 0, ExpansionBehavior::allowRightOnly(), itemStyle.textDirection(), itemStyle.hasTextDirectionOverride());
notSelectedBackingStoreContext->setFillColor(optionTextColor);
selectedBackingStoreContext->setFillColor(activeOptionTextColor);
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp (294606 => 294607)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2022-05-21 02:25:01 UTC (rev 294606)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2022-05-21 02:33:42 UTC (rev 294607)
@@ -271,7 +271,7 @@
UChar characters[] = { 'a' };
size_t charactersLength = WTF_ARRAY_LENGTH(characters);
- TextRun textRun(StringView(characters, charactersLength), 0, 100, ForceLeftExpansion);
+ TextRun textRun(StringView(characters, charactersLength), 0, 100, ExpansionBehavior::forceLeftOnly());
auto run = ComplexTextController::ComplexTextRun::create({ FloatSize(24, 0) }, { }, { 16 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true);
Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
runs.append(WTFMove(run));
@@ -350,7 +350,7 @@
UChar characters[] = { 0x644, ' ', 0x644, ' ', 0x644 };
size_t charactersLength = WTF_ARRAY_LENGTH(characters);
- TextRun textRun(StringView(characters, charactersLength), 0, 14, DefaultExpansion, TextDirection::RTL);
+ TextRun textRun(StringView(characters, charactersLength), 0, 14, ExpansionBehavior::defaultBehavior(), TextDirection::RTL);
auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 5, 6, 7, 8, 9 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false);
Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
runs.append(WTFMove(run));