Bug 1373798 - Move HTML dir attribute state into event state flags

* Stop calling SetHasDirAuto/ClearHasDirAuto in input element code
* Introduce event state flags that track the state of an element's dir attribute
* Rewrite our existing checks for the state of the dir attr on top of the new event state flags
* Add pseudo-classes for matching on the dir attribute states
* Use the new dir attribute pseudoclasses in html.css

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:50:47 -04:00 committed by Roy Tam
commit 3b2a22f085
11 changed files with 139 additions and 72 deletions

View file

@ -1608,10 +1608,11 @@ private:
NodeIsContent,
// Set if the node has animations or transitions
ElementHasAnimations,
// Set if node has a dir attribute with a valid value (ltr, rtl, or auto)
// Set if node has a dir attribute with a valid value (ltr, rtl, or auto).
// Note that we cannot compute this from the dir attribute event state
// flags, because we can't use those to distinguish
// <bdi dir="some-invalid-value"> and <bdi dir="auto">.
NodeHasValidDirAttribute,
// Set if node has a dir attribute with a fixed value (ltr or rtl, NOT auto)
NodeHasFixedDir,
// Set if the node has dir=auto and has a property pointing to the text
// node that determines its direction
NodeHasDirAutoSet,
@ -1619,8 +1620,6 @@ private:
// and has a TextNodeDirectionalityMap property listing the elements whose
// direction it determines.
NodeHasTextNodeDirectionalityMap,
// Set if the node has dir=auto.
NodeHasDirAuto,
// Set if a node in the node's parent chain has dir=auto.
NodeAncestorHasDirAuto,
// Set if the element is in the scope of a scoped style sheet; this flag is
@ -1715,17 +1714,6 @@ public:
void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); }
void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); }
bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); }
void SetHasFixedDir() {
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
"SetHasFixedDir on text node");
SetBoolFlag(NodeHasFixedDir);
}
void ClearHasFixedDir() {
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
"ClearHasFixedDir on text node");
ClearBoolFlag(NodeHasFixedDir);
}
bool HasFixedDir() const { return GetBoolFlag(NodeHasFixedDir); }
void SetHasDirAutoSet() {
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
"SetHasDirAutoSet on text node");
@ -1754,16 +1742,12 @@ public:
return GetBoolFlag(NodeHasTextNodeDirectionalityMap);
}
void SetHasDirAuto() { SetBoolFlag(NodeHasDirAuto); }
void ClearHasDirAuto() { ClearBoolFlag(NodeHasDirAuto); }
bool HasDirAuto() const { return GetBoolFlag(NodeHasDirAuto); }
void SetAncestorHasDirAuto() { SetBoolFlag(NodeAncestorHasDirAuto); }
void ClearAncestorHasDirAuto() { ClearBoolFlag(NodeAncestorHasDirAuto); }
bool AncestorHasDirAuto() const { return GetBoolFlag(NodeAncestorHasDirAuto); }
bool NodeOrAncestorHasDirAuto() const
{ return HasDirAuto() || AncestorHasDirAuto(); }
// Implemented in nsIContentInlines.h.
inline bool NodeOrAncestorHasDirAuto() const;
void SetIsElementInStyleScope(bool aValue) {
MOZ_ASSERT(IsElement(), "SetIsInStyleScope on a non-Element node");