Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_bidi_paragraph.cc

Issue 2563403002: [LayoutNG] Add Bidi reordering and fill in NGPhysicalTextFragment (Closed)
Patch Set: ikilpatrick review Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698