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

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

Issue 2941233002: Refactor PreviousRootInlineBoxCandidatePosition() (Closed)
Patch Set: 2017-06-16T17:14:24 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 4e0da7b8bca4b8bed3208ebaf42b26e0d28fe8f0..c84b7cfd8657b7154b42f8c459475d3125a6a772 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
@@ -231,21 +231,18 @@ Position PreviousRootInlineBoxCandidatePosition(
PreviousLeafWithSameEditability(previous_node, editable_type);
}
- while (previous_node && !previous_node->IsShadowRoot()) {
- if (HighestEditableRoot(FirstPositionInOrBeforeNode(previous_node),
+ for (Node* runner = previous_node; runner && !runner->IsShadowRoot();
+ runner = PreviousLeafWithSameEditability(runner, editable_type)) {
+ if (HighestEditableRoot(FirstPositionInOrBeforeNode(runner),
editable_type) != highest_root)
break;
- Position pos = isHTMLBRElement(*previous_node)
- ? Position::BeforeNode(previous_node)
- : Position::EditingPositionOf(
- previous_node, CaretMaxOffset(previous_node));
-
- if (IsVisuallyEquivalentCandidate(pos))
- return pos;
-
- previous_node =
- PreviousLeafWithSameEditability(previous_node, editable_type);
+ const Position& candidate =
+ isHTMLBRElement(*runner)
+ ? Position::BeforeNode(runner)
+ : Position::EditingPositionOf(runner, CaretMaxOffset(runner));
+ if (IsVisuallyEquivalentCandidate(candidate))
+ return candidate;
}
return Position();
}
« 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