Fix for bug #13176. Changed CantRenderReplacedElement() to reset the

primary frame mapping for OBJECT elements
This commit is contained in:
troy%netscape.com 1999-09-07 02:42:00 +00:00
Родитель 1ef97aa745
Коммит d16e70fca7
2 изменённых файлов: 86 добавлений и 88 удалений

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

@ -7029,6 +7029,37 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex
return rv; return rv;
} }
static inline void
ReplaceFrame(nsIPresContext* aPresContext,
nsIPresShell* aPresShell,
nsIFrameManager* aFrameManager,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aOldFrame,
nsIFrame* aNewFrame,
nsIFrame* aPlaceholderFrame)
{
// Reset the primary frame mapping
aFrameManager->SetPrimaryFrameFor(aContent, aNewFrame);
if (aPlaceholderFrame) {
// Remove the association between the old frame and its placeholder
aFrameManager->SetPlaceholderFrameFor(aOldFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the
// new frame
aFrameManager->SetPlaceholderFrameFor(aNewFrame, aPlaceholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)aPlaceholderFrame)->SetOutOfFlowFrame(aNewFrame);
}
// Replace the old frame with the new frame
aFrameManager->ReplaceFrame(*aPresContext, *aPresShell, aParentFrame,
aListName, aOldFrame, aNewFrame);
}
NS_IMETHODIMP NS_IMETHODIMP
nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext, nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
@ -7078,36 +7109,16 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
nsCOMPtr<nsIFrameManager> frameManager; nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager)); presShell->GetFrameManager(getter_AddRefs(frameManager));
// Delete the current frame // Replace the old frame with the new frame
frameManager->RemoveFrame(*aPresContext, *presShell, parentFrame, ReplaceFrame(aPresContext, presShell, frameManager, content,
listName, aFrame); parentFrame, listName, aFrame, newFrame, placeholderFrame);
// Reset the primary frame mapping
frameManager->SetPrimaryFrameFor(content, newFrame);
if (placeholderFrame) {
// Remove the association between the old frame and its placeholder
frameManager->SetPlaceholderFrameFor(aFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the
// new frame
frameManager->SetPlaceholderFrameFor(newFrame, placeholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)placeholderFrame)->SetOutOfFlowFrame(newFrame);
}
// Insert the new frame
frameManager->InsertFrames(*aPresContext, *presShell, parentFrame, listName,
prevSibling, newFrame);
} }
} else if ((nsHTMLAtoms::object == tag.get()) || } else if ((nsHTMLAtoms::object == tag.get()) ||
(nsHTMLAtoms::embed == tag.get()) || (nsHTMLAtoms::embed == tag.get()) ||
(nsHTMLAtoms::applet == tag.get())) { (nsHTMLAtoms::applet == tag.get())) {
// It's an OBJECT element or APPLET, so we should display the contents // It's an OBJECT element or APPLET, so we should display the contents
// instead. Create a frame based on the display type // instead
nsFrameConstructorState state(aPresContext, mFixedContainingBlock, nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
GetAbsoluteContainingBlock(aPresContext, parentFrame), GetAbsoluteContainingBlock(aPresContext, parentFrame),
GetFloaterContainingBlock(aPresContext, parentFrame)); GetFloaterContainingBlock(aPresContext, parentFrame));
@ -7115,28 +7126,16 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
const nsStyleDisplay* display = (const nsStyleDisplay*) const nsStyleDisplay* display = (const nsStyleDisplay*)
styleContext->GetStyleData(eStyleStruct_Display); styleContext->GetStyleData(eStyleStruct_Display);
// Create a frame based on the display type
rv = ConstructFrameByDisplayType(aPresContext, state, display, content, rv = ConstructFrameByDisplayType(aPresContext, state, display, content,
parentFrame, styleContext, PR_FALSE, frameItems); parentFrame, styleContext, PR_FALSE, frameItems);
nsIFrame* newFrame = frameItems.childList;
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Delete the current frame and insert the new frame nsIFrame* newFrame = frameItems.childList;
state.mFrameManager->RemoveFrame(*aPresContext, *presShell, parentFrame,
listName, aFrame);
if (placeholderFrame) {
// Remove the association between the old frame and its placeholder
state.mFrameManager->SetPlaceholderFrameFor(aFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the // Replace the old frame with the new frame
// new frame ReplaceFrame(aPresContext, presShell, state.mFrameManager, content,
state.mFrameManager->SetPlaceholderFrameFor(newFrame, placeholderFrame); parentFrame, listName, aFrame, newFrame, placeholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)placeholderFrame)->SetOutOfFlowFrame(newFrame);
}
state.mFrameManager->InsertFrames(*aPresContext, *presShell, parentFrame,
listName, prevSibling, newFrame);
// If there are new absolutely positioned child frames, then notify // If there are new absolutely positioned child frames, then notify
// the parent // the parent

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

