|
Lines 6051-6130
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
Link Here
|
---|
|
6051 |
{ |
6051 |
{ |
6052 |
JS::Rooted<JSObject*> obj(aCx, aObject); |
6052 |
JS::Rooted<JSObject*> obj(aCx, aObject); |
6053 |
|
6053 |
|
6054 |
JSAutoCompartment ac(aCx, obj); |
6054 |
JSAutoCompartment ac(aCx, obj); |
6055 |
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj)); |
6055 |
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj)); |
6056 |
nsCOMPtr<nsPIDOMWindowInner> window = |
6056 |
nsCOMPtr<nsPIDOMWindowInner> window = |
6057 |
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global)); |
6057 |
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global)); |
6058 |
|
6058 |
|
6059 |
bool enabled = |
|
|
6060 |
nsContentUtils::IsWebComponentsEnabled() || |
6061 |
// Check for the webcomponents permission. See Bug 1181555. |
6062 |
IsWebComponentsEnabled(window); |
6063 |
|
6064 |
if (!enabled) { |
6065 |
return false; |
6066 |
} |
6067 |
|
6068 |
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr; |
6059 |
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr; |
6069 |
if (doc && doc->IsStyledByServo()) { |
6060 |
if (doc && doc->IsStyledByServo()) { |
6070 |
NS_WARNING("stylo: Web Components not supported yet"); |
6061 |
NS_WARNING("stylo: Web Components not supported yet"); |
6071 |
return false; |
6062 |
return false; |
6072 |
} |
6063 |
} |
6073 |
|
6064 |
|
6074 |
return true; |
6065 |
return true; |
6075 |
} |
6066 |
} |
6076 |
|
6067 |
|
6077 |
bool |
6068 |
bool |
6078 |
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo) |
6069 |
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo) |
6079 |
{ |
6070 |
{ |
6080 |
nsIDocument* doc = aNodeInfo->GetDocument(); |
6071 |
nsIDocument* doc = aNodeInfo->GetDocument(); |
6081 |
|
6072 |
|
6082 |
bool enabled = nsContentUtils::IsWebComponentsEnabled(); |
|
|
6083 |
if (!enabled) { |
6084 |
// Use GetScopeObject() here so that data documents work the same way as the |
6085 |
// main document they're associated with. |
6086 |
nsCOMPtr<nsPIDOMWindowInner> window = |
6087 |
do_QueryInterface(doc->GetScopeObject()); |
6088 |
enabled = IsWebComponentsEnabled(window); |
6089 |
} |
6090 |
|
6091 |
if (!enabled) { |
6092 |
return false; |
6093 |
} |
6094 |
|
6095 |
if (doc->IsStyledByServo()) { |
6073 |
if (doc->IsStyledByServo()) { |
6096 |
NS_WARNING("stylo: Web Components not supported yet"); |
6074 |
NS_WARNING("stylo: Web Components not supported yet"); |
6097 |
return false; |
6075 |
return false; |
6098 |
} |
6076 |
} |
6099 |
|
6077 |
|
6100 |
return true; |
6078 |
return true; |
6101 |
} |
6079 |
} |
6102 |
|
6080 |
|
6103 |
bool |
|
|
6104 |
nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow) |
6105 |
{ |
6106 |
if (aWindow) { |
6107 |
nsresult rv; |
6108 |
nsCOMPtr<nsIPermissionManager> permMgr = |
6109 |
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv); |
6110 |
NS_ENSURE_SUCCESS(rv, false); |
6111 |
|
6112 |
uint32_t perm; |
6113 |
rv = permMgr->TestPermissionFromWindow( |
6114 |
aWindow, "moz-extremely-unstable-and-will-change-webcomponents", &perm); |
6115 |
NS_ENSURE_SUCCESS(rv, false); |
6116 |
|
6117 |
return perm == nsIPermissionManager::ALLOW_ACTION; |
6118 |
} |
6119 |
|
6120 |
return false; |
6121 |
} |
6122 |
|
6123 |
void |
6081 |
void |
6124 |
nsDocument::ScheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG) |
6082 |
nsDocument::ScheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG) |
6125 |
{ |
6083 |
{ |
6126 |
mLazySVGPresElements.PutEntry(aSVG); |
6084 |
mLazySVGPresElements.PutEntry(aSVG); |
6127 |
} |
6085 |
} |
6128 |
|
6086 |
|
6129 |
void |
6087 |
void |
6130 |
nsDocument::UnscheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG) |
6088 |
nsDocument::UnscheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG) |