Bug 562700 part 2. Change the restyle-event functions to take Element. r=dbaron

This commit is contained in:
Boris Zbarsky 2010-05-14 13:04:51 -04:00
parent f691032df2
commit 1b6aa7ce33
5 changed files with 25 additions and 21 deletions

View File

@ -9078,6 +9078,8 @@ nsresult
nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
PRBool aAsyncInsert)
{
NS_PRECONDITION(!aAsyncInsert || aContent->IsElement(),
"Can only insert elements async");
// If there is no document, we don't want to recreate frames for it. (You
// shouldn't generally be giving this method content without a document
// anyway).
@ -9144,7 +9146,8 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
// ContentRemoved triggered reconstruction, then we don't need to do this
// because the frames will already have been built.
if (aAsyncInsert) {
PostRestyleEvent(aContent, nsRestyleHint(0), nsChangeHint_ReconstructFrame);
PostRestyleEvent(aContent->AsElement(), nsRestyleHint(0),
nsChangeHint_ReconstructFrame);
} else {
rv = ContentInserted(container, aContent, indexInContainer,
mTempFrameTreeState, PR_FALSE);
@ -11750,7 +11753,7 @@ nsCSSFrameConstructor::ProcessPendingRestyles()
}
void
nsCSSFrameConstructor::PostRestyleEventCommon(nsIContent* aContent,
nsCSSFrameConstructor::PostRestyleEventCommon(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint,
PRBool aForAnimation)
@ -11764,10 +11767,6 @@ nsCSSFrameConstructor::PostRestyleEventCommon(nsIContent* aContent,
return;
}
// XXXbz this should take Element, not nsIContent
NS_ASSERTION(aContent->IsElement(),
"Shouldn't be trying to restyle non-elements directly");
RestyleData existingData;
existingData.mRestyleHint = nsRestyleHint(0);
existingData.mChangeHint = NS_STYLE_HINT_NONE;
@ -11775,12 +11774,12 @@ nsCSSFrameConstructor::PostRestyleEventCommon(nsIContent* aContent,
nsDataHashtable<nsISupportsHashKey, RestyleData> &restyles =
aForAnimation ? mPendingAnimationRestyles : mPendingRestyles;
restyles.Get(aContent, &existingData);
restyles.Get(aElement, &existingData);
existingData.mRestyleHint =
nsRestyleHint(existingData.mRestyleHint | aRestyleHint);
NS_UpdateHint(existingData.mChangeHint, aMinChangeHint);
restyles.Put(aContent, existingData);
restyles.Put(aElement, existingData);
PostRestyleEventInternal(PR_FALSE);
}

View File

@ -345,31 +345,32 @@ public:
void RebuildAllStyleData(nsChangeHint aExtraHint);
// See PostRestyleEventCommon below.
void PostRestyleEvent(nsIContent* aContent, nsRestyleHint aRestyleHint,
void PostRestyleEvent(mozilla::dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
nsPresContext *presContext = mPresShell->GetPresContext();
if (presContext) {
PostRestyleEventCommon(aContent, aRestyleHint, aMinChangeHint,
PostRestyleEventCommon(aElement, aRestyleHint, aMinChangeHint,
presContext->IsProcessingAnimationStyleChange());
}
}
// See PostRestyleEventCommon below.
void PostAnimationRestyleEvent(nsIContent* aContent,
void PostAnimationRestyleEvent(mozilla::dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
PostRestyleEventCommon(aContent, aRestyleHint, aMinChangeHint, PR_TRUE);
PostRestyleEventCommon(aElement, aRestyleHint, aMinChangeHint, PR_TRUE);
}
// nsARefreshObserver
virtual void WillRefresh(mozilla::TimeStamp aTime);
private:
/**
* Notify the frame constructor that a content node needs to have its
* Notify the frame constructor that an element needs to have its
* style recomputed.
* @param aContent: The content node to be restyled.
* @param aElement: The element to be restyled.
* @param aRestyleHint: Which nodes need to have selector matching run
* on them.
* @param aMinChangeHint: A minimum change hint for aContent and its
@ -381,7 +382,8 @@ private:
* IsProcessingAnimationStyleChange() value
* (which is the default value).
*/
void PostRestyleEventCommon(nsIContent* aContent, nsRestyleHint aRestyleHint,
void PostRestyleEventCommon(mozilla::dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint,
PRBool aForAnimation);
void PostRestyleEventInternal(PRBool aForLazyConstruction);

View File

@ -276,7 +276,7 @@ nsMathMLTokenFrame::ProcessTextData()
// explicitly request a re-resolve to pick up the change of style
PresContext()->PresShell()->FrameConstructor()->
PostRestyleEvent(mContent, eRestyle_Self, NS_STYLE_HINT_NONE);
PostRestyleEvent(mContent->AsElement(), eRestyle_Self, NS_STYLE_HINT_NONE);
}
///////////////////////////////////////////////////////////////////////////

View File

@ -525,7 +525,8 @@ nsMathMLmtableOuterFrame::AttributeChanged(PRInt32 aNameSpaceID,
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
presContext->PresShell()->FrameConstructor()->
PostRestyleEvent(mContent, eRestyle_Self, nsChangeHint_ReflowFrame);
PostRestyleEvent(mContent->AsElement(), eRestyle_Self,
nsChangeHint_ReflowFrame);
return NS_OK;
}
@ -704,7 +705,8 @@ nsMathMLmtableFrame::RestyleTable()
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
PresContext()->PresShell()->FrameConstructor()->
PostRestyleEvent(mContent, eRestyle_Self, nsChangeHint_ReflowFrame);
PostRestyleEvent(mContent->AsElement(), eRestyle_Self,
nsChangeHint_ReflowFrame);
}
// --------
@ -764,7 +766,8 @@ nsMathMLmtrFrame::AttributeChanged(PRInt32 aNameSpaceID,
// Explicitly request a re-resolve and reflow in our subtree to pick up any changes
presContext->PresShell()->FrameConstructor()->
PostRestyleEvent(mContent, eRestyle_Self, nsChangeHint_ReflowFrame);
PostRestyleEvent(mContent->AsElement(), eRestyle_Self,
nsChangeHint_ReflowFrame);
return NS_OK;
}

View File

@ -255,7 +255,7 @@ nsSVGFilterProperty::DoUpdate()
NS_UpdateHint(changeHint, nsChangeHint_ReflowFrame);
}
mFramePresShell->FrameConstructor()->PostRestyleEvent(
mFrame->GetContent(), nsRestyleHint(0), changeHint);
mFrame->GetContent()->AsElement(), nsRestyleHint(0), changeHint);
}
void
@ -272,7 +272,7 @@ nsSVGMarkerProperty::DoUpdate()
nsChangeHint(nsChangeHint_RepaintFrame | nsChangeHint_UpdateEffects);
mFramePresShell->FrameConstructor()->PostRestyleEvent(
mFrame->GetContent(), nsRestyleHint(0), changeHint);
mFrame->GetContent()->AsElement(), nsRestyleHint(0), changeHint);
}
void