Fixed a problem with placeholder frame's clearing the child list and

causing the previous frames to disappear
This commit is contained in:
troy%netscape.com 1999-01-26 05:05:19 +00:00
Родитель f533bfaaf0
Коммит 85b271d4dd
3 изменённых файлов: 132 добавлений и 156 удалений

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

@ -229,20 +229,15 @@ struct nsFrameItems {
nsIFrame* lastChild; nsIFrame* lastChild;
nsFrameItems(); nsFrameItems();
// Appends the frame to the end of the list
void AddChild(nsIFrame* aChild); void AddChild(nsIFrame* aChild);
void Clear();
}; };
nsFrameItems::nsFrameItems() nsFrameItems::nsFrameItems()
:childList(nsnull), lastChild(nsnull) :childList(nsnull), lastChild(nsnull)
{} {}
void
nsFrameItems::Clear()
{
childList = lastChild = nsnull;
}
void void
nsFrameItems::AddChild(nsIFrame* aChild) nsFrameItems::AddChild(nsIFrame* aChild)
{ {
@ -2000,7 +1995,6 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2196,7 +2190,6 @@ HTMLStyleSheetImpl::ConstructXULFrame(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2509,12 +2502,14 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsAbsoluteItems& aAbsoluteItems, nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aFrameItems) nsFrameItems& aFrameItems)
{ {
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
PRBool isAbsolutelyPositioned = PR_FALSE; PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isBlock = aDisplay->IsBlockLevel(); PRBool isBlock = aDisplay->IsBlockLevel();
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Get the position syle info
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
// Initialize frame // Initialize frame
nsIFrame* aNewFrame = nsnull; nsIFrame* aNewFrame = nsnull;
@ -2714,7 +2709,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
return rv; return rv;
@ -2820,7 +2814,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
@ -2952,7 +2945,6 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext->GetStyleData(eStyleStruct_Display); styleContext->GetStyleData(eStyleStruct_Display);
if (NS_STYLE_DISPLAY_NONE != display->mDisplay) { if (NS_STYLE_DISPLAY_NONE != display->mDisplay) {
nsIFrame* lastChild = aFrameItems.lastChild; nsIFrame* lastChild = aFrameItems.lastChild;
// Handle specific frame types // Handle specific frame types
@ -2960,16 +2952,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
#ifdef INCLUDE_XUL #ifdef INCLUDE_XUL
// failing to find a matching HTML frame, try creating a specialized // Failing to find a matching HTML frame, try creating a specialized
// XUL frame. this is temporary, pending planned factoring of this // XUL frame. This is temporary, pending planned factoring of this
// whole process into separate, pluggable steps. // whole process into separate, pluggable steps.
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
{ (lastChild == aFrameItems.lastChild))) {
PRBool haltProcessing = PR_FALSE; PRBool haltProcessing = PR_FALSE;
rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag, rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag,
styleContext, aAbsoluteItems, aFrameItems, haltProcessing); styleContext, aAbsoluteItems, aFrameItems, haltProcessing);
if (haltProcessing) if (haltProcessing) {
{
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
NS_IF_RELEASE(tag); NS_IF_RELEASE(tag);
return rv; return rv;
@ -2977,13 +2968,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
} }
#endif #endif
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) { if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
(lastChild == aFrameItems.lastChild))) {
// When there is no explicit frame to create, assume it's a // When there is no explicit frame to create, assume it's a
// container and let display style dictate the rest // container and let display style dictate the rest
rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame, rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
} }
} }
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
} }
@ -3151,8 +3144,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIFrame *adjustedParentFrame=parentFrame; nsIFrame *adjustedParentFrame=parentFrame;
firstAppendedFrame = frameItems.childList; firstAppendedFrame = frameItems.childList;
if (nsnull!=firstAppendedFrame) if (nsnull != firstAppendedFrame) {
{
const nsStyleDisplay* firstAppendedFrameDisplay; const nsStyleDisplay* firstAppendedFrameDisplay;
firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay); firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay);
result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame); result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame);

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

