From 7f3c544b601b27745cad6d7df7bd1a59b7230b8c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 6 Oct 2003 04:23:56 +0000 Subject: [PATCH] Backing out for now, till fallout from tree redness settles. --- layout/generic/nsHTMLReflowState.cpp | 75 +++++++++++----------- layout/html/base/src/nsHTMLReflowState.cpp | 75 +++++++++++----------- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 2c0f23b121d..1432abdcf34 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" #include "nsStyleConsts.h" -#include "nsCSSAnonBoxes.h" #include "nsFrame.h" #include "nsIContent.h" #include "nsHTMLAtoms.h" @@ -1360,22 +1359,20 @@ GetVerticalMarginBorderPadding(const nsHTMLReflowState* aReflowState) /* Get the height based on the viewport of the containing block specified * in aReflowState when the containing block has mComputedHeight == NS_AUTOHEIGHT * This will walk up the chain of containing blocks looking for a computed height - * until it finds the canvas frame, or it encounters a frame that is not a block, - * area, or scroll frame. This handles compatibility with IE (see bug 85016 and bug 219693) + * until it finds the canvas frame, or it encounters a frame that is not a block + * or and area frame. This handles compatibility with IE (see bug 85016) * - * When the argument aRestrictToFirstLevel is TRUE, we stop looking after the second parent - * block, area, or scroll frame. When FALSE, we look all the way up the frame tree, through nested - * block, area, and scroll frames, and always find a real height. This is needed for percentage-height - * images in unconstrained blocks, like DIVs (see bugzilla bug 85016). - * - * When we encounter scrolledContent area frames, we skip over them, since they are guaranteed to not be useful for computing the containing block. + * When the argument aRestrictToFirstLevel is TRUE, we stop looking after the first parent + * block or area frame. When FALSE, we look all the way up the frame tree, through nested + * blocks and area frames, and always find a real height. This is needed for percentage-height + * images in unconstrained blocks, like DIVs (see bugzilla bug 85016) */ nscoord CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, PRBool aRestrictToFirstLevel) { - nsHTMLReflowState* firstAncestorRS = nsnull; // a candidate for html frame - nsHTMLReflowState* secondAncestorRS = nsnull; // a candidate for body frame + nsHTMLReflowState* firstBlockRS = nsnull; // a candidate for body frame + nsHTMLReflowState* firstAreaRS = nsnull; // a candidate for html frame // initialize the default to NS_AUTOHEIGHT as this is the containings block // computed height when this function is called. It is possible that we @@ -1388,23 +1385,25 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, rs->frame->GetFrameType(getter_AddRefs(frameType)); // if the ancestor is auto height then skip it and continue up if it // is the first block/area frame and possibly the body/html - if (nsLayoutAtoms::blockFrame == frameType || - nsLayoutAtoms::areaFrame == frameType || - nsLayoutAtoms::scrollFrame == frameType) { - nsCOMPtr pseudo = rs->frame->GetStyleContext()->GetPseudoType(); - if (pseudo == nsCSSAnonBoxes::scrolledContent) { - continue; - } - if (aRestrictToFirstLevel && firstAncestorRS && secondAncestorRS) { + if (nsLayoutAtoms::blockFrame == frameType.get()) { + if (aRestrictToFirstLevel && firstBlockRS) { break; } - secondAncestorRS = firstAncestorRS; - firstAncestorRS = (nsHTMLReflowState*)rs; + firstBlockRS = (nsHTMLReflowState*)rs; if (NS_AUTOHEIGHT == rs->mComputedHeight) { continue; } } - else if (nsLayoutAtoms::canvasFrame == frameType) { + else if (nsLayoutAtoms::areaFrame == frameType.get()) { + if (aRestrictToFirstLevel && firstAreaRS) { + break; + } + firstAreaRS = (nsHTMLReflowState*)rs; + if (NS_AUTOHEIGHT == rs->mComputedHeight) { + continue; + } + } + else if (nsLayoutAtoms::canvasFrame == frameType.get()) { // Use scroll frames' computed height if we have one, this will // allow us to get viewport height for native scrollbars. nsHTMLReflowState* scrollState = (nsHTMLReflowState *)rs->parentReflowState; @@ -1414,7 +1413,7 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, rs = scrollState; } } - else if (nsLayoutAtoms::pageContentFrame == frameType) { + else if (nsLayoutAtoms::pageContentFrame == frameType.get()) { nsIFrame* prevInFlow; rs->frame->GetPrevInFlow(&prevInFlow); // only use the page content frame for a height basis if it is the first in flow @@ -1427,35 +1426,35 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, // if the ancestor is the page content frame then the percent base is // the avail height, otherwise it is the computed height - result = (nsLayoutAtoms::pageContentFrame == frameType) + result = (nsLayoutAtoms::pageContentFrame == frameType.get()) ? rs->availableHeight : rs->mComputedHeight; // if unconstrained - don't sutract borders - would result in huge height if (NS_AUTOHEIGHT == result) return result; // if we got to the canvas or page content frame, then subtract out // margin/border/padding for the BODY and HTML elements - if ((nsLayoutAtoms::canvasFrame == frameType) || - (nsLayoutAtoms::pageContentFrame == frameType)) { + if ((nsLayoutAtoms::canvasFrame == frameType.get()) || + (nsLayoutAtoms::pageContentFrame == frameType.get())) { - result -= GetVerticalMarginBorderPadding(firstAncestorRS); - result -= GetVerticalMarginBorderPadding(secondAncestorRS); + result -= GetVerticalMarginBorderPadding(firstBlockRS); + result -= GetVerticalMarginBorderPadding(firstAreaRS); #ifdef DEBUG - // make sure the first ancestor is the HTML and the second is the BODY - if (firstAncestorRS) { - nsIContent* frameContent = firstAncestorRS->frame->GetContent(); + // make sure the Area is the HTML and the Block is the BODY + if (firstBlockRS) { + nsIContent* frameContent = firstBlockRS->frame->GetContent(); if (frameContent) { nsCOMPtr contentTag; frameContent->GetTag(getter_AddRefs(contentTag)); - NS_ASSERTION(contentTag == nsHTMLAtoms::html, "First ancestor is not HTML"); + NS_ASSERTION(contentTag.get() == nsHTMLAtoms::body, "block is not BODY"); } } - if (secondAncestorRS) { - nsIContent* frameContent = secondAncestorRS->frame->GetContent(); + if (firstAreaRS) { + nsIContent* frameContent = firstAreaRS->frame->GetContent(); if (frameContent) { nsCOMPtr contentTag; frameContent->GetTag(getter_AddRefs(contentTag)); - NS_ASSERTION(contentTag == nsHTMLAtoms::body, "Second ancestor is not BODY"); + NS_ASSERTION(contentTag.get() == nsHTMLAtoms::html, "Area frame is not HTML element"); } } #endif @@ -1463,12 +1462,12 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, } // if we got to the html frame, then subtract out // margin/border/padding for the BODY element - else if (nsLayoutAtoms::areaFrame == frameType) { + else if (nsLayoutAtoms::areaFrame == frameType.get()) { // make sure it is the body nsCOMPtr fType; rs->parentReflowState->frame->GetFrameType(getter_AddRefs(fType)); - if (nsLayoutAtoms::canvasFrame == fType) { - result -= GetVerticalMarginBorderPadding(secondAncestorRS); + if (nsLayoutAtoms::canvasFrame == fType.get()) { + result -= GetVerticalMarginBorderPadding(firstBlockRS); } } break; diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp index 2c0f23b121d..1432abdcf34 100644 --- a/layout/html/base/src/nsHTMLReflowState.cpp +++ b/layout/html/base/src/nsHTMLReflowState.cpp @@ -36,7 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" #include "nsStyleConsts.h" -#include "nsCSSAnonBoxes.h" #include "nsFrame.h" #include "nsIContent.h" #include "nsHTMLAtoms.h" @@ -1360,22 +1359,20 @@ GetVerticalMarginBorderPadding(const nsHTMLReflowState* aReflowState) /* Get the height based on the viewport of the containing block specified * in aReflowState when the containing block has mComputedHeight == NS_AUTOHEIGHT * This will walk up the chain of containing blocks looking for a computed height - * until it finds the canvas frame, or it encounters a frame that is not a block, - * area, or scroll frame. This handles compatibility with IE (see bug 85016 and bug 219693) + * until it finds the canvas frame, or it encounters a frame that is not a block + * or and area frame. This handles compatibility with IE (see bug 85016) * - * When the argument aRestrictToFirstLevel is TRUE, we stop looking after the second parent - * block, area, or scroll frame. When FALSE, we look all the way up the frame tree, through nested - * block, area, and scroll frames, and always find a real height. This is needed for percentage-height - * images in unconstrained blocks, like DIVs (see bugzilla bug 85016). - * - * When we encounter scrolledContent area frames, we skip over them, since they are guaranteed to not be useful for computing the containing block. + * When the argument aRestrictToFirstLevel is TRUE, we stop looking after the first parent + * block or area frame. When FALSE, we look all the way up the frame tree, through nested + * blocks and area frames, and always find a real height. This is needed for percentage-height + * images in unconstrained blocks, like DIVs (see bugzilla bug 85016) */ nscoord CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, PRBool aRestrictToFirstLevel) { - nsHTMLReflowState* firstAncestorRS = nsnull; // a candidate for html frame - nsHTMLReflowState* secondAncestorRS = nsnull; // a candidate for body frame + nsHTMLReflowState* firstBlockRS = nsnull; // a candidate for body frame + nsHTMLReflowState* firstAreaRS = nsnull; // a candidate for html frame // initialize the default to NS_AUTOHEIGHT as this is the containings block // computed height when this function is called. It is possible that we @@ -1388,23 +1385,25 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, rs->frame->GetFrameType(getter_AddRefs(frameType)); // if the ancestor is auto height then skip it and continue up if it // is the first block/area frame and possibly the body/html - if (nsLayoutAtoms::blockFrame == frameType || - nsLayoutAtoms::areaFrame == frameType || - nsLayoutAtoms::scrollFrame == frameType) { - nsCOMPtr pseudo = rs->frame->GetStyleContext()->GetPseudoType(); - if (pseudo == nsCSSAnonBoxes::scrolledContent) { - continue; - } - if (aRestrictToFirstLevel && firstAncestorRS && secondAncestorRS) { + if (nsLayoutAtoms::blockFrame == frameType.get()) { + if (aRestrictToFirstLevel && firstBlockRS) { break; } - secondAncestorRS = firstAncestorRS; - firstAncestorRS = (nsHTMLReflowState*)rs; + firstBlockRS = (nsHTMLReflowState*)rs; if (NS_AUTOHEIGHT == rs->mComputedHeight) { continue; } } - else if (nsLayoutAtoms::canvasFrame == frameType) { + else if (nsLayoutAtoms::areaFrame == frameType.get()) { + if (aRestrictToFirstLevel && firstAreaRS) { + break; + } + firstAreaRS = (nsHTMLReflowState*)rs; + if (NS_AUTOHEIGHT == rs->mComputedHeight) { + continue; + } + } + else if (nsLayoutAtoms::canvasFrame == frameType.get()) { // Use scroll frames' computed height if we have one, this will // allow us to get viewport height for native scrollbars. nsHTMLReflowState* scrollState = (nsHTMLReflowState *)rs->parentReflowState; @@ -1414,7 +1413,7 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, rs = scrollState; } } - else if (nsLayoutAtoms::pageContentFrame == frameType) { + else if (nsLayoutAtoms::pageContentFrame == frameType.get()) { nsIFrame* prevInFlow; rs->frame->GetPrevInFlow(&prevInFlow); // only use the page content frame for a height basis if it is the first in flow @@ -1427,35 +1426,35 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, // if the ancestor is the page content frame then the percent base is // the avail height, otherwise it is the computed height - result = (nsLayoutAtoms::pageContentFrame == frameType) + result = (nsLayoutAtoms::pageContentFrame == frameType.get()) ? rs->availableHeight : rs->mComputedHeight; // if unconstrained - don't sutract borders - would result in huge height if (NS_AUTOHEIGHT == result) return result; // if we got to the canvas or page content frame, then subtract out // margin/border/padding for the BODY and HTML elements - if ((nsLayoutAtoms::canvasFrame == frameType) || - (nsLayoutAtoms::pageContentFrame == frameType)) { + if ((nsLayoutAtoms::canvasFrame == frameType.get()) || + (nsLayoutAtoms::pageContentFrame == frameType.get())) { - result -= GetVerticalMarginBorderPadding(firstAncestorRS); - result -= GetVerticalMarginBorderPadding(secondAncestorRS); + result -= GetVerticalMarginBorderPadding(firstBlockRS); + result -= GetVerticalMarginBorderPadding(firstAreaRS); #ifdef DEBUG - // make sure the first ancestor is the HTML and the second is the BODY - if (firstAncestorRS) { - nsIContent* frameContent = firstAncestorRS->frame->GetContent(); + // make sure the Area is the HTML and the Block is the BODY + if (firstBlockRS) { + nsIContent* frameContent = firstBlockRS->frame->GetContent(); if (frameContent) { nsCOMPtr contentTag; frameContent->GetTag(getter_AddRefs(contentTag)); - NS_ASSERTION(contentTag == nsHTMLAtoms::html, "First ancestor is not HTML"); + NS_ASSERTION(contentTag.get() == nsHTMLAtoms::body, "block is not BODY"); } } - if (secondAncestorRS) { - nsIContent* frameContent = secondAncestorRS->frame->GetContent(); + if (firstAreaRS) { + nsIContent* frameContent = firstAreaRS->frame->GetContent(); if (frameContent) { nsCOMPtr contentTag; frameContent->GetTag(getter_AddRefs(contentTag)); - NS_ASSERTION(contentTag == nsHTMLAtoms::body, "Second ancestor is not BODY"); + NS_ASSERTION(contentTag.get() == nsHTMLAtoms::html, "Area frame is not HTML element"); } } #endif @@ -1463,12 +1462,12 @@ CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, } // if we got to the html frame, then subtract out // margin/border/padding for the BODY element - else if (nsLayoutAtoms::areaFrame == frameType) { + else if (nsLayoutAtoms::areaFrame == frameType.get()) { // make sure it is the body nsCOMPtr fType; rs->parentReflowState->frame->GetFrameType(getter_AddRefs(fType)); - if (nsLayoutAtoms::canvasFrame == fType) { - result -= GetVerticalMarginBorderPadding(secondAncestorRS); + if (nsLayoutAtoms::canvasFrame == fType.get()) { + result -= GetVerticalMarginBorderPadding(firstBlockRS); } } break;