Changed FindFrameWithContent() to check for a frame type of "placeholderFrame"

and return the out-of-flow frame instead
This commit is contained in:
troy%netscape.com 1999-04-25 17:00:24 +00:00
Родитель 39e0aad7f0
Коммит c7748fdf2c
2 изменённых файлов: 60 добавлений и 36 удалений

Просмотреть файл

@ -64,6 +64,8 @@
#include "nsXIFDTD.h" #include "nsXIFDTD.h"
#include "nsIFrameSelection.h" #include "nsIFrameSelection.h"
#include "nsViewsCID.h" #include "nsViewsCID.h"
#include "nsLayoutAtoms.h"
#include "nsPlaceholderFrame.h"
#include "nsIDataFlavor.h" #include "nsIDataFlavor.h"
@ -1811,35 +1813,35 @@ static nsIFrame*
FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent) FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent)
{ {
nsIContent* frameContent; nsIContent* frameContent;
PRBool hasSameContent;
// See if the frame points to the same content object
aFrame->GetContent(&frameContent); aFrame->GetContent(&frameContent);
if (frameContent == aContent) { hasSameContent = (frameContent == aContent);
nsIStyleContext* styleContext; NS_IF_RELEASE(frameContent);
nsIAtom* pseudoTag;
PRBool isPlaceholder = PR_FALSE;
// If it's a placeholder frame, then ignore it and keep looking for the if (hasSameContent) {
// primary frame nsIAtom* frameType;
aFrame->GetStyleContext(&styleContext); PRBool isPlaceholder;
styleContext->GetPseudoType(pseudoTag);
if (pseudoTag == nsHTMLAtoms::placeholderPseudo) { // See if it's a placeholder frame
isPlaceholder = PR_TRUE; aFrame->GetFrameType(&frameType);
isPlaceholder = (nsLayoutAtoms::placeholderFrame == frameType);
NS_IF_RELEASE(frameType);
if (isPlaceholder) {
// Ignore the placeholder and return the out-of-flow frame instead
return ((nsPlaceholderFrame*)aFrame)->GetOutOfFlowFrame();
} }
NS_RELEASE(styleContext);
NS_IF_RELEASE(pseudoTag);
// Also ignore frames associated with generated content // Also ignore frames associated with generated content
nsFrameState frameState; nsFrameState frameState;
PRBool isGeneratedContent;
aFrame->GetFrameState(&frameState); aFrame->GetFrameState(&frameState);
isGeneratedContent = (frameState & NS_FRAME_GENERATED_CONTENT) == NS_FRAME_GENERATED_CONTENT; if ((frameState & NS_FRAME_GENERATED_CONTENT) == 0) {
if (!isPlaceholder && !isGeneratedContent) {
NS_IF_RELEASE(frameContent);
return aFrame; return aFrame;
} }
} }
NS_IF_RELEASE(frameContent);
// Search for the frame in each child list that aFrame supports // Search for the frame in each child list that aFrame supports
nsIAtom* listName = nsnull; nsIAtom* listName = nsnull;
@ -1930,6 +1932,16 @@ PresShell::SetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame* aPlaceholderFrame) nsIFrame* aPlaceholderFrame)
{ {
NS_PRECONDITION(nsnull != aFrame, "no frame"); NS_PRECONDITION(nsnull != aFrame, "no frame");
#ifdef NS_DEBUG
// Verify that the placeholder frame is of the correct type
if (aPlaceholderFrame) {
nsIAtom* frameType;
aPlaceholderFrame->GetFrameType(&frameType);
NS_PRECONDITION(nsLayoutAtoms::placeholderFrame == frameType, "unexpected frame type");
NS_IF_RELEASE(frameType);
}
#endif
if (nsnull == mPlaceholderMap) { if (nsnull == mPlaceholderMap) {
mPlaceholderMap = new FrameHashTable; mPlaceholderMap = new FrameHashTable;

Просмотреть файл

@ -64,6 +64,8 @@
#include "nsXIFDTD.h" #include "nsXIFDTD.h"
#include "nsIFrameSelection.h" #include "nsIFrameSelection.h"
#include "nsViewsCID.h" #include "nsViewsCID.h"
#include "nsLayoutAtoms.h"
#include "nsPlaceholderFrame.h"
#include "nsIDataFlavor.h" #include "nsIDataFlavor.h"
@ -1811,35 +1813,35 @@ static nsIFrame*
FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent) FindFrameWithContent(nsIFrame* aFrame, nsIContent* aContent)
{ {
nsIContent* frameContent; nsIContent* frameContent;
PRBool hasSameContent;
// See if the frame points to the same content object
aFrame->GetContent(&frameContent); aFrame->GetContent(&frameContent);
if (frameContent == aContent) { hasSameContent = (frameContent == aContent);
nsIStyleContext* styleContext; NS_IF_RELEASE(frameContent);
nsIAtom* pseudoTag;
PRBool isPlaceholder = PR_FALSE;
// If it's a placeholder frame, then ignore it and keep looking for the if (hasSameContent) {
// primary frame nsIAtom* frameType;
aFrame->GetStyleContext(&styleContext); PRBool isPlaceholder;
styleContext->GetPseudoType(pseudoTag);
if (pseudoTag == nsHTMLAtoms::placeholderPseudo) { // See if it's a placeholder frame
isPlaceholder = PR_TRUE; aFrame->GetFrameType(&frameType);
isPlaceholder = (nsLayoutAtoms::placeholderFrame == frameType);
NS_IF_RELEASE(frameType);
if (isPlaceholder) {
// Ignore the placeholder and return the out-of-flow frame instead
return ((nsPlaceholderFrame*)aFrame)->GetOutOfFlowFrame();
} }
NS_RELEASE(styleContext);
NS_IF_RELEASE(pseudoTag);
// Also ignore frames associated with generated content // Also ignore frames associated with generated content
nsFrameState frameState; nsFrameState frameState;
PRBool isGeneratedContent;
aFrame->GetFrameState(&frameState); aFrame->GetFrameState(&frameState);
isGeneratedContent = (frameState & NS_FRAME_GENERATED_CONTENT) == NS_FRAME_GENERATED_CONTENT; if ((frameState & NS_FRAME_GENERATED_CONTENT) == 0) {
if (!isPlaceholder && !isGeneratedContent) {
NS_IF_RELEASE(frameContent);
return aFrame; return aFrame;
} }
} }
NS_IF_RELEASE(frameContent);
// Search for the frame in each child list that aFrame supports // Search for the frame in each child list that aFrame supports
nsIAtom* listName = nsnull; nsIAtom* listName = nsnull;
@ -1930,6 +1932,16 @@ PresShell::SetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame* aPlaceholderFrame) nsIFrame* aPlaceholderFrame)
{ {
NS_PRECONDITION(nsnull != aFrame, "no frame"); NS_PRECONDITION(nsnull != aFrame, "no frame");
#ifdef NS_DEBUG
// Verify that the placeholder frame is of the correct type
if (aPlaceholderFrame) {
nsIAtom* frameType;
aPlaceholderFrame->GetFrameType(&frameType);
NS_PRECONDITION(nsLayoutAtoms::placeholderFrame == frameType, "unexpected frame type");
NS_IF_RELEASE(frameType);
}
#endif
if (nsnull == mPlaceholderMap) { if (nsnull == mPlaceholderMap) {
mPlaceholderMap = new FrameHashTable; mPlaceholderMap = new FrameHashTable;