@ -229,20 +229,15 @@ struct nsFrameItems {
nsIFrame* lastChild; nsIFrame* lastChild;
nsFrameItems(); nsFrameItems();
// Appends the frame to the end of the list
void AddChild(nsIFrame* aChild); void AddChild(nsIFrame* aChild);
void Clear();
}; };
nsFrameItems::nsFrameItems() nsFrameItems::nsFrameItems()
:childList(nsnull), lastChild(nsnull) :childList(nsnull), lastChild(nsnull)
{} {}
void
nsFrameItems::Clear()
{
childList = lastChild = nsnull;
}
void void
nsFrameItems::AddChild(nsIFrame* aChild) nsFrameItems::AddChild(nsIFrame* aChild)
{ {
@ -2000,7 +1995,6 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2196,7 +2190,6 @@ HTMLStyleSheetImpl::ConstructXULFrame(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2509,12 +2502,14 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsAbsoluteItems& aAbsoluteItems, nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aFrameItems) nsFrameItems& aFrameItems)
{ {
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
PRBool isAbsolutelyPositioned = PR_FALSE; PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isBlock = aDisplay->IsBlockLevel(); PRBool isBlock = aDisplay->IsBlockLevel();
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Get the position syle info
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
// Initialize frame // Initialize frame
nsIFrame* aNewFrame = nsnull; nsIFrame* aNewFrame = nsnull;
@ -2714,7 +2709,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
return rv; return rv;
@ -2820,7 +2814,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
@ -2952,7 +2945,6 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext->GetStyleData(eStyleStruct_Display); styleContext->GetStyleData(eStyleStruct_Display);
if (NS_STYLE_DISPLAY_NONE != display->mDisplay) { if (NS_STYLE_DISPLAY_NONE != display->mDisplay) {
nsIFrame* lastChild = aFrameItems.lastChild; nsIFrame* lastChild = aFrameItems.lastChild;
// Handle specific frame types // Handle specific frame types
@ -2960,16 +2952,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
#ifdef INCLUDE_XUL #ifdef INCLUDE_XUL
// failing to find a matching HTML frame, try creating a specialized // Failing to find a matching HTML frame, try creating a specialized
// XUL frame. this is temporary, pending planned factoring of this // XUL frame. This is temporary, pending planned factoring of this
// whole process into separate, pluggable steps. // whole process into separate, pluggable steps.
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
{ (lastChild == aFrameItems.lastChild))) {
PRBool haltProcessing = PR_FALSE; PRBool haltProcessing = PR_FALSE;
rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag, rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag,
styleContext, aAbsoluteItems, aFrameItems, haltProcessing); styleContext, aAbsoluteItems, aFrameItems, haltProcessing);
if (haltProcessing) if (haltProcessing) {
{
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
NS_IF_RELEASE(tag); NS_IF_RELEASE(tag);
return rv; return rv;
@ -2977,13 +2968,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
} }
#endif #endif
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) { if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
(lastChild == aFrameItems.lastChild))) {
// When there is no explicit frame to create, assume it's a // When there is no explicit frame to create, assume it's a
// container and let display style dictate the rest // container and let display style dictate the rest
rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame, rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
} }
} }
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
} }
@ -3151,8 +3144,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIFrame *adjustedParentFrame=parentFrame; nsIFrame *adjustedParentFrame=parentFrame;
firstAppendedFrame = frameItems.childList; firstAppendedFrame = frameItems.childList;
if (nsnull!=firstAppendedFrame) if (nsnull != firstAppendedFrame) {
{
const nsStyleDisplay* firstAppendedFrameDisplay; const nsStyleDisplay* firstAppendedFrameDisplay;
firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay); firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay);
result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame); result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame);

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

