Diff
Modified: trunk/Source/WebCore/ChangeLog (285806 => 285807)
--- trunk/Source/WebCore/ChangeLog 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/ChangeLog 2021-11-15 15:51:44 UTC (rev 285807)
@@ -1,3 +1,46 @@
+2021-11-15 Antti Koivisto <an...@apple.com>
+
+ [LFC][Integration] fast/text/international/bidi-innertext.html fails with BiDi enabled
+ https://bugs.webkit.org/show_bug.cgi?id=233125
+
+ Reviewed by Alan Bujtas.
+
+ TextIterator needs to know that RenderText contains bidi text.
+
+ * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+ (WebCore::Layout::InlineItemsBuilder::handleTextContent):
+
+ Use the InlineTextBox bit.
+
+ * layout/formattingContexts/inline/text/TextUtil.cpp:
+ (WebCore::Layout::TextUtil::containsBidiText):
+
+ Add a helper.
+
+ * layout/formattingContexts/inline/text/TextUtil.h:
+ * layout/integration/InlineIteratorLogicalOrderTraversal.cpp:
+ (WebCore::InlineIterator::makeTextLogicalOrderCacheIfNeeded):
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::buildTree):
+ * layout/layouttree/LayoutInlineTextBox.cpp:
+ (WebCore::Layout::InlineTextBox::InlineTextBox):
+ (WebCore::Layout::m_containsBidiText):
+
+ Add a bit to the InlineTextBox.
+
+ (WebCore::Layout::m_canUseSimplifiedContentMeasuring): Deleted.
+ * layout/layouttree/LayoutInlineTextBox.h:
+ (WebCore::Layout::InlineTextBox::containsBidiText const):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::TreeBuilder::createTextBox):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::RenderText):
+ (WebCore::RenderText::positionLineBox):
+ * rendering/RenderText.h:
+ (WebCore::RenderText::containsBidiText const):
+ (WebCore::RenderText::setContainsBidiText):
+ (WebCore::RenderText::containsReversedText const): Deleted.
+
2021-11-15 Alan Bujtas <za...@apple.com>
[LFC][IFC] Take text-indent into account when computing preferred width
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -38,8 +38,6 @@
namespace WebCore {
namespace Layout {
-#define ALLOW_BIDI_CONTENT 0
-
struct WhitespaceContent {
size_t length { 0 };
bool isWordSeparator { true };
@@ -358,6 +356,9 @@
if (!contentLength)
return inlineItems.append(InlineTextItem::createEmptyItem(inlineTextBox));
+ if (inlineTextBox.containsBidiText())
+ m_hasSeenBidiContent = true;
+
auto& style = inlineTextBox.style();
auto& fontCascade = style.fontCascade();
auto shouldPreserveSpacesAndTabs = TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
@@ -435,27 +436,7 @@
auto inlineItemLength = endPosition - startPosition;
inlineItems.append(InlineTextItem::createNonWhitespaceItem(inlineTextBox, startPosition, inlineItemLength, UBIDI_DEFAULT_LTR, hasTrailingSoftHyphen, inlineItemWidth(startPosition, inlineItemLength)));
currentPosition = endPosition;
-#if ALLOW_BIDI_CONTENT
- // Check if the content has bidi dependency so that we have to start building the paragraph content for ubidi.
- if (text.is8Bit() || hasSeenBidiContent())
- return true;
- for (auto position = startPosition; position < endPosition;) {
- UChar32 character;
- U16_NEXT(text.characters16(), position, contentLength, character);
-
- auto bidiCategory = u_charDirection(character);
- m_hasSeenBidiContent = bidiCategory == U_RIGHT_TO_LEFT
- || bidiCategory == U_RIGHT_TO_LEFT_ARABIC
- || bidiCategory == U_RIGHT_TO_LEFT_EMBEDDING
- || bidiCategory == U_RIGHT_TO_LEFT_OVERRIDE
- || bidiCategory == U_LEFT_TO_RIGHT_EMBEDDING
- || bidiCategory == U_LEFT_TO_RIGHT_OVERRIDE
- || bidiCategory == U_POP_DIRECTIONAL_FORMAT;
- if (m_hasSeenBidiContent)
- break;
- }
-#endif
return true;
};
if (handleNonWhitespace())
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -251,6 +251,31 @@
return style.collapseWhiteSpace() == firstLineStyle.collapseWhiteSpace() && style.fontCascade() == firstLineStyle.fontCascade();
}
+bool TextUtil::containsBidiText(StringView text)
+{
+ if (text.is8Bit())
+ return false;
+
+ auto length = text.length();
+ for (size_t position = 0; position < length;) {
+ UChar32 character;
+ U16_NEXT(text.characters16(), position, length, character);
+
+ auto bidiCategory = u_charDirection(character);
+ bool hasBidiContent = bidiCategory == U_RIGHT_TO_LEFT
+ || bidiCategory == U_RIGHT_TO_LEFT_ARABIC
+ || bidiCategory == U_RIGHT_TO_LEFT_EMBEDDING
+ || bidiCategory == U_RIGHT_TO_LEFT_OVERRIDE
+ || bidiCategory == U_LEFT_TO_RIGHT_EMBEDDING
+ || bidiCategory == U_LEFT_TO_RIGHT_OVERRIDE
+ || bidiCategory == U_POP_DIRECTIONAL_FORMAT;
+ if (hasBidiContent)
+ return true;
+ }
+
+ return false;
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h (285806 => 285807)
--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h 2021-11-15 15:51:44 UTC (rev 285807)
@@ -64,6 +64,7 @@
static bool shouldPreserveNewline(const Box&);
static bool canUseSimplifiedTextMeasuringForFirstLine(const RenderStyle&, const RenderStyle& firstLineStyle);
static bool isWrappingAllowed(const RenderStyle&);
+ static bool containsBidiText(StringView);
};
}
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -33,7 +33,7 @@
static TextLogicalOrderCache makeTextLogicalOrderCacheIfNeeded(const RenderText& text)
{
- if (!text.containsReversedText())
+ if (!text.containsBidiText())
return { };
auto cache = makeUnique<TextLogicalOrderCacheData>();
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -97,9 +97,12 @@
return false;
return !firstLineStyle || Layout::TextUtil::canUseSimplifiedTextMeasuringForFirstLine(style, *firstLineStyle);
}();
- return makeUnique<Layout::InlineTextBox>(
- style.textSecurity() == TextSecurity::None ? textRenderer.text() : RenderBlock::updateSecurityDiscCharacters(style, textRenderer.text())
- , canUseSimplifiedTextMeasuring, WTFMove(style), WTFMove(firstLineStyle));
+ auto text = style.textSecurity() == TextSecurity::None ? textRenderer.text() : RenderBlock::updateSecurityDiscCharacters(style, textRenderer.text());
+ auto containsBidiText = Layout::TextUtil::containsBidiText(text);
+ if (containsBidiText)
+ textRenderer.setContainsBidiText();
+
+ return makeUnique<Layout::InlineTextBox>(text, canUseSimplifiedTextMeasuring, containsBidiText, WTFMove(style), WTFMove(firstLineStyle));
}
auto style = RenderStyle::clone(childRenderer.style());
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -36,10 +36,11 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineTextBox);
-InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, RenderStyle&& style, std::unique_ptr<RenderStyle>&& firstLineStyle)
+InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, bool containsBidiText, RenderStyle&& style, std::unique_ptr<RenderStyle>&& firstLineStyle)
: Box({ }, WTFMove(style), WTFMove(firstLineStyle), Box::InlineTextBoxFlag)
, m_content(content)
, m_canUseSimplifiedContentMeasuring(canUseSimplifiedContentMeasuring)
+ , m_containsBidiText(containsBidiText)
{
setIsAnonymous();
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h (285806 => 285807)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h 2021-11-15 15:51:44 UTC (rev 285807)
@@ -37,16 +37,18 @@
class InlineTextBox : public Box {
WTF_MAKE_ISO_ALLOCATED(InlineTextBox);
public:
- InlineTextBox(String, bool canUseSimplifiedContentMeasuring, RenderStyle&&, std::unique_ptr<RenderStyle>&& firstLineStyle = nullptr);
+ InlineTextBox(String, bool canUseSimplifiedContentMeasuring, bool containsBidiText, RenderStyle&&, std::unique_ptr<RenderStyle>&& firstLineStyle = nullptr);
virtual ~InlineTextBox() = default;
String content() const { return m_content; }
// FIXME: This should not be a box's property.
bool canUseSimplifiedContentMeasuring() const { return m_canUseSimplifiedContentMeasuring; }
+ bool containsBidiText() const { return m_containsBidiText; }
private:
String m_content;
bool m_canUseSimplifiedContentMeasuring { false };
+ bool m_containsBidiText { false };
};
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (285806 => 285807)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -59,6 +59,7 @@
#include "RenderTableCaption.h"
#include "RenderTableCell.h"
#include "RenderView.h"
+#include "TextUtil.h"
#include "WidthIterator.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/TextStream.h>
@@ -133,7 +134,7 @@
std::unique_ptr<Box> TreeBuilder::createTextBox(String text, bool canUseSimplifiedTextMeasuring, RenderStyle&& style)
{
- return makeUnique<InlineTextBox>(text, canUseSimplifiedTextMeasuring, WTFMove(style));
+ return makeUnique<InlineTextBox>(text, canUseSimplifiedTextMeasuring, TextUtil::containsBidiText(text), WTFMove(style));
}
std::unique_ptr<Box> TreeBuilder::createLineBreakBox(bool isOptional, RenderStyle&& style)
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (285806 => 285807)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2021-11-15 15:51:44 UTC (rev 285807)
@@ -190,7 +190,7 @@
: RenderObject(node)
, m_hasTab(false)
, m_linesDirty(false)
- , m_containsReversedText(false)
+ , m_containsBidiText(false)
, m_isAllASCII(text.impl()->isAllASCII())
, m_knownToHaveNoOverflowAndNoFallbackFonts(false)
, m_useBackslashAsYenSymbol(false)
@@ -1521,7 +1521,7 @@
{
if (!textBox.hasTextContent())
return;
- m_containsReversedText |= !textBox.isLeftToRightDirection();
+ m_containsBidiText |= !textBox.isLeftToRightDirection();
}
bool RenderText::usesLegacyLineLayoutPath() const
Modified: trunk/Source/WebCore/rendering/RenderText.h (285806 => 285807)
--- trunk/Source/WebCore/rendering/RenderText.h 2021-11-15 14:47:03 UTC (rev 285806)
+++ trunk/Source/WebCore/rendering/RenderText.h 2021-11-15 15:51:44 UTC (rev 285807)
@@ -145,7 +145,8 @@
int previousOffsetForBackwardDeletion(int current) const final;
int nextOffset(int current) const final;
- bool containsReversedText() const { return m_containsReversedText; }
+ bool containsBidiText() const { return m_containsBidiText; }
+ void setContainsBidiText() { m_containsBidiText = true; }
void momentarilyRevealLastTypedCharacter(unsigned offsetAfterLastTypedCharacter);
@@ -231,7 +232,7 @@
// line boxes, and this hint will enable layoutInlineChildren to avoid
// just dirtying everything when character data is modified (e.g., appended/inserted
// or removed).
- unsigned m_containsReversedText : 1;
+ unsigned m_containsBidiText : 1;
unsigned m_isAllASCII : 1;
unsigned m_canUseSimpleFontCodePath : 1;
mutable unsigned m_knownToHaveNoOverflowAndNoFallbackFonts : 1;