зеркало из https://github.com/mozilla/pjs.git
New code that isn't being used
This commit is contained in:
Родитель
59ce7cdf55
Коммит
d342b8daf0
|
@ -29,6 +29,7 @@
|
|||
#include "nsIReflowCommand.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIContentIterator;
|
||||
class nsIDocument;
|
||||
class nsIDocumentObserver;
|
||||
class nsIFrame;
|
||||
|
@ -403,6 +404,18 @@ 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
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "nsTimer.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "plarena.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
#ifdef MOZ_PERF_METRICS
|
||||
#include "nsITimeRecorder.h"
|
||||
#endif
|
||||
|
@ -371,6 +372,10 @@ public:
|
|||
NS_IMETHOD GetReflowEventStatus(PRBool* aPending);
|
||||
NS_IMETHOD SetReflowEventStatus(PRBool aPending);
|
||||
|
||||
NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent,
|
||||
GeneratedContentType aType,
|
||||
nsIContentIterator** aIterator) const;
|
||||
|
||||
/**
|
||||
* Reflow batching
|
||||
*/
|
||||
|
@ -2505,6 +2510,123 @@ 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<nsIContent> 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<nsIStyleContext> styleContext;
|
||||
nsCOMPtr<nsIStyleContext> 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()
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIReflowCommand.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIContentIterator;
|
||||
class nsIDocument;
|
||||
class nsIDocumentObserver;
|
||||
class nsIFrame;
|
||||
|
@ -403,6 +404,18 @@ 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
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "nsTimer.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "plarena.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
#ifdef MOZ_PERF_METRICS
|
||||
#include "nsITimeRecorder.h"
|
||||
#endif
|
||||
|
@ -371,6 +372,10 @@ public:
|
|||
NS_IMETHOD GetReflowEventStatus(PRBool* aPending);
|
||||
NS_IMETHOD SetReflowEventStatus(PRBool aPending);
|
||||
|
||||
NS_IMETHOD GetGeneratedContentIterator(nsIContent* aContent,
|
||||
GeneratedContentType aType,
|
||||
nsIContentIterator** aIterator) const;
|
||||
|
||||
/**
|
||||
* Reflow batching
|
||||
*/
|
||||
|
@ -2505,6 +2510,123 @@ 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<nsIContent> 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<nsIStyleContext> styleContext;
|
||||
nsCOMPtr<nsIStyleContext> 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()
|
||||
|
|
Загрузка…
Ссылка в новой задаче