Bug 288117. Fix regressions in nsDocShell::SetCanvasHasFocus and in nsListBoxBodyFrame/nsListBoxObject where code made obsolete assumptions about scrollframe structure. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2005-04-03 21:02:47 +00:00
parent 20d333fbf6
commit fb05d807b2
4 changed files with 29 additions and 51 deletions

View File

@ -7129,9 +7129,10 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus)
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsICanvasFrame), (void**)&canvasFrame))) {
canvasFrame->SetHasFocus(aCanvasHasFocus);
nsIView* canvasView = frame->GetViewExternal();
canvasView->GetViewManager()->UpdateView(canvasView, NS_VMREFRESH_NO_SYNC);
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
}
return NS_OK;
}

View File

@ -4635,18 +4635,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement,
rootFrame->Init(presContext, aDocElement, parentFrame,
rootPseudoStyle, nsnull);
if (!isPaginated || isPrintPreview) {
if (isScrollable) {
FinishBuildingScrollFrame(parentFrame, rootFrame);
// Don't set the root as the primary frame for aDocElement. Its
// primary frame will be set in ConstructDocElementFrame.
} else { // if not scrollable
if (!isXUL) { // if not XUL
parentFrame->SetInitialChildList(presContext, nsnull, rootFrame);
}
}
}
if (isScrollable) {
FinishBuildingScrollFrame(parentFrame, rootFrame);
}
if (isPaginated) { // paginated
// Create the first page
@ -4665,9 +4656,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement,
*aNewFrame = viewportFrame;
return NS_OK;
return NS_OK;
}
nsresult

View File

@ -236,11 +236,7 @@ nsListBoxBodyFrame::Init(nsPresContext* aPresContext, nsIContent* aContent,
mOnePixel = aPresContext->IntScaledPixelsToTwips(1);
nsIFrame* box = aParent->GetParent();
if (!box)
return rv;
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(box));
nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this);
if (!scrollFrame)
return rv;
@ -264,7 +260,6 @@ nsListBoxBodyFrame::Init(nsPresContext* aPresContext, nsIContent* aContent,
fm->GetHeight(mRowHeight);
return rv;
}
NS_IMETHODIMP
@ -344,6 +339,7 @@ nsListBoxBodyFrame::NeedsRecalc()
{
mStringWidth = -1;
return nsBoxFrame::NeedsRecalc();
printf("*** nsListBoxBodyFrame::NeedsRecalc %p\n", this);
}
/////////// nsBox ///////////////
@ -393,6 +389,10 @@ nsListBoxBodyFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize
nsresult rv = nsBoxFrame::GetPrefSize(aBoxLayoutState, aSize);
PRInt32 size = GetFixedRowSize();
nsIBox* box = nsnull;
GetChildBox(&box);
printf("nsListBoxBodyFrame::GetPrefSize %p childbox=%p rowsize=%d height=%d newHeight=%d\n", this,
box, size, aSize.height, size*GetRowHeightTwips());
if (size > -1)
aSize.height = size*GetRowHeightTwips();
@ -713,6 +713,8 @@ nsListBoxBodyFrame::GetFixedRowSize()
void
nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight)
{
printf("*** Setting rowheight on %p to %d (current %d)\n", this,
aRowHeight, mRowHeight);
if (aRowHeight > mRowHeight) {
mRowHeight = aRowHeight;
@ -737,20 +739,16 @@ nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight)
// so we can create or destory rows as needed
mRowHeightWasSet = PR_TRUE;
PostReflowCallback();
}
}
}
nscoord
nsListBoxBodyFrame::GetAvailableHeight()
{
nsIBox* box;
GetParentBox(&box);
if (!box)
return 0;
nsRect contentRect;
box->GetContentRect(contentRect);
return contentRect.height;
nsIScrollableFrame* scrollFrame
= nsLayoutUtils::GetScrollableFrameFor(this);
nsIScrollableView* scrollView = scrollFrame->GetScrollableView();
return scrollView->View()->GetBounds().height;
}
nscoord
@ -987,18 +985,8 @@ nsListBoxBodyFrame::GetSmoother()
void
nsListBoxBodyFrame::VerticalScroll(PRInt32 aPosition)
{
nsIBox* box;
GetParentBox(&box);
if (!box)
return;
box->GetParentBox(&box);
if (!box)
return;
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(box));
if (!scrollFrame)
return;
nsIScrollableFrame* scrollFrame
= nsLayoutUtils::GetScrollableFrameFor(this);
nsPoint scrollPosition = scrollFrame->GetScrollPosition();

View File

@ -46,6 +46,7 @@
#include "nsIDOMElement.h"
#include "nsIDOMNodeList.h"
#include "nsXULAtoms.h"
#include "nsIScrollableFrame.h"
class nsListBoxObject : public nsIListBoxObject, public nsBoxObject
{
@ -227,14 +228,13 @@ nsListBoxObject::GetListBoxBody()
mPresShell->GetPrimaryFrameFor(content, &frame);
if (!frame)
return nsnull;
// this frame will be a nsScrollBoxFrame
nsIFrame* scrollPort = frame->GetFirstChild(nsnull);
if (!scrollPort)
return nsnull;
nsIScrollableFrame* scrollFrame;
CallQueryInterface(frame, &scrollFrame);
if (!scrollFrame)
return nsnull;
// this frame will be the one we want
nsIFrame* yeahBaby = scrollPort->GetFirstChild(nsnull);
nsIFrame* yeahBaby = scrollFrame->GetScrolledFrame();
if (!yeahBaby)
return nsnull;