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

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

Issue 1000533004: Move implementation of Range::firstNode and Range::pastLastNode to Position (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-03-13T16:48:34 Created 5 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') | Source/core/dom/Range.cpp » ('J')
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 b29bca737b8a3dabe204e9fa67aff1cfa8279ea3..2fbcab9f245c343415cab4042dabcd3dbcde3c71 100644
--- a/Source/core/dom/Position.h
+++ b/Source/core/dom/Position.h
@@ -105,6 +105,12 @@ public:
int computeOffsetInContainerNode() const; // O(n) for before/after-anchored positions, O(1) for parent-anchored positions
Position parentAnchoredEquivalent() const; // Convenience method for DOM positions that also fixes up some positions for editing
+ // Returns |PositionIsAnchor| type |Position| which is compatible with
+ // |RangeBoundaryPoint| as safe to pass |Range| constructor. Return value
+ // of this function is different from |parentAnchoredEquivalent()| which
+ // returns editing specific position.
+ Position toOffsetInAnchor() const;
+
// Inline O(1) access for Positions which callers know to be parent-anchored
int offsetInContainerNode() const
{
@@ -124,6 +130,16 @@ public:
Node* computeNodeBeforePosition() const;
Node* computeNodeAfterPosition() const;
+ // Returns node as |Range::firstNode()|. This position must be a
+ // |PositionIs::OffsetInAhcor| to behave as |Range| boundary point.
+ Node* nodeAsRangeFirstNode() const;
+
+ // Returns a node as past last as same as |Range::pastLastNode()|. This
+ // function is supposed to used in HTML serialization and plain text
+ // iterator. This position must be a |PositionIs::OffsetInAhcor| to
+ // behave as |Range| boundary point.
+ Node* nodeAsRangePastLastNode() const;
+
Node* anchorNode() const { return m_anchorNode.get(); }
// FIXME: Callers should be moved off of node(), node() is not always the container for this position.
« no previous file with comments | « no previous file | Source/core/dom/Position.cpp » ('j') | Source/core/dom/Range.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698