зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1319255 part 3. Don't create special elements for <shadow> and <content> unless webcomponents are enabled. r=wchen
This commit is contained in:
Родитель
23cc88e459
Коммит
921224f8f4
|
@ -5731,7 +5731,28 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
|||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
|
||||
|
||||
if (window) {
|
||||
return IsWebComponentsEnabled(window);
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
|
||||
{
|
||||
if (Preferences::GetBool("dom.webcomponents.enabled")) {
|
||||
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);
|
||||
|
@ -5739,7 +5760,7 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
|||
|
||||
uint32_t perm;
|
||||
rv = permMgr->TestPermissionFromWindow(
|
||||
window, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
|
||||
aWindow, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
return perm == nsIPermissionManager::ALLOW_ACTION;
|
||||
|
|
|
@ -1382,7 +1382,13 @@ public:
|
|||
virtual already_AddRefed<mozilla::dom::CustomElementRegistry>
|
||||
GetCustomElementRegistry() override;
|
||||
|
||||
// Check whether web components are enabled for the global of aObject.
|
||||
static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
// Check whether web components are enabled for the global of the document
|
||||
// this nodeinfo comes from.
|
||||
static bool IsWebComponentsEnabled(mozilla::dom::NodeInfo* aNodeInfo);
|
||||
// Check whether web components are enabled for the given window.
|
||||
static bool IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
RefPtr<mozilla::EventListenerManager> mListenerManager;
|
||||
RefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/HTMLContentElement.h"
|
||||
#include "mozilla/dom/HTMLContentElementBinding.h"
|
||||
#include "mozilla/dom/HTMLUnknownElement.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/css/StyleRule.h"
|
||||
|
@ -17,8 +18,28 @@
|
|||
#include "nsRuleProcessorData.h"
|
||||
#include "nsRuleWalker.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsDocument.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Content)
|
||||
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Content) to add check for web components
|
||||
// being enabled.
|
||||
nsGenericHTMLElement*
|
||||
NS_NewHTMLContentElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser)
|
||||
{
|
||||
// When this check is removed, remove the nsDocument.h and
|
||||
// HTMLUnknownElement.h includes. Also remove nsINode::IsHTMLContentElement.
|
||||
//
|
||||
// We have to jump through some hoops to be able to produce both NodeInfo* and
|
||||
// already_AddRefed<NodeInfo>& for our callees.
|
||||
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
|
||||
if (!nsDocument::IsWebComponentsEnabled(nodeInfo)) {
|
||||
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
|
||||
return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
|
||||
return new mozilla::dom::HTMLContentElement(nodeInfoArg);
|
||||
}
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
|
|
@ -8,10 +8,31 @@
|
|||
|
||||
#include "ChildIterator.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocument.h"
|
||||
#include "mozilla/dom/HTMLShadowElement.h"
|
||||
#include "mozilla/dom/HTMLUnknownElement.h"
|
||||
#include "mozilla/dom/HTMLShadowElementBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Shadow)
|
||||
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Shadow) to add check for web components
|
||||
// being enabled.
|
||||
nsGenericHTMLElement*
|
||||
NS_NewHTMLShadowElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser)
|
||||
{
|
||||
// When this check is removed, remove the nsDocument.h and
|
||||
// HTMLUnknownElement.h includes. Also remove nsINode::IsHTMLShadowElement.
|
||||
//
|
||||
// We have to jump through some hoops to be able to produce both NodeInfo* and
|
||||
// already_AddRefed<NodeInfo>& for our callees.
|
||||
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
|
||||
if (!nsDocument::IsWebComponentsEnabled(nodeInfo)) {
|
||||
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
|
||||
return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
|
||||
return new mozilla::dom::HTMLShadowElement(nodeInfoArg);
|
||||
}
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче