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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2950763002: Introduce AdjustInlineBoxPositionForPrimaryDirection() for ComputeInlineBoxPosition() (Closed)
Patch Set: 2017-06-20T18:53:06 rebase for win_clang bot 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index 3bfedbb252a4f91577d61c68a4f703cf2faa192f..d6842c7919a504be604a43fe2211cb3c89b1d944 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -749,48 +749,52 @@ static bool IsStartOfDifferentDirection(const InlineBox* inline_box) {
return prev_box->BidiLevel() > inline_box->BidiLevel();
}
-static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
+static InlineBoxPosition AdjustInlineBoxPositionForPrimaryDirection(
InlineBox* inline_box,
- int caret_offset,
- UnicodeBidi unicode_bidi,
- TextDirection primary_direction) {
- unsigned char level = inline_box->BidiLevel();
+ int caret_offset) {
+ if (caret_offset == inline_box->CaretRightmostOffset()) {
+ InlineBox* const next_box = inline_box->NextLeafChild();
+ if (!next_box || next_box->BidiLevel() >= inline_box->BidiLevel())
+ return InlineBoxPosition(inline_box, caret_offset);
- if (inline_box->Direction() == primary_direction) {
- if (caret_offset == inline_box->CaretRightmostOffset()) {
- InlineBox* next_box = inline_box->NextLeafChild();
- if (!next_box || next_box->BidiLevel() >= level)
- return InlineBoxPosition(inline_box, caret_offset);
+ const unsigned level = next_box->BidiLevel();
+ InlineBox* const prev_box =
+ InlineBoxTraversal::FindLeftBidiRun(*inline_box, level);
- level = next_box->BidiLevel();
- InlineBox* const prev_box =
- InlineBoxTraversal::FindLeftBidiRun(*inline_box, level);
+ // For example, abc FED 123 ^ CBA
+ if (prev_box && prev_box->BidiLevel() == level)
+ return InlineBoxPosition(inline_box, caret_offset);
- // For example, abc FED 123 ^ CBA
- if (prev_box && prev_box->BidiLevel() == level)
- return InlineBoxPosition(inline_box, caret_offset);
+ // For example, abc 123 ^ CBA
+ inline_box = InlineBoxTraversal::FindRightBoundaryOfEntireBidiRun(
+ *inline_box, level);
+ return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
+ }
- // For example, abc 123 ^ CBA
- inline_box = InlineBoxTraversal::FindRightBoundaryOfEntireBidiRun(
- *inline_box, level);
- return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
- }
+ if (IsStartOfDifferentDirection(inline_box))
+ return InlineBoxPosition(inline_box, caret_offset);
- if (IsStartOfDifferentDirection(inline_box))
- return InlineBoxPosition(inline_box, caret_offset);
+ const unsigned level = inline_box->PrevLeafChild()->BidiLevel();
+ InlineBox* const next_box =
+ InlineBoxTraversal::FindRightBidiRun(*inline_box, level);
- level = inline_box->PrevLeafChild()->BidiLevel();
- InlineBox* const next_box =
- InlineBoxTraversal::FindRightBidiRun(*inline_box, level);
+ if (next_box && next_box->BidiLevel() == level)
+ return InlineBoxPosition(inline_box, caret_offset);
- if (next_box && next_box->BidiLevel() == level)
- return InlineBoxPosition(inline_box, caret_offset);
+ inline_box =
+ InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRun(*inline_box, level);
+ return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset());
+}
- inline_box =
- InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRun(*inline_box, level);
- return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset());
- }
+static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
+ InlineBox* inline_box,
+ int caret_offset,
+ UnicodeBidi unicode_bidi,
+ TextDirection primary_direction) {
+ if (inline_box->Direction() == primary_direction)
+ return AdjustInlineBoxPositionForPrimaryDirection(inline_box, caret_offset);
+ const unsigned char level = inline_box->BidiLevel();
if (caret_offset == inline_box->CaretLeftmostOffset()) {
InlineBox* prev_box = inline_box->PrevLeafChildIgnoringLineBreak();
if (!prev_box || prev_box->BidiLevel() < level) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698