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

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

Issue 2950053002: Make Position::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-21T17:56:36 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/Position.cpp
diff --git a/third_party/WebKit/Source/core/editing/Position.cpp b/third_party/WebKit/Source/core/editing/Position.cpp
index 13777618de2d1b135122fdda1ef209f4fc7d0a28..7d79cdf3ad66559c1f13b5b7028c6c858d0dbaed 100644
--- a/third_party/WebKit/Source/core/editing/Position.cpp
+++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -87,10 +87,15 @@ PositionTemplate<Strategy> PositionTemplate<Strategy>::EditingPositionOf(
PositionAnchorType::kAfterAnchor);
}
+// TODO(editing-dev): Once we change type of |anchor_node_| to
+// |Member<const Node>|, we should get rid of |const_cast<Node*>()|.
+// See http://crbug.com/735327
template <typename Strategy>
-PositionTemplate<Strategy>::PositionTemplate(Node* anchor_node,
+PositionTemplate<Strategy>::PositionTemplate(const Node* anchor_node,
PositionAnchorType anchor_type)
- : anchor_node_(anchor_node), offset_(0), anchor_type_(anchor_type) {
+ : anchor_node_(const_cast<Node*>(anchor_node)),
+ offset_(0),
+ anchor_type_(anchor_type) {
if (!anchor_node_) {
anchor_type_ = PositionAnchorType::kOffsetInAnchor;
return;
@@ -461,9 +466,8 @@ PositionTemplate<Strategy> PositionTemplate<Strategy>::InParentAfterNode(
// static
template <typename Strategy>
PositionTemplate<Strategy> PositionTemplate<Strategy>::BeforeNode(
- Node* anchor_node) {
- DCHECK(anchor_node);
- return PositionTemplate<Strategy>(anchor_node,
+ const Node& anchor_node) {
+ return PositionTemplate<Strategy>(&anchor_node,
PositionAnchorType::kBeforeAnchor);
}
@@ -511,7 +515,7 @@ PositionTemplate<Strategy>
PositionTemplate<Strategy>::FirstPositionInOrBeforeNode(Node* node) {
if (!node)
return PositionTemplate<Strategy>();
- return EditingIgnoresContent(*node) ? BeforeNode(node)
+ return EditingIgnoresContent(*node) ? BeforeNode(*node)
: FirstPositionInNode(node);
}
@@ -597,7 +601,7 @@ Position ToPositionInDOMTree(const PositionInFlatTree& position) {
case PositionAnchorType::kBeforeChildren:
return Position(anchor_node, PositionAnchorType::kBeforeChildren);
case PositionAnchorType::kBeforeAnchor:
- return Position::BeforeNode(anchor_node);
+ return Position::BeforeNode(*anchor_node);
case PositionAnchorType::kOffsetInAnchor: {
int offset = position.OffsetInContainerNode();
if (anchor_node->IsCharacterDataNode())
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.h ('k') | third_party/WebKit/Source/core/editing/PositionIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698