@ -229,20 +229,15 @@ struct nsFrameItems {
nsIFrame* lastChild; nsIFrame* lastChild;
nsFrameItems(); nsFrameItems();
// Appends the frame to the end of the list
void AddChild(nsIFrame* aChild); void AddChild(nsIFrame* aChild);
void Clear();
}; };
nsFrameItems::nsFrameItems() nsFrameItems::nsFrameItems()
:childList(nsnull), lastChild(nsnull) :childList(nsnull), lastChild(nsnull)
{} {}
void
nsFrameItems::Clear()
{
childList = lastChild = nsnull;
}
void void
nsFrameItems::AddChild(nsIFrame* aChild) nsFrameItems::AddChild(nsIFrame* aChild)
{ {
@ -2000,7 +1995,6 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2196,7 +2190,6 @@ HTMLStyleSheetImpl::ConstructXULFrame(nsIPresContext* aPresContext,
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
} }
@ -2509,12 +2502,14 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
nsAbsoluteItems& aAbsoluteItems, nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aFrameItems) nsFrameItems& aFrameItems)
{ {
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
PRBool isAbsolutelyPositioned = PR_FALSE; PRBool isAbsolutelyPositioned = PR_FALSE;
PRBool isBlock = aDisplay->IsBlockLevel(); PRBool isBlock = aDisplay->IsBlockLevel();
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Get the position syle info
const nsStylePosition* position = (const nsStylePosition*)
aStyleContext->GetStyleData(eStyleStruct_Position);
// Initialize frame // Initialize frame
nsIFrame* aNewFrame = nsnull; nsIFrame* aNewFrame = nsnull;
@ -2714,7 +2709,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
return rv; return rv;
@ -2820,7 +2814,6 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresConte
aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame); aAbsoluteItems.AddAbsolutelyPositionedChild(aNewFrame);
// Add the placeholder frame to the flow // Add the placeholder frame to the flow
aFrameItems.Clear();
aFrameItems.AddChild(placeholderFrame); aFrameItems.AddChild(placeholderFrame);
} }
@ -2952,7 +2945,6 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext->GetStyleData(eStyleStruct_Display); styleContext->GetStyleData(eStyleStruct_Display);
if (NS_STYLE_DISPLAY_NONE != display->mDisplay) { if (NS_STYLE_DISPLAY_NONE != display->mDisplay) {
nsIFrame* lastChild = aFrameItems.lastChild; nsIFrame* lastChild = aFrameItems.lastChild;
// Handle specific frame types // Handle specific frame types
@ -2960,16 +2952,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
#ifdef INCLUDE_XUL #ifdef INCLUDE_XUL
// failing to find a matching HTML frame, try creating a specialized // Failing to find a matching HTML frame, try creating a specialized
// XUL frame. this is temporary, pending planned factoring of this // XUL frame. This is temporary, pending planned factoring of this
// whole process into separate, pluggable steps. // whole process into separate, pluggable steps.
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
{ (lastChild == aFrameItems.lastChild))) {
PRBool haltProcessing = PR_FALSE; PRBool haltProcessing = PR_FALSE;
rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag, rv = ConstructXULFrame(aPresContext, aContent, aParentFrame, tag,
styleContext, aAbsoluteItems, aFrameItems, haltProcessing); styleContext, aAbsoluteItems, aFrameItems, haltProcessing);
if (haltProcessing) if (haltProcessing) {
{
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
NS_IF_RELEASE(tag); NS_IF_RELEASE(tag);
return rv; return rv;
@ -2977,13 +2968,15 @@ HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext,
} }
#endif #endif
if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) || (lastChild == aFrameItems.lastChild))) { if (NS_SUCCEEDED(rv) && ((nsnull == aFrameItems.childList) ||
(lastChild == aFrameItems.lastChild))) {
// When there is no explicit frame to create, assume it's a // When there is no explicit frame to create, assume it's a
// container and let display style dictate the rest // container and let display style dictate the rest
rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame, rv = ConstructFrameByDisplayType(aPresContext, display, aContent, aParentFrame,
styleContext, aAbsoluteItems, aFrameItems); styleContext, aAbsoluteItems, aFrameItems);
} }
} }
NS_RELEASE(styleContext); NS_RELEASE(styleContext);
} }
@ -3151,8 +3144,7 @@ HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext,
nsresult result = NS_OK; nsresult result = NS_OK;
nsIFrame *adjustedParentFrame=parentFrame; nsIFrame *adjustedParentFrame=parentFrame;
firstAppendedFrame = frameItems.childList; firstAppendedFrame = frameItems.childList;
if (nsnull!=firstAppendedFrame) if (nsnull != firstAppendedFrame) {
{
const nsStyleDisplay* firstAppendedFrameDisplay; const nsStyleDisplay* firstAppendedFrameDisplay;
firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay); firstAppendedFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)firstAppendedFrameDisplay);
result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame); result = GetAdjustedParentFrame(parentFrame, firstAppendedFrameDisplay->mDisplay, adjustedParentFrame);