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

Unified Diff: Source/core/dom/Range.cpp

Issue 1149373003: Remove Range.compareNode() as it is not in the spec (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: updated webexposed/global-interface-listing.html Created 5 years, 5 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 | « Source/core/dom/Range.h ('k') | Source/core/dom/Range.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Range.cpp
diff --git a/Source/core/dom/Range.cpp b/Source/core/dom/Range.cpp
index f9cb4fef91945ad16ed3263304134eb07c4c9f5d..5a67244d385d5c053d7f15ef6c773f65682840bb 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -238,7 +238,15 @@ void Range::collapse(bool toStart)
m_start = m_end;
}
-bool Range::isPointInRange(Node* refNode, int offset, ExceptionState& exceptionState)
+bool Range::isNodeFullyContained(Node& node) const
+{
+ ContainerNode* parentNode = node.parentNode();
+ int nodeIndex = node.nodeIndex();
+ return isPointInRange(parentNode, nodeIndex, IGNORE_EXCEPTION) // starts in the middle of this range, or on the boundary points.
+ && isPointInRange(parentNode, nodeIndex + 1, IGNORE_EXCEPTION); // ends in the middle of this range, or on the boundary points.
+}
+
+bool Range::isPointInRange(Node* refNode, int offset, ExceptionState& exceptionState) const
{
if (!refNode) {
// FIXME: Generated bindings code never calls with null, and neither should other callers!
@@ -293,49 +301,6 @@ short Range::comparePoint(Node* refNode, int offset, ExceptionState& exceptionSt
return 0;
}
-Range::CompareResults Range::compareNode(Node* refNode, ExceptionState& exceptionState) const
-{
- // http://developer.mozilla.org/en/docs/DOM:range.compareNode
- // This method returns 0, 1, 2, or 3 based on if the node is before, after,
- // before and after(surrounds), or inside the range, respectively
-
- if (!refNode) {
- // FIXME: Generated bindings code never calls with null, and neither should other callers!
- exceptionState.throwTypeError("The node provided is null.");
- return NODE_BEFORE;
- }
-
- if (!refNode->inActiveDocument()) {
- // Firefox doesn't throw an exception for this case; it returns 0.
- return NODE_BEFORE;
- }
-
- if (refNode->document() != m_ownerDocument) {
- // Firefox doesn't throw an exception for this case; it returns 0.
- return NODE_BEFORE;
- }
-
- ContainerNode* parentNode = refNode->parentNode();
- int nodeIndex = refNode->nodeIndex();
-
- if (!parentNode) {
- // if the node is the top document we should return NODE_BEFORE_AND_AFTER
- // but we throw to match firefox behavior
- exceptionState.throwDOMException(NotFoundError, "The provided node has no parent.");
- return NODE_BEFORE;
- }
-
- if (comparePoint(parentNode, nodeIndex, exceptionState) < 0) { // starts before
- if (comparePoint(parentNode, nodeIndex + 1, exceptionState) > 0) // ends after the range
- return NODE_BEFORE_AND_AFTER;
- return NODE_BEFORE; // ends before or in the range
- }
- // starts at or after the range start
- if (comparePoint(parentNode, nodeIndex + 1, exceptionState) > 0) // ends after the range
- return NODE_AFTER;
- return NODE_INSIDE; // ends inside the range
-}
-
short Range::compareBoundaryPoints(unsigned how, const Range* sourceRange, ExceptionState& exceptionState) const
{
if (!(how == START_TO_START || how == START_TO_END || how == END_TO_END || how == END_TO_START)) {
« no previous file with comments | « Source/core/dom/Range.h ('k') | Source/core/dom/Range.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698