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

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

Issue 2940153002: [LayoutNG] Implement more text-align values and BiDi base direction (Closed)
Patch Set: eae review Created 3 years, 6 months 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/inline/ng_bidi_paragraph.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_bidi_paragraph.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_bidi_paragraph.cc
index 5c513d68852fbd6f1229da3905a200667d81d83d..44ec374a4318031aad83bafb8ce40201469a1134 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_bidi_paragraph.cc
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_bidi_paragraph.cc
@@ -18,20 +18,30 @@ bool NGBidiParagraph::SetParagraph(const String& text,
const ComputedStyle& block_style) {
DCHECK(!ubidi_);
ubidi_ = ubidi_open();
+
+ bool use_heuristic_base_direction =
+ block_style.GetUnicodeBidi() == UnicodeBidi::kPlaintext;
+ UBiDiLevel para_level;
+ if (use_heuristic_base_direction) {
+ para_level = UBIDI_DEFAULT_LTR;
+ } else {
+ base_direction_ = block_style.Direction();
+ para_level = IsLtr(base_direction_) ? UBIDI_LTR : UBIDI_RTL;
+ }
+
ICUError error;
- ubidi_setPara(
- ubidi_, text.Characters16(), text.length(),
- block_style.GetUnicodeBidi() == UnicodeBidi::kPlaintext
- ? UBIDI_DEFAULT_LTR
- : (block_style.Direction() == TextDirection::kRtl ? UBIDI_RTL
- : UBIDI_LTR),
- nullptr, &error);
+ ubidi_setPara(ubidi_, text.Characters16(), text.length(), para_level, nullptr,
+ &error);
if (U_FAILURE(error)) {
NOTREACHED();
ubidi_close(ubidi_);
ubidi_ = nullptr;
return false;
}
+
+ if (use_heuristic_base_direction)
+ base_direction_ = DirectionFromLevel(ubidi_getParaLevel(ubidi_));
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698