[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
ap at apple.com
ap at apple.com
Wed Dec 22 13:28:08 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5779f3ff3c511c09fe7d7fe105b68df67ab7d5dd
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Sep 16 15:05:58 2010 +0000
2010-09-16 Alexey Proskuryakov <ap at apple.com>
Reviewed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=45852
Range::selectNode and selectNodeContents misbehave when argument is in another document
* fast/dom/Range/select-node-different-document-expected.txt: Added.
* fast/dom/Range/select-node-different-document.html: Added.
2010-09-16 Alexey Proskuryakov <ap at apple.com>
Reviewed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=45852
Range::selectNode and selectNodeContents misbehave when argument is in another document
Test: fast/dom/Range/select-node-different-document.html
There is nothing in DOM Traversal spec that says this shouldn't work, and it does work in
Firefox.
* dom/Range.cpp:
(WebCore::Range::setDocument):
(WebCore::Range::selectNode):
(WebCore::Range::selectNodeContents):
* dom/Range.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a10c6f3..668696a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-16 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Adam Barth.
+
+ https://bugs.webkit.org/show_bug.cgi?id=45852
+ Range::selectNode and selectNodeContents misbehave when argument is in another document
+
+ * fast/dom/Range/select-node-different-document-expected.txt: Added.
+ * fast/dom/Range/select-node-different-document.html: Added.
+
2010-09-16 Satish Sampath <satish at chromium.org>
Unreviewed, build fix after checking in the wrong location.
diff --git a/LayoutTests/fast/dom/Range/select-node-different-document-expected.txt b/LayoutTests/fast/dom/Range/select-node-different-document-expected.txt
new file mode 100644
index 0000000..f107aac
--- /dev/null
+++ b/LayoutTests/fast/dom/Range/select-node-different-document-expected.txt
@@ -0,0 +1,19 @@
+Test whether Range.selectNode and Range.selectNodeContents work across documents
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS selectNodeRange.startContainer === otherDocument.documentElement is true
+PASS selectNodeRange.endContainer === otherDocument.documentElement is true
+PASS selectNodeRange.startContainer.ownerDocument === otherDocument is true
+PASS selectNodeRange.endContainer.ownerDocument === otherDocument is true
+PASS selectNodeRange.cloneContents().ownerDocument === otherDocument is true
+PASS selectNodeRange.startContainer === otherDocument.documentElement is true
+PASS selectNodeRange.endContainer === otherDocument.documentElement is true
+PASS selectNodeContentsRange.startContainer.ownerDocument === otherDocument is true
+PASS selectNodeContentsRange.endContainer.ownerDocument === otherDocument is true
+PASS selectNodeRange.cloneContents().ownerDocument === otherDocument is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Range/select-node-different-document.html b/LayoutTests/fast/dom/Range/select-node-different-document.html
new file mode 100644
index 0000000..7a36582
--- /dev/null
+++ b/LayoutTests/fast/dom/Range/select-node-different-document.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<body>
+<iframe src="about:blank"></iframe>
+<script>
+description("Test whether Range.selectNode and Range.selectNodeContents work across documents");
+
+var otherDocument = document.implementation.createDocument(null, "doc", null);
+var elem = otherDocument.createElement("elem");
+otherDocument.documentElement.appendChild(elem);
+
+var selectNodeRange = document.createRange();
+selectNodeRange.selectNode(elem);
+
+shouldBeTrue("selectNodeRange.startContainer === otherDocument.documentElement");
+shouldBeTrue("selectNodeRange.endContainer === otherDocument.documentElement");
+shouldBeTrue("selectNodeRange.startContainer.ownerDocument === otherDocument");
+shouldBeTrue("selectNodeRange.endContainer.ownerDocument === otherDocument");
+shouldBeTrue("selectNodeRange.cloneContents().ownerDocument === otherDocument");
+
+var selectNodeContentsRange = document.createRange();
+selectNodeContentsRange.selectNodeContents(elem);
+
+shouldBeTrue("selectNodeRange.startContainer === otherDocument.documentElement");
+shouldBeTrue("selectNodeRange.endContainer === otherDocument.documentElement");
+shouldBeTrue("selectNodeContentsRange.startContainer.ownerDocument === otherDocument");
+shouldBeTrue("selectNodeContentsRange.endContainer.ownerDocument === otherDocument");
+shouldBeTrue("selectNodeRange.cloneContents().ownerDocument === otherDocument");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c76f33a..cec9724 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-09-16 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Adam Barth.
+
+ https://bugs.webkit.org/show_bug.cgi?id=45852
+ Range::selectNode and selectNodeContents misbehave when argument is in another document
+
+ Test: fast/dom/Range/select-node-different-document.html
+
+ There is nothing in DOM Traversal spec that says this shouldn't work, and it does work in
+ Firefox.
+
+ * dom/Range.cpp:
+ (WebCore::Range::setDocument):
+ (WebCore::Range::selectNode):
+ (WebCore::Range::selectNodeContents):
+ * dom/Range.h:
+
2010-09-16 Andrey Kosyakov <caseq at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/dom/Range.cpp b/WebCore/dom/Range.cpp
index d93a58e..95502df 100644
--- a/WebCore/dom/Range.cpp
+++ b/WebCore/dom/Range.cpp
@@ -107,6 +107,17 @@ Range::~Range()
#endif
}
+void Range::setDocument(Document* document)
+{
+ ASSERT(m_ownerDocument != document);
+ if (m_ownerDocument)
+ m_ownerDocument->detachRange(this);
+ m_ownerDocument = document;
+ m_start.setToStartOfNode(document);
+ m_end.setToStartOfNode(document);
+ m_ownerDocument->attachRange(this);
+}
+
Node* Range::startContainer(ExceptionCode& ec) const
{
if (!m_start.container()) {
@@ -1316,6 +1327,9 @@ void Range::selectNode(Node* refNode, ExceptionCode& ec)
return;
}
+ if (m_ownerDocument != refNode->document())
+ setDocument(refNode->document());
+
ec = 0;
setStartBefore(refNode, ec);
if (ec)
@@ -1358,6 +1372,9 @@ void Range::selectNodeContents(Node* refNode, ExceptionCode& ec)
}
}
+ if (m_ownerDocument != refNode->document())
+ setDocument(refNode->document());
+
m_start.setToStartOfNode(refNode);
m_end.setToEndOfNode(refNode);
}
diff --git a/WebCore/dom/Range.h b/WebCore/dom/Range.h
index c81bf45..9834aec 100644
--- a/WebCore/dom/Range.h
+++ b/WebCore/dom/Range.h
@@ -135,6 +135,8 @@ private:
Range(PassRefPtr<Document>);
Range(PassRefPtr<Document>, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset);
+ void setDocument(Document*);
+
Node* checkNodeWOffset(Node*, int offset, ExceptionCode&) const;
void checkNodeBA(Node*, ExceptionCode&) const;
void checkDeleteExtract(ExceptionCode&);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list