mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1331334 - Implement :defined pseudo-class for custom elements, r=emilio
--HG-- extra : rebase_source : 5f95c38166d00ae07ef523ab8ecb5b4cb59eceaf
This commit is contained in:
parent
d7f4c99e36
commit
d87b0df953
@ -1155,6 +1155,7 @@ CustomElementRegistry::Upgrade(Element* aElement,
|
||||
|
||||
// Step 8.
|
||||
data->mState = CustomElementData::State::eCustom;
|
||||
aElement->SetDefined(true);
|
||||
|
||||
// Step 9.
|
||||
aElement->SetCustomElementDefinition(aDefinition);
|
||||
|
@ -4284,18 +4284,18 @@ void
|
||||
Element::SetCustomElementData(CustomElementData* aData)
|
||||
{
|
||||
SetHasCustomElementData();
|
||||
|
||||
if (aData->mState != CustomElementData::State::eCustom) {
|
||||
SetDefined(false);
|
||||
}
|
||||
|
||||
nsExtendedDOMSlots *slots = ExtendedDOMSlots();
|
||||
MOZ_ASSERT(!slots->mCustomElementData, "Custom element data may not be changed once set.");
|
||||
#if DEBUG
|
||||
nsAtom* name = NodeInfo()->NameAtom();
|
||||
nsAtom* type = aData->GetCustomElementType();
|
||||
if (NodeInfo()->NamespaceID() == kNameSpaceID_XHTML) {
|
||||
if (nsContentUtils::IsCustomElementName(name, kNameSpaceID_XHTML)) {
|
||||
MOZ_ASSERT(type == name);
|
||||
} else {
|
||||
MOZ_ASSERT(type != name);
|
||||
}
|
||||
} else { // kNameSpaceID_XUL
|
||||
// We assert only XUL usage, since web may pass whatever as 'is' value
|
||||
if (NodeInfo()->NamespaceID() == kNameSpaceID_XUL) {
|
||||
nsAtom* name = NodeInfo()->NameAtom();
|
||||
nsAtom* type = aData->GetCustomElementType();
|
||||
// Check to see if the tag name is a dashed name.
|
||||
if (nsContentUtils::IsNameWithDash(name)) {
|
||||
// Assert that a tag name with dashes is always an autonomous custom
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
explicit Element(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) :
|
||||
FragmentOrElement(aNodeInfo),
|
||||
mState(NS_EVENT_STATE_MOZ_READONLY)
|
||||
mState(NS_EVENT_STATE_MOZ_READONLY | NS_EVENT_STATE_DEFINED)
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->NodeType() == ELEMENT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
@ -553,6 +553,14 @@ public:
|
||||
*/
|
||||
void SetCustomElementDefinition(CustomElementDefinition* aDefinition);
|
||||
|
||||
void SetDefined(bool aSet)
|
||||
{
|
||||
if (aSet) {
|
||||
AddStates(NS_EVENT_STATE_DEFINED);
|
||||
} else {
|
||||
RemoveStates(NS_EVENT_STATE_DEFINED);
|
||||
}
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this element. This is the
|
||||
|
@ -9924,9 +9924,6 @@ nsContentUtils::NewXULOrHTMLElement(Element** aResult, mozilla::dom::NodeInfo* a
|
||||
int32_t tag = eHTMLTag_unknown;
|
||||
bool isCustomElementName = false;
|
||||
if (nodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
|
||||
if (aIsAtom && !nsContentUtils::IsNameWithDash(aIsAtom)) {
|
||||
aIsAtom = nullptr;
|
||||
}
|
||||
tag = nsHTMLTags::CaseSensitiveAtomTagToId(name);
|
||||
isCustomElementName = (tag == eHTMLTag_userdefined &&
|
||||
nsContentUtils::IsCustomElementName(name, kNameSpaceID_XHTML));
|
||||
@ -10042,6 +10039,7 @@ nsContentUtils::NewXULOrHTMLElement(Element** aResult, mozilla::dom::NodeInfo* a
|
||||
} else {
|
||||
NS_IF_ADDREF(*aResult = nsXULElement::Construct(nodeInfo.forget()));
|
||||
}
|
||||
(*aResult)->SetDefined(false);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -243,7 +243,8 @@ private:
|
||||
#define NS_EVENT_STATE_REQUIRED NS_DEFINE_EVENT_STATE_MACRO(21)
|
||||
// Content is optional (and can be required).
|
||||
#define NS_EVENT_STATE_OPTIONAL NS_DEFINE_EVENT_STATE_MACRO(22)
|
||||
// Free bit NS_DEFINE_EVENT_STATE_MACRO(23)
|
||||
// Element is either a defined custom element or uncustomized element.
|
||||
#define NS_EVENT_STATE_DEFINED NS_DEFINE_EVENT_STATE_MACRO(23)
|
||||
// Link has been visited.
|
||||
#define NS_EVENT_STATE_VISITED NS_DEFINE_EVENT_STATE_MACRO(24)
|
||||
// Link hasn't been visited.
|
||||
@ -354,6 +355,7 @@ private:
|
||||
DISABLED_STATES | \
|
||||
REQUIRED_STATES | \
|
||||
NS_EVENT_STATE_ACTIVE | \
|
||||
NS_EVENT_STATE_DEFINED | \
|
||||
NS_EVENT_STATE_DRAGOVER | \
|
||||
NS_EVENT_STATE_FOCUS | \
|
||||
NS_EVENT_STATE_FOCUSRING | \
|
||||
|
@ -71,7 +71,8 @@ bitflags! {
|
||||
const IN_OPTIONAL_STATE = 1 << 22;
|
||||
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
|
||||
const IN_READ_WRITE_STATE = 1 << 22;
|
||||
/// There is a free bit at 23.
|
||||
/// <https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined>
|
||||
const IN_DEFINED_STATE = 1 << 23;
|
||||
/// <https://html.spec.whatwg.org/multipage/#selector-visited>
|
||||
const IN_VISITED_STATE = 1 << 24;
|
||||
/// <https://html.spec.whatwg.org/multipage/#selector-link>
|
||||
|
@ -47,6 +47,7 @@ macro_rules! apply_non_ts_list {
|
||||
("visited", Visited, visited, IN_VISITED_STATE, _),
|
||||
("active", Active, active, IN_ACTIVE_STATE, _),
|
||||
("checked", Checked, checked, IN_CHECKED_STATE, _),
|
||||
("defined", Defined, defined, IN_DEFINED_STATE, _),
|
||||
("disabled", Disabled, disabled, IN_DISABLED_STATE, _),
|
||||
("enabled", Enabled, enabled, IN_ENABLED_STATE, _),
|
||||
("focus", Focus, focus, IN_FOCUS_STATE, _),
|
||||
|
@ -187,6 +187,9 @@ impl NonTSPseudoClass {
|
||||
NonTSPseudoClass::Fullscreen => unsafe {
|
||||
mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled
|
||||
},
|
||||
NonTSPseudoClass::Defined => unsafe {
|
||||
structs::nsContentUtils_sIsCustomElementsEnabled
|
||||
},
|
||||
// Otherwise, a pseudo-class is enabled in content when it
|
||||
// doesn't have any enabled flag.
|
||||
_ => !self.has_any_flag(
|
||||
|
@ -2124,6 +2124,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||
{
|
||||
use selectors::matching::*;
|
||||
match *pseudo_class {
|
||||
NonTSPseudoClass::Defined |
|
||||
NonTSPseudoClass::Focus |
|
||||
NonTSPseudoClass::Enabled |
|
||||
NonTSPseudoClass::Disabled |
|
||||
|
@ -7,6 +7,3 @@
|
||||
|
||||
[document.createElement must not report a NotSupportedError when the element is adopted back from a the document of an iframe during construction]
|
||||
expected: FAIL
|
||||
|
||||
[document.createElement must create an instance of autonomous custom elements when it has is attribute]
|
||||
expected: FAIL
|
||||
|
@ -1,119 +0,0 @@
|
||||
[pseudo-class-defined.html]
|
||||
max-asserts: 4
|
||||
[<div> should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElement("div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/1999/xhtml", "div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/2000/svg", "div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElement("div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/1999/xhtml", "div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "div") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[<a-a> should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElement("a-a") should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/1999/xhtml", "a-a") should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/2000/svg", "a-a") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Upgraded createElement("a-a") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Upgraded createElementNS("http://www.w3.org/1999/xhtml", "a-a") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElement("a-a") should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/1999/xhtml", "a-a") should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "a-a") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[<font-face> should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElement("font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/1999/xhtml", "font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/2000/svg", "font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElement("font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/1999/xhtml", "font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "font-face") should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[<abbr is=my-abbr> should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElement("abbr", { is: "my-abbr" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/1999/xhtml", "abbr", { is: "my-abbr" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/2000/svg", "abbr", { is: "my-abbr" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Upgraded createElement("abbr", { is: "my-abbr" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Upgraded createElementNS("http://www.w3.org/1999/xhtml", "abbr", { is: "my-abbr" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElement("abbr", { is: "my-abbr" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/1999/xhtml", "abbr", { is: "my-abbr" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "abbr", { is: "my-abbr" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[<p> should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElement("p", { is: "" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/1999/xhtml", "p", { is: "" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[createElementNS("http://www.w3.org/2000/svg", "p", { is: "" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElement("p", { is: "" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/1999/xhtml", "p", { is: "" }) should not be :defined]
|
||||
expected: FAIL
|
||||
|
||||
[Without browsing context: createElementNS("http://www.w3.org/2000/svg", "p", { is: "" }) should be :defined]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user