From 2ff643067b1af7fcb8385d5d6e750b955c07c49a Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 05:50:47 -0400 Subject: 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 mcp-graveyard/UXP%1375 --- dom/base/Element.h | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'dom/base/Element.h') 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 @@ -255,6 +255,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. */ @@ -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; -- cgit v1.2.3