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/RenderedPosition.cpp

Issue 2940273002: Utilize Find{Left,Right}BoundaryOfEntireBidiRunIgnoringLineBreak() in RenderedPosition (Closed)
Patch Set: 2017-06-16T14:22:58 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/RenderedPosition.cpp
diff --git a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
index d790a7bf6dc7ddf4f68ed29eb7cce46d43c595d3..db3e2f2121a94171b769143462b9effe0fc5e196 100644
--- a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
+++ b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
@@ -30,6 +30,7 @@
#include "core/editing/RenderedPosition.h"
+#include "core/editing/InlineBoxTraversal.h"
#include "core/editing/TextAffinity.h"
#include "core/editing/VisiblePosition.h"
#include "core/editing/VisibleUnits.h"
@@ -147,18 +148,12 @@ RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun(
if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel())
return RenderedPosition();
- InlineBox* box = inline_box_;
- do {
- InlineBox* prev = box->PrevLeafChildIgnoringLineBreak();
- if (!prev || prev->BidiLevel() < bidi_level_of_run)
- return RenderedPosition(
- LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
- box->CaretLeftmostOffset());
- box = prev;
- } while (box);
-
- NOTREACHED();
- return RenderedPosition();
+ InlineBox* const box =
+ InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak(
+ *inline_box_, bidi_level_of_run);
+ return RenderedPosition(
+ LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
+ box->CaretLeftmostOffset());
}
RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
@@ -166,18 +161,12 @@ RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel())
return RenderedPosition();
- InlineBox* box = inline_box_;
- do {
- InlineBox* next = box->NextLeafChildIgnoringLineBreak();
- if (!next || next->BidiLevel() < bidi_level_of_run)
- return RenderedPosition(
- LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
- box->CaretRightmostOffset());
- box = next;
- } while (box);
-
- NOTREACHED();
- return RenderedPosition();
+ InlineBox* const box =
+ InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak(
+ *inline_box_, bidi_level_of_run);
+ return RenderedPosition(
+ LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
+ box->CaretRightmostOffset());
}
bool RenderedPosition::AtLeftBoundaryOfBidiRun(
« 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