зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341693 - Don't need to check GetDocShell() when creating CustomElementRegistry; r=wchen
MozReview-Commit-ID: 7k3MQBEMpnV --HG-- extra : rebase_source : 463205ff7402b132aa48ebc3b59e9128b249ab6b
This commit is contained in:
Родитель
be3d9f1c9f
Коммит
fa227a0808
|
@ -175,30 +175,6 @@ CustomElementRegistry::IsCustomElementEnabled(JSContext* aCx, JSObject* aObject)
|
|||
nsContentUtils::IsWebComponentsEnabled();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<CustomElementRegistry>
|
||||
CustomElementRegistry::Create(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aWindow->IsInnerWindow());
|
||||
|
||||
if (!aWindow->GetDocShell()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!IsCustomElementEnabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CustomElementRegistry> customElementRegistry =
|
||||
new CustomElementRegistry(aWindow);
|
||||
|
||||
if (!customElementRegistry->Init()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return customElementRegistry.forget();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
CustomElementRegistry::ProcessTopElementQueue()
|
||||
{
|
||||
|
@ -241,6 +217,10 @@ CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow)
|
|||
, mIsCustomDefinitionRunning(false)
|
||||
, mIsBackupQueueProcessing(false)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aWindow->IsInnerWindow());
|
||||
MOZ_ALWAYS_TRUE(mConstructors.init());
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
if (!sProcessingStack) {
|
||||
|
@ -255,12 +235,6 @@ CustomElementRegistry::~CustomElementRegistry()
|
|||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
bool
|
||||
CustomElementRegistry::Init()
|
||||
{
|
||||
return mConstructors.init();
|
||||
}
|
||||
|
||||
CustomElementDefinition*
|
||||
CustomElementRegistry::LookupCustomElementDefinition(const nsAString& aLocalName,
|
||||
const nsAString* aIs) const
|
||||
|
|
|
@ -178,11 +178,13 @@ public:
|
|||
public:
|
||||
static bool IsCustomElementEnabled(JSContext* aCx = nullptr,
|
||||
JSObject* aObject = nullptr);
|
||||
static already_AddRefed<CustomElementRegistry> Create(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
static void ProcessTopElementQueue();
|
||||
|
||||
static void XPCOMShutdown();
|
||||
|
||||
explicit CustomElementRegistry(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
/**
|
||||
* Looking up a custom element definition.
|
||||
* https://html.spec.whatwg.org/#look-up-a-custom-element-definition
|
||||
|
@ -227,11 +229,8 @@ public:
|
|||
void PopAndInvokeElementQueue();
|
||||
|
||||
private:
|
||||
explicit CustomElementRegistry(nsPIDOMWindowInner* aWindow);
|
||||
~CustomElementRegistry();
|
||||
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* Registers an unresolved custom element that is a candidate for
|
||||
* upgrade when the definition is registered via registerElement.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var o1 = document.documentElement;
|
||||
var o2 = document.createElement("frame");
|
||||
document.documentElement.appendChild(o2);
|
||||
var o3 = o2.contentWindow;
|
||||
o1.parentNode.removeChild(o1);
|
||||
o3.customElements;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -212,3 +212,4 @@ pref(dom.IntersectionObserver.enabled,true) load 1324209.html
|
|||
pref(dom.IntersectionObserver.enabled,true) load 1326194-1.html
|
||||
pref(dom.IntersectionObserver.enabled,true) load 1326194-2.html
|
||||
pref(dom.IntersectionObserver.enabled,true) load 1332939.html
|
||||
pref(dom.webcomponents.enabled,true) load 1341693.html
|
|
@ -4097,8 +4097,9 @@ CustomElementRegistry*
|
|||
nsGlobalWindow::CustomElements()
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(IsInnerWindow());
|
||||
|
||||
if (!mCustomElements) {
|
||||
mCustomElements = CustomElementRegistry::Create(AsInner());
|
||||
mCustomElements = new CustomElementRegistry(AsInner());
|
||||
}
|
||||
|
||||
return mCustomElements;
|
||||
|
|
Загрузка…
Ссылка в новой задаче