summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/DirectionalityUtils.cpp4
-rw-r--r--dom/base/Element.h36
-rw-r--r--dom/base/nsIContentInlines.h6
-rw-r--r--dom/base/nsINode.h28
4 files changed, 41 insertions, 33 deletions
diff --git a/dom/base/DirectionalityUtils.cpp b/dom/base/DirectionalityUtils.cpp
index d9a6c4524..632abb2c8 100644
--- a/dom/base/DirectionalityUtils.cpp
+++ b/dom/base/DirectionalityUtils.cpp
@@ -728,7 +728,7 @@ WalkDescendantsResetAutoDirection(Element* aElement)
{
nsIContent* child = aElement->GetFirstChild();
while (child) {
- if (child->HasDirAuto()) {
+ if (child->IsElement() && child->AsElement()->HasDirAuto()) {
child = child->GetNextNonChildNode(aElement);
continue;
}
@@ -791,7 +791,7 @@ WalkDescendantsClearAncestorDirAuto(Element* aElement)
{
nsIContent* child = aElement->GetFirstChild();
while (child) {
- if (child->HasDirAuto()) {
+ if (child->IsElement() && child->AsElement()->HasDirAuto()) {
child = child->GetNextNonChildNode(aElement);
continue;
}
diff --git a/dom/base/Element.h b/dom/base/Element.h
index df0dbcc45..76f0767e6 100644
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -256,6 +256,23 @@ public:
void ClearStyleStateLocks();
/**
+ * Accessors for the state of our dir attribute.
+ */
+ bool HasDirAuto() const
+ {
+ return State().HasState(NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO);
+ }
+
+ /**
+ * Elements with dir="rtl" or dir="ltr".
+ */
+ bool HasFixedDir() const
+ {
+ return State().HasAtLeastOneOfStates(NS_EVENT_STATE_DIR_ATTR_LTR |
+ NS_EVENT_STATE_DIR_ATTR_RTL);
+ }
+
+ /**
* Get the inline style declaration, if any, for this element.
*/
virtual DeclarationBlock* GetInlineStyleDeclaration();
@@ -380,15 +397,6 @@ public:
bool GetBindingURL(nsIDocument *aDocument, css::URLValue **aResult);
- // The bdi element defaults to dir=auto if it has no dir attribute set.
- // Other elements will only have dir=auto if they have an explicit dir=auto,
- // which will mean that HasValidDir() returns true but HasFixedDir() returns
- // false
- inline bool HasDirAuto() const {
- return (!HasFixedDir() &&
- (HasValidDir() || IsHTMLElement(nsGkAtoms::bdi)));
- }
-
Directionality GetComputedDirectionality() const;
inline Element* GetFlattenedTreeParentElementForStyle() const;
@@ -501,6 +509,16 @@ protected:
RemoveStatesSilently(aStates);
NotifyStateChange(aStates);
}
+ virtual void ToggleStates(EventStates aStates, bool aNotify)
+ {
+ NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
+ "Should only be removing externally-managed states here");
+ mState ^= aStates;
+ if (aNotify) {
+ NotifyStateChange(aStates);
+ }
+ }
+
public:
virtual void UpdateEditableState(bool aNotify) override;
diff --git a/dom/base/nsIContentInlines.h b/dom/base/nsIContentInlines.h
index 6a82f7f65..6a9bd7afa 100644
--- a/dom/base/nsIContentInlines.h
+++ b/dom/base/nsIContentInlines.h
@@ -87,4 +87,10 @@ nsINode::GetFlattenedTreeParentNodeForStyle() const
return ::GetFlattenedTreeParentNode<nsIContent::eForStyle>(this);
}
+inline bool
+nsINode::NodeOrAncestorHasDirAuto() const
+{
+ return AncestorHasDirAuto() || (IsElement() && AsElement()->HasDirAuto());
+}
+
#endif // nsIContentInlines_h
diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
index 0f882445f..7c3eb9134 100644
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -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");