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

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

Issue 1364683003: Range.intersectsNode() does not behave according to the specification. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed comments Created 5 years, 3 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 | « third_party/WebKit/LayoutTests/fast/dom/Range/resources/intersectsNode.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Range.cpp
diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
index 0dad7073402860febc75e698ceb6fe87a146a749..8e96b40e14558016f17377c213b44735f20166fe 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -405,14 +405,10 @@ bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState)
return false;
ContainerNode* parentNode = refNode->parentNode();
- int nodeIndex = refNode->nodeIndex();
+ if (!parentNode)
+ return true;
- 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 node provided has no parent.");
- return false;
- }
+ int nodeIndex = refNode->nodeIndex();
if (comparePoint(parentNode, nodeIndex, exceptionState) < 0 // starts before start
&& comparePoint(parentNode, nodeIndex + 1, exceptionState) < 0) { // ends before start
@@ -435,14 +431,10 @@ bool Range::intersectsNode(Node* refNode, const Position& start, const Position&
return false;
ContainerNode* parentNode = refNode->parentNode();
- int nodeIndex = refNode->nodeIndex();
+ if (!parentNode)
+ return true;
- 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 node provided has no parent.");
- return false;
- }
+ int nodeIndex = refNode->nodeIndex();
Node* startContainerNode = start.computeContainerNode();
int startOffset = start.computeOffsetInContainerNode();
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Range/resources/intersectsNode.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698