1) This adds in a new layout atom for the SequenceFrame
2) Now checks all the SeqFrame's children (PageFrames) instead of just the first one Bug 71609 r=dcone sr=attinasi a=asa
This commit is contained in:
@@ -3423,28 +3423,37 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
|
|||||||
// this is the frame where the right-hand side of the frame extends
|
// this is the frame where the right-hand side of the frame extends
|
||||||
// the furthest
|
// the furthest
|
||||||
if (mPrt->mShrinkToFit) {
|
if (mPrt->mShrinkToFit) {
|
||||||
// find pageContent frame
|
// First find the seq frame
|
||||||
nsIFrame* rootFrame;
|
nsIFrame* rootFrame;
|
||||||
aPO->mPresShell->GetRootFrame(&rootFrame);
|
aPO->mPresShell->GetRootFrame(&rootFrame);
|
||||||
NS_ASSERTION(rootFrame, "There has to be a root frame!");
|
NS_ASSERTION(rootFrame, "There has to be a root frame!");
|
||||||
if (rootFrame) {
|
if (rootFrame) {
|
||||||
nsIFrame* child;
|
nsIFrame* seqFrame;
|
||||||
rootFrame->FirstChild(aPO->mPresContext, nsnull, &child);
|
rootFrame->FirstChild(aPO->mPresContext, nsnull, &seqFrame);
|
||||||
while (child) {
|
while (seqFrame) {
|
||||||
nsCOMPtr<nsIAtom> frameType;
|
nsCOMPtr<nsIAtom> frameType;
|
||||||
child->GetFrameType(getter_AddRefs(frameType));
|
seqFrame->GetFrameType(getter_AddRefs(frameType));
|
||||||
if (nsLayoutAtoms::pageContentFrame == frameType.get()) { // placeholder
|
if (nsLayoutAtoms::sequenceFrame == frameType.get()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
child->FirstChild(aPO->mPresContext, nsnull, &child);
|
seqFrame->FirstChild(aPO->mPresContext, nsnull, &seqFrame);
|
||||||
}
|
}
|
||||||
NS_ASSERTION(child, "There has to be a page content frame!");
|
NS_ASSERTION(seqFrame, "There has to be a Sequence frame!");
|
||||||
// Now get it's first child (area frame)
|
if (seqFrame) {
|
||||||
|
// Get the first page of all the pages
|
||||||
|
nsIFrame* pageFrame;
|
||||||
|
seqFrame->FirstChild(aPO->mPresContext, nsnull, &pageFrame);
|
||||||
|
NS_ASSERTION(pageFrame, "There has to be a Page Frame!");
|
||||||
|
// loop thru all the Page Frames
|
||||||
|
nscoord overallMaxWidth = 0;
|
||||||
|
nscoord overMaxRectWidth = 0;
|
||||||
|
while (pageFrame) {
|
||||||
|
nsIFrame* child;
|
||||||
|
// Now get it's first child (for HTML docs it is an area frame)
|
||||||
// then gets it size which would be the size it is suppose to be to fit
|
// then gets it size which would be the size it is suppose to be to fit
|
||||||
if (child) {
|
pageFrame->FirstChild(aPO->mPresContext, nsnull, &child);
|
||||||
child->FirstChild(aPO->mPresContext, nsnull, &child);
|
|
||||||
NS_ASSERTION(child, "There has to be a child frame!");
|
NS_ASSERTION(child, "There has to be a child frame!");
|
||||||
if (child) {
|
|
||||||
nsRect rect;
|
nsRect rect;
|
||||||
child->GetRect(rect);
|
child->GetRect(rect);
|
||||||
// Create a RenderingContext and set the PresContext
|
// Create a RenderingContext and set the PresContext
|
||||||
@@ -3458,11 +3467,21 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
|
|||||||
// then calc the ratio for shrinkage
|
// then calc the ratio for shrinkage
|
||||||
nscoord maxWidth = 0;
|
nscoord maxWidth = 0;
|
||||||
FindXMostFrameSize(aPO->mPresContext, rc, child, 0, 0, maxWidth);
|
FindXMostFrameSize(aPO->mPresContext, rc, child, 0, 0, maxWidth);
|
||||||
float ratio = float(rect.width) / float(maxWidth);
|
if (maxWidth > overallMaxWidth) {
|
||||||
aPO->mXMost = maxWidth;
|
overallMaxWidth = maxWidth;
|
||||||
|
overMaxRectWidth = rect.width;
|
||||||
|
}
|
||||||
|
pageFrame->GetNextSibling(&pageFrame);
|
||||||
|
} // while
|
||||||
|
// Now calc the ratio from the widest frames from all the pages
|
||||||
|
float ratio = 1.0f;
|
||||||
|
NS_ASSERTION(overallMaxWidth, "Overall Max Width must be bigger than zero");
|
||||||
|
if (overallMaxWidth > 0) {
|
||||||
|
ratio = float(overMaxRectWidth) / float(overallMaxWidth);
|
||||||
|
aPO->mXMost = overallMaxWidth;
|
||||||
aPO->mShrinkRatio = PR_MIN(ratio, 1.0f);
|
aPO->mShrinkRatio = PR_MIN(ratio, 1.0f);
|
||||||
#ifdef DEBUG_PRINTING
|
#ifdef DEBUG_PRINTING
|
||||||
printf("PO %p ****** RW: %d MW: %d xMost %d width: %d %10.4f\n", aPO, rect.width, maxWidth, aPO->mXMost, rect.width, ratio*100.0);
|
printf("PO %p ****** RW: %d MW: %d xMost %d width: %d %10.4f\n", aPO, overMaxRectWidth, overallMaxWidth, aPO->mXMost, overMaxRectWidth, ratio*100.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ LAYOUT_ATOM(positionedInlineFrame, "PositionedInlineFrame")
|
|||||||
LAYOUT_ATOM(canvasFrame, "CanvasFrame")
|
LAYOUT_ATOM(canvasFrame, "CanvasFrame")
|
||||||
LAYOUT_ATOM(rootFrame, "RootFrame")
|
LAYOUT_ATOM(rootFrame, "RootFrame")
|
||||||
LAYOUT_ATOM(scrollFrame, "ScrollFrame")
|
LAYOUT_ATOM(scrollFrame, "ScrollFrame")
|
||||||
|
LAYOUT_ATOM(sequenceFrame, "SequenceFrame")
|
||||||
LAYOUT_ATOM(tableCaptionFrame, "TableCaptionFrame")
|
LAYOUT_ATOM(tableCaptionFrame, "TableCaptionFrame")
|
||||||
LAYOUT_ATOM(tableCellFrame, "TableCellFrame")
|
LAYOUT_ATOM(tableCellFrame, "TableCellFrame")
|
||||||
LAYOUT_ATOM(tableColFrame, "TableColFrame")
|
LAYOUT_ATOM(tableColFrame, "TableColFrame")
|
||||||
|
|||||||
@@ -3423,28 +3423,37 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
|
|||||||
// this is the frame where the right-hand side of the frame extends
|
// this is the frame where the right-hand side of the frame extends
|
||||||
// the furthest
|
// the furthest
|
||||||
if (mPrt->mShrinkToFit) {
|
if (mPrt->mShrinkToFit) {
|
||||||
// find pageContent frame
|
// First find the seq frame
|
||||||
nsIFrame* rootFrame;
|
nsIFrame* rootFrame;
|
||||||
aPO->mPresShell->GetRootFrame(&rootFrame);
|
aPO->mPresShell->GetRootFrame(&rootFrame);
|
||||||
NS_ASSERTION(rootFrame, "There has to be a root frame!");
|
NS_ASSERTION(rootFrame, "There has to be a root frame!");
|
||||||
if (rootFrame) {
|
if (rootFrame) {
|
||||||
nsIFrame* child;
|
nsIFrame* seqFrame;
|
||||||
rootFrame->FirstChild(aPO->mPresContext, nsnull, &child);
|
rootFrame->FirstChild(aPO->mPresContext, nsnull, &seqFrame);
|
||||||
while (child) {
|
while (seqFrame) {
|
||||||
nsCOMPtr<nsIAtom> frameType;
|
nsCOMPtr<nsIAtom> frameType;
|
||||||
child->GetFrameType(getter_AddRefs(frameType));
|
seqFrame->GetFrameType(getter_AddRefs(frameType));
|
||||||
if (nsLayoutAtoms::pageContentFrame == frameType.get()) { // placeholder
|
if (nsLayoutAtoms::sequenceFrame == frameType.get()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
child->FirstChild(aPO->mPresContext, nsnull, &child);
|
seqFrame->FirstChild(aPO->mPresContext, nsnull, &seqFrame);
|
||||||
}
|
}
|
||||||
NS_ASSERTION(child, "There has to be a page content frame!");
|
NS_ASSERTION(seqFrame, "There has to be a Sequence frame!");
|
||||||
// Now get it's first child (area frame)
|
if (seqFrame) {
|
||||||
|
// Get the first page of all the pages
|
||||||
|
nsIFrame* pageFrame;
|
||||||
|
seqFrame->FirstChild(aPO->mPresContext, nsnull, &pageFrame);
|
||||||
|
NS_ASSERTION(pageFrame, "There has to be a Page Frame!");
|
||||||
|
// loop thru all the Page Frames
|
||||||
|
nscoord overallMaxWidth = 0;
|
||||||
|
nscoord overMaxRectWidth = 0;
|
||||||
|
while (pageFrame) {
|
||||||
|
nsIFrame* child;
|
||||||
|
// Now get it's first child (for HTML docs it is an area frame)
|
||||||
// then gets it size which would be the size it is suppose to be to fit
|
// then gets it size which would be the size it is suppose to be to fit
|
||||||
if (child) {
|
pageFrame->FirstChild(aPO->mPresContext, nsnull, &child);
|
||||||
child->FirstChild(aPO->mPresContext, nsnull, &child);
|
|
||||||
NS_ASSERTION(child, "There has to be a child frame!");
|
NS_ASSERTION(child, "There has to be a child frame!");
|
||||||
if (child) {
|
|
||||||
nsRect rect;
|
nsRect rect;
|
||||||
child->GetRect(rect);
|
child->GetRect(rect);
|
||||||
// Create a RenderingContext and set the PresContext
|
// Create a RenderingContext and set the PresContext
|
||||||
@@ -3458,11 +3467,21 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
|
|||||||
// then calc the ratio for shrinkage
|
// then calc the ratio for shrinkage
|
||||||
nscoord maxWidth = 0;
|
nscoord maxWidth = 0;
|
||||||
FindXMostFrameSize(aPO->mPresContext, rc, child, 0, 0, maxWidth);
|
FindXMostFrameSize(aPO->mPresContext, rc, child, 0, 0, maxWidth);
|
||||||
float ratio = float(rect.width) / float(maxWidth);
|
if (maxWidth > overallMaxWidth) {
|
||||||
aPO->mXMost = maxWidth;
|
overallMaxWidth = maxWidth;
|
||||||
|
overMaxRectWidth = rect.width;
|
||||||
|
}
|
||||||
|
pageFrame->GetNextSibling(&pageFrame);
|
||||||
|
} // while
|
||||||
|
// Now calc the ratio from the widest frames from all the pages
|
||||||
|
float ratio = 1.0f;
|
||||||
|
NS_ASSERTION(overallMaxWidth, "Overall Max Width must be bigger than zero");
|
||||||
|
if (overallMaxWidth > 0) {
|
||||||
|
ratio = float(overMaxRectWidth) / float(overallMaxWidth);
|
||||||
|
aPO->mXMost = overallMaxWidth;
|
||||||
aPO->mShrinkRatio = PR_MIN(ratio, 1.0f);
|
aPO->mShrinkRatio = PR_MIN(ratio, 1.0f);
|
||||||
#ifdef DEBUG_PRINTING
|
#ifdef DEBUG_PRINTING
|
||||||
printf("PO %p ****** RW: %d MW: %d xMost %d width: %d %10.4f\n", aPO, rect.width, maxWidth, aPO->mXMost, rect.width, ratio*100.0);
|
printf("PO %p ****** RW: %d MW: %d xMost %d width: %d %10.4f\n", aPO, overMaxRectWidth, overallMaxWidth, aPO->mXMost, overMaxRectWidth, ratio*100.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ LAYOUT_ATOM(positionedInlineFrame, "PositionedInlineFrame")
|
|||||||
LAYOUT_ATOM(canvasFrame, "CanvasFrame")
|
LAYOUT_ATOM(canvasFrame, "CanvasFrame")
|
||||||
LAYOUT_ATOM(rootFrame, "RootFrame")
|
LAYOUT_ATOM(rootFrame, "RootFrame")
|
||||||
LAYOUT_ATOM(scrollFrame, "ScrollFrame")
|
LAYOUT_ATOM(scrollFrame, "ScrollFrame")
|
||||||
|
LAYOUT_ATOM(sequenceFrame, "SequenceFrame")
|
||||||
LAYOUT_ATOM(tableCaptionFrame, "TableCaptionFrame")
|
LAYOUT_ATOM(tableCaptionFrame, "TableCaptionFrame")
|
||||||
LAYOUT_ATOM(tableCellFrame, "TableCellFrame")
|
LAYOUT_ATOM(tableCellFrame, "TableCellFrame")
|
||||||
LAYOUT_ATOM(tableColFrame, "TableColFrame")
|
LAYOUT_ATOM(tableColFrame, "TableColFrame")
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "nsIPrintContext.h"
|
#include "nsIPrintContext.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
#include "nsIRegion.h"
|
#include "nsIRegion.h"
|
||||||
|
#include "nsLayoutAtoms.h"
|
||||||
|
|
||||||
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
|
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
|
||||||
|
|
||||||
@@ -1086,6 +1087,14 @@ NS_IMETHODIMP nsSimplePageSequenceFrame::SizeTo(nsIPresContext* aPresContext, ns
|
|||||||
return nsFrame::SizeTo(aPresContext, aWidth, aHeight);
|
return nsFrame::SizeTo(aPresContext, aWidth, aHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSimplePageSequenceFrame::GetFrameType(nsIAtom** aType) const
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
||||||
|
*aType = nsLayoutAtoms::sequenceFrame;
|
||||||
|
NS_ADDREF(*aType);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
@@ -1129,3 +1138,4 @@ nsSimplePageSequenceFrame::SetPageSizes(const nsRect& aRect, const nsMargin& aMa
|
|||||||
mPageData->mReflowRect = aRect;
|
mPageData->mReflowRect = aRect;
|
||||||
mPageData->mReflowMargin = aMarginRect;
|
mPageData->mReflowMargin = aMarginRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,13 @@ public:
|
|||||||
|
|
||||||
static nsIRegion* CreateRegion();
|
static nsIRegion* CreateRegion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "type" of the frame
|
||||||
|
*
|
||||||
|
* @see nsLayoutAtoms::sequenceFrame
|
||||||
|
*/
|
||||||
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
// Debugging
|
// Debugging
|
||||||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "nsIPrintContext.h"
|
#include "nsIPrintContext.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
#include "nsIRegion.h"
|
#include "nsIRegion.h"
|
||||||
|
#include "nsLayoutAtoms.h"
|
||||||
|
|
||||||
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
|
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
|
||||||
|
|
||||||
@@ -1086,6 +1087,14 @@ NS_IMETHODIMP nsSimplePageSequenceFrame::SizeTo(nsIPresContext* aPresContext, ns
|
|||||||
return nsFrame::SizeTo(aPresContext, aWidth, aHeight);
|
return nsFrame::SizeTo(aPresContext, aWidth, aHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSimplePageSequenceFrame::GetFrameType(nsIAtom** aType) const
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
||||||
|
*aType = nsLayoutAtoms::sequenceFrame;
|
||||||
|
NS_ADDREF(*aType);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
@@ -1129,3 +1138,4 @@ nsSimplePageSequenceFrame::SetPageSizes(const nsRect& aRect, const nsMargin& aMa
|
|||||||
mPageData->mReflowRect = aRect;
|
mPageData->mReflowRect = aRect;
|
||||||
mPageData->mReflowMargin = aMarginRect;
|
mPageData->mReflowMargin = aMarginRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,13 @@ public:
|
|||||||
|
|
||||||
static nsIRegion* CreateRegion();
|
static nsIRegion* CreateRegion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "type" of the frame
|
||||||
|
*
|
||||||
|
* @see nsLayoutAtoms::sequenceFrame
|
||||||
|
*/
|
||||||
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
// Debugging
|
// Debugging
|
||||||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user