Skip to content

Commit

Permalink
Introduce HighestEditableRootOfNode() in VisibleUnitLine.cpp
Browse files Browse the repository at this point in the history
This patch introduces |HighestEditableRootOfNode()| in "VisibleUnitLine.cpp"
to unify the pattern,
  HighestEditableRoot(FirstPositionInOrBeforeNode(node), editable_type)
for improving readability.

BUG=n/a
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2949483002
Cr-Commit-Position: refs/heads/master@{#480760}
  • Loading branch information
yosinch authored and Commit Bot committed Jun 20, 2017
1 parent 88efc12 commit 147c403
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions third_party/WebKit/Source/core/editing/VisibleUnitsLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ ContainerNode* HighestEditableRoot(const Position& position,
return HighestEditableRoot(position);
}

ContainerNode* HighestEditableRootOfNode(const Node& node,
EditableType editable_type) {
// TODO(editing-dev): We should introduce |const Node&| version of
// |FirstPositionInOrBeforeNode()|. See http://crbug.com/734849
return HighestEditableRoot(
FirstPositionInOrBeforeNode(const_cast<Node*>(&node)), editable_type);
}

Node* PreviousNodeConsideringAtomicNodes(const Node& start) {
if (start.previousSibling()) {
Node* node = start.previousSibling();
Expand Down Expand Up @@ -288,8 +296,7 @@ Position PreviousRootInlineBoxCandidatePosition(
FindNodeInPreviousLine(*node, visible_position, editable_type);
for (Node* runner = previous_node; runner && !runner->IsShadowRoot();
runner = PreviousLeafWithSameEditability(runner, editable_type)) {
if (HighestEditableRoot(FirstPositionInOrBeforeNode(runner),
editable_type) != highest_root)
if (HighestEditableRootOfNode(*runner, editable_type) != highest_root)
break;

const Position& candidate =
Expand All @@ -315,8 +322,7 @@ Position NextRootInlineBoxCandidatePosition(

for (Node* runner = next_node; runner && !runner->IsShadowRoot();
runner = NextLeafWithSameEditability(runner, editable_type)) {
if (HighestEditableRoot(FirstPositionInOrBeforeNode(runner),
editable_type) != highest_root)
if (HighestEditableRootOfNode(*runner, editable_type) != highest_root)
break;

const Position& candidate =
Expand Down

0 comments on commit 147c403

Please sign in to comment.