Bug 823549 - Make NodeIterator.detach() a no-op; r=mounir

This commit is contained in:
Ms2ger 2013-03-10 08:58:25 +01:00
Родитель 34912e5df7
Коммит 5ac502d205
5 изменённых файлов: 10 добавлений и 19 удалений

Просмотреть файл

@ -27,3 +27,4 @@ DEPRECATED_OPERATION(MutationEvent)
DEPRECATED_OPERATION(MozSlice)
DEPRECATED_OPERATION(Components)
DEPRECATED_OPERATION(PrefixedVisibilityAPI)
DEPRECATED_OPERATION(NodeIteratorDetach)

Просмотреть файл

@ -143,7 +143,6 @@ NodeIterator::NodeIterator(nsINode *aRoot,
uint32_t aWhatToShow,
const NodeFilterHolder &aFilter) :
nsTraversal(aRoot, aWhatToShow, aFilter),
mDetached(false),
mPointer(mRoot, true)
{
aRoot->AddMutationObserver(this);
@ -152,7 +151,7 @@ NodeIterator::NodeIterator(nsINode *aRoot,
NodeIterator::~NodeIterator()
{
/* destructor code */
if (!mDetached && mRoot)
if (mRoot)
mRoot->RemoveMutationObserver(this);
}
@ -161,7 +160,7 @@ NodeIterator::~NodeIterator()
*/
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NodeIterator)
if (!tmp->mDetached && tmp->mRoot)
if (tmp->mRoot)
tmp->mRoot->RemoveMutationObserver(tmp);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFilter)
@ -222,7 +221,7 @@ already_AddRefed<nsINode>
NodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
ErrorResult& aResult)
{
if (mDetached || mInAcceptNode) {
if (mInAcceptNode) {
aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
@ -242,11 +241,6 @@ NodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
return nullptr;
}
if (mDetached) {
aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
mPointer = mWorkingPointer;
return testNode.forget();
@ -259,14 +253,9 @@ NodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
/* void detach (); */
NS_IMETHODIMP NodeIterator::Detach(void)
{
if (!mDetached) {
mRoot->RemoveMutationObserver(this);
mPointer.Clear();
mDetached = true;
if (mRoot) {
mRoot->OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeIteratorDetach);
}
return NS_OK;
}

Просмотреть файл

@ -110,7 +110,6 @@ private:
already_AddRefed<nsINode>
NextOrPrevNode(NodePointer::MoveToMethodType aMove, ErrorResult& aResult);
bool mDetached;
NodePointer mPointer;
NodePointer mWorkingPointer;
};

Просмотреть файл

@ -121,8 +121,8 @@
iterator.nextNode();
try {
iterator[method]();
ok(false, "Able to call " + method + " on a detached NodeIterator");
} catch (x) { ok(true, x) }
ok(true, "Able to call " + method + " on a NodeIterator after calling no-op detach()");
} catch (x) { ok(false, x) }
}
checkBadFilter("nextNode", 2);
checkBadFilter("previousNode", 3);

Просмотреть файл

@ -132,3 +132,5 @@ PrefixedVisibilityApiWarning='mozHidden' and 'mozVisibilityState' are deprecated
OldCSPHeaderDeprecated=The X-Content-Security-Policy and X-Content-Security-Report-Only headers will be deprecated in the future. Please use the Content-Security-Policy and Content-Security-Report-Only headers with CSP spec compliant syntax instead.
# LOCALIZATION NOTE: Do not translate "X-Content-Security-Policy/Report-Only" or "Content-Security-Policy/Report-Only"
BothCSPHeadersPresent=This site specified both an X-Content-Security-Policy/Report-Only header and a Content-Security-Policy/Report-Only header. The X-Content-Security-Policy/Report-Only header(s) will be ignored.
# LOCALIZATION NOTE: Do not translate "NodeIterator" or "detach()".
NodeIteratorDetachWarning=Calling detach() on a NodeIterator no longer has an effect.