Diff
Modified: trunk/LayoutTests/ChangeLog (287499 => 287500)
--- trunk/LayoutTests/ChangeLog 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/LayoutTests/ChangeLog 2022-01-01 14:55:43 UTC (rev 287500)
@@ -1,3 +1,13 @@
+2022-01-01 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Incorrect word-spacing gaps between RTL runs
+ https://bugs.webkit.org/show_bug.cgi?id=234771
+
+ Reviewed by Antti Koivisto.
+
+ * fast/text/word-spacing-rtl-expected.html: Added.
+ * fast/text/word-spacing-rtl.html: Added.
+
2021-12-31 Tim Nguyen <[email protected]>
Re-import css/css-writing-modes WPT
Added: trunk/LayoutTests/fast/text/word-spacing-rtl-expected.html (0 => 287500)
--- trunk/LayoutTests/fast/text/word-spacing-rtl-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/word-spacing-rtl-expected.html 2022-01-01 14:55:43 UTC (rev 287500)
@@ -0,0 +1,14 @@
+<style>
+div {
+ font-family: Ahem;
+ font-size: 20px;
+ width: 200px;
+ white-space: pre;
+ color: green;
+}
+</style>
+<div style="direction: ltr;">X X X</div>
+<div style="direction: rtl;">X X X</div>
+
+<div style="direction: ltr;">XXX</div>
+<div style="direction: rtl;">XXX</div>
Added: trunk/LayoutTests/fast/text/word-spacing-rtl.html (0 => 287500)
--- trunk/LayoutTests/fast/text/word-spacing-rtl.html (rev 0)
+++ trunk/LayoutTests/fast/text/word-spacing-rtl.html 2022-01-01 14:55:43 UTC (rev 287500)
@@ -0,0 +1,13 @@
+<style>
+div {
+ font-family: Ahem;
+ font-size: 20px;
+ width: 200px;
+ color: green;
+}
+</style>
+<div style="direction: ltr; word-spacing: 20px;">X X X</div>
+<div style="direction: rtl; word-spacing: 20px;">X X X</div>
+
+<div style="direction: ltr; word-spacing: -20px;">X X X</div>
+<div style="direction: rtl; word-spacing: -20px;">X X X</div>
Modified: trunk/Source/WebCore/ChangeLog (287499 => 287500)
--- trunk/Source/WebCore/ChangeLog 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/Source/WebCore/ChangeLog 2022-01-01 14:55:43 UTC (rev 287500)
@@ -1,3 +1,30 @@
+2022-01-01 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Incorrect word-spacing gaps between RTL runs
+ https://bugs.webkit.org/show_bug.cgi?id=234771
+
+ Reviewed by Antti Koivisto.
+
+ "word-spacing" acts as a margin for word separator type of runs.
+ In this patch we take this margin into account the same way we do for atomic inline level boxes with margins.
+
+ Test: fast/text/word-spacing-rtl.html
+
+ * layout/formattingContexts/inline/InlineLine.cpp:
+ (WebCore::Layout::Line::Run::Run):
+ * layout/formattingContexts/inline/InlineLine.h:
+ (WebCore::Layout::Line::Run::isText const):
+ (WebCore::Layout::Line::Run::isWordSeparator const):
+ * layout/formattingContexts/inline/display/InlineDisplayBox.h:
+ (WebCore::InlineDisplay::Box::isText const):
+ (WebCore::InlineDisplay::Box::isWordSeparator const):
+ (WebCore::InlineDisplay::Box::isNonRootInlineLevelBox const):
+ (WebCore::InlineDisplay::Box::type const): Deleted.
+ * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+ (WebCore::Layout::InlineDisplayContentBuilder::appendTextDisplayBox):
+ (WebCore::Layout::InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox):
+ (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+
2021-12-31 Tyler Wilcock <[email protected]>
Reduce repetition in Internals "set page activity state" methods
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (287499 => 287500)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-01-01 14:55:43 UTC (rev 287500)
@@ -572,7 +572,7 @@
}
Line::Run::Run(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
- : m_type(Type::Text)
+ : m_type(inlineTextItem.isWordSeparator() ? Type::WordSeparator : Type::Text)
, m_layoutBox(&inlineTextItem.layoutBox())
, m_logicalLeft(logicalLeft)
, m_logicalWidth(logicalWidth)
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (287499 => 287500)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h 2022-01-01 14:55:43 UTC (rev 287500)
@@ -71,6 +71,7 @@
struct Run {
enum class Type : uint8_t {
Text,
+ WordSeparator,
HardLineBreak,
SoftLineBreak,
WordBreakOpportunity,
@@ -80,7 +81,8 @@
LineSpanningInlineBoxStart
};
- bool isText() const { return m_type == Type::Text; }
+ bool isText() const { return m_type == Type::Text || isWordSeparator(); }
+ bool isWordSeparator() const { return m_type == Type::WordSeparator; }
bool isBox() const { return m_type == Type::AtomicBox; }
bool isLineBreak() const { return isHardLineBreak() || isSoftLineBreak(); }
bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h (287499 => 287500)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2022-01-01 14:55:43 UTC (rev 287500)
@@ -61,6 +61,7 @@
enum class Type {
Text,
+ WordSeparator,
Ellipsis,
SoftLineBreak,
LineBreakBox,
@@ -76,7 +77,8 @@
};
Box(size_t lineIndex, Type, const Layout::Box&, UBiDiLevel, const FloatRect&, const FloatRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true, OptionSet<PositionWithinInlineLevelBox> = { });
- bool isText() const { return m_type == Type::Text; }
+ bool isText() const { return m_type == Type::Text || isWordSeparator(); }
+ bool isWordSeparator() const { return m_type == Type::WordSeparator; }
bool isEllipsis() const { return m_type == Type::Ellipsis; }
bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
bool isTextOrSoftLineBreak() const { return isText() || isSoftLineBreak(); }
@@ -89,7 +91,6 @@
bool isGenericInlineLevelBox() const { return m_type == Type::GenericInlineLevelBox; }
bool isInlineLevelBox() const { return isAtomicInlineLevelBox() || isLineBreakBox() || isInlineBox() || isGenericInlineLevelBox(); }
bool isNonRootInlineLevelBox() const { return isInlineLevelBox() && !isRootInlineBox(); }
- Type type() const { return m_type; }
UBiDiLevel bidiLevel() const { return m_bidiLevel; }
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp (287499 => 287500)
--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp 2022-01-01 14:15:48 UTC (rev 287499)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp 2022-01-01 14:55:43 UTC (rev 287500)
@@ -152,7 +152,7 @@
return text->needsHyphen ? makeString(content.substring(text->start, text->length), style.hyphenString()) : String();
};
boxes.append({ m_lineIndex
- , InlineDisplay::Box::Type::Text
+ , lineRun.isWordSeparator() ? InlineDisplay::Box::Type::WordSeparator : InlineDisplay::Box::Type::Text
, layoutBox
, lineRun.bidiLevel()
, textRunRect
@@ -483,8 +483,9 @@
contentRightInVisualOrder += boxMarginLeft + displayBox.width() + boxMarginRight;
} else {
- displayBox.setLeft(contentRightInVisualOrder);
- contentRightInVisualOrder += displayBox.width();
+ auto wordSpacingMargin = displayBox.isWordSeparator() ? layoutBox.style().fontCascade().wordSpacing() : 0.0f;
+ displayBox.setLeft(contentRightInVisualOrder + wordSpacingMargin);
+ contentRightInVisualOrder += displayBox.width() + wordSpacingMargin;
}
return;
}
@@ -566,8 +567,11 @@
auto parentDisplayBoxNodeIndex = ensureDisplayBoxForContainer(layoutBox.parent(), displayBoxTree, ancestorStack, boxes);
if (lineRun.isText()) {
auto visualRect = visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun));
+ auto wordSpacingMargin = lineRun.isWordSeparator() ? layoutBox.style().fontCascade().wordSpacing() : 0.0f;
+
+ visualRect.moveHorizontally(wordSpacingMargin);
appendTextDisplayBox(lineRun, visualRect, boxes);
- contentRightInVisualOrder += visualRect.width();
+ contentRightInVisualOrder += visualRect.width() + wordSpacingMargin;
displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
continue;
}