mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #1375 - Fix IsWebComponentsEnabled checks
This commit is contained in:
parent
a6f048fc42
commit
ca48752304
13 changed files with 154 additions and 137 deletions
|
|
@ -2242,6 +2242,29 @@ WarnIfSandboxIneffective(nsIDocShell* aDocShell,
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
if (!nsContentUtils::IsWebComponentsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
|
||||
|
||||
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
|
||||
if (doc && doc->IsStyledByServo()) {
|
||||
NS_WARNING("stylo: Web Components not supported yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
|
|
@ -5581,65 +5604,12 @@ nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
|
|||
return attribute.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
|
||||
if (nsContentUtils::IsWebComponentsEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for the webcomponents permission. See Bug 1181555.
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
|
||||
|
||||
return IsWebComponentsEnabled(window);
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(const nsINode* aNode)
|
||||
{
|
||||
return aNode->OwnerDoc()->IsWebComponentsEnabled();
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
|
||||
{
|
||||
if (nsContentUtils::IsWebComponentsEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsIDocument* doc = aNodeInfo->GetDocument();
|
||||
// Use GetScopeObject() here so that data documents work the same way as the
|
||||
// main document they're associated with.
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(doc->GetScopeObject());
|
||||
return IsWebComponentsEnabled(window);
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
if (aWindow) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPermissionManager> permMgr =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
uint32_t perm;
|
||||
rv = permMgr->TestPermissionFromWindow(
|
||||
aWindow, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return perm == nsIPermissionManager::ALLOW_ACTION;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementsByTagName(const nsAString& aTagname,
|
||||
nsIDOMNodeList** aReturn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue