Make DeleteSelectionCommand not to use Position::deprecatedEditingOffset() (issue 1265123002 by yosin@chromium.org)

0 views
Skip to first unread message

yo...@chromium.org

unread,
Aug 3, 2015, 4:17:51 AM8/3/15
to tk...@chromium.org, yoi...@chromium.org, hajim...@chromium.org, blink-...@chromium.org
Reviewers: tkent, yoichio, hajimehoshi,

Message:
PTAL

Description:
Make DeleteSelectionCommand not to use Position::deprecatedEditingOffset()

This patch replaces |Position::deprecatedEditingOffset()| call in
|DeleteSelectionCommand| class by |Position::computeEditingOffset()|, since
it
is used for computing offset for upstream/downstream positions which can
not be
middle of editing ignore content, for improving code health.

This patch is a preparation of getting rid of legacy editing position.

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


Please review this at https://codereview.chromium.org/1265123002/

Base URL: https://chromium.googlesource.com/chromium/blink.git@master

Affected files (+8, -8 lines):
M Source/core/editing/DeleteSelectionCommand.cpp


Index: Source/core/editing/DeleteSelectionCommand.cpp
diff --git a/Source/core/editing/DeleteSelectionCommand.cpp
b/Source/core/editing/DeleteSelectionCommand.cpp
index
70c10f47c2554061c2fce475611503c1ad10ff81..eb6d624bdfc2853fd5f02cda0c7b2f5a25566c6a
100644
--- a/Source/core/editing/DeleteSelectionCommand.cpp
+++ b/Source/core/editing/DeleteSelectionCommand.cpp
@@ -447,7 +447,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (m_upstreamStart.isNull())
return;

- int startOffset = m_upstreamStart.deprecatedEditingOffset();
+ int startOffset = m_upstreamStart.computeEditingOffset();
Node* startNode = m_upstreamStart.anchorNode();
ASSERT(startNode);

@@ -477,13 +477,13 @@ void DeleteSelectionCommand::handleGeneralDelete()
return;

if (startNode == m_downstreamEnd.anchorNode()) {
- if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) {
+ if (m_downstreamEnd.computeEditingOffset() - startOffset > 0) {
if (startNode->isTextNode()) {
// in a text node that needs to be trimmed
Text* text = toText(startNode);
deleteTextFromNode(text, startOffset,
m_downstreamEnd.computeOffsetInContainerNode() - startOffset);
} else {
- removeChildrenInRange(startNode, startOffset,
m_downstreamEnd.deprecatedEditingOffset());
+ removeChildrenInRange(startNode, startOffset,
m_downstreamEnd.computeEditingOffset());
m_endingPosition = m_upstreamStart;
}
}
@@ -525,7 +525,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
node = nextNode.get();
} else {
Node& n = NodeTraversal::lastWithinOrSelf(*node);
- if (m_downstreamEnd.anchorNode() == n &&
m_downstreamEnd.deprecatedEditingOffset() >= caretMaxOffset(&n)) {
+ if (m_downstreamEnd.anchorNode() == n &&
m_downstreamEnd.computeEditingOffset() >= caretMaxOffset(&n)) {
removeNode(node.get());
node = nullptr;
} else {
@@ -534,7 +534,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
}
}

- if (m_downstreamEnd.anchorNode() != startNode
&& !m_upstreamStart.anchorNode()->isDescendantOf(m_downstreamEnd.anchorNode())
&& m_downstreamEnd.inDocument() &&
m_downstreamEnd.deprecatedEditingOffset() >=
caretMinOffset(m_downstreamEnd.anchorNode())) {
+ if (m_downstreamEnd.anchorNode() != startNode
&& !m_upstreamStart.anchorNode()->isDescendantOf(m_downstreamEnd.anchorNode())
&& m_downstreamEnd.inDocument() && m_downstreamEnd.computeEditingOffset()
>= caretMinOffset(m_downstreamEnd.anchorNode())) {
if (m_downstreamEnd.atLastEditingPositionForNode()
&& !canHaveChildrenForEditing(m_downstreamEnd.anchorNode())) {
// The node itself is fully selected, not just its
contents. Delete it.
removeNode(m_downstreamEnd.anchorNode());
@@ -542,8 +542,8 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (m_downstreamEnd.anchorNode()->isTextNode()) {
// in a text node that needs to be trimmed
Text* text = toText(m_downstreamEnd.anchorNode());
- if (m_downstreamEnd.deprecatedEditingOffset() > 0) {
- deleteTextFromNode(text, 0,
m_downstreamEnd.deprecatedEditingOffset());
+ if (m_downstreamEnd.computeEditingOffset() > 0) {
+ deleteTextFromNode(text, 0,
m_downstreamEnd.computeEditingOffset());
}
// Remove children of m_downstreamEnd.anchorNode() that
come after m_upstreamStart.
// Don't try to remove children if m_upstreamStart was
inside m_downstreamEnd.anchorNode()
@@ -560,7 +560,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
if (n)
offset = n->nodeIndex() + 1;
}
- removeChildrenInRange(m_downstreamEnd.anchorNode(),
offset, m_downstreamEnd.deprecatedEditingOffset());
+ removeChildrenInRange(m_downstreamEnd.anchorNode(),
offset, m_downstreamEnd.computeEditingOffset());
m_downstreamEnd =
createLegacyEditingPosition(m_downstreamEnd.anchorNode(), offset);
}
}


tk...@chromium.org

unread,
Aug 3, 2015, 4:29:44 AM8/3/15
to yo...@chromium.org, yoi...@chromium.org, hajim...@chromium.org, blink-...@chromium.org

commit-bot@chromium.org via codereview.chromium.org

unread,
Aug 3, 2015, 4:30:01 AM8/3/15
to yo...@chromium.org, tk...@chromium.org, yoi...@chromium.org, hajim...@chromium.org, commi...@chromium.org, blink-...@chromium.org

commit-bot@chromium.org via codereview.chromium.org

unread,
Aug 3, 2015, 4:33:35 AM8/3/15
to yo...@chromium.org, tk...@chromium.org, yoi...@chromium.org, hajim...@chromium.org, commi...@chromium.org, blink-...@chromium.org
Reply all
Reply to author
Forward
0 new messages