diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
index 264ae79a4dd..fdbad650752 100644
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -8065,22 +8065,22 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
}
void
-nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
+nsCSSFrameConstructor::RestyleElement(Element *aElement,
nsIFrame *aPrimaryFrame,
nsChangeHint aMinHint)
{
- NS_ASSERTION(aPrimaryFrame == aContent->GetPrimaryFrame(),
+ NS_ASSERTION(aPrimaryFrame == aElement->GetPrimaryFrame(),
"frame/content mismatch");
- if (aPrimaryFrame && aPrimaryFrame->GetContent() != aContent) {
+ if (aPrimaryFrame && aPrimaryFrame->GetContent() != aElement) {
// XXXbz this is due to image maps messing with the primary frame pointer
// of s. See bug 135040. We can remove this block once that's fixed.
aPrimaryFrame = nsnull;
}
- NS_ASSERTION(!aPrimaryFrame || aPrimaryFrame->GetContent() == aContent,
+ NS_ASSERTION(!aPrimaryFrame || aPrimaryFrame->GetContent() == aElement,
"frame/content mismatch");
if (aMinHint & nsChangeHint_ReconstructFrame) {
- RecreateFramesForContent(aContent, PR_FALSE);
+ RecreateFramesForContent(aElement, PR_FALSE);
} else if (aPrimaryFrame) {
nsStyleChangeList changeList;
mPresShell->FrameManager()->
@@ -8088,26 +8088,21 @@ nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
ProcessRestyledFrames(changeList);
} else {
// no frames, reconstruct for content
- MaybeRecreateFramesForContent(aContent);
+ MaybeRecreateFramesForElement(aElement);
}
}
void
-nsCSSFrameConstructor::RestyleLaterSiblings(nsIContent *aContent)
+nsCSSFrameConstructor::RestyleLaterSiblings(Element *aElement)
{
- nsIContent *parent = aContent->GetParent();
- if (!parent)
- return; // root element has no later siblings
-
- for (PRInt32 index = parent->IndexOf(aContent) + 1,
- index_end = parent->GetChildCount();
- index != index_end; ++index) {
- nsIContent *child = parent->GetChildAt(index);
- if (!child->IsElement())
+ for (nsIContent* sibling = aElement->GetNextSibling();
+ sibling;
+ sibling = sibling->GetNextSibling()) {
+ if (!sibling->IsElement())
continue;
- nsIFrame* primaryFrame = child->GetPrimaryFrame();
- RestyleElement(child, primaryFrame, NS_STYLE_HINT_NONE);
+ RestyleElement(sibling->AsElement(), sibling->GetPrimaryFrame(),
+ NS_STYLE_HINT_NONE);
}
}
@@ -8898,21 +8893,20 @@ nsCSSFrameConstructor::CaptureStateFor(nsIFrame* aFrame,
}
nsresult
-nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIContent* aContent)
+nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement)
{
nsresult result = NS_OK;
nsFrameManager *frameManager = mPresShell->FrameManager();
- nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent);
+ nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aElement);
if (oldContext) {
// The parent has a frame, so try resolving a new context.
- // XXXbz this should take Element, not nsIContent
nsRefPtr newContext = mPresShell->StyleSet()->
- ResolveStyleFor(aContent->AsElement(), oldContext->GetParent());
+ ResolveStyleFor(aElement, oldContext->GetParent());
- frameManager->ChangeUndisplayedContent(aContent, newContext);
+ frameManager->ChangeUndisplayedContent(aElement, newContext);
if (newContext->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_NONE) {
- result = RecreateFramesForContent(aContent, PR_FALSE);
+ result = RecreateFramesForContent(aElement, PR_FALSE);
}
}
return result;
@@ -11547,7 +11541,7 @@ nsCSSFrameConstructor::RestyleForRemove(Element* aContainer,
static PLDHashOperator
-CollectRestyles(nsISupports* aContent,
+CollectRestyles(nsISupports* aElement,
nsCSSFrameConstructor::RestyleData& aData,
void* aRestyleArrayPtr)
{
@@ -11556,7 +11550,7 @@ CollectRestyles(nsISupports* aContent,
(aRestyleArrayPtr);
nsCSSFrameConstructor::RestyleEnumerateData* currentRestyle =
*restyleArrayPtr;
- currentRestyle->mContent = static_cast(aContent);
+ currentRestyle->mElement = static_cast(aElement);
currentRestyle->mRestyleHint = aData.mRestyleHint;
currentRestyle->mChangeHint = aData.mChangeHint;
@@ -11567,33 +11561,33 @@ CollectRestyles(nsISupports* aContent,
}
void
-nsCSSFrameConstructor::ProcessOneRestyle(nsIContent* aContent,
+nsCSSFrameConstructor::ProcessOneRestyle(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aChangeHint)
{
- NS_PRECONDITION(aContent, "Must have content node");
+ NS_PRECONDITION(aElement, "Must have element");
- if (!aContent->IsInDoc() ||
- aContent->GetCurrentDoc() != mDocument) {
+ if (!aElement->IsInDoc() ||
+ aElement->GetCurrentDoc() != mDocument) {
// Content node has been removed from our document; nothing else
// to do here
return;
}
- nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
+ nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
if (aRestyleHint & eRestyle_Self) {
- RestyleElement(aContent, primaryFrame, aChangeHint);
+ RestyleElement(aElement, primaryFrame, aChangeHint);
} else if (aChangeHint &&
(primaryFrame ||
(aChangeHint & nsChangeHint_ReconstructFrame))) {
// Don't need to recompute style; just apply the hint
nsStyleChangeList changeList;
- changeList.AppendChange(primaryFrame, aContent, aChangeHint);
+ changeList.AppendChange(primaryFrame, aElement, aChangeHint);
ProcessRestyledFrames(changeList);
}
if (aRestyleHint & eRestyle_LaterSiblings) {
- RestyleLaterSiblings(aContent);
+ RestyleLaterSiblings(aElement);
}
}
@@ -11689,7 +11683,7 @@ nsCSSFrameConstructor::ProcessPendingRestyleTable(
for (RestyleEnumerateData* currentRestyle = restylesToProcess;
currentRestyle != lastRestyle;
++currentRestyle) {
- ProcessOneRestyle(currentRestyle->mContent,
+ ProcessOneRestyle(currentRestyle->mElement,
currentRestyle->mRestyleHint,
currentRestyle->mChangeHint);
}
diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h
index 39b008b7a8c..fcdcc3572a0 100644
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -82,6 +82,8 @@ class nsFrameConstructorSaveState;
class nsCSSFrameConstructor : public nsARefreshObserver
{
public:
+ typedef mozilla::dom::Element Element;
+
nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell);
~nsCSSFrameConstructor(void) {
NS_ASSERTION(mUpdateCount == 0, "Dying in the middle of our own update?");
@@ -305,7 +307,8 @@ private:
// This function does not call ProcessAttachedQueue() on the binding manager.
// If the caller wants that to happen synchronously, it needs to handle that
// itself.
- void ProcessOneRestyle(nsIContent* aContent, nsRestyleHint aRestyleHint,
+ void ProcessOneRestyle(Element* aElement,
+ nsRestyleHint aRestyleHint,
nsChangeHint aChangeHint);
void ProcessPendingRestyleTable(
@@ -315,20 +318,19 @@ public:
// Restyling for a ContentInserted (notification after insertion) or
// for a CharacterDataChanged. |aContainer| must be non-null; when
// the container is null, no work is needed.
- void RestyleForInsertOrChange(mozilla::dom::Element* aContainer,
- nsIContent* aChild);
+ void RestyleForInsertOrChange(Element* aContainer, nsIContent* aChild);
+
// This would be the same as RestyleForInsertOrChange if we got the
// notification before the removal. However, we get it after, so we
// have to use the index. |aContainer| must be non-null; when the
// container is null, no work is needed. aFollowingSibling is the
// sibling that used to come after aOldChild before the removal.
- void RestyleForRemove(mozilla::dom::Element* aContainer,
+ void RestyleForRemove(Element* aContainer,
nsIContent* aOldChild,
nsIContent* aFollowingSibling);
// Same for a ContentAppended. |aContainer| must be non-null; when
// the container is null, no work is needed.
- void RestyleForAppend(mozilla::dom::Element* aContainer,
- nsIContent* aFirstNewContent);
+ void RestyleForAppend(Element* aContainer, nsIContent* aFirstNewContent);
// Process any pending restyles. This should be called after
// CreateNeededFrames.
@@ -345,7 +347,7 @@ public:
void RebuildAllStyleData(nsChangeHint aExtraHint);
// See PostRestyleEventCommon below.
- void PostRestyleEvent(mozilla::dom::Element* aElement,
+ void PostRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
@@ -357,7 +359,7 @@ public:
}
// See PostRestyleEventCommon below.
- void PostAnimationRestyleEvent(mozilla::dom::Element* aElement,
+ void PostAnimationRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
@@ -382,7 +384,7 @@ private:
* IsProcessingAnimationStyleChange() value
* (which is the default value).
*/
- void PostRestyleEventCommon(mozilla::dom::Element* aElement,
+ void PostRestyleEventCommon(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint,
PRBool aForAnimation);
@@ -450,16 +452,16 @@ private:
nsIFrame*& aPageFrame,
nsIFrame*& aCanvasFrame);
- void DoContentStateChanged(mozilla::dom::Element* aElement,
+ void DoContentStateChanged(Element* aElement,
PRInt32 aStateMask);
/* aMinHint is the minimal change that should be made to the element */
// XXXbz do we really need the aPrimaryFrame argument here?
- void RestyleElement(nsIContent* aContent,
+ void RestyleElement(Element* aElement,
nsIFrame* aPrimaryFrame,
nsChangeHint aMinHint);
- void RestyleLaterSiblings(nsIContent* aContent);
+ void RestyleLaterSiblings(Element* aElement);
nsresult InitAndRestoreFrame (const nsFrameConstructorState& aState,
nsIContent* aContent,
@@ -499,7 +501,7 @@ private:
// Construct the frames for the document element. This must always return a
// singe new frame (which may, of course, have a bunch of kids).
// XXXbz no need to return a frame here, imo.
- nsresult ConstructDocElementFrame(mozilla::dom::Element* aDocElement,
+ nsresult ConstructDocElementFrame(Element* aDocElement,
nsILayoutHistoryState* aFrameState,
nsIFrame** aNewFrame);
@@ -1499,7 +1501,7 @@ private:
PendingBinding* aPendingBinding,
nsFrameItems& aFrameItems);
- nsresult MaybeRecreateFramesForContent(nsIContent* aContent);
+ nsresult MaybeRecreateFramesForElement(Element* aElement);
// If aAsyncInsert is true then a restyle event will be posted to handle the
// required ContentInserted call instead of doing it immediately.
@@ -1839,7 +1841,7 @@ public:
};
struct RestyleEnumerateData : public RestyleData {
- nsCOMPtr mContent;
+ nsCOMPtr mElement;
};
friend class nsFrameConstructorState;