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

Unified Diff: Source/core/dom/Position.h

Issue 188033005: Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Source/core/dom/Position.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Position.h
diff --git a/Source/core/dom/Position.h b/Source/core/dom/Position.h
index 643ba2b7ac41bb4b65eb16a77d280ec9ebd34753..84289dc994de9a2d8406d30b34e4696909bea2cb 100644
--- a/Source/core/dom/Position.h
+++ b/Source/core/dom/Position.h
@@ -152,9 +152,9 @@ public:
// using composed characters, the result may be inside a single user-visible character if a ligature is formed.
Position previous(PositionMoveType = CodePoint) const;
Position next(PositionMoveType = CodePoint) const;
- static int uncheckedPreviousOffset(const Node*, int current);
- static int uncheckedPreviousOffsetForBackwardDeletion(const Node*, int current);
- static int uncheckedNextOffset(const Node*, int current);
+ static int uncheckedPreviousOffset(const Node&, int current);
+ static int uncheckedPreviousOffsetForBackwardDeletion(const Node&, int current);
+ static int uncheckedNextOffset(const Node&, int current);
// These can be either inside or just before/after the node, depending on
// if the node is ignored by editing or not.
@@ -193,8 +193,6 @@ public:
static bool nodeIsUserSelectAll(const Node*);
static Node* rootUserSelectAllForNode(Node*);
- static ContainerNode* findParent(const Node*);
-
void debugPosition(const char* msg = "") const;
#ifndef NDEBUG
@@ -260,21 +258,19 @@ inline Position positionInParentAfterNode(const Node& node)
}
// positionBeforeNode and positionAfterNode return neighbor-anchored positions, construction is O(1)
-inline Position positionBeforeNode(Node* anchorNode)
+inline Position positionBeforeNode(Node& anchorNode)
{
- ASSERT(anchorNode);
- return Position(anchorNode, Position::PositionIsBeforeAnchor);
+ return Position(PassRefPtr<Node>(anchorNode), Position::PositionIsBeforeAnchor);
}
-inline Position positionAfterNode(Node* anchorNode)
+inline Position positionAfterNode(Node& anchorNode)
{
- ASSERT(anchorNode);
- return Position(anchorNode, Position::PositionIsAfterAnchor);
+ return Position(PassRefPtr<Node>(anchorNode), Position::PositionIsAfterAnchor);
}
-inline int lastOffsetInNode(Node* node)
+inline int lastOffsetInNode(Node& node)
{
- return node->offsetInCharacters() ? node->maxCharacterOffset() : static_cast<int>(node->countChildren());
+ return node.offsetInCharacters() ? node.maxCharacterOffset() : static_cast<int>(node.countChildren());
}
// firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to countChildren()
@@ -288,7 +284,7 @@ inline Position firstPositionInNode(Node* anchorNode)
inline Position lastPositionInNode(Node* anchorNode)
{
if (anchorNode->isTextNode())
- return Position(anchorNode, lastOffsetInNode(anchorNode), Position::PositionIsOffsetInAnchor);
+ return Position(anchorNode, lastOffsetInNode(*anchorNode), Position::PositionIsOffsetInAnchor);
return Position(anchorNode, Position::PositionIsAfterChildren);
}
« no previous file with comments | « no previous file | Source/core/dom/Position.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698