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

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

Issue 2942523003: Introduce Find{Left,Right}BoundaryOfBidiRun() and variations (Closed)
Patch Set: 2017-06-15T12:30:33 Pass Bidi level to FindBoundary 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 | « third_party/WebKit/Source/core/editing/InlineBoxTraversal.cpp ('k') | 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 5def96008bcf39ce3f192892caeeb93e0db0ea4e..b43443a937223a479b41b6b0b6af55109d2ae710 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -34,6 +34,7 @@
#include "core/dom/Text.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/FrameSelection.h"
+#include "core/editing/InlineBoxTraversal.h"
#include "core/editing/Position.h"
#include "core/editing/PositionIterator.h"
#include "core/editing/RenderedPosition.h"
@@ -881,11 +882,8 @@ static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
return InlineBoxPosition(inline_box, caret_offset);
// For example, abc 123 ^ CBA
- while (InlineBox* next_box = inline_box->NextLeafChild()) {
- if (next_box->BidiLevel() < level)
- break;
- inline_box = next_box;
- }
+ inline_box = InlineBoxTraversal::FindRightBoundaryOfEntireBidiRun(
+ *inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
}
@@ -901,11 +899,8 @@ static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
if (next_box && next_box->BidiLevel() == level)
return InlineBoxPosition(inline_box, caret_offset);
- while (InlineBox* prev_box = inline_box->PrevLeafChild()) {
- if (prev_box->BidiLevel() < level)
- break;
- inline_box = prev_box;
- }
+ inline_box =
+ InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRun(*inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset());
}
@@ -914,23 +909,17 @@ static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
if (!prev_box || prev_box->BidiLevel() < level) {
// Left edge of a secondary run. Set to the right edge of the entire
// run.
- while (InlineBox* next_box =
- inline_box->NextLeafChildIgnoringLineBreak()) {
- if (next_box->BidiLevel() < level)
- break;
- inline_box = next_box;
- }
+ inline_box =
+ InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak(
+ *inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
}
if (prev_box->BidiLevel() > level) {
// Right edge of a "tertiary" run. Set to the left edge of that run.
- while (InlineBox* tertiary_box =
- inline_box->PrevLeafChildIgnoringLineBreak()) {
- if (tertiary_box->BidiLevel() <= level)
- break;
- inline_box = tertiary_box;
- }
+ inline_box =
+ InlineBoxTraversal::FindLeftBoundaryOfBidiRunIgnoringLineBreak(
+ *inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset());
}
return InlineBoxPosition(inline_box, caret_offset);
@@ -946,11 +935,9 @@ static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
if (!next_box || next_box->BidiLevel() < level) {
// Right edge of a secondary run. Set to the left edge of the entire
// run.
- while (InlineBox* prev_box = inline_box->PrevLeafChildIgnoringLineBreak()) {
- if (prev_box->BidiLevel() < level)
- break;
- inline_box = prev_box;
- }
+ inline_box =
+ InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak(
+ *inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset());
}
@@ -958,12 +945,8 @@ static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
return InlineBoxPosition(inline_box, caret_offset);
// Left edge of a "tertiary" run. Set to the right edge of that run.
- while (InlineBox* tertiary_box =
- inline_box->NextLeafChildIgnoringLineBreak()) {
- if (tertiary_box->BidiLevel() <= level)
- break;
- inline_box = tertiary_box;
- }
+ inline_box = InlineBoxTraversal::FindRightBoundaryOfBidiRunIgnoringLineBreak(
+ *inline_box, level);
return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/InlineBoxTraversal.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698