Index: third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc b/third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc |
index 48b234fadf809732a01dda1a10ee65b3e560ecd2..bd5a0847195a948f12ed77a918080725acba5d63 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc |
@@ -4,6 +4,7 @@ |
#include "core/layout/ng/ng_bidi_paragraph.h" |
+#include "core/layout/ng/ng_inline_node.h" |
#include "core/style/ComputedStyle.h" |
#include "platform/text/ICUError.h" |
@@ -39,4 +40,23 @@ unsigned NGBidiParagraph::GetLogicalRun(unsigned start, |
return end; |
} |
+void NGBidiParagraph::IndiciesInVisualOrder( |
+ const NGLayoutInlineItemRange& items, |
+ Vector<int32_t, 32>* item_indicies_in_visual_order_out) { |
+ // ICU |ubidi_getVisualMap()| works for a run of characters. Since we can |
+ // handle the direction of each run, we use |ubidi_reorderVisual()| to reorder |
+ // runs instead of characters. |
+ // To do so, create a list of bidi levels by pretending a run is a character. |
+ Vector<UBiDiLevel, 32> levels; |
+ levels.reserveInitialCapacity(items.Size()); |
+ for (const NGLayoutInlineItem& item : items) |
+ levels.append(item.BidiLevel()); |
+ |
+ // Check the size before passing the raw pointers to ICU. |
+ CHECK_EQ(items.Size(), levels.size()); |
+ CHECK_EQ(items.Size(), item_indicies_in_visual_order_out->size()); |
+ ubidi_reorderVisual(levels.data(), items.Size(), |
+ item_indicies_in_visual_order_out->data()); |
+} |
+ |
} // namespace blink |