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

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

Issue 2949763002: Introduce Position constructor with const Node& (Closed)
Patch Set: 2017-06-21T13:23:13 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
Index: third_party/WebKit/Source/core/editing/SelectionEditor.cpp
diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
index 4f3e990c05ddbcf6000daecd9eb15164a07658af..fdf7cea3a9d9a492eb7d2e2d47b17408efdf6e86 100644
--- a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
@@ -277,8 +277,6 @@ void SelectionEditor::DidUpdateCharacterData(CharacterData* node,
DidFinishTextChange(new_base, new_extent);
}
-// TODO(yosin): We should introduce |Position(const Text&, int)| to avoid
-// |const_cast<Text*>|.
static Position UpdatePostionAfterAdoptingTextNodesMerged(
const Position& position,
const Text& merged_node,
@@ -292,21 +290,21 @@ static Position UpdatePostionAfterAdoptingTextNodesMerged(
return position;
case PositionAnchorType::kBeforeAnchor:
if (anchor_node == node_to_be_removed)
- return Position(const_cast<Text*>(&merged_node), merged_node.length());
+ return Position(merged_node, merged_node.length());
return position;
case PositionAnchorType::kAfterAnchor:
if (anchor_node == node_to_be_removed)
- return Position(const_cast<Text*>(&merged_node), merged_node.length());
+ return Position(merged_node, merged_node.length());
if (anchor_node == merged_node)
- return Position(const_cast<Text*>(&merged_node), old_length);
+ return Position(merged_node, old_length);
return position;
case PositionAnchorType::kOffsetInAnchor: {
const int offset = position.OffsetInContainerNode();
if (anchor_node == node_to_be_removed)
- return Position(const_cast<Text*>(&merged_node), old_length + offset);
+ return Position(merged_node, old_length + offset);
if (anchor_node == node_to_be_removed.parentNode() &&
offset == node_to_be_removed_with_index.Index()) {
- return Position(const_cast<Text*>(&merged_node), old_length);
+ return Position(merged_node, old_length);
}
return position;
}

Powered by Google App Engine
This is Rietveld 408576698