From 3857c96081de9b5e44e69b58a1e136b43b97c754 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 31 May 2011 21:46:57 -0400 Subject: [PATCH] Bug 598833 part 7. Make IntrinsicState protected. r=smaug --- accessible/src/base/nsAccessible.cpp | 8 ++++---- accessible/src/html/nsHTMLLinkAccessible.cpp | 4 ++-- content/base/public/Element.h | 17 +++++++++-------- .../html/content/src/nsGenericHTMLElement.cpp | 4 ++-- layout/base/nsCSSFrameConstructor.cpp | 6 +++--- layout/forms/nsButtonFrameRenderer.cpp | 4 +--- layout/forms/nsComboboxControlFrame.cpp | 6 +++--- layout/forms/nsFileControlFrame.cpp | 4 ++-- layout/forms/nsListControlFrame.cpp | 8 ++++---- layout/generic/nsImageFrame.cpp | 6 +++--- layout/style/nsCSSRuleProcessor.cpp | 2 +- 11 files changed, 34 insertions(+), 35 deletions(-) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index f0a45f9d5e2..1d6aea11f1c 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -696,16 +696,16 @@ nsAccessible::NativeState() PRUint64 state = 0; PRBool disabled = PR_FALSE; if (mContent->IsElement()) { - nsEventStates intrinsicState = mContent->AsElement()->IntrinsicState(); + nsEventStates elementState = mContent->AsElement()->State(); - if (intrinsicState.HasState(NS_EVENT_STATE_INVALID)) + 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, diff --git a/accessible/src/html/nsHTMLLinkAccessible.cpp b/accessible/src/html/nsHTMLLinkAccessible.cpp index ee1cec92795..86abd171855 100644 --- a/accessible/src/html/nsHTMLLinkAccessible.cpp +++ b/accessible/src/html/nsHTMLLinkAccessible.cpp @@ -81,7 +81,7 @@ nsHTMLLinkAccessible::NativeState() 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; @@ -187,7 +187,7 @@ 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); } diff --git a/content/base/public/Element.h b/content/base/public/Element.h index e000309e19b..64cd1fe0f5f 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -92,14 +92,6 @@ public: Element(already_AddRefed aNodeInfo) : nsIContent(aNodeInfo) {} #endif // MOZILLA_INTERNAL_API - /** - * 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. @@ -108,6 +100,15 @@ public: 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; + private: // Need to allow the ESM, nsGlobalWindow, and the focus manager to // set our state diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 58691097dcc..d516ea14103 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -3553,11 +3553,11 @@ MakeContentDescendantsEditable(nsIContent *aContent, nsIDocument *aDocument) } 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); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 515921833ca..beb427e6a31 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3626,9 +3626,9 @@ nsCSSFrameConstructor::FindObjectData(Element* aElement, // 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 objContent(do_QueryInterface(aElement)); diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 32ade89ff77..3180fc180ee 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -86,10 +86,8 @@ nsButtonFrameRenderer::SetDisabled(PRBool aDisabled, PRBool 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 { diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index b417ddbfd62..97e7b212876 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -749,7 +749,7 @@ nsComboboxControlFrame::GetFrameName(nsAString& aResult) const void nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown) { - nsEventStates eventStates = mContent->AsElement()->IntrinsicState(); + nsEventStates eventStates = mContent->AsElement()->State(); if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) { return; } @@ -949,7 +949,7 @@ nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext, return NS_OK; } - nsEventStates eventStates = mContent->AsElement()->IntrinsicState(); + nsEventStates eventStates = mContent->AsElement()->State(); if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) { return NS_OK; } @@ -1405,7 +1405,7 @@ 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; diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index b0045c11f99..36d1fb68bb7 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -591,7 +591,7 @@ nsFileControlFrame::SyncAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, 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); @@ -704,7 +704,7 @@ nsFileControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // 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)); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 66144baced7..883ee837931 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1074,7 +1074,7 @@ nsListControlFrame::HandleEvent(nsPresContext* aPresContext, 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; @@ -1915,7 +1915,7 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) mButtonDown = PR_FALSE; - nsEventStates eventStates = mContent->AsElement()->IntrinsicState(); + nsEventStates eventStates = mContent->AsElement()->State(); if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) { return NS_OK; } @@ -2124,7 +2124,7 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) UpdateInListState(aMouseEvent); - nsEventStates eventStates = mContent->AsElement()->IntrinsicState(); + nsEventStates eventStates = mContent->AsElement()->State(); if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) { return NS_OK; } @@ -2431,7 +2431,7 @@ 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; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index cd803a53937..a443bd3a374 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -476,7 +476,7 @@ 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 @@ -1164,7 +1164,7 @@ static void PaintAltFeedback(nsIFrame* aFrame, nsRenderingContext* aCtx, const nsRect& aDirtyRect, nsPoint aPt) { nsImageFrame* f = static_cast(aFrame); - nsEventStates state = f->GetContent()->AsElement()->IntrinsicState(); + nsEventStates state = f->GetContent()->AsElement()->State(); f->DisplayAltFeedback(*aCtx, aDirtyRect, IMAGE_OK(state, PR_TRUE) @@ -1328,7 +1328,7 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, getter_AddRefs(currentRequest)); } - nsEventStates contentState = mContent->AsElement()->IntrinsicState(); + nsEventStates contentState = mContent->AsElement()->State(); PRBool imageOK = IMAGE_OK(contentState, PR_TRUE); nsCOMPtr imgCon; diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 6a6a0aeca15..ea8a79467b6 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1168,7 +1168,7 @@ nsCSSRuleProcessor::GetContentState(Element* aElement) PRBool nsCSSRuleProcessor::IsLink(Element* aElement) { - nsEventStates state = aElement->IntrinsicState(); + nsEventStates state = aElement->State(); return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED); }