Bug 598833 part 7. Make IntrinsicState protected. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 31 May 2011 21:46:57 -0400
changeset 70921 a847b71c7685b8bf0fc9d0826a48ceb5cd7288b5
parent 70920 693f73d9ee75d7c7ecd1fb77bf3b80ee7bba6be0
child 70922 a9578a576fa6833483d3b8b78d921c014e7980a8
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs598833
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 598833 part 7. Make IntrinsicState protected. r=smaug
accessible/src/base/nsAccessible.cpp
accessible/src/html/nsHTMLLinkAccessible.cpp
content/base/public/Element.h
content/html/content/src/nsGenericHTMLElement.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/forms/nsButtonFrameRenderer.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFileControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/generic/nsImageFrame.cpp
layout/style/nsCSSRuleProcessor.cpp
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -691,26 +691,26 @@ nsAccessible::IsVisible(PRBool* aIsOffsc
 }
 
 PRUint64
 nsAccessible::NativeState()
 {
   PRUint64 state = 0;
   PRBool disabled = PR_FALSE;
   if (mContent->IsElement()) {
-    nsEventStates intrinsicState = mContent->AsElement()->IntrinsicState();
-
-    if (intrinsicState.HasState(NS_EVENT_STATE_INVALID))
+    nsEventStates elementState = mContent->AsElement()->State();
+
+    if (elementState.HasState(NS_EVENT_STATE_INVALID))
       state |= states::INVALID;
 
-    if (intrinsicState.HasState(NS_EVENT_STATE_REQUIRED))
+    if (elementState.HasState(NS_EVENT_STATE_REQUIRED))
       state |= states::REQUIRED;
 
     disabled = mContent->IsHTML() ? 
-      (intrinsicState.HasState(NS_EVENT_STATE_DISABLED)) :
+      (elementState.HasState(NS_EVENT_STATE_DISABLED)) :
       (mContent->AttrValueIs(kNameSpaceID_None,
                              nsAccessibilityAtoms::disabled,
                              nsAccessibilityAtoms::_true,
                              eCaseMatters));
   }
 
   // Set unavailable state based on disabled state, otherwise set focus states
   if (disabled) {
--- a/accessible/src/html/nsHTMLLinkAccessible.cpp
+++ b/accessible/src/html/nsHTMLLinkAccessible.cpp
@@ -76,17 +76,17 @@ nsHTMLLinkAccessible::NativeState()
 
   if (mContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::name)) {
     // This is how we indicate it is a named anchor
     // In other words, this anchor can be selected as a location :)
     // There is no other better state to use to indicate this.
     states |= states::SELECTABLE;
   }
 
-  nsEventStates state = mContent->AsElement()->IntrinsicState();
+  nsEventStates state = mContent->AsElement()->State();
   if (state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
                                   NS_EVENT_STATE_UNVISITED)) {
     states |= states::LINKED;
 
     if (state.HasState(NS_EVENT_STATE_VISITED))
       states |= states::TRAVERSED;
 
     return states;
@@ -182,12 +182,12 @@ nsHTMLLinkAccessible::GetAnchorURI(PRUin
 // Protected members
 
 PRBool
 nsHTMLLinkAccessible::IsLinked()
 {
   if (IsDefunct())
     return PR_FALSE;
 
-  nsEventStates state = mContent->AsElement()->IntrinsicState();
+  nsEventStates state = mContent->AsElement()->State();
   return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
                                      NS_EVENT_STATE_UNVISITED);
 }
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -88,31 +88,32 @@ namespace dom {
 class Element : public nsIContent
 {
 public:
 #ifdef MOZILLA_INTERNAL_API
   Element(already_AddRefed<nsINodeInfo> aNodeInfo) : nsIContent(aNodeInfo) {}
 #endif // MOZILLA_INTERNAL_API
 
   /**
+   * Method to get the full state of this element.  See nsEventStates.h for
+   * the possible bits that could be set here.
+   */
+  nsEventStates State() const {
+    return IntrinsicState() | mState;
+  }
+
+protected:
+  /**
    * Method to get the _intrinsic_ content state of this element.  This is the
    * state that is independent of the element's presentation.  To get the full
    * content state, use State().  See nsEventStates.h for
    * the possible bits that could be set here.
    */
   virtual nsEventStates IntrinsicState() const;
 
-  /**
-   * Method to get the full state of this element.  See nsEventStates.h for
-   * the possible bits that could be set here.
-   */
-  nsEventStates State() const {
-    return IntrinsicState() | mState;
-  }
-
 private:
   // Need to allow the ESM, nsGlobalWindow, and the focus manager to
   // set our state
   friend class ::nsEventStateManager;
   friend class ::nsGlobalWindow;
   friend class ::nsFocusManager;
 
   void NotifyStateChange(nsEventStates aStates);
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -3548,21 +3548,21 @@ MakeContentDescendantsEditable(nsIConten
   // that.  For elements, we need to send a ContentStateChanged
   // notification.
   if (!aContent->IsElement()) {
     aContent->UpdateEditableState();
     return;
   }
 
   Element *element = aContent->AsElement();
-  nsEventStates stateBefore = element->IntrinsicState();
+  nsEventStates stateBefore = element->State();
 
   element->UpdateEditableState();
 
-  if (aDocument && stateBefore != element->IntrinsicState()) {
+  if (aDocument && stateBefore != element->State()) {
     aDocument->ContentStateChanged(element,
                                    NS_EVENT_STATE_MOZ_READONLY |
                                    NS_EVENT_STATE_MOZ_READWRITE);
   }
 
   for (nsIContent *child = aContent->GetFirstChild();
        child;
        child = child->GetNextSibling()) {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3621,19 +3621,19 @@ nsCSSFrameConstructor::FindInputData(Ele
 const nsCSSFrameConstructor::FrameConstructionData*
 nsCSSFrameConstructor::FindObjectData(Element* aElement,
                                       nsStyleContext* aStyleContext)
 {
   // GetDisplayedType isn't necessarily nsIObjectLoadingContent::TYPE_NULL for
   // cases when the object is broken/suppressed/etc (e.g. a broken image), but
   // we want to treat those cases as TYPE_NULL
   PRUint32 type;
-  if (aElement->IntrinsicState().HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN |
-                                                       NS_EVENT_STATE_USERDISABLED |
-                                                       NS_EVENT_STATE_SUPPRESSED)) {
+  if (aElement->State().HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN |
+                                              NS_EVENT_STATE_USERDISABLED |
+                                              NS_EVENT_STATE_SUPPRESSED)) {
     type = nsIObjectLoadingContent::TYPE_NULL;
   } else {
     nsCOMPtr<nsIObjectLoadingContent> objContent(do_QueryInterface(aElement));
     NS_ASSERTION(objContent,
                  "applet, embed and object must implement "
                  "nsIObjectLoadingContent!");
 
     objContent->GetDisplayedType(&type);
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -81,20 +81,18 @@ nsButtonFrameRenderer::SetDisabled(PRBoo
                                   notify);
   else
     mFrame->GetContent()->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, notify);
 }
 
 PRBool
 nsButtonFrameRenderer::isDisabled() 
 {
-  // NOTE: we might want to remove this method to prevent calling too often
-  // IntrinsicState().
   return mFrame->GetContent()->AsElement()->
-    IntrinsicState().HasState(NS_EVENT_STATE_DISABLED);
+    State().HasState(NS_EVENT_STATE_DISABLED);
 }
 
 class nsDisplayButtonBoxShadowOuter : public nsDisplayItem {
 public:
   nsDisplayButtonBoxShadowOuter(nsDisplayListBuilder* aBuilder,
                                 nsButtonFrameRenderer* aRenderer)
     : nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
     MOZ_COUNT_CTOR(nsDisplayButtonBoxShadowOuter);
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -744,17 +744,17 @@ nsComboboxControlFrame::GetFrameName(nsA
 
 
 //----------------------------------------------------------------------
 // nsIComboboxControlFrame
 //----------------------------------------------------------------------
 void
 nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown) 
 {
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return;
   }
 
   if (!mDroppedDown && aDoDropDown) {
     if (mListControlFrame) {
       mListControlFrame->SyncViewWithFrame();
     }
@@ -944,17 +944,17 @@ nsComboboxControlFrame::HandleEvent(nsPr
                                        nsEventStatus*  aEventStatus)
 {
   NS_ENSURE_ARG_POINTER(aEventStatus);
 
   if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
     return NS_OK;
   }
 
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
 
   // If we have style that affects how we are selected, feed event down to
   // nsFrame::HandleEvent so that selection takes place when appropriate.
   const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
   if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
@@ -1400,17 +1400,17 @@ nsComboboxControlFrame::BuildDisplayList
 
   return DisplaySelectionOverlay(aBuilder, aLists.Content());
 }
 
 void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
                                         nsPoint aPt)
 {
   /* Do we need to do anything? */
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || mFocused != this)
     return;
 
   aRenderingContext.PushState();
   nsRect clipRect = mDisplayFrame->GetRect() + aPt;
   aRenderingContext.IntersectClip(clipRect);
 
   // REVIEW: Why does the old code paint mDisplayFrame again? We've
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -586,17 +586,17 @@ nsFileControlFrame::SyncAttr(PRInt32 aNa
       mBrowse->UnsetAttr(aNameSpaceID, aAttribute, PR_TRUE);
     }
   }
 }
 
 void
 nsFileControlFrame::SyncDisabledState()
 {
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
                           PR_TRUE);
     mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
                      PR_TRUE);
   } else {
     mTextContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, PR_TRUE);
     mBrowse->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, PR_TRUE);
@@ -699,17 +699,17 @@ nsFileControlFrame::BuildDisplayList(nsD
   clipRect.width = GetVisualOverflowRect().XMost();
   nscoord radii[8] = {0, 0, 0, 0, 0, 0, 0, 0};
   rv = OverflowClip(aBuilder, tempList, aLists, clipRect, radii);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Disabled file controls don't pass mouse events to their children, so we
   // put an invisible item in the display list above the children
   // just to catch events
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED) && IsVisibleForPainting(aBuilder)) {
     rv = aLists.Content()->AppendNewToTop(
         new (aBuilder) nsDisplayEventReceiver(aBuilder, this));
     if (NS_FAILED(rv))
       return rv;
   }
 
   return DisplaySelectionOverlay(aBuilder, aLists.Content());
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1069,17 +1069,17 @@ nsListControlFrame::HandleEvent(nsPresCo
     return NS_OK;
 
   // do we have style that affects how we are selected?
   // do we have user-input style?
   const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
   if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
     return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
 
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED))
     return NS_OK;
 
   return nsHTMLScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
 }
 
 
 //---------------------------------------------------------
