Title: [285095] trunk/Source/WebCore
- Revision
- 285095
- Author
- [email protected]
- Date
- 2021-10-31 10:26:51 -0700 (Sun, 31 Oct 2021)
Log Message
[LFC][IFC] Keep track of the text box offset in ubidi's paragraph content
https://bugs.webkit.org/show_bug.cgi?id=232540
Reviewed by Antti Koivisto.
This hashmap helps to map bidi boundary positions back to inline items.
The paragraph content string holds the InlineTextBox content (and injected control characters)
in DOM order. InlineTextItems hold start/end positions relative to their InlineTextBoxes.
We'll use this hashmap to figure out which InlineTextItems need splitting at bidi boundaries.
* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::InlineItemsBuilder::handleInlineBox):
(WebCore::Layout::InlineItemsBuilder::enterBidiContext):
(WebCore::Layout::InlineItemsBuilder::exitBidiContext):
* layout/formattingContexts/inline/InlineItemsBuilder.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (285094 => 285095)
--- trunk/Source/WebCore/ChangeLog 2021-10-31 15:18:55 UTC (rev 285094)
+++ trunk/Source/WebCore/ChangeLog 2021-10-31 17:26:51 UTC (rev 285095)
@@ -1,3 +1,22 @@
+2021-10-31 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Keep track of the text box offset in ubidi's paragraph content
+ https://bugs.webkit.org/show_bug.cgi?id=232540
+
+ Reviewed by Antti Koivisto.
+
+ This hashmap helps to map bidi boundary positions back to inline items.
+
+ The paragraph content string holds the InlineTextBox content (and injected control characters)
+ in DOM order. InlineTextItems hold start/end positions relative to their InlineTextBoxes.
+ We'll use this hashmap to figure out which InlineTextItems need splitting at bidi boundaries.
+
+ * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+ (WebCore::Layout::InlineItemsBuilder::handleInlineBox):
+ (WebCore::Layout::InlineItemsBuilder::enterBidiContext):
+ (WebCore::Layout::InlineItemsBuilder::exitBidiContext):
+ * layout/formattingContexts/inline/InlineItemsBuilder.h:
+
2021-10-31 Simon Fraser <[email protected]>
Scroll animations should run at 120Hz on 120Hz displays
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (285094 => 285095)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-10-31 15:18:55 UTC (rev 285094)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-10-31 17:26:51 UTC (rev 285095)
@@ -255,9 +255,9 @@
}
if (enteringContentControlChar)
- enterBidiContext(inlineBox, *enteringContentControlChar);
+ enterBidiContext(inlineBox, *enteringContentControlChar, inlineItems);
if (nestedContentControlChar)
- enterBidiContext(inlineBox, *nestedContentControlChar);
+ enterBidiContext(inlineBox, *nestedContentControlChar, inlineItems);
}
void InlineItemsBuilder::handleInlineBoxEnd(const Box& inlineBox, InlineItems& inlineItems)
@@ -313,14 +313,36 @@
ASSERT_NOT_REACHED();
}
-void InlineItemsBuilder::enterBidiContext(const Box&, UChar)
+void InlineItemsBuilder::enterBidiContext(const Box& box, UChar controlCharacter, const InlineItems& inlineItems)
{
- // FIXME: Inject the control character to the paragraph string.
+ if (m_paragraphContentBuilder.isEmpty()) {
+ // FIXME: Move this to a dedicated function to support control characters embedded in text content.
+ auto buildPreviousTextContent = [&] {
+ const Box* lastLayoutBox = nullptr;
+ for (auto& inlineItem : inlineItems) {
+ if (!inlineItem.isText())
+ continue;
+ auto& layoutBox = inlineItem.layoutBox();
+ if (lastLayoutBox == &layoutBox) {
+ // We've already appended this content.
+ continue;
+ }
+ m_contentOffsetMap.set(&layoutBox, m_paragraphContentBuilder.length());
+ m_paragraphContentBuilder.append(downcast<InlineTextBox>(layoutBox).content());
+ lastLayoutBox = &layoutBox;
+ }
+ };
+ buildPreviousTextContent();
+ }
+ // Let the first control character represent the box.
+ m_contentOffsetMap.add(&box, m_paragraphContentBuilder.length());
+ m_paragraphContentBuilder.append(controlCharacter);
}
-void InlineItemsBuilder::exitBidiContext(const Box&, UChar)
+void InlineItemsBuilder::exitBidiContext(const Box&, UChar controlCharacter)
{
- // FIXME: Inject the control character to the paragraph string.
+ ASSERT(!m_paragraphContentBuilder.isEmpty());
+ m_paragraphContentBuilder.append(controlCharacter);
}
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (285094 => 285095)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h 2021-10-31 15:18:55 UTC (rev 285094)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h 2021-10-31 17:26:51 UTC (rev 285095)
@@ -29,6 +29,7 @@
#include "InlineFormattingState.h"
#include "LayoutContainerBox.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
namespace Layout {
@@ -48,7 +49,7 @@
void handleInlineBoxEnd(const Box&, InlineItems&);
void handleInlineLevelBox(const Box&, InlineItems&);
- void enterBidiContext(const Box&, UChar);
+ void enterBidiContext(const Box&, UChar, const InlineItems&);
void exitBidiContext(const Box&, UChar);
const ContainerBox& root() const { return m_root; }
@@ -56,6 +57,10 @@
const ContainerBox& m_root;
// FIXME: We should not need this here. This is only required by the out of flow boxes.
InlineFormattingState& m_formattingState;
+
+ StringBuilder m_paragraphContentBuilder;
+ // Keep track of where each layout box starts in the paragraph content.
+ HashMap<const Box*, size_t> m_contentOffsetMap;
};
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes