diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 17ca2a93d70f..1bfc8a44d63c 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -201,6 +201,7 @@ public: NS_IMETHOD EndLoad() = 0; NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent) = 0; + NS_IMETHOD ContentStateChanged(nsIContent* aContent) = 0; NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint) = 0; // See nsStyleConsts fot hint values diff --git a/content/base/public/nsIDocumentObserver.h b/content/base/public/nsIDocumentObserver.h index a27b9ac4d699..a7673766e48c 100644 --- a/content/base/public/nsIDocumentObserver.h +++ b/content/base/public/nsIDocumentObserver.h @@ -91,6 +91,25 @@ public: nsIContent* aContent, nsISupports* aSubContent) = 0; + /** + * Notification that the state of a content node has changed. + * (ie: gained or lost focus, became active or hovered over) + * This method is called automatically by content objects + * when their state is changed (therefore there is normally + * no need to invoke this method directly). The notification + * is passed to any IDocumentObservers. The notification is + * passed on to all of the document observers.

+ * + * This notification is not sent when a piece of content is + * added/removed from the document or the content itself changed + * (the other notifications are used for that). + * + * @param aDocument The document being observed + * @param aContent the piece of content that changed + */ + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) = 0; + /** * Notification that the content model has changed. This method is called * automatically by content objects when an attribute's value has changed diff --git a/content/base/src/nsContentList.h b/content/base/src/nsContentList.h index 982f157762e2..beacdfc132e5 100644 --- a/content/base/src/nsContentList.h +++ b/content/base/src/nsContentList.h @@ -72,6 +72,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) { return NS_OK; } NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 595c46d1fbfa..cdcbc8a9647b 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -123,6 +123,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) { return NS_OK; } NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, @@ -1197,6 +1199,24 @@ nsDocument::ContentChanged(nsIContent* aContent, return NS_OK; } +NS_IMETHODIMP +nsDocument::ContentStateChanged(nsIContent* aContent) +{ + PRInt32 count = mObservers.Count(); + for (PRInt32 i = 0; i < count; i++) { + nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i]; + observer->ContentStateChanged(this, aContent); + // Make sure that the observer didn't remove itself during the + // notification. If it did, update our index and count. + if (observer != (nsIDocumentObserver*)mObservers[i]) { + i--; + count--; + } + } + return NS_OK; +} + + NS_IMETHODIMP nsDocument::ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer) diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index c9c8108f84c1..d8e47f28264d 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -209,6 +209,7 @@ public: NS_IMETHOD EndLoad(); NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 00e6417e8c25..aab2d8dfab76 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -391,6 +391,8 @@ public: NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIContent* aContent); + NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint); // See nsStyleConsts fot hint values @@ -1323,6 +1325,17 @@ XULDocumentImpl::ContentChanged(nsIContent* aContent, return NS_OK; } +NS_IMETHODIMP +XULDocumentImpl::ContentStateChanged(nsIContent* aContent) +{ + PRInt32 count = mObservers.Count(); + for (PRInt32 i = 0; i < count; i++) { + nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i]; + observer->ContentStateChanged(this, aContent); + } + return NS_OK; +} + NS_IMETHODIMP XULDocumentImpl::AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index e12d284a368e..ca44328090d5 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3468,6 +3468,9 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, // Trigger rendering updates by damaging this frame and any // continuations of this frame. + + // XXX this needs to detect the need for a view due to an opacity change and deal with it... + while (nsnull != aFrame) { // Get the frame's bounding rect nsRect r; @@ -3559,6 +3562,87 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, return rv; } + +NS_IMETHODIMP +nsCSSFrameConstructor::ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent) +{ + nsresult result = NS_OK; + + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + nsIFrame* frame; + + shell->GetPrimaryFrameFor(aContent, &frame); + + PRInt32 hint = NS_STYLE_HINT_NONE; + PRBool reflow = PR_FALSE; + PRBool reframe = PR_FALSE; + PRBool render = PR_FALSE; + PRBool notify = PR_FALSE; + +#if 0 + NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, + ("HTMLStyleSheet::ContentStateChanged: content=%p[%s] frame=%p", + aContent, ContentTag(aContent, 0), frame)); +#endif + + if (frame) { + nsIStyleContext* oldFrameContext; + frame->GetStyleContext(&oldFrameContext); + NS_ASSERTION(nsnull != oldFrameContext, "frame must have style context"); + if (oldFrameContext) { + nsIStyleContext* parentContext = oldFrameContext->GetParent(); + frame->ReResolveStyleContext(aPresContext, parentContext); + NS_IF_RELEASE(parentContext); + nsIStyleContext* newFrameContext; + frame->GetStyleContext(&newFrameContext); + if (newFrameContext) { + if (newFrameContext != oldFrameContext) { + newFrameContext->CalcStyleDifference(oldFrameContext, hint); + } + NS_RELEASE(newFrameContext); + } + NS_RELEASE(oldFrameContext); + } + + switch (hint) { + default: + case NS_STYLE_HINT_UNKNOWN: + case NS_STYLE_HINT_FRAMECHANGE: + reframe = PR_TRUE; + case NS_STYLE_HINT_REFLOW: + reflow = PR_TRUE; + case NS_STYLE_HINT_VISUAL: + render = PR_TRUE; + case NS_STYLE_HINT_CONTENT: + notify = PR_TRUE; + case NS_STYLE_HINT_AURAL: + case NS_STYLE_HINT_NONE: + break; + } + + // apply changes + if (reframe) { + result = RecreateFramesForContent(aPresContext, aContent); + } + else if (reflow) { + StyleChangeReflow(aPresContext, frame, nsnull); + } + else if (render) { + ApplyRenderingChangeToTree(aPresContext, frame); + } + else if (notify) { + result = frame->ContentChanged(aPresContext, aContent, nsnull); + } + } + else { + result = RecreateFramesForContent(aPresContext, aContent); + } + return result; +} + + NS_IMETHODIMP nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, @@ -3617,7 +3701,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // apply changes if (PR_TRUE == reframe) { - RecreateFramesOnAttributeChange(aPresContext, aContent, aAttribute); + RecreateFramesForContent(aPresContext, aContent); } else if (PR_TRUE == restyle) { // If there is no frame then there is no point in re-styling it, @@ -4155,9 +4239,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } nsresult -nsCSSFrameConstructor::RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute) +nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, + nsIContent* aContent) { nsresult rv = NS_OK; diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index f9f7a910725e..667e8c96cacd 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -78,6 +78,8 @@ public: NS_IMETHOD ContentChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsIAtom* aAttribute, @@ -369,9 +371,9 @@ protected: PRBool aIsFixedPositioned, PRBool aCreateBlock); - nsresult RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute); + nsresult RecreateFramesForContent(nsIPresContext* aPresContext, + nsIContent* aContent); + nsresult CreateContinuingOuterTableFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index d4f8424a5eaf..967e2ea8e830 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -205,6 +205,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, @@ -1482,6 +1484,22 @@ PresShell::ContentChanged(nsIDocument *aDocument, return rv; } +NS_IMETHODIMP +PresShell::ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) +{ + NS_PRECONDITION(nsnull != mRootFrame, "null root frame"); + + EnterReflowLock(); + nsresult rv = mStyleSet->ContentStateChanged(mPresContext, aContent); + ExitReflowLock(); + if (mSelection) + mSelection->ResetSelection(this, mRootFrame); + + return rv; +} + + NS_IMETHODIMP PresShell::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, diff --git a/layout/base/public/nsIDocument.h b/layout/base/public/nsIDocument.h index 17ca2a93d70f..1bfc8a44d63c 100644 --- a/layout/base/public/nsIDocument.h +++ b/layout/base/public/nsIDocument.h @@ -201,6 +201,7 @@ public: NS_IMETHOD EndLoad() = 0; NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent) = 0; + NS_IMETHOD ContentStateChanged(nsIContent* aContent) = 0; NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint) = 0; // See nsStyleConsts fot hint values diff --git a/layout/base/public/nsIDocumentObserver.h b/layout/base/public/nsIDocumentObserver.h index a27b9ac4d699..a7673766e48c 100644 --- a/layout/base/public/nsIDocumentObserver.h +++ b/layout/base/public/nsIDocumentObserver.h @@ -91,6 +91,25 @@ public: nsIContent* aContent, nsISupports* aSubContent) = 0; + /** + * Notification that the state of a content node has changed. + * (ie: gained or lost focus, became active or hovered over) + * This method is called automatically by content objects + * when their state is changed (therefore there is normally + * no need to invoke this method directly). The notification + * is passed to any IDocumentObservers. The notification is + * passed on to all of the document observers.

+ * + * This notification is not sent when a piece of content is + * added/removed from the document or the content itself changed + * (the other notifications are used for that). + * + * @param aDocument The document being observed + * @param aContent the piece of content that changed + */ + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) = 0; + /** * Notification that the content model has changed. This method is called * automatically by content objects when an attribute's value has changed diff --git a/layout/base/public/nsIStyleFrameConstruction.h b/layout/base/public/nsIStyleFrameConstruction.h index a0a4f85945b9..91c087a596b8 100644 --- a/layout/base/public/nsIStyleFrameConstruction.h +++ b/layout/base/public/nsIStyleFrameConstruction.h @@ -73,6 +73,9 @@ public: nsIContent* aContent, nsISupports* aSubContent) = 0; + NS_IMETHOD ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent) = 0; + NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsIAtom* aAttribute, diff --git a/layout/base/public/nsIStyleSet.h b/layout/base/public/nsIStyleSet.h index a44282a87e54..28ab51d11729 100644 --- a/layout/base/public/nsIStyleSet.h +++ b/layout/base/public/nsIStyleSet.h @@ -120,6 +120,8 @@ public: NS_IMETHOD ContentChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsISupports* aSubContent) = 0; + NS_IMETHOD ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent) = 0; NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsIAtom* aAttribute, diff --git a/layout/base/src/nsContentList.h b/layout/base/src/nsContentList.h index 982f157762e2..beacdfc132e5 100644 --- a/layout/base/src/nsContentList.h +++ b/layout/base/src/nsContentList.h @@ -72,6 +72,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) { return NS_OK; } NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, diff --git a/layout/base/src/nsDocument.cpp b/layout/base/src/nsDocument.cpp index 595c46d1fbfa..cdcbc8a9647b 100644 --- a/layout/base/src/nsDocument.cpp +++ b/layout/base/src/nsDocument.cpp @@ -123,6 +123,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) { return NS_OK; } NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, @@ -1197,6 +1199,24 @@ nsDocument::ContentChanged(nsIContent* aContent, return NS_OK; } +NS_IMETHODIMP +nsDocument::ContentStateChanged(nsIContent* aContent) +{ + PRInt32 count = mObservers.Count(); + for (PRInt32 i = 0; i < count; i++) { + nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i]; + observer->ContentStateChanged(this, aContent); + // Make sure that the observer didn't remove itself during the + // notification. If it did, update our index and count. + if (observer != (nsIDocumentObserver*)mObservers[i]) { + i--; + count--; + } + } + return NS_OK; +} + + NS_IMETHODIMP nsDocument::ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer) diff --git a/layout/base/src/nsDocument.h b/layout/base/src/nsDocument.h index c9c8108f84c1..d8e47f28264d 100644 --- a/layout/base/src/nsDocument.h +++ b/layout/base/src/nsDocument.h @@ -209,6 +209,7 @@ public: NS_IMETHOD EndLoad(); NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint); diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index 7940cc59a1c9..8cbdef1b7cbb 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -901,6 +901,14 @@ nsImageMap::ContentChanged(nsIDocument *aDocument, return NS_OK; } +NS_IMETHODIMP +nsImageMap::ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) +{ + return NS_OK; +} + + NS_IMETHODIMP nsImageMap::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, diff --git a/layout/generic/nsImageMap.h b/layout/generic/nsImageMap.h index 8713c52f9ede..f8b63670e3e5 100644 --- a/layout/generic/nsImageMap.h +++ b/layout/generic/nsImageMap.h @@ -74,6 +74,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, diff --git a/layout/html/base/src/nsImageMap.cpp b/layout/html/base/src/nsImageMap.cpp index 7940cc59a1c9..8cbdef1b7cbb 100644 --- a/layout/html/base/src/nsImageMap.cpp +++ b/layout/html/base/src/nsImageMap.cpp @@ -901,6 +901,14 @@ nsImageMap::ContentChanged(nsIDocument *aDocument, return NS_OK; } +NS_IMETHODIMP +nsImageMap::ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) +{ + return NS_OK; +} + + NS_IMETHODIMP nsImageMap::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, diff --git a/layout/html/base/src/nsImageMap.h b/layout/html/base/src/nsImageMap.h index 8713c52f9ede..f8b63670e3e5 100644 --- a/layout/html/base/src/nsImageMap.h +++ b/layout/html/base/src/nsImageMap.h @@ -74,6 +74,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index d4f8424a5eaf..967e2ea8e830 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -205,6 +205,8 @@ public: NS_IMETHOD ContentChanged(nsIDocument *aDocument, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, nsIAtom* aAttribute, @@ -1482,6 +1484,22 @@ PresShell::ContentChanged(nsIDocument *aDocument, return rv; } +NS_IMETHODIMP +PresShell::ContentStateChanged(nsIDocument* aDocument, + nsIContent* aContent) +{ + NS_PRECONDITION(nsnull != mRootFrame, "null root frame"); + + EnterReflowLock(); + nsresult rv = mStyleSet->ContentStateChanged(mPresContext, aContent); + ExitReflowLock(); + if (mSelection) + mSelection->ResetSelection(this, mRootFrame); + + return rv; +} + + NS_IMETHODIMP PresShell::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index e12d284a368e..ca44328090d5 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3468,6 +3468,9 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, // Trigger rendering updates by damaging this frame and any // continuations of this frame. + + // XXX this needs to detect the need for a view due to an opacity change and deal with it... + while (nsnull != aFrame) { // Get the frame's bounding rect nsRect r; @@ -3559,6 +3562,87 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, return rv; } + +NS_IMETHODIMP +nsCSSFrameConstructor::ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent) +{ + nsresult result = NS_OK; + + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + nsIFrame* frame; + + shell->GetPrimaryFrameFor(aContent, &frame); + + PRInt32 hint = NS_STYLE_HINT_NONE; + PRBool reflow = PR_FALSE; + PRBool reframe = PR_FALSE; + PRBool render = PR_FALSE; + PRBool notify = PR_FALSE; + +#if 0 + NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, + ("HTMLStyleSheet::ContentStateChanged: content=%p[%s] frame=%p", + aContent, ContentTag(aContent, 0), frame)); +#endif + + if (frame) { + nsIStyleContext* oldFrameContext; + frame->GetStyleContext(&oldFrameContext); + NS_ASSERTION(nsnull != oldFrameContext, "frame must have style context"); + if (oldFrameContext) { + nsIStyleContext* parentContext = oldFrameContext->GetParent(); + frame->ReResolveStyleContext(aPresContext, parentContext); + NS_IF_RELEASE(parentContext); + nsIStyleContext* newFrameContext; + frame->GetStyleContext(&newFrameContext); + if (newFrameContext) { + if (newFrameContext != oldFrameContext) { + newFrameContext->CalcStyleDifference(oldFrameContext, hint); + } + NS_RELEASE(newFrameContext); + } + NS_RELEASE(oldFrameContext); + } + + switch (hint) { + default: + case NS_STYLE_HINT_UNKNOWN: + case NS_STYLE_HINT_FRAMECHANGE: + reframe = PR_TRUE; + case NS_STYLE_HINT_REFLOW: + reflow = PR_TRUE; + case NS_STYLE_HINT_VISUAL: + render = PR_TRUE; + case NS_STYLE_HINT_CONTENT: + notify = PR_TRUE; + case NS_STYLE_HINT_AURAL: + case NS_STYLE_HINT_NONE: + break; + } + + // apply changes + if (reframe) { + result = RecreateFramesForContent(aPresContext, aContent); + } + else if (reflow) { + StyleChangeReflow(aPresContext, frame, nsnull); + } + else if (render) { + ApplyRenderingChangeToTree(aPresContext, frame); + } + else if (notify) { + result = frame->ContentChanged(aPresContext, aContent, nsnull); + } + } + else { + result = RecreateFramesForContent(aPresContext, aContent); + } + return result; +} + + NS_IMETHODIMP nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, @@ -3617,7 +3701,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // apply changes if (PR_TRUE == reframe) { - RecreateFramesOnAttributeChange(aPresContext, aContent, aAttribute); + RecreateFramesForContent(aPresContext, aContent); } else if (PR_TRUE == restyle) { // If there is no frame then there is no point in re-styling it, @@ -4155,9 +4239,8 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } nsresult -nsCSSFrameConstructor::RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute) +nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, + nsIContent* aContent) { nsresult rv = NS_OK; diff --git a/layout/html/style/src/nsCSSFrameConstructor.h b/layout/html/style/src/nsCSSFrameConstructor.h index f9f7a910725e..667e8c96cacd 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.h +++ b/layout/html/style/src/nsCSSFrameConstructor.h @@ -78,6 +78,8 @@ public: NS_IMETHOD ContentChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIPresContext* aPresContext, + nsIContent* aContent); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsIAtom* aAttribute, @@ -369,9 +371,9 @@ protected: PRBool aIsFixedPositioned, PRBool aCreateBlock); - nsresult RecreateFramesOnAttributeChange(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute); + nsresult RecreateFramesForContent(nsIPresContext* aPresContext, + nsIContent* aContent); + nsresult CreateContinuingOuterTableFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 00e6417e8c25..aab2d8dfab76 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -391,6 +391,8 @@ public: NS_IMETHOD ContentChanged(nsIContent* aContent, nsISupports* aSubContent); + NS_IMETHOD ContentStateChanged(nsIContent* aContent); + NS_IMETHOD AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint); // See nsStyleConsts fot hint values @@ -1323,6 +1325,17 @@ XULDocumentImpl::ContentChanged(nsIContent* aContent, return NS_OK; } +NS_IMETHODIMP +XULDocumentImpl::ContentStateChanged(nsIContent* aContent) +{ + PRInt32 count = mObservers.Count(); + for (PRInt32 i = 0; i < count; i++) { + nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i]; + observer->ContentStateChanged(this, aContent); + } + return NS_OK; +} + NS_IMETHODIMP XULDocumentImpl::AttributeChanged(nsIContent* aChild, nsIAtom* aAttribute,