Chromium Code Reviews| Index: Source/core/dom/Range.cpp |
| diff --git a/Source/core/dom/Range.cpp b/Source/core/dom/Range.cpp |
| index 7fcf747fe1d2476db9679bdc674188f6c7f9b49d..16960ac6d08c30fc50cf619d4a6c238752928095 100644 |
| --- a/Source/core/dom/Range.cpp |
| +++ b/Source/core/dom/Range.cpp |
| @@ -293,47 +293,21 @@ short Range::comparePoint(Node* refNode, int offset, ExceptionState& exceptionSt |
| return 0; |
| } |
| -Range::CompareResults Range::compareNode(Node* refNode, ExceptionState& exceptionState) const |
| +bool Range::isNodeFullyContained(Node& node, 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(); |
| + ContainerNode* parentNode = node.parentNode(); |
| + int nodeIndex = node.nodeIndex(); |
|
philipj_slow
2015/07/01 08:22:01
Move this down to after the parentNode check, just
deepak.s
2015/07/07 05:41:32
Done.
|
| 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; |
| + exceptionState.throwDOMException(NotFoundError, "The node provided has no parent."); |
|
philipj_slow
2015/07/01 08:22:01
This exception is ignored on both call sites, so j
deepak.s
2015/07/07 05:41:32
Done.
|
| + return false; |
| } |
| - 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 |
| + if (comparePoint(parentNode, nodeIndex, exceptionState) == 0 // starts in the middle of this range, or on the boundary points |
|
philipj_slow
2015/07/01 08:22:01
To actually handle these exceptions, you'll have t
deepak.s
2015/07/07 05:41:32
Removed exception handling and passed IGNORE_EXCEP
philipj_slow
2015/07/07 08:27:29
There are exception cases in Range::comparePoint t
deepak.s
2015/07/08 04:57:02
Updated method by using isPointInRange.
|
| + && comparePoint(parentNode, nodeIndex + 1, exceptionState) == 0) // ends in the middle of this range, or on the boundary points |
| + return true; |
| + |
| + return false; |
| } |
| short Range::compareBoundaryPoints(unsigned how, const Range* sourceRange, ExceptionState& exceptionState) const |