Create a rendering context before calling GetPrefSize and friends and assert in those methods that we have one. b=379090 r+sr=dbaron

This commit is contained in:
mats.palmgren@bredband.net 2007-04-29 15:24:59 -07:00
Родитель 3552c2e515
Коммит 96d3d9687b
3 изменённых файлов: 22 добавлений и 4 удалений

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

@ -456,6 +456,8 @@ nsBox::GetLayoutManager(nsIBoxLayout** aLayout)
nsSize
nsBox::GetPrefSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize pref(0,0);
DISPLAY_PREF_SIZE(this, pref);
@ -475,6 +477,8 @@ nsBox::GetPrefSize(nsBoxLayoutState& aState)
nsSize
nsBox::GetMinSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize min(0,0);
DISPLAY_MIN_SIZE(this, min);
@ -495,6 +499,8 @@ nsBox::GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState)
nsSize
nsBox::GetMaxSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize max(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
DISPLAY_MAX_SIZE(this, max);
@ -547,6 +553,8 @@ nsBox::IsCollapsed(nsBoxLayoutState& aState)
nsresult
nsIFrame::Layout(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsBox *box = NS_STATIC_CAST(nsBox*, this);
DISPLAY_LAYOUT(box);

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

@ -804,6 +804,9 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
nsSize
nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
{
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
"must have rendering context");
nsSize size(0,0);
DISPLAY_PREF_SIZE(this, size);
if (!DoesNeedRecalc(mPrefSize)) {
@ -860,6 +863,9 @@ nsBoxFrame::GetBoxAscent(nsBoxLayoutState& aBoxLayoutState)
nsSize
nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
{
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
"must have rendering context");
nsSize size(0,0);
DISPLAY_MIN_SIZE(this, size);
if (!DoesNeedRecalc(mMinSize)) {
@ -893,6 +899,9 @@ nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
nsSize
nsBoxFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState)
{
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
"must have rendering context");
nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
DISPLAY_MAX_SIZE(this, size);
if (!DoesNeedRecalc(mMaxSize)) {

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

@ -724,9 +724,11 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
if (childIndex == 0 || childIndex == childCount - 1)
return NS_OK;
// XXXbz using this state for GetPrefSize/GetMinSize is wrong. It
// needs a rendering context!
nsBoxLayoutState state(outerPresContext);
nsCOMPtr<nsIRenderingContext> rc;
nsresult rv = outerPresContext->PresShell()->
CreateRenderingContext(mOuter, getter_AddRefs(rc));
NS_ENSURE_SUCCESS(rv, rv);
nsBoxLayoutState state(outerPresContext, rc);
mCurrentPos = 0;
mPressed = PR_TRUE;
@ -753,7 +755,6 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
while (nsnull != childBox)
{
nsIContent* content = childBox->GetContent();
nsresult rv;
nsIDocument* doc = content->GetOwnerDoc();
nsIAtom* atom;
if (doc) {