mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1000199 - Enable web components for certified apps. r=gabor,smaug
This commit is contained in:
parent
8d65effbf6
commit
4bebd4307b
@ -665,7 +665,8 @@ nsContentSink::ProcessLink(const nsSubstring& aAnchor, const nsSubstring& aHref,
|
||||
const nsSubstring& aRel, const nsSubstring& aTitle,
|
||||
const nsSubstring& aType, const nsSubstring& aMedia)
|
||||
{
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(aRel);
|
||||
uint32_t linkTypes =
|
||||
nsStyleLinkElement::ParseLinkTypes(aRel, mDocument->NodePrincipal());
|
||||
|
||||
// The link relation may apply to a different resource, specified
|
||||
// in the anchor parameter. For the link relations supported so far,
|
||||
|
@ -5445,7 +5445,7 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsRegisterElementEnabled(JSContext* aCx, JSObject* aObject)
|
||||
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
return Preferences::GetBool("dom.webcomponents.enabled") ||
|
||||
|
@ -1479,7 +1479,7 @@ public:
|
||||
uint32_t aNamespaceID,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
||||
static bool IsRegisterElementEnabled(JSContext* aCx, JSObject* aObject);
|
||||
static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
|
||||
// The "registry" from the web components spec.
|
||||
nsRefPtr<mozilla::dom::Registry> mRegistry;
|
||||
|
@ -120,21 +120,30 @@ nsStyleLinkElement::SetLineNumber(uint32_t aLineNumber)
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsStyleLinkElement::IsImportEnabled()
|
||||
nsStyleLinkElement::IsImportEnabled(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
static bool sAdded = false;
|
||||
static bool sImportEnabled;
|
||||
static bool sWebComponentsEnabled;
|
||||
if (!sAdded) {
|
||||
// This part runs only once because of the static flag.
|
||||
Preferences::AddBoolVarCache(&sImportEnabled,
|
||||
Preferences::AddBoolVarCache(&sWebComponentsEnabled,
|
||||
"dom.webcomponents.enabled",
|
||||
false);
|
||||
sAdded = true;
|
||||
}
|
||||
return sImportEnabled;
|
||||
|
||||
if (sWebComponentsEnabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the web components pref is not enabled, check
|
||||
// if we are in a certified app because imports is enabled
|
||||
// for certified apps.
|
||||
return aPrincipal &&
|
||||
aPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
|
||||
}
|
||||
|
||||
static uint32_t ToLinkMask(const nsAString& aLink)
|
||||
static uint32_t ToLinkMask(const nsAString& aLink, nsIPrincipal* aPrincipal)
|
||||
{
|
||||
if (aLink.EqualsLiteral("prefetch"))
|
||||
return nsStyleLinkElement::ePREFETCH;
|
||||
@ -146,13 +155,14 @@ static uint32_t ToLinkMask(const nsAString& aLink)
|
||||
return nsStyleLinkElement::eNEXT;
|
||||
else if (aLink.EqualsLiteral("alternate"))
|
||||
return nsStyleLinkElement::eALTERNATE;
|
||||
else if (aLink.EqualsLiteral("import") && nsStyleLinkElement::IsImportEnabled())
|
||||
else if (aLink.EqualsLiteral("import") && aPrincipal &&
|
||||
nsStyleLinkElement::IsImportEnabled(aPrincipal))
|
||||
return nsStyleLinkElement::eHTMLIMPORT;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
|
||||
uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes, nsIPrincipal* aPrincipal)
|
||||
{
|
||||
uint32_t linkMask = 0;
|
||||
nsAString::const_iterator start, done;
|
||||
@ -169,7 +179,7 @@ uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
|
||||
if (nsContentUtils::IsHTMLWhitespace(*current)) {
|
||||
if (inString) {
|
||||
nsContentUtils::ASCIIToLower(Substring(start, current), subString);
|
||||
linkMask |= ToLinkMask(subString);
|
||||
linkMask |= ToLinkMask(subString, aPrincipal);
|
||||
inString = false;
|
||||
}
|
||||
}
|
||||
@ -183,7 +193,7 @@ uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
|
||||
}
|
||||
if (inString) {
|
||||
nsContentUtils::ASCIIToLower(Substring(start, current), subString);
|
||||
linkMask |= ToLinkMask(subString);
|
||||
linkMask |= ToLinkMask(subString, aPrincipal);
|
||||
}
|
||||
return linkMask;
|
||||
}
|
||||
|
@ -61,10 +61,13 @@ public:
|
||||
eHTMLIMPORT = 0x00000020
|
||||
};
|
||||
|
||||
// The return value is a bitwise or of 0 or more RelValues
|
||||
static uint32_t ParseLinkTypes(const nsAString& aTypes);
|
||||
// The return value is a bitwise or of 0 or more RelValues.
|
||||
// aPrincipal is used to check if HTML imports is enabled for the
|
||||
// provided principal.
|
||||
static uint32_t ParseLinkTypes(const nsAString& aTypes,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
static bool IsImportEnabled();
|
||||
static bool IsImportEnabled(nsIPrincipal* aPrincipal);
|
||||
|
||||
void UpdateStyleSheetInternal()
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ HTMLLinkElement::UpdateImport()
|
||||
// 2. rel type should be import.
|
||||
nsAutoString rel;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel, NodePrincipal());
|
||||
if (!(linkTypes & eHTMLIMPORT)) {
|
||||
mImportLoader = nullptr;
|
||||
return;
|
||||
@ -288,7 +288,7 @@ HTMLLinkElement::UpdateImport()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nsStyleLinkElement::IsImportEnabled()) {
|
||||
if (!nsStyleLinkElement::IsImportEnabled(NodePrincipal())) {
|
||||
// For now imports are hidden behind a pref...
|
||||
return;
|
||||
}
|
||||
@ -330,7 +330,8 @@ HTMLLinkElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
aName == nsGkAtoms::type)) {
|
||||
bool dropSheet = false;
|
||||
if (aName == nsGkAtoms::rel) {
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(aValue);
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(aValue,
|
||||
NodePrincipal());
|
||||
if (GetSheet()) {
|
||||
dropSheet = !(linkTypes & nsStyleLinkElement::eSTYLESHEET);
|
||||
} else if (linkTypes & eHTMLIMPORT) {
|
||||
@ -456,7 +457,7 @@ HTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
|
||||
|
||||
nsAutoString rel;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel, NodePrincipal());
|
||||
// Is it a stylesheet link?
|
||||
if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
|
||||
return;
|
||||
|
@ -607,7 +607,8 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
nsAutoString relVal;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
if (!relVal.IsEmpty()) {
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
|
||||
uint32_t linkTypes =
|
||||
nsStyleLinkElement::ParseLinkTypes(relVal, aContent->NodePrincipal());
|
||||
bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
|
||||
if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
|
||||
nsAutoString hrefVal;
|
||||
|
@ -229,7 +229,7 @@ partial interface Document {
|
||||
|
||||
//http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
|
||||
partial interface Document {
|
||||
[Throws, Func="nsDocument::IsRegisterElementEnabled"]
|
||||
[Throws, Func="nsDocument::IsWebComponentsEnabled"]
|
||||
object registerElement(DOMString name, optional ElementRegistrationOptions options);
|
||||
};
|
||||
|
||||
|
@ -201,11 +201,11 @@ partial interface Element {
|
||||
|
||||
// http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-element-interface
|
||||
partial interface Element {
|
||||
[Throws,Pref="dom.webcomponents.enabled"]
|
||||
[Throws,Func="nsDocument::IsWebComponentsEnabled"]
|
||||
ShadowRoot createShadowRoot();
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
[Func="nsDocument::IsWebComponentsEnabled"]
|
||||
NodeList getDestinationInsertionPoints();
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
[Func="nsDocument::IsWebComponentsEnabled"]
|
||||
readonly attribute ShadowRoot? shadowRoot;
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ partial interface HTMLLinkElement {
|
||||
|
||||
// http://w3c.github.io/webcomponents/spec/imports/#interface-import
|
||||
partial interface HTMLLinkElement {
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
[Func="nsDocument::IsWebComponentsEnabled"]
|
||||
readonly attribute Document? import;
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
[Func="nsDocument::IsWebComponentsEnabled"]
|
||||
interface ShadowRoot : DocumentFragment
|
||||
{
|
||||
Element? getElementById(DOMString elementId);
|
||||
|
@ -86,7 +86,8 @@ nsHtml5DocumentBuilder::UpdateStyleSheet(nsIContent* aElement)
|
||||
nsAutoString relVal;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
if (!relVal.IsEmpty()) {
|
||||
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
|
||||
uint32_t linkTypes =
|
||||
nsStyleLinkElement::ParseLinkTypes(relVal, aElement->NodePrincipal());
|
||||
bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
|
||||
if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
|
||||
nsAutoString hrefVal;
|
||||
|
Loading…
Reference in New Issue
Block a user