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

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

Issue 2937173002: Introduce FindLeftNonPseudoNodeInlineBox() (Closed)
Patch Set: 2017-06-15T16:47:50 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/VisibleUnitsLine.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp b/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
index 624a66267d6c0b6620ffdfc98e00facc41445f91..803bce1662c5f2f007ebd098521196b7a2ea06a6 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
@@ -321,6 +321,15 @@ VisiblePositionInFlatTree LogicalStartOfLine(
current_position.ToPositionWithAffinity()));
}
+InlineBox* FindLeftNonPseudoNodeInlineBox(const RootInlineBox& root_box) {
+ for (InlineBox* runner = root_box.LastLeafChild(); runner;
+ runner = runner->PrevLeafChild()) {
+ if (runner->GetLineLayoutItem().NonPseudoNode())
+ return runner;
+ }
+ return nullptr;
+}
+
template <typename Strategy>
static VisiblePositionTemplate<Strategy> EndPositionForLine(
const VisiblePositionTemplate<Strategy>& c,
@@ -351,17 +360,12 @@ static VisiblePositionTemplate<Strategy> EndPositionForLine(
// Generated content (e.g. list markers and CSS :before and :after
// pseudo elements) have no corresponding DOM element, and so cannot be
// represented by a VisiblePosition. Use whatever precedes instead.
- end_box = root_box->LastLeafChild();
- while (true) {
- if (!end_box)
- return VisiblePositionTemplate<Strategy>();
-
- end_node = end_box->GetLineLayoutItem().NonPseudoNode();
- if (end_node)
- break;
-
- end_box = end_box->PrevLeafChild();
- }
+ // TODO(editing-dev): We should consider text-direction of line to
+ // find non-pseudo node.
+ end_box = FindLeftNonPseudoNodeInlineBox(*root_box);
+ if (!end_box)
+ return VisiblePositionTemplate<Strategy>();
+ end_node = end_box->GetLineLayoutItem().NonPseudoNode();
}
PositionTemplate<Strategy> pos;
« 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