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

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

Issue 2944563002: Utilize InlineBoxTraversal in {Left,Right}PositionOf() left/right traversal (Closed)
Patch Set: 2017-06-16T12:38:41 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/SelectionModifierCharacter.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionModifierCharacter.cpp b/third_party/WebKit/Source/core/editing/SelectionModifierCharacter.cpp
index 9809c33c2d7e2a706861c29bc6cbb9b576a4b4ab..58aeaf3a224fe46e0afef099397d189217b5f389 100644
--- a/third_party/WebKit/Source/core/editing/SelectionModifierCharacter.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionModifierCharacter.cpp
@@ -31,6 +31,7 @@
#include "core/editing/SelectionModifier.h"
#include "core/editing/EditingUtilities.h"
+#include "core/editing/InlineBoxTraversal.h"
#include "core/editing/VisibleUnits.h"
#include "core/layout/api/LineLayoutAPIShim.h"
#include "core/layout/api/LineLayoutItem.h"
@@ -64,6 +65,17 @@ struct TraversalLeft {
return box.CaretLeftmostOffset();
}
+ static InlineBox* FindBackwardBoundaryOfEntireBidiRun(const InlineBox& box,
+ unsigned bidi_level) {
+ return InlineBoxTraversal::FindRightBoundaryOfEntireBidiRun(box,
+ bidi_level);
+ }
+
+ static InlineBox* FindForwardBoundaryOfEntireBidiRun(const InlineBox& box,
+ unsigned bidi_level) {
+ return InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRun(box, bidi_level);
+ }
+
static int ForwardGraphemeBoundaryOf(TextDirection direction,
Node* node,
int offset) {
@@ -135,6 +147,17 @@ struct TraversalRight {
return box.CaretRightmostOffset();
}
+ static InlineBox* FindBackwardBoundaryOfEntireBidiRun(const InlineBox& box,
+ unsigned bidi_level) {
+ return InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRun(box, bidi_level);
+ }
+
+ static InlineBox* FindForwardBoundaryOfEntireBidiRun(const InlineBox& box,
+ unsigned bidi_level) {
+ return InlineBoxTraversal::FindRightBoundaryOfEntireBidiRun(box,
+ bidi_level);
+ }
+
static int ForwardGraphemeBoundaryOf(TextDirection direction,
Node* node,
int offset) {
@@ -323,19 +346,11 @@ static PositionTemplate<Strategy> TraverseInternalAlgorithm(
// Trailing edge of a secondary run. Set to the leading edge of
// the entire run.
while (true) {
- while (InlineBox* next_box = Traversal::BackwardLeafChildOf(*box)) {
- if (next_box->BidiLevel() < level)
- break;
- box = next_box;
- }
+ box = Traversal::FindBackwardBoundaryOfEntireBidiRun(*box, level);
if (box->BidiLevel() == level)
break;
level = box->BidiLevel();
- while (InlineBox* prev_box = Traversal::ForwardLeafChildOf(*box)) {
- if (prev_box->BidiLevel() < level)
- break;
- box = prev_box;
- }
+ box = Traversal::FindForwardBoundaryOfEntireBidiRun(*box, level);
if (box->BidiLevel() == level)
break;
level = box->BidiLevel();
« 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