@@ -1910,17 +1910,17 @@ nsresult
 nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
 
   UpdateInListState(aMouseEvent);
 
   mButtonDown = PR_FALSE;
 
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
 
   // only allow selection with the left button
   // if a right button click is on the combobox itself
   // or on the select when in listbox mode, then let the click through
   if (!IsLeftButton(aMouseEvent)) {
@@ -2119,17 +2119,17 @@ nsListControlFrame::GetIndexFromDOMEvent
 
 nsresult
 nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent != nsnull, "aMouseEvent is null.");
 
   UpdateInListState(aMouseEvent);
 
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
 
   // only allow selection with the left button
   // if a right button click is on the combobox itself
   // or on the select when in listbox mode, then let the click through
   if (!IsLeftButton(aMouseEvent)) {
@@ -2426,17 +2426,17 @@ nsListControlFrame::DropDownToggleKey(ns
   }
 }
 
 nsresult
 nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
 {
   NS_ASSERTION(aKeyEvent, "keyEvent is null.");
 
-  nsEventStates eventStates = mContent->AsElement()->IntrinsicState();
+  nsEventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED))
     return NS_OK;
 
   // Start by making sure we can query for a key event
   nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
   NS_ENSURE_TRUE(keyEvent, NS_ERROR_FAILURE);
 
   PRUint32 keycode = 0;
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -471,17 +471,17 @@ nsImageFrame::SourceRectToDest(const nsI
     (!(_state).HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED) && \
      (_state).HasState(NS_EVENT_STATE_LOADING) && (_loadingOK)))
 
 /* static */
 PRBool
 nsImageFrame::ShouldCreateImageFrameFor(Element* aElement,
                                         nsStyleContext* aStyleContext)
 {
-  nsEventStates state = aElement->IntrinsicState();
+  nsEventStates state = aElement->State();
   if (IMAGE_OK(state,
                HaveFixedSize(aStyleContext->GetStylePosition()))) {
     // Image is fine; do the image frame thing
     return PR_TRUE;
   }
 
   // Check if we want to use a placeholder box with an icon or just
   // let the presShell make us into inline text.  Decide as follows:
@@ -1159,17 +1159,17 @@ nsImageFrame::DisplayAltFeedback(nsRende
 
   aRenderingContext.PopState();
 }
 
 static void PaintAltFeedback(nsIFrame* aFrame, nsRenderingContext* aCtx,
      const nsRect& aDirtyRect, nsPoint aPt)
 {
   nsImageFrame* f = static_cast<nsImageFrame*>(aFrame);
-  nsEventStates state = f->GetContent()->AsElement()->IntrinsicState();
+  nsEventStates state = f->GetContent()->AsElement()->State();
   f->DisplayAltFeedback(*aCtx,
                         aDirtyRect,
                         IMAGE_OK(state, PR_TRUE)
                            ? nsImageFrame::gIconLoad->mLoadingImage
                            : nsImageFrame::gIconLoad->mBrokenImage,
                         aPt);
 }
 
@@ -1323,17 +1323,17 @@ nsImageFrame::BuildDisplayList(nsDisplay
     NS_ASSERTION(imageLoader, "Not an image loading content?");
 
     nsCOMPtr<imgIRequest> currentRequest;
     if (imageLoader) {
       imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
                               getter_AddRefs(currentRequest));
     }
 
-    nsEventStates contentState = mContent->AsElement()->IntrinsicState();
+    nsEventStates contentState = mContent->AsElement()->State();
     PRBool imageOK = IMAGE_OK(contentState, PR_TRUE);
 
     nsCOMPtr<imgIContainer> imgCon;
     if (currentRequest) {
       currentRequest->GetImage(getter_AddRefs(imgCon));
     }
 
     // Determine if the size is available
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1163,17 +1163,17 @@ nsCSSRuleProcessor::GetContentState(Elem
   }
   return state;
 }
 
 /* static */
 PRBool
 nsCSSRuleProcessor::IsLink(Element* aElement)
 {
-  nsEventStates state = aElement->IntrinsicState();
+  nsEventStates state = aElement->State();
   return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED);
 }
 
 /* static */
 nsEventStates
 nsCSSRuleProcessor::GetContentStateForVisitedHandling(
                      Element* aElement,
                      nsRuleWalker::VisitedHandlingType aVisitedHandling,