mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 06:09:19 +00:00
Bug 1878888 - Add the runtime flag and parsing for the blocking attribute, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D200810
This commit is contained in:
parent
214e343253
commit
d7bb85c04b
@ -276,6 +276,9 @@ nsIFrame* nsIContent::GetPrimaryFrame(mozilla::FlushType aType) {
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
const DOMTokenListSupportedToken Element::sSupportedBlockingValues[] = {
|
||||
"render", nullptr};
|
||||
|
||||
nsDOMAttributeMap* Element::Attributes() {
|
||||
nsDOMSlots* slots = DOMSlots();
|
||||
if (!slots->mAttributeMap) {
|
||||
|
@ -1834,6 +1834,11 @@ class Element : public FragmentOrElement {
|
||||
static const bool kCallAfterSetAttr = true;
|
||||
static const bool kDontCallAfterSetAttr = false;
|
||||
|
||||
/*
|
||||
* The supported values of blocking attribute for use with nsDOMTokenList.
|
||||
*/
|
||||
static const DOMTokenListSupportedToken sSupportedBlockingValues[];
|
||||
|
||||
/**
|
||||
* Set attribute and (if needed) notify documentobservers and fire off
|
||||
* mutation events. This will send the AttributeChanged notification.
|
||||
|
@ -60,6 +60,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLLinkElement,
|
||||
tmp->LinkStyle::Traverse(cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSizes)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBlocking)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement,
|
||||
@ -67,6 +68,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement,
|
||||
tmp->LinkStyle::Unlink();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSizes)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBlocking)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLLinkElement,
|
||||
@ -693,4 +695,12 @@ bool HTMLLinkElement::IsCSSMimeTypeAttributeForLinkElement(
|
||||
return mimeType.IsEmpty() || mimeType.LowerCaseEqualsLiteral("text/css");
|
||||
}
|
||||
|
||||
nsDOMTokenList* HTMLLinkElement::Blocking() {
|
||||
if (!mBlocking) {
|
||||
mBlocking =
|
||||
new nsDOMTokenList(this, nsGkAtoms::blocking, sSupportedBlockingValues);
|
||||
}
|
||||
return mBlocking;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -166,6 +166,8 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
|
||||
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
|
||||
}
|
||||
|
||||
nsDOMTokenList* Blocking();
|
||||
|
||||
void NodeInfoChanged(Document* aOldDoc) final {
|
||||
mCachedURI = nullptr;
|
||||
nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
|
||||
@ -197,6 +199,7 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
|
||||
|
||||
RefPtr<nsDOMTokenList> mRelList;
|
||||
RefPtr<nsDOMTokenList> mSizes;
|
||||
RefPtr<nsDOMTokenList> mBlocking;
|
||||
|
||||
// A weak reference to our preload is held only to cancel the preload when
|
||||
// this node updates or unbounds from the tree. We want to prevent cycles,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsDOMTokenList.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/HTMLScriptElement.h"
|
||||
#include "mozilla/dom/HTMLScriptElementBinding.h"
|
||||
@ -47,9 +48,14 @@ HTMLScriptElement::HTMLScriptElement(
|
||||
|
||||
HTMLScriptElement::~HTMLScriptElement() = default;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement,
|
||||
nsIScriptLoaderObserver, nsIScriptElement,
|
||||
nsIMutationObserver)
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLScriptElement,
|
||||
nsGenericHTMLElement,
|
||||
nsIScriptLoaderObserver,
|
||||
nsIScriptElement,
|
||||
nsIMutationObserver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLScriptElement, nsGenericHTMLElement,
|
||||
mBlocking)
|
||||
|
||||
nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
|
||||
nsINode& aParent) {
|
||||
@ -237,4 +243,12 @@ bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
|
||||
aType.EqualsLiteral("importmap");
|
||||
}
|
||||
|
||||
nsDOMTokenList* HTMLScriptElement::Blocking() {
|
||||
if (!mBlocking) {
|
||||
mBlocking =
|
||||
new nsDOMTokenList(this, nsGkAtoms::blocking, sSupportedBlockingValues);
|
||||
}
|
||||
return mBlocking;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
class nsDOMTokenList;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
@ -26,6 +28,10 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// CC
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLScriptElement,
|
||||
nsGenericHTMLElement)
|
||||
|
||||
void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
|
||||
virtual void SetInnerHTML(const nsAString& aInnerHTML,
|
||||
nsIPrincipal* aSubjectPrincipal,
|
||||
@ -131,6 +137,8 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy);
|
||||
}
|
||||
|
||||
nsDOMTokenList* Blocking();
|
||||
|
||||
// Required for the webidl-binding because `GetFetchPriority` is overloaded.
|
||||
using nsGenericHTMLElement::GetFetchPriority;
|
||||
|
||||
@ -150,6 +158,8 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
|
||||
|
||||
// ScriptElement
|
||||
virtual bool HasScriptContent() override;
|
||||
|
||||
RefPtr<nsDOMTokenList> mBlocking;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsDOMTokenList.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Style)
|
||||
|
||||
@ -32,11 +33,13 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLStyleElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLStyleElement,
|
||||
nsGenericHTMLElement)
|
||||
tmp->LinkStyle::Traverse(cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBlocking)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLStyleElement,
|
||||
nsGenericHTMLElement)
|
||||
tmp->LinkStyle::Unlink();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBlocking)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLStyleElement,
|
||||
@ -188,4 +191,12 @@ JSObject* HTMLStyleElement::WrapNode(JSContext* aCx,
|
||||
return HTMLStyleElement_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
nsDOMTokenList* HTMLStyleElement::Blocking() {
|
||||
if (!mBlocking) {
|
||||
mBlocking =
|
||||
new nsDOMTokenList(this, nsGkAtoms::blocking, sSupportedBlockingValues);
|
||||
}
|
||||
return mBlocking;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
|
||||
class nsDOMTokenList;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
class HTMLStyleElement final : public nsGenericHTMLElement,
|
||||
@ -71,6 +73,8 @@ class HTMLStyleElement final : public nsGenericHTMLElement,
|
||||
SetHTMLAttr(nsGkAtoms::type, aType, aError);
|
||||
}
|
||||
|
||||
nsDOMTokenList* Blocking();
|
||||
|
||||
virtual JSObject* WrapNode(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
@ -87,6 +91,8 @@ class HTMLStyleElement final : public nsGenericHTMLElement,
|
||||
* parent; we should only respond to the change if aContent is non-anonymous.
|
||||
*/
|
||||
void ContentChanged(nsIContent* aContent);
|
||||
|
||||
RefPtr<nsDOMTokenList> mBlocking;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -39,6 +39,8 @@ interface HTMLLinkElement : HTMLElement {
|
||||
attribute USVString imageSrcset;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute USVString imageSizes;
|
||||
[Pref="dom.element.blocking.enabled", SameObject, PutForwards=value]
|
||||
readonly attribute DOMTokenList blocking;
|
||||
[Pref="network.fetchpriority.enabled", CEReactions]
|
||||
attribute DOMString fetchPriority;
|
||||
};
|
||||
|
@ -30,6 +30,8 @@ interface HTMLScriptElement : HTMLElement {
|
||||
attribute DOMString referrerPolicy;
|
||||
[CEReactions, Throws]
|
||||
attribute DOMString text;
|
||||
[Pref="dom.element.blocking.enabled", SameObject, PutForwards=value]
|
||||
readonly attribute DOMTokenList blocking;
|
||||
[Pref="network.fetchpriority.enabled", CEReactions]
|
||||
attribute DOMString fetchPriority;
|
||||
|
||||
|
@ -18,6 +18,8 @@ interface HTMLStyleElement : HTMLElement {
|
||||
attribute DOMString media;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString type;
|
||||
[Pref="dom.element.blocking.enabled", SameObject, PutForwards=value]
|
||||
readonly attribute DOMTokenList blocking;
|
||||
};
|
||||
HTMLStyleElement includes LinkStyle;
|
||||
|
||||
|
@ -2343,6 +2343,13 @@
|
||||
mirror: always
|
||||
rust: true
|
||||
|
||||
# Whether the blocking attribute implementation is enabled,
|
||||
# see https://html.spec.whatwg.org/#blocking-attributes
|
||||
- name: dom.element.blocking.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Whether CustomStateSet is enabled
|
||||
- name: dom.element.customstateset.enabled
|
||||
type: RelaxedAtomicBool
|
||||
|
@ -0,0 +1 @@
|
||||
prefs: [dom.element.blocking.enabled: true]
|
@ -1,18 +0,0 @@
|
||||
[blocking-idl-attr.html]
|
||||
[Supported tokens of the 'blocking' IDL attribute of the link element]
|
||||
expected: FAIL
|
||||
|
||||
[Setting the 'blocking' IDL attribute of the link element]
|
||||
expected: FAIL
|
||||
|
||||
[Supported tokens of the 'blocking' IDL attribute of the script element]
|
||||
expected: FAIL
|
||||
|
||||
[Setting the 'blocking' IDL attribute of the script element]
|
||||
expected: FAIL
|
||||
|
||||
[Supported tokens of the 'blocking' IDL attribute of the style element]
|
||||
expected: FAIL
|
||||
|
||||
[Setting the 'blocking' IDL attribute of the style element]
|
||||
expected: FAIL
|
@ -189,6 +189,7 @@ STATIC_ATOMS = [
|
||||
Atom("black", "black"),
|
||||
Atom("block", "block"),
|
||||
Atom("block_size", "block-size"),
|
||||
Atom("blocking", "blocking"),
|
||||
Atom("blockquote", "blockquote"),
|
||||
Atom("blur", "blur"),
|
||||
Atom("body", "body"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user