Bug 1341230 - Part 1: Rename ESM_MANAGED_STATES to EXTERNALLY_MANAGED_STATES. r=smaug
☠☠ backed out by 95e0ba5f61da ☠ ☠
authorCameron McCormack <cam@mcc.id.au>
Mon, 06 Mar 2017 10:44:13 +0800
changeset 374993 41bd2eefc82322918a7f5d299dd913fc20c65316
parent 374992 5368b2790c4292a3004bd2c9b44ecd3dd6187e0d
child 374994 f879b73eb504400f64b52bb84efdb2b6af8309c7
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1341230
milestone54.0a1
Bug 1341230 - Part 1: Rename ESM_MANAGED_STATES to EXTERNALLY_MANAGED_STATES. r=smaug Since it's not just the EventStateManager that has access to modify these EventStates bits. MozReview-Commit-ID: 17EpfQT5M40
dom/base/Element.cpp
dom/base/Element.h
dom/events/EventStates.h
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -219,17 +219,17 @@ Element::UpdateLinkState(EventStates aSt
     (mState & ~(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)) |
     aState;
 }
 
 void
 Element::UpdateState(bool aNotify)
 {
   EventStates oldState = mState;
-  mState = IntrinsicState() | (oldState & ESM_MANAGED_STATES);
+  mState = IntrinsicState() | (oldState & EXTERNALLY_MANAGED_STATES);
   if (aNotify) {
     EventStates changedStates = oldState ^ mState;
     if (!changedStates.IsEmpty()) {
       nsIDocument* doc = GetComposedDoc();
       if (doc) {
         nsAutoScriptBlocker scriptBlocker;
         doc->ContentStateChanged(this, changedStates);
       }
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -510,30 +510,31 @@ private:
   void NotifyStateChange(EventStates aStates);
 
   void NotifyStyleStateChange(EventStates aStates);
 
   // Style state computed from element's state and style locks.
   EventStates StyleStateFromLocks() const;
 
 protected:
-  // Methods for the ESM to manage state bits.  These will handle
-  // setting up script blockers when they notify, so no need to do it
-  // in the callers unless desired.
+  // Methods for the ESM, nsGlobalWindow and focus manager to manage state bits.
+  // These will handle setting up script blockers when they notify, so no need
+  // to do it in the callers unless desired.  States passed here must only be
+  // those in EXTERNALLY_MANAGED_STATES.
   virtual void AddStates(EventStates aStates)
   {
     NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
-                    "Should only be adding ESM-managed states here");
+                    "Should only be adding externally-managed states here");
     AddStatesSilently(aStates);
     NotifyStateChange(aStates);
   }
   virtual void RemoveStates(EventStates aStates)
   {
     NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES),
-                    "Should only be removing ESM-managed states here");
+                    "Should only be removing externally-managed states here");
     RemoveStatesSilently(aStates);
     NotifyStateChange(aStates);
   }
 public:
   virtual void UpdateEditableState(bool aNotify) override;
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
--- a/dom/events/EventStates.h
+++ b/dom/events/EventStates.h
@@ -309,17 +309,27 @@ private:
 #define NS_EVENT_STATE_IGNORE NS_DEFINE_EVENT_STATE_MACRO(63)
 
 /**
  * NOTE: do not go over 63 without updating EventStates::InternalType!
  */
 
 #define DIRECTION_STATES (NS_EVENT_STATE_LTR | NS_EVENT_STATE_RTL)
 
-#define ESM_MANAGED_STATES (NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS |  \
-                            NS_EVENT_STATE_HOVER | NS_EVENT_STATE_DRAGOVER |   \
-                            NS_EVENT_STATE_URLTARGET | NS_EVENT_STATE_FOCUSRING | \
-                            NS_EVENT_STATE_FULL_SCREEN | NS_EVENT_STATE_UNRESOLVED | \
-                            NS_EVENT_STATE_FOCUS_WITHIN)
+// Event states that are managed externally to an element (by the
+// EventStateManager, or by other code).  As opposed to those in
+// INTRINSIC_STATES, which are are computed by the element itself
+// and returned from Element::IntrinsicState.
+#define EXTERNALLY_MANAGED_STATES (           \
+  NS_EVENT_STATE_ACTIVE |                     \
+  NS_EVENT_STATE_DRAGOVER |                   \
+  NS_EVENT_STATE_FOCUS |                      \
+  NS_EVENT_STATE_FOCUSRING |                  \
+  NS_EVENT_STATE_FOCUS_WITHIN |               \
+  NS_EVENT_STATE_FULL_SCREEN |                \
+  NS_EVENT_STATE_HOVER |                      \
+  NS_EVENT_STATE_UNRESOLVED |                 \
+  NS_EVENT_STATE_URLTARGET                    \
+)
 
-#define INTRINSIC_STATES (~ESM_MANAGED_STATES)
+#define INTRINSIC_STATES (~EXTERNALLY_MANAGED_STATES)
 
 #endif // mozilla_EventStates_h_