diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index c58ce771c6e..d0e1235e663 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -29,7 +29,6 @@ #include "nsIReflowCommand.h" class nsIContent; -class nsIContentIterator; class nsIDocument; class nsIDocumentObserver; class nsIFrame; @@ -404,18 +403,6 @@ public: */ NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0; - /** - * Returns a content iterator to iterate the generated content nodes. - * You must specify whether you want to iterate the "before" generated - * content or the "after" generated content. If there is no generated - * content of the specified type for the promary frame associated with - * with the content object then NULL is returned - */ - enum GeneratedContentType {Before, After}; - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const = 0; - /** * See if reflow verification is enabled. To enable reflow verification add * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 219d37bcef9..befd8272edf 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -75,7 +75,6 @@ #include "nsTimer.h" #include "nsWeakPtr.h" #include "plarena.h" -#include "nsCSSAtoms.h" #ifdef MOZ_PERF_METRICS #include "nsITimeRecorder.h" #endif @@ -372,10 +371,6 @@ public: NS_IMETHOD GetReflowEventStatus(PRBool* aPending); NS_IMETHOD SetReflowEventStatus(PRBool aPending); - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const; - /** * Reflow batching */ @@ -2510,123 +2505,6 @@ PresShell::SetReflowEventStatus(PRBool aPending) mPendingReflowEvent = aPending; return NS_OK; } - -static PRBool -IsGeneratedContentFrame(nsIFrame* aFrame) -{ - nsFrameState frameState; - - aFrame->GetFrameState(&frameState); - return (frameState & NS_FRAME_GENERATED_CONTENT) != 0; -} - -static PRBool -IsPseudoFrame(nsIFrame* aFrame, nsIContent* aParentContent) -{ - nsCOMPtr content; - - aFrame->GetContent(getter_AddRefs(content)); - return content.get() == aParentContent; -} - -static nsIFrame* -GetFirstChildFrame(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIContent* aContent) -{ - nsIFrame* childFrame; - - // Get the first child frame - aFrame->FirstChild(aPresContext, nsnull, &childFrame); - - // If the child frame is a pseudo-frame, then return its first child - if (childFrame && IsPseudoFrame(childFrame, aContent)) { - return GetFirstChildFrame(aPresContext, childFrame, aContent); - } - - return childFrame; -} - -static nsIFrame* -GetLastChildFrame(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIContent* aContent) -{ - NS_PRECONDITION(aFrame, "NULL frame pointer"); - - // Get the last in flow frame - nsIFrame* lastInFlow; - while (aFrame) { - lastInFlow = aFrame; - lastInFlow->GetNextInFlow(&aFrame); - } - - // Get the first child frame - nsIFrame* firstChildFrame; - lastInFlow->FirstChild(aPresContext, nsnull, &firstChildFrame); - if (firstChildFrame) { - nsFrameList frameList(firstChildFrame); - nsIFrame* lastChildFrame = frameList.LastChild(); - - NS_ASSERTION(lastChildFrame, "unexpected error"); - - // If the last child frame is a pseudo-frame, then return its last child - if (lastChildFrame && IsPseudoFrame(lastChildFrame, aContent)) { - return GetLastChildFrame(aPresContext, lastChildFrame, aContent); - } - - return lastChildFrame; - } - - return nsnull; -} - -NS_IMETHODIMP -PresShell::GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const -{ - nsIFrame* primaryFrame; - nsresult rv = NS_OK; - - // Initialize OUT parameter - *aIterator = nsnull; - - // Get the primary frame associated with the content object - GetPrimaryFrameFor(aContent, &primaryFrame); - if (primaryFrame) { - // See whether it's a request for the before or after generated content - if (Before == aType) { - // The most efficient thing to do is to get the first child frame, - // and see if it is associated with generated content - nsIFrame* firstChildFrame = GetFirstChildFrame(mPresContext, primaryFrame, aContent); - if (firstChildFrame && IsGeneratedContentFrame(firstChildFrame)) { - // Create an iterator - rv = NS_NewGeneratedContentIterator(mPresContext, firstChildFrame, aIterator); - } - - } else { - // Avoid finding the last child frame unless we need to. Instead probe - // for the existence of the pseudo-element - nsCOMPtr styleContext; - nsCOMPtr pseudoStyleContext; - - primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); - mPresContext->ProbePseudoStyleContextFor(aContent, nsCSSAtoms::afterPseudo, - styleContext, PR_FALSE, - getter_AddRefs(pseudoStyleContext)); - if (pseudoStyleContext) { - nsIFrame* lastChildFrame = GetLastChildFrame(mPresContext, primaryFrame, aContent); - NS_ASSERTION(lastChildFrame && IsGeneratedContentFrame(lastChildFrame), - "can't find generated content frame"); - // Create an iterator - rv = NS_NewGeneratedContentIterator(mPresContext, lastChildFrame, aIterator); - } - } - } - - return rv; -} NS_IMETHODIMP PresShell::FlushPendingNotifications() diff --git a/layout/base/public/nsIPresShell.h b/layout/base/public/nsIPresShell.h index c58ce771c6e..d0e1235e663 100644 --- a/layout/base/public/nsIPresShell.h +++ b/layout/base/public/nsIPresShell.h @@ -29,7 +29,6 @@ #include "nsIReflowCommand.h" class nsIContent; -class nsIContentIterator; class nsIDocument; class nsIDocumentObserver; class nsIFrame; @@ -404,18 +403,6 @@ public: */ NS_IMETHOD IsReflowLocked(PRBool* aIsLocked) = 0; - /** - * Returns a content iterator to iterate the generated content nodes. - * You must specify whether you want to iterate the "before" generated - * content or the "after" generated content. If there is no generated - * content of the specified type for the promary frame associated with - * with the content object then NULL is returned - */ - enum GeneratedContentType {Before, After}; - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const = 0; - /** * See if reflow verification is enabled. To enable reflow verification add * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 219d37bcef9..befd8272edf 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -75,7 +75,6 @@ #include "nsTimer.h" #include "nsWeakPtr.h" #include "plarena.h" -#include "nsCSSAtoms.h" #ifdef MOZ_PERF_METRICS #include "nsITimeRecorder.h" #endif @@ -372,10 +371,6 @@ public: NS_IMETHOD GetReflowEventStatus(PRBool* aPending); NS_IMETHOD SetReflowEventStatus(PRBool aPending); - NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const; - /** * Reflow batching */ @@ -2510,123 +2505,6 @@ PresShell::SetReflowEventStatus(PRBool aPending) mPendingReflowEvent = aPending; return NS_OK; } - -static PRBool -IsGeneratedContentFrame(nsIFrame* aFrame) -{ - nsFrameState frameState; - - aFrame->GetFrameState(&frameState); - return (frameState & NS_FRAME_GENERATED_CONTENT) != 0; -} - -static PRBool -IsPseudoFrame(nsIFrame* aFrame, nsIContent* aParentContent) -{ - nsCOMPtr content; - - aFrame->GetContent(getter_AddRefs(content)); - return content.get() == aParentContent; -} - -static nsIFrame* -GetFirstChildFrame(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIContent* aContent) -{ - nsIFrame* childFrame; - - // Get the first child frame - aFrame->FirstChild(aPresContext, nsnull, &childFrame); - - // If the child frame is a pseudo-frame, then return its first child - if (childFrame && IsPseudoFrame(childFrame, aContent)) { - return GetFirstChildFrame(aPresContext, childFrame, aContent); - } - - return childFrame; -} - -static nsIFrame* -GetLastChildFrame(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIContent* aContent) -{ - NS_PRECONDITION(aFrame, "NULL frame pointer"); - - // Get the last in flow frame - nsIFrame* lastInFlow; - while (aFrame) { - lastInFlow = aFrame; - lastInFlow->GetNextInFlow(&aFrame); - } - - // Get the first child frame - nsIFrame* firstChildFrame; - lastInFlow->FirstChild(aPresContext, nsnull, &firstChildFrame); - if (firstChildFrame) { - nsFrameList frameList(firstChildFrame); - nsIFrame* lastChildFrame = frameList.LastChild(); - - NS_ASSERTION(lastChildFrame, "unexpected error"); - - // If the last child frame is a pseudo-frame, then return its last child - if (lastChildFrame && IsPseudoFrame(lastChildFrame, aContent)) { - return GetLastChildFrame(aPresContext, lastChildFrame, aContent); - } - - return lastChildFrame; - } - - return nsnull; -} - -NS_IMETHODIMP -PresShell::GetGeneratedContentIterator(nsIContent* aContent, - GeneratedContentType aType, - nsIContentIterator** aIterator) const -{ - nsIFrame* primaryFrame; - nsresult rv = NS_OK; - - // Initialize OUT parameter - *aIterator = nsnull; - - // Get the primary frame associated with the content object - GetPrimaryFrameFor(aContent, &primaryFrame); - if (primaryFrame) { - // See whether it's a request for the before or after generated content - if (Before == aType) { - // The most efficient thing to do is to get the first child frame, - // and see if it is associated with generated content - nsIFrame* firstChildFrame = GetFirstChildFrame(mPresContext, primaryFrame, aContent); - if (firstChildFrame && IsGeneratedContentFrame(firstChildFrame)) { - // Create an iterator - rv = NS_NewGeneratedContentIterator(mPresContext, firstChildFrame, aIterator); - } - - } else { - // Avoid finding the last child frame unless we need to. Instead probe - // for the existence of the pseudo-element - nsCOMPtr styleContext; - nsCOMPtr pseudoStyleContext; - - primaryFrame->GetStyleContext(getter_AddRefs(styleContext)); - mPresContext->ProbePseudoStyleContextFor(aContent, nsCSSAtoms::afterPseudo, - styleContext, PR_FALSE, - getter_AddRefs(pseudoStyleContext)); - if (pseudoStyleContext) { - nsIFrame* lastChildFrame = GetLastChildFrame(mPresContext, primaryFrame, aContent); - NS_ASSERTION(lastChildFrame && IsGeneratedContentFrame(lastChildFrame), - "can't find generated content frame"); - // Create an iterator - rv = NS_NewGeneratedContentIterator(mPresContext, lastChildFrame, aIterator); - } - } - } - - return rv; -} NS_IMETHODIMP PresShell::FlushPendingNotifications()