зеркало из https://github.com/mozilla/gecko-dev.git
Bug 698381 - Make Node.cloneNode aDeep argument optional, default to true. r=smaug
This commit is contained in:
Родитель
2a964e5f93
Коммит
e6f5aa8906
|
@ -480,10 +480,14 @@ nsDOMAttribute::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CloneNode(bool aDeep, nsIDOMNode** aResult)
|
||||
nsDOMAttribute::CloneNode(bool aDeep, PRUint8 aOptionalArgc, nsIDOMNode** aResult)
|
||||
{
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eCloneNode);
|
||||
|
||||
if (!aOptionalArgc) {
|
||||
aDeep = true;
|
||||
}
|
||||
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -5830,8 +5830,12 @@ nsDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CloneNode(bool aDeep, nsIDOMNode** aReturn)
|
||||
nsDocument::CloneNode(bool aDeep, PRUint8 aOptionalArgc, nsIDOMNode** aReturn)
|
||||
{
|
||||
if (!aOptionalArgc) {
|
||||
aDeep = true;
|
||||
}
|
||||
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, !mCreatingStaticClone, aReturn);
|
||||
}
|
||||
|
||||
|
@ -8062,7 +8066,7 @@ nsIDocument::CreateStaticClone(nsISupports* aCloneContainer)
|
|||
nsCOMPtr<nsISupports> originalContainer = GetContainer();
|
||||
SetContainer(aCloneContainer);
|
||||
nsCOMPtr<nsIDOMNode> clonedNode;
|
||||
nsresult rv = domDoc->CloneNode(true, getter_AddRefs(clonedNode));
|
||||
nsresult rv = domDoc->CloneNode(true, 1, getter_AddRefs(clonedNode));
|
||||
SetContainer(originalContainer);
|
||||
|
||||
nsCOMPtr<nsIDocument> clonedDoc;
|
||||
|
|
|
@ -143,8 +143,12 @@ public:
|
|||
nsresult IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
bool* aReturn);
|
||||
nsresult CloneNode(bool aDeep, nsIDOMNode** aReturn)
|
||||
nsresult CloneNode(bool aDeep, PRUint8 aOptionalArgc, nsIDOMNode** aReturn)
|
||||
{
|
||||
if (!aOptionalArgc) {
|
||||
aDeep = true;
|
||||
}
|
||||
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aReturn);
|
||||
}
|
||||
|
||||
|
|
|
@ -437,8 +437,12 @@ public:
|
|||
// nsIDOMElement method implementation
|
||||
NS_DECL_NSIDOMELEMENT
|
||||
|
||||
nsresult CloneNode(bool aDeep, nsIDOMNode **aResult)
|
||||
nsresult CloneNode(bool aDeep, PRUint8 aOptionalArgc, nsIDOMNode **aResult)
|
||||
{
|
||||
if (!aOptionalArgc) {
|
||||
aDeep = true;
|
||||
}
|
||||
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, true, aResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -1596,7 +1596,7 @@ nsresult nsRange::CutContents(nsIDOMDocumentFragment** aFragment)
|
|||
cutValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDOMNode> clone;
|
||||
rv = charData->CloneNode(false, getter_AddRefs(clone));
|
||||
rv = charData->CloneNode(false, 1, getter_AddRefs(clone));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
clone->SetNodeValue(cutValue);
|
||||
nodeToResult = clone;
|
||||
|
@ -1656,7 +1656,7 @@ nsresult nsRange::CutContents(nsIDOMDocumentFragment** aFragment)
|
|||
{
|
||||
if (retval) {
|
||||
nsCOMPtr<nsIDOMNode> clone;
|
||||
rv = node->CloneNode(false, getter_AddRefs(clone));
|
||||
rv = node->CloneNode(false, 1, getter_AddRefs(clone));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nodeToResult = clone;
|
||||
}
|
||||
|
@ -1827,7 +1827,7 @@ nsRange::CloneParentsBetween(nsIDOMNode *aAncestor,
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode> clone, tmpNode;
|
||||
|
||||
res = parent->CloneNode(false, getter_AddRefs(clone));
|
||||
res = parent->CloneNode(false, 1, getter_AddRefs(clone));
|
||||
|
||||
if (NS_FAILED(res)) return res;
|
||||
if (!clone) return NS_ERROR_FAILURE;
|
||||
|
@ -1928,7 +1928,7 @@ nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
|
|||
// Clone the current subtree!
|
||||
|
||||
nsCOMPtr<nsIDOMNode> clone;
|
||||
res = node->CloneNode(deepClone, getter_AddRefs(clone));
|
||||
res = node->CloneNode(deepClone, 1, getter_AddRefs(clone));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// If it's CharacterData, make sure we only clone what
|
||||
|
|
|
@ -555,6 +555,7 @@ _TEST_FILES2 = \
|
|||
file_bug717511_2.html \
|
||||
file_bug717511_2.html^headers^ \
|
||||
test_bug726364.html \
|
||||
test_bug698381.html \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=698381
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 698381</title>
|
||||
<script type="text/javascript"
|
||||
src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"
|
||||
type="text/javascript"></script>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="runTests();">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=698381">
|
||||
Mozilla Bug 698381</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<div id="noChildren" style="display: none"></div>
|
||||
<div id="hasChildren" style="display: none">
|
||||
<div id="childOne" style="display: none"></div>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
Checks to see if default parameter handling is correct when 0
|
||||
parameters are passed.
|
||||
|
||||
If none are passed, then Node.cloneNode should default aDeep
|
||||
to true.
|
||||
*/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var hasChildren = document.getElementById("hasChildren"),
|
||||
noChildren = document.getElementById("noChildren"),
|
||||
clonedNode;
|
||||
|
||||
function runTests() {
|
||||
|
||||
// Test Node.cloneNode when no arguments are given
|
||||
clonedNode = hasChildren.cloneNode();
|
||||
is(clonedNode.hasChildNodes(), true, "Node.cloneNode with true " +
|
||||
"default on a node with children clones the child nodes.");
|
||||
|
||||
clonedNode = noChildren.cloneNode();
|
||||
is(clonedNode.hasChildNodes(), false, "Node.cloneNode with true " +
|
||||
"default on a node without children doesn't clone child nodes." );
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -808,7 +808,7 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength)
|
|||
if (i + 1 < aLength) {
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
|
||||
rv = node->CloneNode(true, getter_AddRefs(newNode));
|
||||
rv = node->CloneNode(true, 1, getter_AddRefs(newNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
node = newNode;
|
||||
|
|
|
@ -153,7 +153,7 @@ NS_IMETHODIMP nsXPathNamespace::HasChildNodes(bool *aResult)
|
|||
}
|
||||
|
||||
/* nsIDOMNode cloneNode (in boolean deep); */
|
||||
NS_IMETHODIMP nsXPathNamespace::CloneNode(bool deep, nsIDOMNode **aResult)
|
||||
NS_IMETHODIMP nsXPathNamespace::CloneNode(bool deep, PRUint8 aOptionalArgc, nsIDOMNode **aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -677,7 +677,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> clonedNode;
|
||||
tmplTextNode->CloneNode(false, getter_AddRefs(clonedNode));
|
||||
tmplTextNode->CloneNode(false, 1, getter_AddRefs(clonedNode));
|
||||
nsCOMPtr<nsIContent> clonedContent = do_QueryInterface(clonedNode);
|
||||
if (!clonedContent) {
|
||||
NS_ERROR("failed to clone textnode");
|
||||
|
|
|
@ -52,7 +52,7 @@ interface nsIDOMUserDataHandler;
|
|||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(ce82fb71-60f2-4c38-be31-de5f2f90dada)]
|
||||
[scriptable, uuid(5e9bcec9-5928-4f77-8a9c-424ef01c20e1)]
|
||||
interface nsIDOMNode : nsISupports
|
||||
{
|
||||
const unsigned short ELEMENT_NODE = 1;
|
||||
|
@ -94,7 +94,8 @@ interface nsIDOMNode : nsISupports
|
|||
nsIDOMNode appendChild(in nsIDOMNode newChild)
|
||||
raises(DOMException);
|
||||
boolean hasChildNodes();
|
||||
nsIDOMNode cloneNode(in boolean deep);
|
||||
// Modified in DOM Level 4:
|
||||
[optional_argc] nsIDOMNode cloneNode([optional] in boolean deep);
|
||||
// Modified in DOM Level 2:
|
||||
void normalize();
|
||||
// Introduced in DOM Level 2:
|
||||
|
|
|
@ -98,7 +98,7 @@ NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
|||
if (!mExistingRightNode || !mEditor) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
||||
// create a new node
|
||||
nsresult result = mExistingRightNode->CloneNode(false, getter_AddRefs(mNewLeftNode));
|
||||
nsresult result = mExistingRightNode->CloneNode(false, 1, getter_AddRefs(mNewLeftNode));
|
||||
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewLeftNode)), "could not create element.");
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
NS_ENSURE_TRUE(mNewLeftNode, NS_ERROR_NULL_POINTER);
|
||||
|
|
|
@ -2970,7 +2970,7 @@ nsWebBrowserPersist::GetNodeToFixup(nsIDOMNode *aNodeIn, nsIDOMNode **aNodeOut)
|
|||
{
|
||||
if (!(mPersistFlags & PERSIST_FLAGS_FIXUP_ORIGINAL_DOM))
|
||||
{
|
||||
nsresult rv = aNodeIn->CloneNode(false, aNodeOut);
|
||||
nsresult rv = aNodeIn->CloneNode(false, 1, aNodeOut);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else
|
||||
|
|
Загрузка…
Ссылка в новой задаче