2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-07-14 07:02:37 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsPageFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIRenderingContext.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIPresShell.h"
|
2004-01-22 02:05:10 +03:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2001-01-27 17:09:34 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
2002-01-25 17:30:14 +03:00
|
|
|
#include "nsPageContentFrame.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2005-12-06 03:32:52 +03:00
|
|
|
#include "nsLayoutUtils.h" // for function BinarySearchForPosition
|
2001-12-05 01:46:41 +03:00
|
|
|
#include "nsCSSRendering.h"
|
2001-11-03 17:59:39 +03:00
|
|
|
#include "nsSimplePageSequence.h" // for nsSharedPageData
|
2006-07-14 07:02:37 +04:00
|
|
|
#include "nsTextFormatter.h" // for page number localization formatting
|
2002-04-30 04:37:12 +04:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiUtils.h"
|
|
|
|
#endif
|
2001-01-27 17:09:34 +03:00
|
|
|
#include "nsIFontMetrics.h"
|
2002-01-01 15:58:53 +03:00
|
|
|
#include "nsIPrintSettings.h"
|
2007-02-07 10:46:44 +03:00
|
|
|
#include "nsRegion.h"
|
2001-04-12 17:04:29 +04:00
|
|
|
|
2002-06-20 01:51:13 +04:00
|
|
|
#include "prlog.h"
|
|
|
|
#ifdef PR_LOGGING
|
2002-08-27 01:20:31 +04:00
|
|
|
extern PRLogModuleInfo * kLayoutPrintingLogMod;
|
|
|
|
#define PR_PL(_p1) PR_LOG(kLayoutPrintingLogMod, PR_LOG_DEBUG, _p1)
|
2002-06-20 01:51:13 +04:00
|
|
|
#else
|
|
|
|
#define PR_PL(_p1)
|
2001-04-12 17:04:29 +04:00
|
|
|
#endif
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-05-12 02:03:29 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsPageFrame(aContext);
|
1999-05-12 02:03:29 +04:00
|
|
|
}
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsPageFrame::nsPageFrame(nsStyleContext* aContext)
|
2006-03-30 04:27:42 +04:00
|
|
|
: nsContainerFrame(aContext)
|
1999-02-19 01:23:36 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
nsPageFrame::~nsPageFrame()
|
|
|
|
{
|
2001-11-03 17:59:39 +03:00
|
|
|
}
|
2001-09-26 18:01:26 +04:00
|
|
|
|
2009-02-27 02:47:03 +03:00
|
|
|
NS_IMETHODIMP nsPageFrame::Reflow(nsPresContext* aPresContext,
|
2001-11-03 17:59:39 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsPageFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_ASSERTION(mFrames.FirstChild() &&
|
|
|
|
nsGkAtoms::pageContentFrame == mFrames.FirstChild()->GetType(),
|
|
|
|
"pageFrame must have a pageContentFrame child");
|
1998-05-30 00:36:05 +04:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
// Resize our frame allowing it only to be as big as we are
|
|
|
|
// XXX Pay attention to the page's border and padding...
|
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
|
|
|
// When the reflow size is NS_UNCONSTRAINEDSIZE it means we are reflowing
|
|
|
|
// a single page to print selection. So this means we want to use
|
|
|
|
// NS_UNCONSTRAINEDSIZE without altering it
|
|
|
|
nscoord avHeight;
|
|
|
|
if (mPD->mReflowSize.height == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
avHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
} else {
|
|
|
|
avHeight = mPD->mReflowSize.height - mPD->mReflowMargin.TopBottom();
|
|
|
|
}
|
|
|
|
nsSize maxSize(mPD->mReflowSize.width - mPD->mReflowMargin.LeftRight(),
|
|
|
|
avHeight);
|
2007-02-07 10:46:44 +03:00
|
|
|
float scale = aPresContext->GetPageScale();
|
|
|
|
maxSize.width = NSToCoordCeil(maxSize.width / scale);
|
2008-04-11 02:34:38 +04:00
|
|
|
if (maxSize.height != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
maxSize.height = NSToCoordCeil(maxSize.height / scale);
|
|
|
|
}
|
2006-04-01 05:19:28 +04:00
|
|
|
// Get the number of Twips per pixel from the PresContext
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixelInTwips = nsPresContext::CSSPixelsToAppUnits(1);
|
2006-04-01 05:19:28 +04:00
|
|
|
// insurance against infinite reflow, when reflowing less than a pixel
|
|
|
|
// XXX Shouldn't we do something more friendly when invalid margins
|
|
|
|
// are set?
|
|
|
|
if (maxSize.width < onePixelInTwips || maxSize.height < onePixelInTwips) {
|
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
NS_WARNING("Reflow aborted; no space for content");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-11-28 18:19:47 +03:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame, maxSize);
|
|
|
|
kidReflowState.mFlags.mIsTopOfPage = PR_TRUE;
|
2007-01-21 20:51:33 +03:00
|
|
|
kidReflowState.mFlags.mTableIsSplittable = PR_TRUE;
|
2001-11-28 18:19:47 +03:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
// calc location of frame
|
2006-04-11 05:48:48 +04:00
|
|
|
nscoord xc = mPD->mReflowMargin.left + mPD->mExtraMargin.left;
|
|
|
|
nscoord yc = mPD->mReflowMargin.top + mPD->mExtraMargin.top;
|
2001-11-06 17:34:00 +03:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
// Get the child's desired size
|
|
|
|
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, xc, yc, 0, aStatus);
|
1999-10-30 06:52:11 +04:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
// Place and size the child
|
|
|
|
FinishReflowChild(frame, aPresContext, &kidReflowState, aDesiredSize, xc, yc, 0);
|
1999-10-30 06:52:11 +04:00
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_ASSERTION(!NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
|
2006-04-01 05:19:28 +04:00
|
|
|
!frame->GetNextInFlow(), "bad child flow list");
|
|
|
|
}
|
|
|
|
PR_PL(("PageFrame::Reflow %p ", this));
|
|
|
|
PR_PL(("[%d,%d][%d,%d]\n", aDesiredSize.width, aDesiredSize.height, aReflowState.availableWidth, aReflowState.availableHeight));
|
|
|
|
|
|
|
|
// Return our desired size
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-05-25 21:31:49 +04:00
|
|
|
}
|
2002-06-20 01:51:13 +04:00
|
|
|
PR_PL(("PageFrame::Reflow %p ", this));
|
|
|
|
PR_PL(("[%d,%d]\n", aReflowState.availableWidth, aReflowState.availableHeight));
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsPageFrame::GetType() const
|
1999-02-14 06:47:33 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::pageFrame;
|
1999-02-14 06:47:33 +03:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsPageFrame::GetFrameName(nsAString& aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Page"), aResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-03-12 07:40:17 +03:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsPageFrame::IsContainingBlock() const
|
1999-03-05 07:28:07 +03:00
|
|
|
{
|
2004-03-12 07:40:17 +03:00
|
|
|
return PR_TRUE;
|
1999-03-05 07:28:07 +03:00
|
|
|
}
|
2001-01-27 17:09:34 +03:00
|
|
|
|
2001-09-26 18:01:26 +04:00
|
|
|
void
|
|
|
|
nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
|
|
|
|
{
|
|
|
|
|
|
|
|
aNewStr = aStr;
|
|
|
|
|
|
|
|
// Search to see if the &D code is in the string
|
|
|
|
// then subst in the current date/time
|
2002-03-19 09:46:56 +03:00
|
|
|
NS_NAMED_LITERAL_STRING(kDate, "&D");
|
|
|
|
if (aStr.Find(kDate) != kNotFound) {
|
|
|
|
if (mPD->mDateTimeStr != nsnull) {
|
|
|
|
aNewStr.ReplaceSubstring(kDate.get(), mPD->mDateTimeStr);
|
|
|
|
} else {
|
2004-01-30 01:04:45 +03:00
|
|
|
aNewStr.ReplaceSubstring(kDate.get(), EmptyString().get());
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Must search for &PT before searching for &P
|
|
|
|
//
|
|
|
|
// Search to see if the "page number and page" total code are in the string
|
2002-03-19 09:46:56 +03:00
|
|
|
// and replace the page number and page total code with the actual
|
|
|
|
// values
|
|
|
|
NS_NAMED_LITERAL_STRING(kPageAndTotal, "&PT");
|
|
|
|
if (aStr.Find(kPageAndTotal) != kNotFound) {
|
|
|
|
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
|
|
|
|
aNewStr.ReplaceSubstring(kPageAndTotal.get(), uStr);
|
|
|
|
nsMemory::Free(uStr);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Search to see if the page number code is in the string
|
2002-03-19 09:46:56 +03:00
|
|
|
// and replace the page number code with the actual value
|
|
|
|
NS_NAMED_LITERAL_STRING(kPage, "&P");
|
|
|
|
if (aStr.Find(kPage) != kNotFound) {
|
|
|
|
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
|
|
|
|
aNewStr.ReplaceSubstring(kPage.get(), uStr);
|
|
|
|
nsMemory::Free(uStr);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
|
2002-03-19 09:46:56 +03:00
|
|
|
NS_NAMED_LITERAL_STRING(kTitle, "&T");
|
|
|
|
if (aStr.Find(kTitle) != kNotFound) {
|
2005-04-29 08:57:51 +04:00
|
|
|
if (mPD->mDocTitle != nsnull) {
|
|
|
|
aNewStr.ReplaceSubstring(kTitle.get(), mPD->mDocTitle);
|
|
|
|
} else {
|
|
|
|
aNewStr.ReplaceSubstring(kTitle.get(), EmptyString().get());
|
|
|
|
}
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
|
2002-03-19 09:46:56 +03:00
|
|
|
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
|
|
|
|
if (aStr.Find(kDocURL) != kNotFound) {
|
2005-04-29 08:57:51 +04:00
|
|
|
if (mPD->mDocURL != nsnull) {
|
|
|
|
aNewStr.ReplaceSubstring(kDocURL.get(), mPD->mDocURL);
|
|
|
|
} else {
|
|
|
|
aNewStr.ReplaceSubstring(kDocURL.get(), EmptyString().get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(kPageTotal, "&L");
|
|
|
|
if (aStr.Find(kPageTotal) != kNotFound) {
|
|
|
|
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mTotNumPages);
|
|
|
|
aNewStr.ReplaceSubstring(kPageTotal.get(), uStr);
|
|
|
|
nsMemory::Free(uStr);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
nscoord nsPageFrame::GetXPosition(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aRect,
|
|
|
|
PRInt32 aJust,
|
|
|
|
const nsString& aStr)
|
|
|
|
{
|
2007-01-23 05:58:55 +03:00
|
|
|
nscoord width = nsLayoutUtils::GetStringWidth(this, &aRenderingContext,
|
|
|
|
aStr.get(), aStr.Length());
|
2001-01-27 17:09:34 +03:00
|
|
|
|
|
|
|
nscoord x = aRect.x;
|
|
|
|
switch (aJust) {
|
2002-01-01 15:58:53 +03:00
|
|
|
case nsIPrintSettings::kJustLeft:
|
2002-02-01 18:31:15 +03:00
|
|
|
x += mPD->mExtraMargin.left + mPD->mEdgePaperMargin.left;
|
2001-01-27 17:09:34 +03:00
|
|
|
break;
|
|
|
|
|
2002-01-01 15:58:53 +03:00
|
|
|
case nsIPrintSettings::kJustCenter:
|
2001-01-27 17:09:34 +03:00
|
|
|
x += (aRect.width - width) / 2;
|
|
|
|
break;
|
|
|
|
|
2002-01-01 15:58:53 +03:00
|
|
|
case nsIPrintSettings::kJustRight:
|
2002-02-01 18:31:15 +03:00
|
|
|
x += aRect.width - width - mPD->mExtraMargin.right - mPD->mEdgePaperMargin.right;
|
2001-01-27 17:09:34 +03:00
|
|
|
break;
|
|
|
|
} // switch
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2006-07-14 07:02:37 +04:00
|
|
|
// Draw a header or footer
|
|
|
|
// @param aRenderingContext - rendering content ot draw into
|
|
|
|
// @param aHeaderFooter - indicates whether it is a header or footer
|
|
|
|
// @param aStrLeft - string for the left header or footer; can be empty
|
|
|
|
// @param aStrCenter - string for the center header or footer; can be empty
|
|
|
|
// @param aStrRight - string for the right header or footer; can be empty
|
|
|
|
// @param aRect - the rect of the page
|
|
|
|
// @param aAscent - the ascent of the font
|
|
|
|
// @param aHeight - the height of the font
|
2001-01-27 17:09:34 +03:00
|
|
|
void
|
2006-07-14 07:02:37 +04:00
|
|
|
nsPageFrame::DrawHeaderFooter(nsIRenderingContext& aRenderingContext,
|
2001-09-26 18:01:26 +04:00
|
|
|
nsHeaderFooterEnum aHeaderFooter,
|
2006-07-14 07:02:37 +04:00
|
|
|
const nsString& aStrLeft,
|
|
|
|
const nsString& aStrCenter,
|
|
|
|
const nsString& aStrRight,
|
2001-09-26 18:01:26 +04:00
|
|
|
const nsRect& aRect,
|
2001-10-31 01:58:00 +03:00
|
|
|
nscoord aAscent,
|
2001-09-26 18:01:26 +04:00
|
|
|
nscoord aHeight)
|
|
|
|
{
|
|
|
|
PRInt32 numStrs = 0;
|
2006-07-14 07:02:37 +04:00
|
|
|
if (!aStrLeft.IsEmpty()) numStrs++;
|
|
|
|
if (!aStrCenter.IsEmpty()) numStrs++;
|
|
|
|
if (!aStrRight.IsEmpty()) numStrs++;
|
2001-09-26 18:01:26 +04:00
|
|
|
|
|
|
|
if (numStrs == 0) return;
|
2001-10-02 03:57:57 +04:00
|
|
|
nscoord strSpace = aRect.width / numStrs;
|
2001-09-26 18:01:26 +04:00
|
|
|
|
2006-07-14 07:02:37 +04:00
|
|
|
if (!aStrLeft.IsEmpty()) {
|
|
|
|
DrawHeaderFooter(aRenderingContext, aHeaderFooter,
|
|
|
|
nsIPrintSettings::kJustLeft, aStrLeft, aRect, aAscent,
|
|
|
|
aHeight, strSpace);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
2006-07-14 07:02:37 +04:00
|
|
|
if (!aStrCenter.IsEmpty()) {
|
|
|
|
DrawHeaderFooter(aRenderingContext, aHeaderFooter,
|
|
|
|
nsIPrintSettings::kJustCenter, aStrCenter, aRect, aAscent,
|
|
|
|
aHeight, strSpace);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
2006-07-14 07:02:37 +04:00
|
|
|
if (!aStrRight.IsEmpty()) {
|
|
|
|
DrawHeaderFooter(aRenderingContext, aHeaderFooter,
|
|
|
|
nsIPrintSettings::kJustRight, aStrRight, aRect, aAscent,
|
|
|
|
aHeight, strSpace);
|
2001-09-26 18:01:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-14 07:02:37 +04:00
|
|
|
// Draw a header or footer string
|
|
|
|
// @param aRenderingContext - rendering content ot draw into
|
|
|
|
// @param aHeaderFooter - indicates whether it is a header or footer
|
|
|
|
// @param aJust - indicates where the string is located within the header/footer
|
|
|
|
// @param aStr - the string to be drawn
|
|
|
|
// @param aRect - the rect of the page
|
|
|
|
// @param aHeight - the height of the font
|
|
|
|
// @param aAscent - the ascent of the font
|
|
|
|
// @param aWidth - available width for the string
|
2001-09-26 18:01:26 +04:00
|
|
|
void
|
2006-07-14 07:02:37 +04:00
|
|
|
nsPageFrame::DrawHeaderFooter(nsIRenderingContext& aRenderingContext,
|
2001-01-27 17:09:34 +03:00
|
|
|
nsHeaderFooterEnum aHeaderFooter,
|
|
|
|
PRInt32 aJust,
|
|
|
|
const nsString& aStr,
|
|
|
|
const nsRect& aRect,
|
2001-10-31 01:58:00 +03:00
|
|
|
nscoord aAscent,
|
2001-01-27 17:09:34 +03:00
|
|
|
nscoord aHeight,
|
2001-09-26 18:01:26 +04:00
|
|
|
nscoord aWidth)
|
2001-01-27 17:09:34 +03:00
|
|
|
{
|
2001-04-12 17:04:29 +04:00
|
|
|
|
2002-02-01 18:31:15 +03:00
|
|
|
nscoord contentWidth = aWidth - (mPD->mEdgePaperMargin.left + mPD->mEdgePaperMargin.right);
|
2001-11-28 18:19:47 +03:00
|
|
|
|
2006-07-14 07:02:37 +04:00
|
|
|
if ((aHeaderFooter == eHeader && aHeight < mPD->mReflowMargin.top) ||
|
|
|
|
(aHeaderFooter == eFooter && aHeight < mPD->mReflowMargin.bottom)) {
|
2001-09-26 18:01:26 +04:00
|
|
|
nsAutoString str;
|
|
|
|
ProcessSpecialCodes(aStr, str);
|
|
|
|
|
2002-04-26 15:30:33 +04:00
|
|
|
PRInt32 indx;
|
|
|
|
PRInt32 textWidth = 0;
|
|
|
|
const PRUnichar* text = str.get();
|
2001-09-26 18:01:26 +04:00
|
|
|
|
2002-04-26 15:30:33 +04:00
|
|
|
PRInt32 len = (PRInt32)str.Length();
|
|
|
|
if (len == 0) {
|
|
|
|
return; // bail is empty string
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
2003-03-19 07:35:08 +03:00
|
|
|
// find how much text fits, the "position" is the size of the available area
|
2005-12-06 03:32:52 +03:00
|
|
|
if (nsLayoutUtils::BinarySearchForPosition(&aRenderingContext, text, 0, 0, 0, len,
|
2002-04-26 15:30:33 +04:00
|
|
|
PRInt32(contentWidth), indx, textWidth)) {
|
2004-10-20 01:46:45 +04:00
|
|
|
if (indx < len-1 ) {
|
|
|
|
// we can't fit in all the text
|
|
|
|
if (indx > 3) {
|
|
|
|
// But we can fit in at least 4 chars. Show all but 3 of them, then
|
|
|
|
// an ellipsis.
|
|
|
|
// XXXbz for non-plane0 text, this may be cutting things in the
|
|
|
|
// middle of a codepoint! Also, we have no guarantees that the three
|
|
|
|
// dots will fit in the space the three chars we removed took up with
|
|
|
|
// these font metrics!
|
|
|
|
str.Truncate(indx-3);
|
|
|
|
str.AppendLiteral("...");
|
|
|
|
} else {
|
|
|
|
// We can only fit 3 or fewer chars. Just show nothing
|
|
|
|
str.Truncate();
|
|
|
|
}
|
2002-04-26 15:30:33 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return; // bail if couldn't find the correct length
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
2008-03-12 10:56:38 +03:00
|
|
|
|
2008-06-15 10:51:00 +04:00
|
|
|
if (HasRTLChars(str)) {
|
2008-06-16 13:28:17 +04:00
|
|
|
PresContext()->SetBidiEnabled();
|
2008-06-15 10:51:00 +04:00
|
|
|
}
|
2001-01-27 17:09:34 +03:00
|
|
|
|
|
|
|
// cacl the x and y positions of the text
|
2006-07-14 07:02:37 +04:00
|
|
|
nscoord x = GetXPosition(aRenderingContext, aRect, aJust, str);
|
2001-01-27 17:09:34 +03:00
|
|
|
nscoord y;
|
|
|
|
if (aHeaderFooter == eHeader) {
|
2006-07-14 07:02:37 +04:00
|
|
|
y = aRect.y + mPD->mExtraMargin.top + mPD->mEdgePaperMargin.top;
|
2001-01-27 17:09:34 +03:00
|
|
|
} else {
|
2006-07-14 07:02:37 +04:00
|
|
|
y = aRect.YMost() - aHeight - mPD->mExtraMargin.bottom - mPD->mEdgePaperMargin.bottom;
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// set up new clip and draw the text
|
|
|
|
aRenderingContext.PushState();
|
2001-11-03 17:59:39 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
2006-07-14 07:02:37 +04:00
|
|
|
aRenderingContext.SetClipRect(aRect, nsClipCombine_kReplace);
|
2007-01-23 05:58:55 +03:00
|
|
|
nsLayoutUtils::DrawString(this, &aRenderingContext, str.get(), str.Length(), nsPoint(x, y + aAscent));
|
2004-04-18 17:13:35 +04:00
|
|
|
aRenderingContext.PopState();
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
static void PaintPrintPreviewBackground(nsIFrame* aFrame, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
2001-01-27 17:09:34 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsPageFrame*>(aFrame)->PaintPrintPreviewBackground(*aCtx, aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2001-11-03 17:59:39 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
static void PaintPageContent(nsIFrame* aFrame, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsPageFrame*>(aFrame)->PaintPageContent(*aCtx, aDirtyRect, aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2001-09-26 18:01:26 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
static void PaintHeaderFooter(nsIFrame* aFrame, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsPageFrame*>(aFrame)->PaintHeaderFooter(*aCtx, aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2001-04-12 17:04:29 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayListCollection set;
|
2007-02-07 10:46:44 +03:00
|
|
|
nsresult rv;
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
if (PresContext()->IsScreen()) {
|
2007-02-07 10:46:44 +03:00
|
|
|
rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayGeneric(this, ::PaintPrintPreviewBackground, "PrintPreviewBackground"));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-02-22 04:45:05 +03:00
|
|
|
}
|
2007-02-07 10:46:44 +03:00
|
|
|
|
|
|
|
rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayGeneric(this, ::PaintPageContent, "PageContent"));
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-01-27 17:09:34 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
if (PresContext()->IsRootPaginatedDocument()) {
|
2006-01-26 05:29:17 +03:00
|
|
|
rv = set.Content()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayGeneric(this, ::PaintHeaderFooter, "HeaderFooter"));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
set.MoveTo(aLists);
|
|
|
|
return NS_OK;
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
nsPageFrame::SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages)
|
|
|
|
{
|
|
|
|
mPageNum = aPageNumber;
|
2001-04-12 17:04:29 +04:00
|
|
|
mTotNumPages = aTotalPages;
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
|
|
|
nsPageFrame::PaintPrintPreviewBackground(nsIRenderingContext& aRenderingContext,
|
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
// fill page with White
|
|
|
|
aRenderingContext.SetColor(NS_RGB(255,255,255));
|
|
|
|
// REVIEW: this used to have rect's width and height be the
|
|
|
|
// mClipRect if specialClipIsSet ... but that seems completely bogus
|
|
|
|
// and inconsistent with the painting of the shadow below
|
|
|
|
nsRect rect(aPt, GetSize());
|
|
|
|
rect.width -= mPD->mShadowSize.width;
|
|
|
|
rect.height -= mPD->mShadowSize.height;
|
|
|
|
aRenderingContext.FillRect(rect);
|
|
|
|
// draw line around outside of page
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
|
|
|
aRenderingContext.DrawRect(rect);
|
|
|
|
|
|
|
|
if (mPD->mShadowSize.width > 0 && mPD->mShadowSize.height > 0) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(51,51,51));
|
|
|
|
nsRect r(aPt.x,aPt.y, mRect.width, mRect.height);
|
|
|
|
nsRect shadowRect;
|
|
|
|
shadowRect.x = r.x + r.width - mPD->mShadowSize.width;
|
|
|
|
shadowRect.y = r.y + mPD->mShadowSize.height;
|
|
|
|
shadowRect.width = mPD->mShadowSize.width;
|
|
|
|
shadowRect.height = r.height - mPD->mShadowSize.height;
|
|
|
|
aRenderingContext.FillRect(shadowRect);
|
|
|
|
|
|
|
|
shadowRect.x = r.x + mPD->mShadowSize.width;
|
|
|
|
shadowRect.y = r.y + r.height - mPD->mShadowSize.height;
|
|
|
|
shadowRect.width = r.width - mPD->mShadowSize.width;
|
|
|
|
shadowRect.height = mPD->mShadowSize.height;
|
|
|
|
aRenderingContext.FillRect(shadowRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPageFrame::PaintHeaderFooter(nsIRenderingContext& aRenderingContext,
|
|
|
|
nsPoint aPt)
|
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* pc = PresContext();
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
if (!mPD->mPrintSettings) {
|
2006-04-01 05:19:28 +04:00
|
|
|
if (pc->Type() == nsPresContext::eContext_PrintPreview || pc->IsDynamic())
|
2006-01-26 05:29:17 +03:00
|
|
|
mPD->mPrintSettings = pc->GetPrintSettings();
|
2006-04-01 05:19:28 +04:00
|
|
|
if (!mPD->mPrintSettings)
|
|
|
|
return;
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRect rect(aPt.x, aPt.y, mRect.width - mPD->mShadowSize.width,
|
|
|
|
mRect.height - mPD->mShadowSize.height);
|
|
|
|
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,0));
|
|
|
|
|
|
|
|
// Get the FontMetrics to determine width.height of strings
|
|
|
|
nsCOMPtr<nsIFontMetrics> fontMet;
|
|
|
|
pc->DeviceContext()->GetMetricsFor(*mPD->mHeadFootFont, nsnull,
|
2008-12-04 19:09:53 +03:00
|
|
|
pc->GetUserFontSet(),
|
2006-01-26 05:29:17 +03:00
|
|
|
*getter_AddRefs(fontMet));
|
2008-12-04 19:09:53 +03:00
|
|
|
|
|
|
|
aRenderingContext.SetFont(fontMet);
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nscoord ascent = 0;
|
|
|
|
nscoord visibleHeight = 0;
|
|
|
|
if (fontMet) {
|
|
|
|
fontMet->GetHeight(visibleHeight);
|
|
|
|
fontMet->GetMaxAscent(ascent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// print document headers and footers
|
2006-07-14 07:02:37 +04:00
|
|
|
nsXPIDLString headerLeft, headerCenter, headerRight;
|
|
|
|
mPD->mPrintSettings->GetHeaderStrLeft(getter_Copies(headerLeft));
|
|
|
|
mPD->mPrintSettings->GetHeaderStrCenter(getter_Copies(headerCenter));
|
|
|
|
mPD->mPrintSettings->GetHeaderStrRight(getter_Copies(headerRight));
|
|
|
|
DrawHeaderFooter(aRenderingContext, eHeader,
|
|
|
|
headerLeft, headerCenter, headerRight,
|
2006-01-26 05:29:17 +03:00
|
|
|
rect, ascent, visibleHeight);
|
2006-07-14 07:02:37 +04:00
|
|
|
|
|
|
|
nsXPIDLString footerLeft, footerCenter, footerRight;
|
|
|
|
mPD->mPrintSettings->GetFooterStrLeft(getter_Copies(footerLeft));
|
|
|
|
mPD->mPrintSettings->GetFooterStrCenter(getter_Copies(footerCenter));
|
|
|
|
mPD->mPrintSettings->GetFooterStrRight(getter_Copies(footerRight));
|
|
|
|
DrawHeaderFooter(aRenderingContext, eFooter,
|
|
|
|
footerLeft, footerCenter, footerRight,
|
2006-01-26 05:29:17 +03:00
|
|
|
rect, ascent, visibleHeight);
|
|
|
|
}
|
|
|
|
|
2001-12-05 01:46:41 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void
|
2007-02-07 10:46:44 +03:00
|
|
|
nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsPoint aPt) {
|
|
|
|
nsIFrame* pageContentFrame = mFrames.FirstChild();
|
|
|
|
nsRect rect = aDirtyRect;
|
2007-03-31 01:11:41 +04:00
|
|
|
float scale = PresContext()->GetPageScale();
|
2007-02-07 10:46:44 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
|
|
|
|
aRenderingContext.Translate(framePos.x, framePos.y);
|
2008-04-08 17:06:12 +04:00
|
|
|
// aPt translates to coords relative to this, then margins translate to
|
|
|
|
// pageContentFrame's coords
|
2007-02-07 10:46:44 +03:00
|
|
|
rect -= framePos;
|
|
|
|
aRenderingContext.Scale(scale, scale);
|
|
|
|
rect.ScaleRoundOut(1.0f / scale);
|
2008-04-08 17:06:12 +04:00
|
|
|
// Make sure we don't draw where we aren't supposed to draw, especially
|
|
|
|
// when printing selection
|
|
|
|
nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize());
|
2008-05-01 10:32:25 +04:00
|
|
|
// Note: this computation matches how we compute maxSize.height
|
|
|
|
// in nsPageFrame::Reflow
|
|
|
|
nscoord expectedPageContentHeight =
|
|
|
|
NSToCoordCeil((GetSize().height - mPD->mReflowMargin.TopBottom()) / scale);
|
|
|
|
if (clipRect.height > expectedPageContentHeight) {
|
|
|
|
// We're doing print-selection, with one long page-content frame.
|
|
|
|
// Clip to the appropriate page-content slice for the current page.
|
|
|
|
NS_ASSERTION(mPageNum > 0, "page num should be positive");
|
2008-07-01 00:46:23 +04:00
|
|
|
// Note: The pageContentFrame's y-position has been set such that a zero
|
|
|
|
// y-value matches the top edge of the current page. So, to clip to the
|
|
|
|
// current page's content (in coordinates *relative* to the page content
|
|
|
|
// frame), we just negate its y-position and add the top margin.
|
|
|
|
clipRect.y = NSToCoordCeil((-pageContentFrame->GetRect().y +
|
|
|
|
mPD->mReflowMargin.top) / scale);
|
2008-05-01 10:32:25 +04:00
|
|
|
clipRect.height = expectedPageContentHeight;
|
|
|
|
NS_ASSERTION(clipRect.y < pageContentFrame->GetSize().height,
|
|
|
|
"Should be clipping to region inside the page content bounds");
|
|
|
|
}
|
2008-04-08 17:06:12 +04:00
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
|
2007-02-07 10:46:44 +03:00
|
|
|
|
|
|
|
nsRect backgroundRect = nsRect(nsPoint(0, 0), pageContentFrame->GetSize());
|
2007-03-31 01:11:41 +04:00
|
|
|
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
|
2009-05-28 09:01:42 +04:00
|
|
|
rect, backgroundRect, 0);
|
2007-02-07 10:46:44 +03:00
|
|
|
|
2007-02-16 11:04:44 +03:00
|
|
|
nsLayoutUtils::PaintFrame(&aRenderingContext, pageContentFrame,
|
|
|
|
nsRegion(rect), NS_RGBA(0,0,0,0));
|
2007-02-07 10:46:44 +03:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
2001-12-05 01:46:41 +03:00
|
|
|
}
|
|
|
|
|
2002-09-20 01:45:07 +04:00
|
|
|
void
|
|
|
|
nsPageFrame::SetSharedPageData(nsSharedPageData* aPD)
|
|
|
|
{
|
|
|
|
mPD = aPD;
|
|
|
|
// Set the shared data into the page frame before reflow
|
2007-07-08 11:08:04 +04:00
|
|
|
nsPageContentFrame * pcf = static_cast<nsPageContentFrame*>(mFrames.FirstChild());
|
2002-09-20 01:45:07 +04:00
|
|
|
if (pcf) {
|
|
|
|
pcf->SetSharedPageData(mPD);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2002-03-18 00:35:08 +03:00
|
|
|
{
|
2005-11-04 05:38:33 +03:00
|
|
|
NS_PRECONDITION(aPresShell, "null PresShell");
|
2002-03-18 00:35:08 +03:00
|
|
|
//check that we are only creating page break frames when printing
|
2004-08-21 00:34:37 +04:00
|
|
|
NS_ASSERTION(aPresShell->GetPresContext()->IsPaginated(), "created a page break frame while not printing");
|
2002-03-18 00:35:08 +03:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsPageBreakFrame(aContext);
|
2002-03-18 00:35:08 +03:00
|
|
|
}
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsPageBreakFrame::nsPageBreakFrame(nsStyleContext* aContext) :
|
|
|
|
nsLeafFrame(aContext), mHaveReflowed(PR_FALSE)
|
2002-03-18 00:35:08 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPageBreakFrame::~nsPageBreakFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord
|
|
|
|
nsPageBreakFrame::GetIntrinsicWidth()
|
2002-03-18 00:35:08 +03:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(1);
|
2002-03-18 00:35:08 +03:00
|
|
|
}
|
|
|
|
|
2008-04-12 09:32:49 +04:00
|
|
|
nscoord
|
|
|
|
nsPageBreakFrame::GetIntrinsicHeight()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-03-18 00:35:08 +03:00
|
|
|
nsresult
|
2009-02-27 02:47:03 +03:00
|
|
|
nsPageBreakFrame::Reflow(nsPresContext* aPresContext,
|
2002-03-18 00:35:08 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsPageBreakFrame");
|
2002-03-18 00:35:08 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Override reflow, since we don't want to deal with what our
|
|
|
|
// computed values are.
|
|
|
|
aDesiredSize.width = GetIntrinsicWidth();
|
2007-11-07 22:49:44 +03:00
|
|
|
aDesiredSize.height = (aReflowState.availableHeight == NS_UNCONSTRAINEDSIZE ?
|
|
|
|
0 : aReflowState.availableHeight);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// round the height down to the nearest pixel
|
|
|
|
aDesiredSize.height -=
|
2007-02-07 10:46:44 +03:00
|
|
|
aDesiredSize.height % nsPresContext::CSSPixelsToAppUnits(1);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// Note: not using NS_FRAME_FIRST_REFLOW here, since it's not clear whether
|
|
|
|
// DidReflow will always get called before the next Reflow() call.
|
2002-03-18 00:35:08 +03:00
|
|
|
mHaveReflowed = PR_TRUE;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-03-18 00:35:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsPageBreakFrame::GetType() const
|
2002-03-18 00:35:08 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::pageBreakFrame;
|
2002-03-18 00:35:08 +03:00
|
|
|
}
|
|
|
|
|
2008-12-29 18:07:36 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPageBreakFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("PageBreak"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|