Bug 1361235 - Part 1: Clear ServoElementData from doomed NAC before adding the script runner that would destroy it. r?emilio
MozReview-Commit-ID: KqJelGoA4NU
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -215,16 +215,17 @@
#include "mozilla/EnumSet.h"
#include "mozilla/BloomFilter.h"
#include "TabChild.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/TabGroup.h"
#include "nsIWebNavigationInfo.h"
#include "nsPluginHost.h"
#include "mozilla/HangAnnotations.h"
+#include "mozilla/ServoRestyleManager.h"
#include "nsIBidiKeyboard.h"
#if defined(XP_WIN)
// Undefine LoadImage to prevent naming conflict with Windows.
#undef LoadImage
#endif
@@ -5299,25 +5300,37 @@ private:
nsCOMPtr<nsIContent> mParent;
};
/* static */
void
nsContentUtils::DestroyAnonymousContent(nsCOMPtr<nsIContent>* aContent)
{
if (*aContent) {
+ // Don't wait until UnbindFromTree to clear ServoElementData, since
+ // leak checking at shutdown can run before the AnonymousContentDestroyer
+ // runs.
+ if ((*aContent)->IsStyledByServo() && (*aContent)->IsElement()) {
+ ServoRestyleManager::ClearServoDataFromSubtree((*aContent)->AsElement());
+ }
AddScriptRunner(new AnonymousContentDestroyer(aContent));
}
}
/* static */
void
nsContentUtils::DestroyAnonymousContent(nsCOMPtr<Element>* aElement)
{
if (*aElement) {
+ // Don't wait until UnbindFromTree to clear ServoElementData, since
+ // leak checking at shutdown can run before the AnonymousContentDestroyer
+ // runs.
+ if ((*aElement)->IsStyledByServo()) {
+ ServoRestyleManager::ClearServoDataFromSubtree(*aElement);
+ }
AddScriptRunner(new AnonymousContentDestroyer(aElement));
}
}
/* static */
void
nsContentUtils::NotifyInstalledMenuKeyboardListener(bool aInstalling)
{