mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1050360 - Fix script blocker warning (r=smaug)
This commit is contained in:
parent
20f413d371
commit
6fe00b051a
@ -2252,9 +2252,7 @@ private:
|
|||||||
|
|
||||||
static bool sInitialized;
|
static bool sInitialized;
|
||||||
static uint32_t sScriptBlockerCount;
|
static uint32_t sScriptBlockerCount;
|
||||||
#ifdef DEBUG
|
|
||||||
static uint32_t sDOMNodeRemovedSuppressCount;
|
static uint32_t sDOMNodeRemovedSuppressCount;
|
||||||
#endif
|
|
||||||
static uint32_t sMicroTaskLevel;
|
static uint32_t sMicroTaskLevel;
|
||||||
// Not an nsCOMArray because removing elements from those is slower
|
// Not an nsCOMArray because removing elements from those is slower
|
||||||
static nsTArray< nsCOMPtr<nsIRunnable> >* sBlockedScriptRunners;
|
static nsTArray< nsCOMPtr<nsIRunnable> >* sBlockedScriptRunners;
|
||||||
@ -2311,14 +2309,10 @@ class MOZ_STACK_CLASS nsAutoScriptBlockerSuppressNodeRemoved :
|
|||||||
public nsAutoScriptBlocker {
|
public nsAutoScriptBlocker {
|
||||||
public:
|
public:
|
||||||
nsAutoScriptBlockerSuppressNodeRemoved() {
|
nsAutoScriptBlockerSuppressNodeRemoved() {
|
||||||
#ifdef DEBUG
|
|
||||||
++nsContentUtils::sDOMNodeRemovedSuppressCount;
|
++nsContentUtils::sDOMNodeRemovedSuppressCount;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
~nsAutoScriptBlockerSuppressNodeRemoved() {
|
~nsAutoScriptBlockerSuppressNodeRemoved() {
|
||||||
#ifdef DEBUG
|
|
||||||
--nsContentUtils::sDOMNodeRemovedSuppressCount;
|
--nsContentUtils::sDOMNodeRemovedSuppressCount;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,9 +214,7 @@ nsILineBreaker *nsContentUtils::sLineBreaker;
|
|||||||
nsIWordBreaker *nsContentUtils::sWordBreaker;
|
nsIWordBreaker *nsContentUtils::sWordBreaker;
|
||||||
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
|
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
|
||||||
uint32_t nsContentUtils::sScriptBlockerCount = 0;
|
uint32_t nsContentUtils::sScriptBlockerCount = 0;
|
||||||
#ifdef DEBUG
|
|
||||||
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
|
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
|
||||||
#endif
|
|
||||||
uint32_t nsContentUtils::sMicroTaskLevel = 0;
|
uint32_t nsContentUtils::sMicroTaskLevel = 0;
|
||||||
nsTArray< nsCOMPtr<nsIRunnable> >* nsContentUtils::sBlockedScriptRunners = nullptr;
|
nsTArray< nsCOMPtr<nsIRunnable> >* nsContentUtils::sBlockedScriptRunners = nullptr;
|
||||||
uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0;
|
uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0;
|
||||||
@ -3889,30 +3887,27 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent,
|
|||||||
NS_PRECONDITION(aChild->GetParentNode() == aParent, "Wrong parent");
|
NS_PRECONDITION(aChild->GetParentNode() == aParent, "Wrong parent");
|
||||||
NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
|
NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
|
||||||
|
|
||||||
// This checks that IsSafeToRunScript is true since we don't want to fire
|
|
||||||
// events when that is false. We can't rely on EventDispatcher to assert
|
|
||||||
// this in this situation since most of the time there are no mutation
|
|
||||||
// event listeners, in which case we won't even attempt to dispatch events.
|
|
||||||
// However this also allows for two exceptions. First off, we don't assert
|
|
||||||
// if the mutation happens to native anonymous content since we never fire
|
|
||||||
// mutation events on such content anyway.
|
|
||||||
// Second, we don't assert if sDOMNodeRemovedSuppressCount is true since
|
|
||||||
// that is a know case when we'd normally fire a mutation event, but can't
|
|
||||||
// make that safe and so we suppress it at this time. Ideally this should
|
|
||||||
// go away eventually.
|
|
||||||
NS_ASSERTION((aChild->IsNodeOfType(nsINode::eCONTENT) &&
|
|
||||||
static_cast<nsIContent*>(aChild)->
|
|
||||||
IsInNativeAnonymousSubtree()) ||
|
|
||||||
IsSafeToRunScript() ||
|
|
||||||
sDOMNodeRemovedSuppressCount,
|
|
||||||
"Want to fire DOMNodeRemoved event, but it's not safe");
|
|
||||||
|
|
||||||
// Having an explicit check here since it's an easy mistake to fall into,
|
// Having an explicit check here since it's an easy mistake to fall into,
|
||||||
// and there might be existing code with problems. We'd rather be safe
|
// and there might be existing code with problems. We'd rather be safe
|
||||||
// than fire DOMNodeRemoved in all corner cases. We also rely on it for
|
// than fire DOMNodeRemoved in all corner cases. We also rely on it for
|
||||||
// nsAutoScriptBlockerSuppressNodeRemoved.
|
// nsAutoScriptBlockerSuppressNodeRemoved.
|
||||||
if (!IsSafeToRunScript()) {
|
if (!IsSafeToRunScript()) {
|
||||||
WarnScriptWasIgnored(aOwnerDoc);
|
// This checks that IsSafeToRunScript is true since we don't want to fire
|
||||||
|
// events when that is false. We can't rely on EventDispatcher to assert
|
||||||
|
// this in this situation since most of the time there are no mutation
|
||||||
|
// event listeners, in which case we won't even attempt to dispatch events.
|
||||||
|
// However this also allows for two exceptions. First off, we don't assert
|
||||||
|
// if the mutation happens to native anonymous content since we never fire
|
||||||
|
// mutation events on such content anyway.
|
||||||
|
// Second, we don't assert if sDOMNodeRemovedSuppressCount is true since
|
||||||
|
// that is a know case when we'd normally fire a mutation event, but can't
|
||||||
|
// make that safe and so we suppress it at this time. Ideally this should
|
||||||
|
// go away eventually.
|
||||||
|
if (!(aChild->IsContent() && aChild->AsContent()->IsInNativeAnonymousSubtree()) &&
|
||||||
|
!sDOMNodeRemovedSuppressCount) {
|
||||||
|
NS_ERROR("Want to fire DOMNodeRemoved event, but it's not safe");
|
||||||
|
WarnScriptWasIgnored(aOwnerDoc);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user