@ -7029,6 +7029,37 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex
return rv; return rv;
} }
static inline void
ReplaceFrame(nsIPresContext* aPresContext,
nsIPresShell* aPresShell,
nsIFrameManager* aFrameManager,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aOldFrame,
nsIFrame* aNewFrame,
nsIFrame* aPlaceholderFrame)
{
// Reset the primary frame mapping
aFrameManager->SetPrimaryFrameFor(aContent, aNewFrame);
if (aPlaceholderFrame) {
// Remove the association between the old frame and its placeholder
aFrameManager->SetPlaceholderFrameFor(aOldFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the
// new frame
aFrameManager->SetPlaceholderFrameFor(aNewFrame, aPlaceholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)aPlaceholderFrame)->SetOutOfFlowFrame(aNewFrame);
}
// Replace the old frame with the new frame
aFrameManager->ReplaceFrame(*aPresContext, *aPresShell, aParentFrame,
aListName, aOldFrame, aNewFrame);
}
NS_IMETHODIMP NS_IMETHODIMP
nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext, nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
@ -7078,36 +7109,16 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
nsCOMPtr<nsIFrameManager> frameManager; nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager)); presShell->GetFrameManager(getter_AddRefs(frameManager));
// Delete the current frame // Replace the old frame with the new frame
frameManager->RemoveFrame(*aPresContext, *presShell, parentFrame, ReplaceFrame(aPresContext, presShell, frameManager, content,
listName, aFrame); parentFrame, listName, aFrame, newFrame, placeholderFrame);
// Reset the primary frame mapping
frameManager->SetPrimaryFrameFor(content, newFrame);
if (placeholderFrame) {
// Remove the association between the old frame and its placeholder
frameManager->SetPlaceholderFrameFor(aFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the
// new frame
frameManager->SetPlaceholderFrameFor(newFrame, placeholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)placeholderFrame)->SetOutOfFlowFrame(newFrame);
}
// Insert the new frame
frameManager->InsertFrames(*aPresContext, *presShell, parentFrame, listName,
prevSibling, newFrame);
} }
} else if ((nsHTMLAtoms::object == tag.get()) || } else if ((nsHTMLAtoms::object == tag.get()) ||
(nsHTMLAtoms::embed == tag.get()) || (nsHTMLAtoms::embed == tag.get()) ||
(nsHTMLAtoms::applet == tag.get())) { (nsHTMLAtoms::applet == tag.get())) {
// It's an OBJECT element or APPLET, so we should display the contents // It's an OBJECT element or APPLET, so we should display the contents
// instead. Create a frame based on the display type // instead
nsFrameConstructorState state(aPresContext, mFixedContainingBlock, nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
GetAbsoluteContainingBlock(aPresContext, parentFrame), GetAbsoluteContainingBlock(aPresContext, parentFrame),
GetFloaterContainingBlock(aPresContext, parentFrame)); GetFloaterContainingBlock(aPresContext, parentFrame));
@ -7115,28 +7126,16 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresContext* aPresContext,
const nsStyleDisplay* display = (const nsStyleDisplay*) const nsStyleDisplay* display = (const nsStyleDisplay*)
styleContext->GetStyleData(eStyleStruct_Display); styleContext->GetStyleData(eStyleStruct_Display);
// Create a frame based on the display type
rv = ConstructFrameByDisplayType(aPresContext, state, display, content, rv = ConstructFrameByDisplayType(aPresContext, state, display, content,
parentFrame, styleContext, PR_FALSE, frameItems); parentFrame, styleContext, PR_FALSE, frameItems);
nsIFrame* newFrame = frameItems.childList;
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Delete the current frame and insert the new frame nsIFrame* newFrame = frameItems.childList;
state.mFrameManager->RemoveFrame(*aPresContext, *presShell, parentFrame,
listName, aFrame);
if (placeholderFrame) {
// Remove the association between the old frame and its placeholder
state.mFrameManager->SetPlaceholderFrameFor(aFrame, nsnull);
// Reuse the existing placeholder frame, and add an association to the // Replace the old frame with the new frame
// new frame ReplaceFrame(aPresContext, presShell, state.mFrameManager, content,
state.mFrameManager->SetPlaceholderFrameFor(newFrame, placeholderFrame); parentFrame, listName, aFrame, newFrame, placeholderFrame);
// Placeholder frames have a pointer back to the out-of-flow frame.
// Make sure that's correct
((nsPlaceholderFrame*)placeholderFrame)->SetOutOfFlowFrame(newFrame);
}
state.mFrameManager->InsertFrames(*aPresContext, *presShell, parentFrame,
listName, prevSibling, newFrame);
// If there are new absolutely positioned child frames, then notify // If there are new absolutely positioned child frames, then notify
// the parent // the parent