Make sure to properly delegate all framelist updates to our anonymous div. Bug

226016/98239, r+sr=dbaron
This commit is contained in:
bzbarsky@mit.edu
2003-11-18 02:12:24 +00:00
parent d301b2207f
commit 7563f70754
4 changed files with 172 additions and 62 deletions

View File

@@ -218,6 +218,22 @@ nsHTMLButtonControlFrame::GetValue(nsAString* aResult)
return nsFormControlHelper::GetValueAttr(mContent, aResult);
}
void
nsHTMLButtonControlFrame::ReParentFrameList(nsIFrameManager* aFrameManager,
nsIFrame* aFrameList)
{
// get the new parent context from the first child: that is the
// frame that the subsequent children will be made children of
nsStyleContext* newParentContext = mFrames.FirstChild()->GetStyleContext();
// Set the parent for each of the child frames
for (nsIFrame* frame = aFrameList; frame; frame = frame->GetNextSibling()) {
frame->SetParent(mFrames.FirstChild());
// now reparent the contexts for the reparented frame too
aFrameManager->ReParentStyleContext(frame, newParentContext);
}
}
PRBool
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
{
@@ -317,31 +333,9 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
// get the frame manager and the style context of the new parent frame
// this is used whent he children are reparented below
// NOTE: the whole reparenting should not need to happen: see bugzilla bug 51767
//
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIFrameManager> frameManager;
nsStyleContext* newParentContext;
aPresContext->GetShell(getter_AddRefs(shell));
if (shell) {
shell->GetFrameManager(getter_AddRefs(frameManager));
}
// get the new parent context from the first child: that is the frame that the
// subsequent children will be made children of
newParentContext = mFrames.FirstChild()->GetStyleContext();
// Set the parent for each of the child frames
for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) {
frame->SetParent(mFrames.FirstChild());
// now reparent the contexts for the reparented frame too
if (frameManager) {
frameManager->ReParentStyleContext(frame, newParentContext);
}
}
// Queue up the frames for the inline frame
ReParentFrameList(aPresContext->GetFrameManager(), aChildList);
return mFrames.FirstChild()->SetInitialChildList(aPresContext, nsnull, aChildList);
}
@@ -722,10 +716,53 @@ nsHTMLButtonControlFrame::AppendFrames(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
ReParentFrameList(aPresContext->GetFrameManager(), aFrameList);
return mFrames.FirstChild()->AppendFrames(aPresContext,
aPresShell,
aListName,
aFrameList);
aPresShell,
aListName,
aFrameList);
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
ReParentFrameList(aPresContext->GetFrameManager(), aFrameList);
return mFrames.FirstChild()->InsertFrames(aPresContext,
aPresShell,
aListName,
aPrevFrame,
aFrameList);
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
return mFrames.FirstChild()->RemoveFrame(aPresContext,
aPresShell,
aListName,
aOldFrame);
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::ReplaceFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame,
nsIFrame* aNewFrame)
{
ReParentFrameList(aPresContext->GetFrameManager(), aNewFrame);
return mFrames.FirstChild()->ReplaceFrame(aPresContext,
aPresShell,
aListName,
aOldFrame,
aNewFrame);
}
NS_IMETHODIMP