diff --git a/mozilla/accessible/src/base/nsDocAccessible.cpp b/mozilla/accessible/src/base/nsDocAccessible.cpp index fbb0893ac5d..25f8d32934a 100644 --- a/mozilla/accessible/src/base/nsDocAccessible.cpp +++ b/mozilla/accessible/src/base/nsDocAccessible.cpp @@ -918,7 +918,7 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsDocAccessible) void nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, PRUint32 aStateMask) { // Fire accessible event after short timer, because we need to wait for // DOM attribute & resulting layout to actually change. Otherwise, @@ -958,6 +958,7 @@ nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, // set for XUL, HTML or ARIA namespace. // Checking the namespace would not seem to gain us anything, because // disabled really is going to mean the same thing in any namespace. + // XXXbz wouldn't it make more sense to observe the disabled state bit? nsCOMPtr enabledChangeEvent = new nsAccStateChangeEvent(targetNode, nsIAccessibleStates::EXT_STATE_ENABLED, diff --git a/mozilla/content/base/public/nsIMutationObserver.h b/mozilla/content/base/public/nsIMutationObserver.h index 020892e12c6..e60db1d47a0 100755 --- a/mozilla/content/base/public/nsIMutationObserver.h +++ b/mozilla/content/base/public/nsIMutationObserver.h @@ -101,12 +101,15 @@ public: * @param aModType Whether or not the attribute was added, changed, or * removed. The constants are defined in * nsIDOMMutationEvent.h. + * @param aStateMask If this attribute change caused content state changes, + * the bits that changed. Might be 0 if no bits changed. */ virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) = 0; + PRInt32 aModType, + PRUint32 aStateMask) = 0; /** * Notification that one or more content nodes have been appended to the @@ -201,7 +204,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver, NS_IMUTATION_OBSERVER_IID) nsIContent* aContent, \ PRInt32 aNameSpaceID, \ nsIAtom* aAttribute, \ - PRInt32 aModType); + PRInt32 aModType, \ + PRUint32 aStateMask); #define NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED \ virtual void ContentAppended(nsIDocument* aDocument, \ @@ -253,7 +257,8 @@ _class::AttributeChanged(nsIDocument* aDocument, \ nsIContent* aContent, \ PRInt32 aNameSpaceID, \ nsIAtom* aAttribute, \ - PRInt32 aModType) \ + PRInt32 aModType, \ + PRUint32 aStateMask) \ { \ } \ void \ diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index 51481f4532c..a81987722db 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -495,7 +495,7 @@ nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn) void nsContentList::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, PRUint32 aStateMask) { NS_PRECONDITION(aContent, "Must have a content node to work with"); diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h index 031ea981171..980cb2589db 100644 --- a/mozilla/content/base/src/nsContentList.h +++ b/mozilla/content/base/src/nsContentList.h @@ -245,17 +245,12 @@ public: // nsIMutationObserver - virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument *aDocument, nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void NodeWillBeDestroyed(const nsINode *aNode); - + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED + static void OnDocumentDestroy(nsIDocument *aDocument); protected: diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index e9027d92b45..92044c5a8df 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -3564,8 +3564,16 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIDocument* document = GetCurrentDoc(); mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify); - if (aNotify && document) { - document->AttributeWillChange(this, aNamespaceID, aName); + + // When notifying, make sure to keep track of states whose value + // depends solely on the value of an attribute. + PRUint32 stateMask; + if (aNotify) { + stateMask = PRUint32(IntrinsicState()); + + if (document) { + document->AttributeWillChange(this, aNamespaceID, aName); + } } if (aNamespaceID == kNameSpaceID_None) { @@ -3596,7 +3604,13 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, } if (aNotify) { - nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, modType); + stateMask = stateMask ^ PRUint32(IntrinsicState()); + if (stateMask && document) { + MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify); + document->ContentStatesChanged(this, nsnull, stateMask); + } + nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, modType, + stateMask); } if (aFireMutation) { @@ -3795,6 +3809,13 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, } } + // When notifying, make sure to keep track of states whose value + // depends solely on the value of an attribute. + PRUint32 stateMask; + if (aNotify) { + stateMask = PRUint32(IntrinsicState()); + } + PRBool hasMutationListeners = aNotify && nsContentUtils::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED, @@ -3827,8 +3848,14 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, } if (aNotify) { + stateMask = stateMask ^ PRUint32(IntrinsicState()); + if (stateMask && document) { + MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify); + document->ContentStatesChanged(this, nsnull, stateMask); + } nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName, - nsIDOMMutationEvent::REMOVAL); + nsIDOMMutationEvent::REMOVAL, + stateMask); } if (hasMutationListeners) { diff --git a/mozilla/content/base/src/nsNodeUtils.cpp b/mozilla/content/base/src/nsNodeUtils.cpp index 01abf066c45..8d871005287 100755 --- a/mozilla/content/base/src/nsNodeUtils.cpp +++ b/mozilla/content/base/src/nsNodeUtils.cpp @@ -92,12 +92,13 @@ void nsNodeUtils::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { nsIDocument* doc = aContent->GetOwnerDoc(); IMPL_MUTATION_NOTIFICATION(AttributeChanged, aContent, (doc, aContent, aNameSpaceID, aAttribute, - aModType)); + aModType, aStateMask)); } void diff --git a/mozilla/content/base/src/nsNodeUtils.h b/mozilla/content/base/src/nsNodeUtils.h index c43a0f0e96e..7fdd8e35d0b 100755 --- a/mozilla/content/base/src/nsNodeUtils.h +++ b/mozilla/content/base/src/nsNodeUtils.h @@ -70,12 +70,14 @@ public: * @param aNameSpaceID Namespace of changed attribute * @param aAttribute Local-name of changed attribute * @param aModType Type of change (add/change/removal) + * @param aStateMask States which changed * @see nsIMutationObserver::AttributeChanged */ static void AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); + PRInt32 aModType, + PRUint32 aStateMask); /** * Send ContentAppended notifications to nsIMutationObservers diff --git a/mozilla/content/base/src/nsScriptElement.cpp b/mozilla/content/base/src/nsScriptElement.cpp index 20e0999e088..e69ebd2c94f 100755 --- a/mozilla/content/base/src/nsScriptElement.cpp +++ b/mozilla/content/base/src/nsScriptElement.cpp @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -134,7 +135,8 @@ nsScriptElement::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { MaybeProcessScript(); } diff --git a/mozilla/content/base/src/nsScriptElement.h b/mozilla/content/base/src/nsScriptElement.h index e03ad70998b..a78256dce00 100755 --- a/mozilla/content/base/src/nsScriptElement.h +++ b/mozilla/content/base/src/nsScriptElement.h @@ -54,21 +54,10 @@ public: NS_DECL_NSISCRIPTLOADEROBSERVER // nsIMutationObserver - virtual void CharacterDataChanged(nsIDocument* aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo); - virtual void AttributeChanged(nsIDocument* aDocument, - nsIContent* aContent, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED protected: // Internal methods diff --git a/mozilla/content/base/src/nsTextNode.cpp b/mozilla/content/base/src/nsTextNode.cpp index 53f97542d6c..4f30768a338 100644 --- a/mozilla/content/base/src/nsTextNode.cpp +++ b/mozilla/content/base/src/nsTextNode.cpp @@ -109,11 +109,7 @@ public: virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, PRBool aNullParent = PR_TRUE); - virtual void AttributeChanged(nsIDocument* aDocument, - nsIContent* aContent, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const @@ -336,7 +332,8 @@ nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName && aContent == GetNodeParent()) { diff --git a/mozilla/content/events/src/nsXMLEventsManager.cpp b/mozilla/content/events/src/nsXMLEventsManager.cpp index 54289332023..0924f30b2a3 100644 --- a/mozilla/content/events/src/nsXMLEventsManager.cpp +++ b/mozilla/content/events/src/nsXMLEventsManager.cpp @@ -356,7 +356,8 @@ nsXMLEventsManager::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { if (aNameSpaceID == kNameSpaceID_XMLEvents && (aAttribute == nsGkAtoms::event || diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 993edd6c60d..cc8c0d6eae2 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -2904,6 +2904,9 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, } if (mForm && aName == nsGkAtoms::type) { + nsIDocument* doc = GetCurrentDoc(); + MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, aNotify); + GetAttr(kNameSpaceID_None, nsGkAtoms::name, tmp); if (!tmp.IsEmpty()) { @@ -2917,6 +2920,14 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, } mForm->RemoveElement(this, aNotify); + + // Removing the element from the form can make it not be the default + // control anymore. Go ahead and notify on that change, though we might + // end up readding and becoming the default control again in + // AfterSetAttr. + if (doc && aNotify) { + doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DEFAULT); + } } } @@ -2958,23 +2969,14 @@ nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, mForm->AddElement(this, aNotify); + // Adding the element to the form can make it be the default control . + // Go ahead and notify on that change. // Note: no need to notify on CanBeDisabled(), since type attr // changes can't affect that. if (doc && aNotify) { doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DEFAULT); } } - - // And notify on content state changes, if any - - if (aNotify && aName == nsGkAtoms::disabled && CanBeDisabled()) { - nsIDocument* document = GetCurrentDoc(); - if (document) { - mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, PR_TRUE); - document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DISABLED | - NS_EVENT_STATE_ENABLED); - } - } } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 68b7a3b977e..96a30a27ad5 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -1353,7 +1353,7 @@ nsHTMLFormElement::ResetDefaultSubmitElement(PRBool aNotify, mDefaultSubmitElement = FindDefaultSubmit(aPrevDefaultInElements, aPrevDefaultIndex); - // Inform about change. Note that we dont' notify on the old default submit + // Inform about change. Note that we don't notify on the old default submit // (which is being removed) because it's either being removed from the DOM or // changing attributes in a way that makes it responsible for sending its own // notifications. diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 821205e9554..b443f3dc328 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -489,7 +489,10 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsCOMPtr oldCurrentRequest = mCurrentRequest; // Force image loading here, so that we'll try to load the image from - // network if it's set to be not cacheable... + // network if it's set to be not cacheable... If we change things so that + // the state gets in nsGenericElement's attr-setting happen around this + // LoadImage call, we could start passing PR_FALSE instead of aNotify + // here. LoadImage(aValue, PR_TRUE, aNotify); if (mCurrentRequest && !mPendingRequest && diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 974f518e918..0908c51dbff 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -525,28 +525,17 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // // Checked must be set no matter what type of control it is, since // GetChecked() must reflect the new value - if (aName == nsGkAtoms::checked) { - if (aNotify && - (mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_CHECKBOX)) { - // the checked attribute being changed, no matter the current checked - // state, influences the :default state, so notify about changes - nsIDocument* document = GetCurrentDoc(); - if (document) { - MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify); - document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DEFAULT); - } - } - if (!GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) { - // Delay setting checked if the parser is creating this element (wait - // until everything is set) - if (GET_BOOLBIT(mBitField, BF_PARSER_CREATING)) { - SET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED, PR_TRUE); - } else { - PRBool defaultChecked; - GetDefaultChecked(&defaultChecked); - DoSetChecked(defaultChecked); - SetCheckedChanged(PR_FALSE); - } + if (aName == nsGkAtoms::checked && + !GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) { + // Delay setting checked if the parser is creating this element (wait + // until everything is set) + if (GET_BOOLBIT(mBitField, BF_PARSER_CREATING)) { + SET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED, PR_TRUE); + } else { + PRBool defaultChecked; + GetDefaultChecked(&defaultChecked); + DoSetChecked(defaultChecked); + SetCheckedChanged(PR_FALSE); } } @@ -596,7 +585,9 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // on them all now, just in case. Note that we can't rely on the // notifications LoadImage or CancelImageRequests might have sent, // because those didn't include all the possibly-changed states in the - // mask. + // mask. We have to do this here because we just updated mType, so the + // code in nsGenericElement::SetAttrAndNotify didn't see the new + // states. document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED | NS_EVENT_STATE_DEFAULT | diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp index 2587b30700b..80fd636c5df 100644 --- a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp @@ -84,15 +84,6 @@ public: virtual PRInt32 IntrinsicState() const; - virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRBool aNotify) - { - nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, - aNotify); - - AfterSetAttr(aNameSpaceID, aAttribute, nsnull, aNotify); - return rv; - } virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: @@ -102,12 +93,6 @@ protected: * @param aSelectElement the select element [OUT] */ nsIContent* GetSelect(); - - /** - * Called when an attribute has just been changed - */ - virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, PRBool aNotify); }; @@ -184,24 +169,6 @@ nsHTMLOptGroupElement::GetSelect() return nsnull; } -nsresult -nsHTMLOptGroupElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, PRBool aNotify) -{ - if (aNotify && aNameSpaceID == kNameSpaceID_None && - aName == nsGkAtoms::disabled) { - nsIDocument* document = GetCurrentDoc(); - if (document) { - mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, PR_TRUE); - document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DISABLED | - NS_EVENT_STATE_ENABLED); - } - } - - return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aNotify); -} - nsresult nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 2e05efb3366..d4e50db3b27 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -113,15 +113,6 @@ public: // nsIContent virtual PRInt32 IntrinsicState() const; - virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRBool aNotify) - { - nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, - aNotify); - - AfterSetAttr(aNameSpaceID, aAttribute, nsnull, aNotify); - return rv; - } virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; protected: @@ -133,11 +124,6 @@ protected: */ nsIContent* GetSelect(); - /** - * Called when an attribute has just been changed - */ - virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, PRBool aNotify); PRPackedBool mIsInitialized; PRPackedBool mIsSelected; }; @@ -419,30 +405,6 @@ nsHTMLOptionElement::GetSelect() return nsnull; } -nsresult -nsHTMLOptionElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, PRBool aNotify) -{ - if (aNotify && aNameSpaceID == kNameSpaceID_None && - (aName == nsGkAtoms::disabled || aName == nsGkAtoms::selected)) { - PRInt32 states; - if (aName == nsGkAtoms::disabled) { - states = NS_EVENT_STATE_DISABLED | NS_EVENT_STATE_ENABLED; - } else { - states = NS_EVENT_STATE_DEFAULT; - } - - nsIDocument* document = GetCurrentDoc(); - if (document) { - mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, PR_TRUE); - document->ContentStatesChanged(this, nsnull, states); - } - } - - return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aNotify); -} - NS_IMETHODIMP nsHTMLOptionElement::Initialize(JSContext* aContext, JSObject *aObj, diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index ab7ea266e4f..0d0f765be53 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1388,7 +1388,8 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, void nsHTMLDocument::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, - nsIAtom* aAttribute, PRInt32 aModType) + nsIAtom* aAttribute, PRInt32 aModType, + PRUint32 aStateMask) { NS_ASSERTION(aDocument == this, "unexpected doc"); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index d4ead1465de..cd0b1c5d443 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -130,22 +130,11 @@ public: virtual PRBool IsCaseSensitive(); // nsIMutationObserver - virtual void ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void AttributeChanged(nsIDocument* aDocument, - nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + // nsIDOMDocument interface NS_DECL_NSIDOMDOCUMENT diff --git a/mozilla/content/svg/content/src/nsSVGPatternElement.cpp b/mozilla/content/svg/content/src/nsSVGPatternElement.cpp index c9b9ceea6c5..985dee12c00 100644 --- a/mozilla/content/svg/content/src/nsSVGPatternElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGPatternElement.cpp @@ -332,7 +332,8 @@ nsSVGPatternElement::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { PushUpdate(); } diff --git a/mozilla/content/svg/content/src/nsSVGUseElement.cpp b/mozilla/content/svg/content/src/nsSVGUseElement.cpp index d28d2134cf0..08c496a7bfc 100644 --- a/mozilla/content/svg/content/src/nsSVGUseElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGUseElement.cpp @@ -213,7 +213,8 @@ nsSVGUseElement::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { TriggerReclone(); diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index db4a48f8b77..64140390d5c 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -1188,11 +1188,12 @@ nsBindingManager::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { NS_BINDINGMANAGER_NOTIFY_OBSERVERS(AttributeChanged, (aDocument, aContent, aNameSpaceID, - aAttribute, aModType)); + aAttribute, aModType, aStateMask)); } void diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp index 6051519bc42..f8247763cc0 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -238,7 +238,8 @@ nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { MaybeUnhook(aContent); } diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h index be399516c2a..303d649b176 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h @@ -54,18 +54,13 @@ public: // nsIDocumentObserver virtual void BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType); virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType); - virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void NodeWillBeDestroyed(const nsINode* aNode); + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED /** * This will prettyprint the document if the document is loaded in a diff --git a/mozilla/content/xslt/src/xpath/nsXPathResult.cpp b/mozilla/content/xslt/src/xpath/nsXPathResult.cpp index 5444db5a0c9..196a1619a0d 100644 --- a/mozilla/content/xslt/src/xpath/nsXPathResult.cpp +++ b/mozilla/content/xslt/src/xpath/nsXPathResult.cpp @@ -220,7 +220,8 @@ nsXPathResult::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { Invalidate(); } diff --git a/mozilla/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp b/mozilla/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp index 9bdd49f638d..9e49b13a313 100644 --- a/mozilla/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp +++ b/mozilla/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp @@ -1212,7 +1212,8 @@ txMozillaXSLTProcessor::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { mStylesheet = nsnull; } diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index a664d4a05f5..770477b2532 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1232,8 +1232,16 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) nsIDocument* doc = GetCurrentDoc(); mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify); - if (aNotify && doc) { - doc->AttributeWillChange(this, aNameSpaceID, aName); + + // When notifying, make sure to keep track of states whose value + // depends solely on the value of an attribute. + PRUint32 stateMask; + if (aNotify) { + stateMask = PRUint32(IntrinsicState()); + + if (doc) { + doc->AttributeWillChange(this, aNameSpaceID, aName); + } } PRBool hasMutationListeners = aNotify && @@ -1305,8 +1313,14 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) } if (aNotify) { + stateMask = stateMask ^ PRUint32(IntrinsicState()); + if (stateMask && doc) { + MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, aNotify); + doc->ContentStatesChanged(this, nsnull, stateMask); + } nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName, - nsIDOMMutationEvent::REMOVAL); + nsIDOMMutationEvent::REMOVAL, + stateMask); } if (hasMutationListeners) { diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 6769876de28..88de793d1e4 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -920,7 +920,8 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, void nsXULDocument::AttributeChanged(nsIDocument* aDocument, nsIContent* aElement, PRInt32 aNameSpaceID, - nsIAtom* aAttribute, PRInt32 aModType) + nsIAtom* aAttribute, PRInt32 aModType, + PRUint32 aStateMask) { NS_ASSERTION(aDocument == this, "unexpected doc"); diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 61fe1f0baca..f9e8d7f664f 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -116,20 +116,10 @@ public: virtual void EndLoad(); // nsIMutationObserver interface - virtual void ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aElement, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED // nsIXULDocument interface NS_IMETHOD AddElementForID(const nsAString& aID, nsIContent* aElement); diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index e9c69e60360..56ed80aeee9 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -137,14 +137,9 @@ public: NS_IMETHOD GetResultForContent(nsIDOMElement* aContent, nsIXULTemplateResult** aResult); - // nsIDocumentObserver interface - virtual void AttributeChanged(nsIDocument* aDocument, - nsIContent* aContent, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); - - void NodeWillBeDestroyed(const nsINode* aNode); + // nsIMutationObserver interface + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED protected: friend NS_IMETHODIMP @@ -1771,7 +1766,8 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { // Handle "open" and "close" cases. We do this handling before // we've notified the observer, so that content is already created @@ -1795,7 +1791,7 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument, // Pass along to the generic template builder. nsXULTemplateBuilder::AttributeChanged(aDocument, aContent, aNameSpaceID, - aAttribute, aModType); + aAttribute, aModType, aStateMask); } void diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 4109bdb9314..f90c1c52cfa 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1037,7 +1037,8 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { if (aContent == mRoot && aNameSpaceID == kNameSpaceID_None) { // Check for a change to the 'ref' attribute on an atom, in which diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h index fcd63353daf..1e24c2e7f90 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.h @@ -103,15 +103,10 @@ public: NS_DECL_NSIDOMEVENTLISTENER - // nsIDocumentObserver - virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void NodeWillBeDestroyed(const nsINode* aNode); + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED /** * Remove an old result and/or add a new result. This method will retrieve diff --git a/mozilla/docshell/shistory/src/nsSHEntry.cpp b/mozilla/docshell/shistory/src/nsSHEntry.cpp index 311bb98eca1..23809399e45 100644 --- a/mozilla/docshell/shistory/src/nsSHEntry.cpp +++ b/mozilla/docshell/shistory/src/nsSHEntry.cpp @@ -661,7 +661,8 @@ nsSHEntry::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { DocumentMutated(); } diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 2e63a266011..27d353a1aab 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10055,7 +10055,8 @@ nsresult nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { nsresult result = NS_OK; @@ -10135,7 +10136,8 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, nsFrameManager *frameManager = shell->FrameManager(); nsReStyleHint rshint = frameManager->HasAttributeDependentStyle(aContent, aAttribute, - aModType); + aModType, + aStateMask); PostRestyleEvent(aContent, rshint, hint); diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index e479992c900..c29d97f204c 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -143,7 +143,8 @@ public: nsresult AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); + PRInt32 aModType, + PRUint32 aStateMask); void BeginUpdate() { ++mUpdateCount; } void EndUpdate(); diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 6360130b4e0..c1e0a2e870a 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -1446,12 +1446,14 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame, nsReStyleHint nsFrameManager::HasAttributeDependentStyle(nsIContent *aContent, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { nsReStyleHint hint = mStyleSet->HasAttributeDependentStyle(GetPresContext(), aContent, aAttribute, - aModType); + aModType, + aStateMask); if (aAttribute == nsGkAtoms::style) { // Perhaps should check that it's XUL, SVG, (or HTML) namespace, but diff --git a/mozilla/layout/base/nsFrameManager.h b/mozilla/layout/base/nsFrameManager.h index 113b6160fac..31cd2cc2688 100644 --- a/mozilla/layout/base/nsFrameManager.h +++ b/mozilla/layout/base/nsFrameManager.h @@ -192,7 +192,8 @@ public: // Determine whether an attribute affects style NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent, nsIAtom *aAttribute, - PRInt32 aModType); + PRInt32 aModType, + PRUint32 aStateMask); /* * Capture/restore frame state for the frame subtree rooted at aFrame. diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index b280dc268d8..34c489b5c40 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -941,22 +941,10 @@ public: virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType); virtual void BeginLoad(nsIDocument* aDocument); virtual void EndLoad(nsIDocument* aDocument); - virtual void CharacterDataChanged(nsIDocument* aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo); virtual void ContentStatesChanged(nsIDocument* aDocument, nsIContent* aContent1, nsIContent* aContent2, PRInt32 aStateMask); - virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument* aDocument, nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); virtual void StyleSheetAdded(nsIDocument* aDocument, nsIStyleSheet* aStyleSheet, PRBool aDocumentSheet); @@ -977,6 +965,13 @@ public: nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule); + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIOBSERVER #ifdef MOZ_REFLOW_PERF @@ -4381,10 +4376,12 @@ PresShell::ContentStatesChanged(nsIDocument* aDocument, NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStatesChanged"); NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); - WillCauseReflow(); - mFrameConstructor->ContentStatesChanged(aContent1, aContent2, aStateMask); - VERIFY_STYLE_TREE; - DidCauseReflow(); + if (mDidInitialReflow) { + WillCauseReflow(); + mFrameConstructor->ContentStatesChanged(aContent1, aContent2, aStateMask); + VERIFY_STYLE_TREE; + DidCauseReflow(); + } } @@ -4393,7 +4390,8 @@ PresShell::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged"); NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); @@ -4404,7 +4402,7 @@ PresShell::AttributeChanged(nsIDocument* aDocument, if (mDidInitialReflow) { WillCauseReflow(); mFrameConstructor->AttributeChanged(aContent, aNameSpaceID, - aAttribute, aModType); + aAttribute, aModType, aStateMask); VERIFY_STYLE_TREE; DidCauseReflow(); } diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index bf94e96b154..140b1562cb2 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -287,7 +287,7 @@ nsHTMLFramesetFrame::FrameResizePrefCallback(const char* aPref, void* aClosure) nsNodeUtils::AttributeChanged(frame->GetContent(), kNameSpaceID_None, nsGkAtoms::frameborder, - nsIDOMMutationEvent::MODIFICATION); + nsIDOMMutationEvent::MODIFICATION, 0); } return 0; diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index 537b00bf007..c220b0d4d8a 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -927,7 +927,8 @@ nsImageMap::AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { // If the parent of the changing content node is our map then update // the map. But only do this if the node is an HTML or diff --git a/mozilla/layout/generic/nsImageMap.h b/mozilla/layout/generic/nsImageMap.h index 3cb4e4108b2..d353fee57b3 100644 --- a/mozilla/layout/generic/nsImageMap.h +++ b/mozilla/layout/generic/nsImageMap.h @@ -85,15 +85,10 @@ public: NS_DECL_ISUPPORTS // nsIMutationObserver - virtual void AttributeChanged(nsIDocument* aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument* aDocument, nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED //nsIDOMFocusListener NS_IMETHOD Focus(nsIDOMEvent* aEvent); diff --git a/mozilla/layout/inspector/src/inDOMView.cpp b/mozilla/layout/inspector/src/inDOMView.cpp index adcff2a92f0..e1e0e732499 100644 --- a/mozilla/layout/inspector/src/inDOMView.cpp +++ b/mozilla/layout/inspector/src/inDOMView.cpp @@ -702,7 +702,7 @@ inDOMView::NodeWillBeDestroyed(const nsINode* aNode) void inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, PRUint32 aStateMask) { if (!mTree) { return; diff --git a/mozilla/layout/style/nsCSSRuleProcessor.cpp b/mozilla/layout/style/nsCSSRuleProcessor.cpp index 5a82ff2379f..fe360c931f7 100644 --- a/mozilla/layout/style/nsCSSRuleProcessor.cpp +++ b/mozilla/layout/style/nsCSSRuleProcessor.cpp @@ -1751,7 +1751,7 @@ PR_STATIC_CALLBACK(PRBool) AttributeEnumFunc(void* aSelector, void* aData) // bother calling SelectorMatches, since even if it returns false // enumData->change won't change. if ((possibleChange & ~(enumData->change)) && - SelectorMatches(*data, selector, 0, data->mAttribute) && + SelectorMatches(*data, selector, data->mStateMask, data->mAttribute) && SelectorMatchesTree(*data, selector->mNext)) { enumData->change = nsReStyleHint(enumData->change | possibleChange); } diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 13d4f29b164..7a3ca644814 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -533,6 +533,10 @@ NS_IMETHODIMP nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData, nsReStyleHint* aResult) { + // Note: no need to worry about whether some states changed with this + // attribute here, because we handle that under HasStateDependentStyle() as + // needed. + // Result is true for |href| changes on HTML links if we have link rules. nsIContent *content = aData->mContent; if (aData->mAttribute == nsGkAtoms::href && diff --git a/mozilla/layout/style/nsIStyleRuleProcessor.h b/mozilla/layout/style/nsIStyleRuleProcessor.h index 8c33d851efb..e0224d6f40c 100644 --- a/mozilla/layout/style/nsIStyleRuleProcessor.h +++ b/mozilla/layout/style/nsIStyleRuleProcessor.h @@ -152,17 +152,20 @@ struct StateRuleProcessorData : public RuleProcessorData { struct AttributeRuleProcessorData : public RuleProcessorData { AttributeRuleProcessorData(nsPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute, - PRInt32 aModType) + nsIContent* aContent, + nsIAtom* aAttribute, + PRInt32 aModType, + PRUint32 aStateMask) : RuleProcessorData(aPresContext, aContent, nsnull), mAttribute(aAttribute), - mModType(aModType) + mModType(aModType), + mStateMask(aStateMask) { NS_PRECONDITION(aContent, "null pointer"); } nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute? PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent). + PRUint32 mStateMask; // The states that changed with the attr change. }; diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index 7f4c1c4a2b7..a4c1da41837 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -894,8 +894,10 @@ nsStyleSet::HasStateDependentStyle(nsPresContext* aPresContext, struct AttributeData : public AttributeRuleProcessorData { AttributeData(nsPresContext* aPresContext, - nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) - : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType), + nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType, + PRUint32 aStateMask) + : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType, + aStateMask), mHint(nsReStyleHint(0)) {} nsReStyleHint mHint; @@ -914,9 +916,10 @@ SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData) // Test if style is dependent on content state nsReStyleHint nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute, - PRInt32 aModType) + nsIContent* aContent, + nsIAtom* aAttribute, + PRInt32 aModType, + PRUint32 aStateMask) { nsReStyleHint result = nsReStyleHint(0); @@ -928,7 +931,8 @@ nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext, mRuleProcessors[eDocSheet] || mRuleProcessors[eStyleAttrSheet] || mRuleProcessors[eOverrideSheet])) { - AttributeData data(aPresContext, aContent, aAttribute, aModType); + AttributeData data(aPresContext, aContent, aAttribute, aModType, + aStateMask); WalkRuleProcessors(SheetHasAttributeStyle, &data); result = data.mHint; } diff --git a/mozilla/layout/style/nsStyleSet.h b/mozilla/layout/style/nsStyleSet.h index 6afdf50cb98..4cd8748eed3 100644 --- a/mozilla/layout/style/nsStyleSet.h +++ b/mozilla/layout/style/nsStyleSet.h @@ -136,9 +136,10 @@ class nsStyleSet // Test if style is dependent on the presence of an attribute. nsReStyleHint HasAttributeDependentStyle(nsPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute, - PRInt32 aModType); + nsIContent* aContent, + nsIAtom* aAttribute, + PRInt32 aModType, + PRUint32 aStateMask); // APIs for registering objects that can supply additional // rules during processing. diff --git a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 478637b5f6a..654508a47dd 100644 --- a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -83,7 +83,8 @@ nsSVGMutationObserver::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { if (aNameSpaceID != kNameSpaceID_XML || aAttribute != nsGkAtoms::space) { return; diff --git a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp index dcb101bea11..9cd2949131b 100644 --- a/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPathGeometryFrame.cpp @@ -170,7 +170,8 @@ nsSVGMarkerProperty::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { DoUpdate(); } diff --git a/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp b/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp index 1e16720acf3..0a40329a6a9 100644 --- a/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGTextPathFrame.cpp @@ -68,7 +68,8 @@ nsSVGPathListener::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { mTextPathFrame->UpdateGraphic(); } diff --git a/mozilla/layout/svg/base/src/nsSVGUtils.cpp b/mozilla/layout/svg/base/src/nsSVGUtils.cpp index 1d68e44e960..f4fdd8b2157 100644 --- a/mozilla/layout/svg/base/src/nsSVGUtils.cpp +++ b/mozilla/layout/svg/base/src/nsSVGUtils.cpp @@ -131,7 +131,8 @@ nsSVGPropertyBase::AttributeChanged(nsIDocument *aDocument, nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { DoUpdate(); } diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp index f90675c4ec4..f5b182cc826 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -802,7 +802,8 @@ nsTreeContentView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType) + PRInt32 aModType, + PRUint32 aStateMask) { // Make sure this notification concerns us. // First check the tag to see if it's one that we care about. diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h index 708d79baa2a..e8fdf7f3488 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h @@ -72,19 +72,11 @@ class nsTreeContentView : public nsINativeTreeView, nsIContent* aContent1, nsIContent* aContent2, PRInt32 aStateMask); - virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRInt32 aModType); - virtual void ContentAppended(nsIDocument *aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - virtual void ContentInserted(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, - nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void NodeWillBeDestroyed(const nsINode* aNode); + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED protected: // Recursive methods which deal with serializing of nested content. diff --git a/mozilla/widget/src/cocoa/nsMenuBarX.mm b/mozilla/widget/src/cocoa/nsMenuBarX.mm index 443bb099b30..110ae8b40d4 100644 --- a/mozilla/widget/src/cocoa/nsMenuBarX.mm +++ b/mozilla/widget/src/cocoa/nsMenuBarX.mm @@ -909,7 +909,7 @@ nsMenuBarX::NodeWillBeDestroyed(const nsINode * aNode) void nsMenuBarX::AttributeChanged(nsIDocument * aDocument, nsIContent * aContent, PRInt32 aNameSpaceID, nsIAtom * aAttribute, - PRInt32 aModType) + PRInt32 aModType, PRUint32 aStateMask) { // lookup and dispatch to registered thang nsCOMPtr obs;