Bug 562698 - Part c: Pass Elements to AttributeWillChange; r=bzbarsky, a=dbaron

This commit is contained in:
Ms2ger 2010-08-24 09:06:20 +02:00
parent 00001ff39e
commit 0cf7a5d525
13 changed files with 32 additions and 30 deletions

View File

@ -898,7 +898,8 @@ NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsDocAccessible)
void
nsDocAccessible::AttributeWillChange(nsIDocument *aDocument,
nsIContent* aContent, PRInt32 aNameSpaceID,
dom::Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute, PRInt32 aModType)
{
// XXX TODO: bugs 381599 467143 472142 472143

View File

@ -180,7 +180,7 @@ public:
* the stack.
*/
virtual void AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent,
mozilla::dom::Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType) = 0;
@ -334,7 +334,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver, NS_IMUTATION_OBSERVER_IID)
#define NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE \
virtual void AttributeWillChange(nsIDocument* aDocument, \
nsIContent* aContent, \
mozilla::dom::Element* aElement, \
PRInt32 aNameSpaceID, \
nsIAtom* aAttribute, \
PRInt32 aModType);
@ -403,7 +403,7 @@ _class::CharacterDataChanged(nsIDocument* aDocument, \
} \
void \
_class::AttributeWillChange(nsIDocument* aDocument, \
nsIContent* aContent, \
mozilla::dom::Element* aElement, \
PRInt32 aNameSpaceID, \
nsIAtom* aAttribute, \
PRInt32 aModType) \

View File

@ -105,14 +105,14 @@ nsNodeUtils::CharacterDataChanged(nsIContent* aContent,
}
void
nsNodeUtils::AttributeWillChange(nsIContent* aContent,
nsNodeUtils::AttributeWillChange(Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsIDocument* doc = aContent->GetOwnerDoc();
IMPL_MUTATION_NOTIFICATION(AttributeWillChange, aContent,
(doc, aContent, aNameSpaceID, aAttribute,
nsIDocument* doc = aElement->GetOwnerDoc();
IMPL_MUTATION_NOTIFICATION(AttributeWillChange, aElement,
(doc, aElement, aNameSpaceID, aAttribute,
aModType));
}

View File

@ -72,13 +72,13 @@ public:
/**
* Send AttributeWillChange notifications to nsIMutationObservers.
* @param aContent Node whose data will change
* @param aElement Element whose data will change
* @param aNameSpaceID Namespace of changing attribute
* @param aAttribute Local-name of changing attribute
* @param aModType Type of change (add/change/removal)
* @see nsIMutationObserver::AttributeWillChange
*/
static void AttributeWillChange(nsIContent* aContent,
static void AttributeWillChange(mozilla::dom::Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);

View File

@ -976,19 +976,19 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
void
nsXULDocument::AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent, PRInt32 aNameSpaceID,
Element* aElement, PRInt32 aNameSpaceID,
nsIAtom* aAttribute, PRInt32 aModType)
{
NS_ABORT_IF_FALSE(aContent, "Null content!");
NS_ABORT_IF_FALSE(aElement, "Null content!");
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
// XXXbz check aNameSpaceID, dammit!
// See if we need to update our ref map.
if (aAttribute == nsGkAtoms::ref ||
(aAttribute == nsGkAtoms::id && !aContent->GetIDAttributeName())) {
(aAttribute == nsGkAtoms::id && !aElement->GetIDAttributeName())) {
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
RemoveElementFromRefMap(aContent->AsElement());
RemoveElementFromRefMap(aElement);
}
}

View File

@ -815,7 +815,7 @@ nsSHEntry::CharacterDataChanged(nsIDocument* aDocument,
void
nsSHEntry::AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent,
dom::Element* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)

View File

@ -8119,12 +8119,11 @@ nsCSSFrameConstructor::DoContentStateChanged(Element* aElement,
}
void
nsCSSFrameConstructor::AttributeWillChange(nsIContent* aContent,
nsCSSFrameConstructor::AttributeWillChange(Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
Element* aElement = aContent->AsElement();
nsRestyleHint rshint =
mPresShell->StyleSet()->HasAttributeDependentStyle(mPresShell->GetPresContext(),
aElement,

View File

@ -259,10 +259,10 @@ public:
// WillDestroyFrameTree hasn't been called yet.
void NotifyDestroyingFrame(nsIFrame* aFrame);
void AttributeWillChange(nsIContent* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
void AttributeWillChange(Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
void AttributeChanged(Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,

View File

@ -4928,12 +4928,12 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument,
void
PresShell::AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent,
Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged");
NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeWillChange");
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
// XXXwaterson it might be more elegant to wait until after the
@ -4941,7 +4941,7 @@ PresShell::AttributeWillChange(nsIDocument* aDocument,
// squelch any other inappropriate notifications as well.
if (mDidInitialReflow) {
nsAutoCauseReflowNotifier crNotifier(this);
mFrameConstructor->AttributeWillChange(aContent, aNameSpaceID,
mFrameConstructor->AttributeWillChange(aElement, aNameSpaceID,
aAttribute, aModType);
VERIFY_STYLE_TREE;
}

View File

@ -258,7 +258,8 @@ nsHTMLFramesetFrame::FrameResizePrefCallback(const char* aPref, void* aClosure)
nsIDocument* doc = frame->mContent->GetDocument();
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
if (doc) {
nsNodeUtils::AttributeWillChange(frame->mContent, kNameSpaceID_None,
nsNodeUtils::AttributeWillChange(frame->GetContent()->AsElement(),
kNameSpaceID_None,
nsGkAtoms::frameborder,
nsIDOMMutationEvent::MODIFICATION);
}

View File

@ -119,7 +119,7 @@ nsDOMCSSAttributeDeclaration::DocToUpdate()
if (!mIsSMILOverride)
#endif
{
nsNodeUtils::AttributeWillChange(mContent, kNameSpaceID_None,
nsNodeUtils::AttributeWillChange(mContent->AsElement(), kNameSpaceID_None,
nsGkAtoms::style,
nsIDOMMutationEvent::MODIFICATION);
}

View File

@ -37,8 +37,8 @@
/* DOM object for element.style */
#ifndef nsDOMCSSAttributeDeclaration_h___
#define nsDOMCSSAttributeDeclaration_h___
#ifndef nsDOMCSSAttributeDeclaration_h
#define nsDOMCSSAttributeDeclaration_h
#include "nsDOMCSSDeclaration.h"
@ -85,6 +85,7 @@ protected:
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl);
virtual nsIDocument* DocToUpdate();
// XXX bug 585014 use nsRefPtr<Element> and fix mContent->AsElement()
nsCOMPtr<nsIContent> mContent;
#ifdef MOZ_SMIL
@ -96,4 +97,4 @@ protected:
#endif // MOZ_SMIL
};
#endif /* nsDOMCSSAttributeDeclaration_h___ */
#endif /* nsDOMCSSAttributeDeclaration_h */

View File

@ -139,7 +139,7 @@ void nsMenuGroupOwnerX::NodeWillBeDestroyed(const nsINode * aNode)
void nsMenuGroupOwnerX::AttributeWillChange(nsIDocument* aDocument,
nsIContent* aContent,
dom::Element* aContent,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)