зеркало из https://github.com/mozilla/gecko-dev.git
Folded reflow functions into nsIFrame and eliminated nsIFrameReflow and
nsIHTMLReflow. This saves 4 bytes per frame and cleans things up
This commit is contained in:
Родитель
1748f71059
Коммит
a12c3d6c5d
|
@ -63,7 +63,6 @@
|
|||
#include "nsIDTD.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLElementFactory.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -112,6 +111,7 @@
|
|||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "prprf.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsplugin.h"
|
||||
#include "nsIFrame.h"
|
||||
//#include "nsPluginsCID.h"
|
||||
#include "nsIPluginManager.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -65,7 +66,6 @@
|
|||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "stopwatch.h"
|
||||
|
||||
#include "nsILocaleService.h"
|
||||
|
|
|
@ -939,7 +939,6 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -947,18 +946,16 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Initial, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::InitialReflow"));
|
||||
RAPTOR_STOPWATCH_DEBUGTRACE(("Stop: Reflow: PresShell::InitialReflow(), this=%p\n", this));
|
||||
|
@ -1019,7 +1016,6 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -1027,16 +1023,14 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Resize, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::ResizeReflow"));
|
||||
|
||||
|
@ -1198,7 +1192,6 @@ PresShell::StyleChangeReflow()
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -1207,16 +1200,14 @@ PresShell::StyleChangeReflow()
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Resize, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::StyleChangeReflow"));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleStruct.h"
|
||||
#include "nsStyleCoord.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
|
@ -41,6 +43,9 @@ class nsAutoString;
|
|||
class nsString;
|
||||
class nsIFocusTracker;
|
||||
class nsStyleChangeList;
|
||||
class nsISpaceManager;
|
||||
class nsBlockFrame;
|
||||
class nsLineLayout;
|
||||
|
||||
struct nsPeekOffsetStruct;
|
||||
struct nsPoint;
|
||||
|
@ -49,6 +54,9 @@ struct nsStyleStruct;
|
|||
class nsIDOMRange;
|
||||
class nsICaret;
|
||||
struct PRLogModuleInfo;
|
||||
struct nsStyleDisplay;
|
||||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
// IID for the nsIFrame interface
|
||||
// a6cf9050-15b3-11d2-932e-00805f8add32
|
||||
|
@ -177,6 +185,489 @@ enum nsSpread {
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reflow metrics used to return the frame's desired size and alignment
|
||||
* information.
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
struct nsHTMLReflowMetrics {
|
||||
nscoord width, height; // [OUT] desired width and height
|
||||
nscoord ascent, descent; // [OUT] ascent and descent information
|
||||
|
||||
// Set this to null if you don't need to compute the max element size
|
||||
nsSize* maxElementSize; // [IN OUT]
|
||||
|
||||
// Carried out bottom margin values. This is the collapsed
|
||||
// (generational) bottom margin value.
|
||||
nscoord mCarriedOutBottomMargin;
|
||||
|
||||
// For frames that have children that stick outside their rect
|
||||
// (NS_FRAME_OUTSIDE_CHILDREN) this rectangle will contain the
|
||||
// absolute bounds of the frame. Since the frame doesn't know where
|
||||
// it is going to be positioned in its parent, the assumption is
|
||||
// that it is placed at 0,0 when computing this area.
|
||||
nsRect mCombinedArea;
|
||||
|
||||
nsHTMLReflowMetrics(nsSize* aMaxElementSize) {
|
||||
maxElementSize = aMaxElementSize;
|
||||
mCarriedOutBottomMargin = 0;
|
||||
mCombinedArea.x = 0;
|
||||
mCombinedArea.y = 0;
|
||||
mCombinedArea.width = 0;
|
||||
mCombinedArea.height = 0;
|
||||
|
||||
// XXX These are OUT parameters and so they shouldn't have to be
|
||||
// initialized, but there are some bad frame classes that aren't
|
||||
// properly setting them when returning from Reflow()...
|
||||
width = height = 0;
|
||||
ascent = descent = 0;
|
||||
}
|
||||
|
||||
void AddBorderPaddingToMaxElementSize(const nsMargin& aBorderPadding) {
|
||||
maxElementSize->width += aBorderPadding.left + aBorderPadding.right;
|
||||
maxElementSize->height += aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
};
|
||||
|
||||
// Carried out margin flags
|
||||
#define NS_CARRIED_TOP_MARGIN_IS_AUTO 0x1
|
||||
#define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
|
||||
|
||||
/**
|
||||
* Constant used to indicate an unconstrained size.
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
|
||||
|
||||
/**
|
||||
* The reason the frame is being reflowed.
|
||||
*
|
||||
* XXX Should probably be a #define so it can be extended for specialized
|
||||
* reflow interfaces...
|
||||
*
|
||||
* @see nsReflowState
|
||||
*/
|
||||
enum nsReflowReason {
|
||||
eReflowReason_Initial = 0, // initial reflow of a newly created frame
|
||||
eReflowReason_Incremental = 1, // an incremental change has occured. see the reflow command for details
|
||||
eReflowReason_Resize = 2, // general request to determine a desired size
|
||||
eReflowReason_StyleChange = 3 // request to reflow because of a style change. Note: you must reflow
|
||||
// all your child frames
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CSS Frame type. Included as part of the reflow state.
|
||||
*/
|
||||
typedef PRUint32 nsCSSFrameType;
|
||||
|
||||
#define NS_CSS_FRAME_TYPE_UNKNOWN 0
|
||||
#define NS_CSS_FRAME_TYPE_INLINE 1
|
||||
#define NS_CSS_FRAME_TYPE_BLOCK 2 /* block-level in normal flow */
|
||||
#define NS_CSS_FRAME_TYPE_FLOATING 3
|
||||
#define NS_CSS_FRAME_TYPE_ABSOLUTE 4
|
||||
#define NS_CSS_FRAME_TYPE_INTERNAL_TABLE 5 /* row group frame, row frame, cell frame, ... */
|
||||
|
||||
/**
|
||||
* Bit-flag that indicates whether the element is replaced. Applies to inline,
|
||||
* block-level, floating, and absolutely positioned elements
|
||||
*/
|
||||
#define NS_CSS_FRAME_TYPE_REPLACED 0x8000
|
||||
|
||||
/**
|
||||
* Helper macros for telling whether items are replaced
|
||||
*/
|
||||
#define NS_FRAME_IS_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED == ((_ft) & NS_CSS_FRAME_TYPE_REPLACED))
|
||||
|
||||
#define NS_FRAME_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED | (_ft))
|
||||
|
||||
/**
|
||||
* A macro to extract the type. Masks off the 'replaced' bit-flag
|
||||
*/
|
||||
#define NS_FRAME_GET_TYPE(_ft) \
|
||||
((_ft) & ~NS_CSS_FRAME_TYPE_REPLACED)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define NS_INTRINSICSIZE NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOHEIGHT NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOMARGIN NS_UNCONSTRAINEDSIZE
|
||||
|
||||
/**
|
||||
* Reflow state passed to a frame during reflow. The reflow states are linked
|
||||
* together. The availableWidth and availableHeight represent the available
|
||||
* space in which to reflow your frame, and are computed based on the parent
|
||||
* frame's computed width and computed height. The available space is the total
|
||||
* space including margins, border, padding, and content area. A value of
|
||||
* NS_UNCONSTRAINEDSIZE means you can choose whatever size you want
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
struct nsHTMLReflowState {
|
||||
// pointer to parent's reflow state
|
||||
const nsHTMLReflowState* parentReflowState;
|
||||
|
||||
// the frame being reflowed
|
||||
nsIFrame* frame;
|
||||
|
||||
// the reason for the reflow
|
||||
nsReflowReason reason;
|
||||
|
||||
// the reflow command. only set for eReflowReason_Incremental
|
||||
nsIReflowCommand* reflowCommand;
|
||||
|
||||
// the available space in which to reflow
|
||||
nscoord availableWidth, availableHeight;
|
||||
|
||||
// rendering context to use for measurement
|
||||
nsIRenderingContext* rendContext;
|
||||
|
||||
// is the current context at the top of a page?
|
||||
PRPackedBool isTopOfPage;
|
||||
|
||||
// The type of frame, from css's perspective. This value is
|
||||
// initialized by the Init method below.
|
||||
nsCSSFrameType mFrameType;
|
||||
|
||||
nsISpaceManager* mSpaceManager;
|
||||
|
||||
// LineLayout object (only for inline reflow; set to NULL otherwise)
|
||||
nsLineLayout* mLineLayout;
|
||||
|
||||
// The computed width specifies the frame's content width, and it does not
|
||||
// apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic width as the computed width
|
||||
//
|
||||
// For block-level frames, the computed width is based on the width of the
|
||||
// containing block, the margin/border/padding areas, and the min/max width
|
||||
nscoord mComputedWidth;
|
||||
|
||||
// The computed height specifies the frame's content height, and it does
|
||||
// not apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic height as the computed height
|
||||
//
|
||||
// For non-replaced block-level frames in the flow and floated, a value of
|
||||
// NS_AUTOHEIGHT means you choose a height to shrink wrap around the normal
|
||||
// flow child frames. The height must be within the limit of the min/max
|
||||
// height if there is such a limit
|
||||
//
|
||||
// For replaced block-level frames, a value of NS_INTRINSICSIZE
|
||||
// means you use your intrinsic height as the computed height
|
||||
nscoord mComputedHeight;
|
||||
|
||||
// Computed margin values
|
||||
nsMargin mComputedMargin;
|
||||
|
||||
// Cached copy of the border values
|
||||
nsMargin mComputedBorderPadding;
|
||||
|
||||
// Computed padding values
|
||||
nsMargin mComputedPadding;
|
||||
|
||||
// Computed values for 'left/top/right/bottom' offsets. Only applies to
|
||||
// 'positioned' elements
|
||||
nsMargin mComputedOffsets;
|
||||
|
||||
// Computed values for 'min-width/max-width' and 'min-height/max-height'
|
||||
nscoord mComputedMinWidth, mComputedMaxWidth;
|
||||
nscoord mComputedMinHeight, mComputedMaxHeight;
|
||||
|
||||
// Compact margin available space
|
||||
nscoord mCompactMarginWidth;
|
||||
|
||||
// The following data members are relevant if nsStyleText.mTextAlign
|
||||
// == NS_STYLE_TEXT_ALIGN_CHAR
|
||||
|
||||
// distance from reference edge (as specified in nsStyleDisplay.mDirection)
|
||||
// to the align character (which will be specified in nsStyleTable)
|
||||
nscoord mAlignCharOffset;
|
||||
|
||||
// if true, the reflow honors alignCharOffset and does not
|
||||
// set it. if false, the reflow sets alignCharOffset
|
||||
PRPackedBool mUseAlignCharOffset;
|
||||
|
||||
// Cached pointers to the various style structs used during intialization
|
||||
const nsStyleDisplay* mStyleDisplay;
|
||||
const nsStylePosition* mStylePosition;
|
||||
const nsStyleSpacing* mStyleSpacing;
|
||||
|
||||
// This value keeps track of how deeply nested a given reflow state
|
||||
// is from the top of the frame tree.
|
||||
PRInt32 mReflowDepth;
|
||||
|
||||
// Note: The copy constructor is written by the compiler
|
||||
// automatically. You can use that and then override specific values
|
||||
// if you want, or you can call Init as desired...
|
||||
|
||||
// Initialize a <b>root</b> reflow state with a rendering context to
|
||||
// use for measuring things.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsReflowReason aReason,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a <b>root</b> reflow state for an <b>incremental</b>
|
||||
// reflow.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsIReflowCommand& aReflowCommand,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a reflow state for a child frames reflow. Some state
|
||||
// is copied from the parent reflow state; the remaining state is
|
||||
// computed.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nsReflowReason aReason);
|
||||
|
||||
// Same as the previous except that the reason is taken from the
|
||||
// parent's reflow state.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Used when you want to override the default containing block
|
||||
// width and height. Used by absolute positioning code
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
/**
|
||||
* Get the containing block reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetContainingBlockReflowState(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* First find the containing block's reflow state using
|
||||
* GetContainingBlockReflowState, then ask the containing block for
|
||||
* it's content width using GetContentWidth
|
||||
*/
|
||||
static nscoord
|
||||
GetContainingBlockContentWidth(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Get the page box reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetPageBoxReflowState(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Compute the border plus padding for <TT>aFrame</TT>. If a
|
||||
* percentage needs to be computed it will be computed by finding
|
||||
* the containing block, use GetContainingBlockReflowState.
|
||||
* aParentReflowState is aFrame's
|
||||
* parent's reflow state. The resulting computed border plus padding
|
||||
* is returned in aResult.
|
||||
*/
|
||||
static void ComputeBorderPaddingFor(nsIFrame* aFrame,
|
||||
const nsHTMLReflowState* aParentRS,
|
||||
nsMargin& aResult);
|
||||
|
||||
/**
|
||||
* Calculate the raw line-height property for the given frame. The return
|
||||
* value, if line-height was applied and is valid will be >= 0. Otherwise,
|
||||
* the return value will be <0 which is illegal (CSS2 spec: section 10.8.1).
|
||||
*/
|
||||
static nscoord CalcLineHeight(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIFrame* aFrame);
|
||||
|
||||
static PRBool UseComputedHeight();
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame);
|
||||
|
||||
void ComputeContainingBlockRectangle(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord& aContainingBlockWidth,
|
||||
nscoord& aContainingBlockHeight);
|
||||
|
||||
protected:
|
||||
// This method initializes various data members. It is automatically
|
||||
// called by the various constructors
|
||||
void Init(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth = -1,
|
||||
nscoord aContainingBlockHeight = -1);
|
||||
|
||||
void InitConstraints(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void InitAbsoluteConstraints(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeBlockBoxData(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nsStyleUnit aWidthUnit,
|
||||
nsStyleUnit aHeightUnit,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void CalculateBlockSideMargins(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord aComputedWidth);
|
||||
|
||||
void ComputeHorizontalValue(nscoord aContainingBlockWidth,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
void ComputeVerticalValue(nscoord aContainingBlockHeight,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame,
|
||||
const nsStylePosition* aPosition,
|
||||
const nsStyleDisplay* aDisplay);
|
||||
|
||||
// Computes margin values from the specified margin style information, and
|
||||
// fills in the mComputedMargin member
|
||||
void ComputeMargin(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Computes padding values from the specified padding style information, and
|
||||
// fills in the mComputedPadding member
|
||||
void ComputePadding(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Calculates the computed values for the 'min-Width', 'max-Width',
|
||||
// 'min-Height', and 'max-Height' properties, and stores them in the assorted
|
||||
// data members
|
||||
void ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
};
|
||||
|
||||
// For HTML reflow we rename with the different paint layers are
|
||||
// actually used for.
|
||||
#define NS_FRAME_PAINT_LAYER_BACKGROUND eFramePaintLayer_Underlay
|
||||
#define NS_FRAME_PAINT_LAYER_FLOATERS eFramePaintLayer_Content
|
||||
#define NS_FRAME_PAINT_LAYER_FOREGROUND eFramePaintLayer_Overlay
|
||||
#define NS_FRAME_PAINT_LAYER_DEBUG eFramePaintLayer_Overlay
|
||||
|
||||
/**
|
||||
* Reflow status returned by the reflow methods.
|
||||
*
|
||||
* NS_FRAME_NOT_COMPLETE bit flag means the frame does not map all its
|
||||
* content, and that the parent frame should create a continuing frame.
|
||||
* If this bit isn't set it means the frame does map all its content.
|
||||
*
|
||||
* NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
|
||||
* dirty, and also needs to be reflowed. This status only makes sense
|
||||
* for a frame that is not complete, i.e. you wouldn't set both
|
||||
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW
|
||||
*
|
||||
* The low 8 bits of the nsReflowStatus are reserved for future extensions;
|
||||
* the remaining 24 bits are zero (and available for extensions; however
|
||||
* API's that accept/return nsReflowStatus must not receive/return any
|
||||
* extension bits).
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
typedef PRUint32 nsReflowStatus;
|
||||
|
||||
#define NS_FRAME_COMPLETE 0 // Note: not a bit!
|
||||
#define NS_FRAME_NOT_COMPLETE 0x1
|
||||
#define NS_FRAME_REFLOW_NEXTINFLOW 0x2
|
||||
|
||||
#define NS_FRAME_IS_COMPLETE(status) \
|
||||
(0 == ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
#define NS_FRAME_IS_NOT_COMPLETE(status) \
|
||||
(0 != ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
// This macro tests to see if an nsReflowStatus is an error value
|
||||
// or just a regular return value
|
||||
#define NS_IS_REFLOW_ERROR(_status) (PRInt32(_status) < 0)
|
||||
|
||||
/**
|
||||
* Extensions to the reflow status bits defined by nsIFrameReflow
|
||||
*/
|
||||
|
||||
// This bit is set, when a break is requested. This bit is orthogonal
|
||||
// to the nsIFrame::nsReflowStatus completion bits.
|
||||
#define NS_INLINE_BREAK 0x0100
|
||||
|
||||
// When a break is requested, this bit when set indicates that the
|
||||
// break should occur after the frame just reflowed; when the bit is
|
||||
// clear the break should occur before the frame just reflowed.
|
||||
#define NS_INLINE_BREAK_BEFORE 0x0000
|
||||
#define NS_INLINE_BREAK_AFTER 0x0200
|
||||
|
||||
// The type of break requested can be found in these bits.
|
||||
#define NS_INLINE_BREAK_TYPE_MASK 0xF000
|
||||
|
||||
//----------------------------------------
|
||||
// Macros that use those bits
|
||||
|
||||
#define NS_INLINE_IS_BREAK(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_AFTER(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK_AFTER))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_BEFORE(_status) \
|
||||
(NS_INLINE_BREAK == ((_status) & (NS_INLINE_BREAK|NS_INLINE_BREAK_AFTER)))
|
||||
|
||||
#define NS_INLINE_GET_BREAK_TYPE(_status) (((_status) >> 12) & 0xF)
|
||||
|
||||
#define NS_INLINE_MAKE_BREAK_TYPE(_type) ((_type) << 12)
|
||||
|
||||
// Construct a line-break-before status. Note that there is no
|
||||
// completion status for a line-break before because we *know* that
|
||||
// the frame will be reflowed later and hence it's current completion
|
||||
// status doesn't matter.
|
||||
#define NS_INLINE_LINE_BREAK_BEFORE() \
|
||||
(NS_INLINE_BREAK | NS_INLINE_BREAK_BEFORE | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
// Take a completion status and add to it the desire to have a
|
||||
// line-break after. For this macro we do need the completion status
|
||||
// because the user of the status will need to know whether to
|
||||
// continue the frame or not.
|
||||
#define NS_INLINE_LINE_BREAK_AFTER(_completionStatus) \
|
||||
((_completionStatus) | NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DidReflow status values.
|
||||
*/
|
||||
typedef PRBool nsDidReflowStatus;
|
||||
|
||||
#define NS_FRAME_REFLOW_NOT_FINISHED PR_FALSE
|
||||
#define NS_FRAME_REFLOW_FINISHED PR_TRUE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A frame in the layout model. This interface is supported by all frame
|
||||
* objects.
|
||||
|
@ -566,6 +1057,97 @@ public:
|
|||
NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0;
|
||||
NS_IMETHOD SetNextInFlow(nsIFrame*) = 0;
|
||||
|
||||
/**
|
||||
* Pre-reflow hook. Before a frame is reflowed this method will be called.
|
||||
* This call will always be invoked at least once before a subsequent Reflow
|
||||
* and DidReflow call. It may be called more than once, In general you will
|
||||
* receive on WillReflow notification before each Reflow request.
|
||||
*
|
||||
* XXX Is this really the semantics we want? Because we have the NS_FRAME_IN_REFLOW
|
||||
* bit we can ensure we don't call it more than once...
|
||||
*/
|
||||
NS_IMETHOD WillReflow(nsIPresContext& aPresContext) = 0;
|
||||
|
||||
/**
|
||||
* The frame is given a maximum size and asked for its desired size.
|
||||
* This is the frame's opportunity to reflow its children.
|
||||
*
|
||||
* @param aDesiredSize <i>out</i> parameter where you should return the
|
||||
* desired size and ascent/descent info. You should include any
|
||||
* space you want for border/padding in the desired size you return.
|
||||
*
|
||||
* It's okay to return a desired size that exceeds the max
|
||||
* size if that's the smallest you can be, i.e. it's your
|
||||
* minimum size.
|
||||
*
|
||||
* maxElementSize is an optional parameter for returning your
|
||||
* maximum element size. If may be null in which case you
|
||||
* don't have to compute a maximum element size. The
|
||||
* maximum element size must be less than or equal to your
|
||||
* desired size.
|
||||
*
|
||||
* For an incremental reflow you are responsible for invalidating
|
||||
* any area within your frame that needs repainting (including
|
||||
* borders). If your new desired size is different than your current
|
||||
* size, then your parent frame is responsible for making sure that
|
||||
* the difference between the two rects is repainted
|
||||
*
|
||||
* @param aReflowState information about your reflow including the reason
|
||||
* for the reflow and the available space in which to lay out. Each
|
||||
* dimension of the available space can either be constrained or
|
||||
* unconstrained (a value of NS_UNCONSTRAINEDSIZE). If constrained
|
||||
* you should choose a value that's less than or equal to the
|
||||
* constrained size. If unconstrained you can choose as
|
||||
* large a value as you like.
|
||||
*
|
||||
* Note that the available space can be negative. In this case you
|
||||
* still must return an accurate desired size. If you're a container
|
||||
* you must <b>always</b> reflow at least one frame regardless of the
|
||||
* available space
|
||||
*
|
||||
* @param aStatus a return value indicating whether the frame is complete
|
||||
* and whether the next-in-flow is dirty and needs to be reflowed
|
||||
*/
|
||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aReflowMetrics,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Post-reflow hook. After a frame is reflowed this method will be called
|
||||
* informing the frame that this reflow process is complete, and telling the
|
||||
* frame the status returned by the Reflow member function.
|
||||
*
|
||||
* This call may be invoked many times, while NS_FRAME_IN_REFLOW is set, before
|
||||
* it is finally called once with a NS_FRAME_REFLOW_COMPLETE value. When called
|
||||
* with a NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
|
||||
* frame state will be cleared.
|
||||
*
|
||||
* XXX This doesn't make sense. If the frame is reflowed but not complete, then
|
||||
* the status should be NS_FRAME_NOT_COMPLETE and not NS_FRAME_COMPLETE
|
||||
* XXX Don't we want the semantics to dictate that we only call this once for
|
||||
* a given reflow?
|
||||
*/
|
||||
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus) = 0;
|
||||
|
||||
// XXX Maybe these three should be a separate interface?
|
||||
|
||||
// Helper method used by block reflow to identify runs of text so that
|
||||
// proper word-breaking can be done.
|
||||
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout) = 0;
|
||||
|
||||
// Justification helper method used to distribute extra space in a
|
||||
// line to leaf frames. aUsedSpace is filled in with the amount of
|
||||
// space actually used.
|
||||
NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace) = 0;
|
||||
|
||||
// Justification helper method that is used to remove trailing
|
||||
// whitespace before justification.
|
||||
NS_IMETHOD TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRC,
|
||||
nscoord& aDeltaWidth) = 0;
|
||||
|
||||
/**
|
||||
* Accessor functions to get/set the associated view object
|
||||
*/
|
||||
|
|
|
@ -1,263 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsIFrameReflow_h___
|
||||
#define nsIFrameReflow_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIPresContext;
|
||||
class nsIReflowCommand;
|
||||
class nsIRenderingContext;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reflow metrics used to return the frame's desired size and alignment
|
||||
* information.
|
||||
*
|
||||
* @see #Reflow()
|
||||
* @see #GetReflowMetrics()
|
||||
*/
|
||||
struct nsReflowMetrics {
|
||||
nscoord width, height; // [OUT] desired width and height
|
||||
nscoord ascent, descent; // [OUT] ascent and descent information
|
||||
|
||||
// Set this to null if you don't need to compute the max element size
|
||||
nsSize* maxElementSize; // [IN OUT]
|
||||
|
||||
nsReflowMetrics(nsSize* aMaxElementSize) {
|
||||
maxElementSize = aMaxElementSize;
|
||||
|
||||
// XXX These are OUT parameters and so they shouldn't have to be
|
||||
// initialized, but there are some bad frame classes that aren't
|
||||
// properly setting them when returning from Reflow()...
|
||||
width = height = 0;
|
||||
ascent = descent = 0;
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constant used to indicate an unconstrained size.
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The reason the frame is being reflowed.
|
||||
*
|
||||
* XXX Should probably be a #define so it can be extended for specialized
|
||||
* reflow interfaces...
|
||||
*
|
||||
* @see nsReflowState
|
||||
*/
|
||||
enum nsReflowReason {
|
||||
eReflowReason_Initial = 0, // initial reflow of a newly created frame
|
||||
eReflowReason_Incremental = 1, // an incremental change has occured. see the reflow command for details
|
||||
eReflowReason_Resize = 2, // general request to determine a desired size
|
||||
eReflowReason_StyleChange = 3 // request to reflow because of a style change. Note: you must reflow
|
||||
// all your child frames
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reflow state passed to a frame during reflow. The reflow states are linked
|
||||
* together. The availableWidth and availableHeight represent the available
|
||||
* space in which to reflow your frame, and are computed based on the parent
|
||||
* frame's computed width and computed height. The available space is the total
|
||||
* space including margins, border, padding, and content area. A value of
|
||||
* NS_UNCONSTRAINEDSIZE means you can choose whatever size you want
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
struct nsReflowState {
|
||||
// pointer to parent's reflow state
|
||||
const nsReflowState* parentReflowState;
|
||||
|
||||
// the frame being reflowed
|
||||
nsIFrame* frame;
|
||||
|
||||
// the reason for the reflow
|
||||
nsReflowReason reason;
|
||||
|
||||
// the reflow command. only set for eReflowReason_Incremental
|
||||
nsIReflowCommand* reflowCommand;
|
||||
|
||||
// the available space in which to reflow
|
||||
nscoord availableWidth, availableHeight;
|
||||
|
||||
// rendering context to use for measurement
|
||||
nsIRenderingContext* rendContext;
|
||||
|
||||
// is the current context at the top of a page?
|
||||
PRPackedBool isTopOfPage;
|
||||
|
||||
// Note: there is no copy constructor, so the compiler can generate an
|
||||
// optimal one.
|
||||
|
||||
protected:
|
||||
nsReflowState() { }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reflow status returned by the reflow methods.
|
||||
*
|
||||
* NS_FRAME_NOT_COMPLETE bit flag means the frame does not map all its
|
||||
* content, and that the parent frame should create a continuing frame.
|
||||
* If this bit isn't set it means the frame does map all its content.
|
||||
*
|
||||
* NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
|
||||
* dirty, and also needs to be reflowed. This status only makes sense
|
||||
* for a frame that is not complete, i.e. you wouldn't set both
|
||||
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW
|
||||
*
|
||||
* The low 8 bits of the nsReflowStatus are reserved for future extensions;
|
||||
* the remaining 24 bits are zero (and available for extensions; however
|
||||
* API's that accept/return nsReflowStatus must not receive/return any
|
||||
* extension bits).
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
typedef PRUint32 nsReflowStatus;
|
||||
|
||||
#define NS_FRAME_COMPLETE 0 // Note: not a bit!
|
||||
#define NS_FRAME_NOT_COMPLETE 0x1
|
||||
#define NS_FRAME_REFLOW_NEXTINFLOW 0x2
|
||||
|
||||
#define NS_FRAME_IS_COMPLETE(status) \
|
||||
(0 == ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
#define NS_FRAME_IS_NOT_COMPLETE(status) \
|
||||
(0 != ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
// This macro tests to see if an nsReflowStatus is an error value
|
||||
// or just a regular return value
|
||||
#define NS_IS_REFLOW_ERROR(_status) (PRInt32(_status) < 0)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DidReflow status values.
|
||||
*/
|
||||
typedef PRBool nsDidReflowStatus;
|
||||
|
||||
#define NS_FRAME_REFLOW_NOT_FINISHED PR_FALSE
|
||||
#define NS_FRAME_REFLOW_FINISHED PR_TRUE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Basic layout protocol.
|
||||
*
|
||||
* This template class defines the basic layout reflow protocol. You instantiate
|
||||
* a particular reflow interface by specifying the reflow state and reflow
|
||||
* metrics structures. These can be nsReflowState and nsReflowMetrics, or
|
||||
* they can be derived structures containing additional information.
|
||||
*/
|
||||
template<class ReflowState, class ReflowMetrics> class nsIFrameReflow : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Pre-reflow hook. Before a frame is reflowed this method will be called.
|
||||
* This call will always be invoked at least once before a subsequent Reflow
|
||||
* and DidReflow call. It may be called more than once, In general you will
|
||||
* receive on WillReflow notification before each Reflow request.
|
||||
*
|
||||
* XXX Is this really the semantics we want? Because we have the NS_FRAME_IN_REFLOW
|
||||
* bit we can ensure we don't call it more than once...
|
||||
*/
|
||||
NS_IMETHOD WillReflow(nsIPresContext& aPresContext) = 0;
|
||||
|
||||
/**
|
||||
* The frame is given a maximum size and asked for its desired size.
|
||||
* This is the frame's opportunity to reflow its children.
|
||||
*
|
||||
* @param aDesiredSize <i>out</i> parameter where you should return the
|
||||
* desired size and ascent/descent info. You should include any
|
||||
* space you want for border/padding in the desired size you return.
|
||||
*
|
||||
* It's okay to return a desired size that exceeds the max
|
||||
* size if that's the smallest you can be, i.e. it's your
|
||||
* minimum size.
|
||||
*
|
||||
* maxElementSize is an optional parameter for returning your
|
||||
* maximum element size. If may be null in which case you
|
||||
* don't have to compute a maximum element size. The
|
||||
* maximum element size must be less than or equal to your
|
||||
* desired size.
|
||||
*
|
||||
* For an incremental reflow you are responsible for invalidating
|
||||
* any area within your frame that needs repainting (including
|
||||
* borders). If your new desired size is different than your current
|
||||
* size, then your parent frame is responsible for making sure that
|
||||
* the difference between the two rects is repainted
|
||||
*
|
||||
* @param aReflowState information about your reflow including the reason
|
||||
* for the reflow and the available space in which to lay out. Each
|
||||
* dimension of the available space can either be constrained or
|
||||
* unconstrained (a value of NS_UNCONSTRAINEDSIZE). If constrained
|
||||
* you should choose a value that's less than or equal to the
|
||||
* constrained size. If unconstrained you can choose as
|
||||
* large a value as you like.
|
||||
*
|
||||
* Note that the available space can be negative. In this case you
|
||||
* still must return an accurate desired size. If you're a container
|
||||
* you must <b>always</b> reflow at least one frame regardless of the
|
||||
* available space
|
||||
*
|
||||
* @param aStatus a return value indicating whether the frame is complete
|
||||
* and whether the next-in-flow is dirty and needs to be reflowed
|
||||
*/
|
||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||
ReflowMetrics& aDesiredSize,
|
||||
const ReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Post-reflow hook. After a frame is reflowed this method will be called
|
||||
* informing the frame that this reflow process is complete, and telling the
|
||||
* frame the status returned by the Reflow member function.
|
||||
*
|
||||
* This call may be invoked many times, while NS_FRAME_IN_REFLOW is set, before
|
||||
* it is finally called once with a NS_FRAME_REFLOW_COMPLETE value. When called
|
||||
* with a NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
|
||||
* frame state will be cleared.
|
||||
*
|
||||
* XXX This doesn't make sense. If the frame is reflowed but not complete, then
|
||||
* the status should be NS_FRAME_NOT_COMPLETE and not NS_FRAME_COMPLETE
|
||||
* XXX Don't we want the semantics to dictate that we only call this once for
|
||||
* a given reflow?
|
||||
*/
|
||||
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus) = 0;
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIFrameReflow_h___ */
|
|
@ -256,118 +256,114 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
|
|||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
}
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
|
||||
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize, aContainingBlockWidth,
|
||||
aContainingBlockHeight);
|
||||
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize, aContainingBlockWidth,
|
||||
aContainingBlockHeight);
|
||||
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Because we don't know the size of a replaced element until after we reflow
|
||||
// it 'auto' margins must be computed now, and we need to take into account
|
||||
// min-max information
|
||||
if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) {
|
||||
// Factor in any minimum and maximum size information
|
||||
if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMaxWidth;
|
||||
} else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMinWidth;
|
||||
}
|
||||
if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMaxHeight;
|
||||
} else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMinHeight;
|
||||
}
|
||||
|
||||
rv = htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
// Get the containing block width/height
|
||||
nscoord containingBlockWidth, containingBlockHeight;
|
||||
kidReflowState.ComputeContainingBlockRectangle(&aReflowState,
|
||||
containingBlockWidth,
|
||||
containingBlockHeight);
|
||||
|
||||
// Because we don't know the size of a replaced element until after we reflow
|
||||
// it 'auto' margins must be computed now, and we need to take into account
|
||||
// min-max information
|
||||
if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) {
|
||||
// Factor in any minimum and maximum size information
|
||||
if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMaxWidth;
|
||||
} else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMinWidth;
|
||||
}
|
||||
if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMaxHeight;
|
||||
} else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMinHeight;
|
||||
}
|
||||
// XXX This code belongs in nsHTMLReflowState...
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.right)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockWidth -
|
||||
kidReflowState.mComputedOffsets.left - kidReflowState.mComputedBorderPadding.left -
|
||||
kidDesiredSize.width - kidReflowState.mComputedBorderPadding.right -
|
||||
kidReflowState.mComputedOffsets.right;
|
||||
|
||||
// Get the containing block width/height
|
||||
nscoord containingBlockWidth, containingBlockHeight;
|
||||
kidReflowState.ComputeContainingBlockRectangle(&aReflowState,
|
||||
containingBlockWidth,
|
||||
containingBlockHeight);
|
||||
|
||||
// XXX This code belongs in nsHTMLReflowState...
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.right)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockWidth -
|
||||
kidReflowState.mComputedOffsets.left - kidReflowState.mComputedBorderPadding.left -
|
||||
kidDesiredSize.width - kidReflowState.mComputedBorderPadding.right -
|
||||
kidReflowState.mComputedOffsets.right;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.right) {
|
||||
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
} else {
|
||||
// Just 'margin-left' is 'auto'
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.right;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-right' is 'auto'
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.right) {
|
||||
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
}
|
||||
}
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockHeight -
|
||||
kidReflowState.mComputedOffsets.top - kidReflowState.mComputedBorderPadding.top -
|
||||
kidDesiredSize.height - kidReflowState.mComputedBorderPadding.bottom -
|
||||
kidReflowState.mComputedOffsets.bottom;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom) {
|
||||
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
} else {
|
||||
// Just 'margin-top' is 'auto'
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-bottom' is 'auto'
|
||||
// Just 'margin-left' is 'auto'
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.right;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-right' is 'auto'
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
}
|
||||
}
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockHeight -
|
||||
kidReflowState.mComputedOffsets.top - kidReflowState.mComputedBorderPadding.top -
|
||||
kidDesiredSize.height - kidReflowState.mComputedBorderPadding.bottom -
|
||||
kidReflowState.mComputedOffsets.bottom;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom) {
|
||||
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
} else {
|
||||
// Just 'margin-top' is 'auto'
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-bottom' is 'auto'
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child relative to our padding edge
|
||||
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
}
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child relative to our padding edge
|
||||
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define nsAbsoluteContainingBlock_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsFrameList.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsBlockBandData.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -221,12 +221,7 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
|
|||
mY = y;
|
||||
|
||||
// Let frame know that we are reflowing it
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = aFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
htmlReflow->WillReflow(*mPresContext);
|
||||
aFrame->WillReflow(*mPresContext);
|
||||
|
||||
#ifdef DEBUG
|
||||
mMetrics.width = nscoord(0xdeadbeef);
|
||||
|
@ -249,8 +244,8 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
|
|||
nscoord tx = x - mOuterReflowState.mComputedBorderPadding.left;
|
||||
nscoord ty = y - mOuterReflowState.mComputedBorderPadding.top;
|
||||
mOuterReflowState.mSpaceManager->Translate(tx, ty);
|
||||
rv = htmlReflow->Reflow(*mPresContext, mMetrics, reflowState,
|
||||
aFrameReflowStatus);
|
||||
rv = aFrame->Reflow(*mPresContext, mMetrics, reflowState,
|
||||
aFrameReflowStatus);
|
||||
mOuterReflowState.mSpaceManager->Translate(-tx, -ty);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef nsBlockReflowContext_h___
|
||||
#define nsBlockReflowContext_h___
|
||||
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsBlockFrame;
|
||||
class nsIFrame;
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -111,12 +111,7 @@ nsContainerFrame::DidReflow(nsIPresContext& aPresContext,
|
|||
nsIFrame* kid;
|
||||
FirstChild(listName, &kid);
|
||||
while (nsnull != kid) {
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv;
|
||||
rv = kid->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->DidReflow(aPresContext, aStatus);
|
||||
}
|
||||
kid->DidReflow(aPresContext, aStatus);
|
||||
kid->GetNextSibling(&kid);
|
||||
}
|
||||
NS_IF_RELEASE(listName);
|
||||
|
@ -354,13 +349,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|||
{
|
||||
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
|
||||
|
||||
// Query for the nsIHTMLReflow interface
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult result;
|
||||
result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
nsresult result;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsSize* saveMaxElementSize = aDesiredSize.maxElementSize;
|
||||
|
@ -373,9 +362,9 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|||
#endif
|
||||
|
||||
// Send the WillReflow notification, and reflow the child frame
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState,
|
||||
aStatus);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
result = aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState,
|
||||
aStatus);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (saveMaxElementSize != aDesiredSize.maxElementSize) {
|
||||
|
|
|
@ -153,11 +153,7 @@ nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
{
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
while (nsnull != frame) {
|
||||
nsIHTMLReflow* ihr;
|
||||
nsresult rv = frame->QueryInterface(kIHTMLReflowIID, (void**)&ihr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ihr->FindTextRuns(aLineLayout);
|
||||
}
|
||||
frame->FindTextRuns(aLineLayout);
|
||||
frame->GetNextSibling(&frame);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -209,13 +205,8 @@ nsFirstLetterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
rs.mLineLayout = ≪
|
||||
ll.SetFirstLetterStyleOK(PR_TRUE);
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = kid->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
htmlReflow->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
||||
kid->WillReflow(aPresContext);
|
||||
kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
||||
|
||||
ll.EndLineReflow();
|
||||
}
|
||||
|
|
|
@ -220,10 +220,7 @@ nsresult nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, kIFrameIID);
|
||||
if (aIID.Equals(kIHTMLReflowIID)) {
|
||||
*aInstancePtr = (void*)(nsIHTMLReflow*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
||||
if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define nsFrame_h___
|
||||
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsString.h"
|
||||
#include "prlog.h"
|
||||
|
@ -93,7 +92,7 @@
|
|||
* Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default
|
||||
* behavior is to keep the frame and view position and size in sync.
|
||||
*/
|
||||
class nsFrame : public nsIFrame, public nsIHTMLReflow
|
||||
class nsFrame : public nsIFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -350,16 +350,12 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstChild,
|
||||
innerSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == firstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(offset.x, offset.y, innerSize.width, innerSize.height);
|
||||
firstChild->SetRect(&aPresContext, rect);
|
||||
}
|
||||
// Place and size the child
|
||||
nsRect rect(offset.x, offset.y, innerSize.width, innerSize.height);
|
||||
firstChild->SetRect(&aPresContext, rect);
|
||||
|
||||
// XXX what should the max-element-size of an iframe be? Shouldn't
|
||||
// iframe's normally shrink wrap around their content when they
|
||||
|
|
|
@ -771,22 +771,19 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
|||
}
|
||||
|
||||
// reflow and place the child
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
||||
nsHTMLReflowMetrics metrics(nsnull);
|
||||
metrics.width = aSize.width;
|
||||
metrics.height= aSize.height;
|
||||
nsReflowStatus status;
|
||||
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
||||
nsHTMLReflowMetrics metrics(nsnull);
|
||||
metrics.width = aSize.width;
|
||||
metrics.height= aSize.height;
|
||||
nsReflowStatus status;
|
||||
|
||||
ReflowChild(aChild, aPresContext, metrics, reflowState, status);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
||||
ReflowChild(aChild, aPresContext, metrics, reflowState, status);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(aOffset.x, aOffset.y, aSize.width, aSize.height);
|
||||
aChild->SetRect(&aPresContext, rect);
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // this call is needed
|
||||
}
|
||||
// Place and size the child
|
||||
nsRect rect(aOffset.x, aOffset.y, aSize.width, aSize.height);
|
||||
aChild->SetRect(&aPresContext, rect);
|
||||
aChild->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // this call is needed
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
@ -319,83 +319,80 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
|
||||
// The document element's background should cover the entire canvas, so
|
||||
// take into account the combined area and any space taken up by
|
||||
// absolutely positioned elements
|
||||
nsMargin border;
|
||||
nsFrameState kidState;
|
||||
// The document element's background should cover the entire canvas, so
|
||||
// take into account the combined area and any space taken up by
|
||||
// absolutely positioned elements
|
||||
nsMargin border;
|
||||
nsFrameState kidState;
|
||||
|
||||
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
|
||||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
|
||||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
}
|
||||
kidFrame->GetFrameState(&kidState);
|
||||
|
||||
// First check the combined area
|
||||
if (NS_FRAME_OUTSIDE_CHILDREN & kidState) {
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the child frame's padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (kidDesiredSize.mCombinedArea.XMost() > paddingEdgeX) {
|
||||
kidDesiredSize.width = kidDesiredSize.mCombinedArea.XMost() +
|
||||
border.right;
|
||||
}
|
||||
kidFrame->GetFrameState(&kidState);
|
||||
|
||||
// First check the combined area
|
||||
if (NS_FRAME_OUTSIDE_CHILDREN & kidState) {
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the child frame's padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (kidDesiredSize.mCombinedArea.XMost() > paddingEdgeX) {
|
||||
kidDesiredSize.width = kidDesiredSize.mCombinedArea.XMost() +
|
||||
border.right;
|
||||
}
|
||||
if (kidDesiredSize.mCombinedArea.YMost() > paddingEdgeY) {
|
||||
kidDesiredSize.height = kidDesiredSize.mCombinedArea.YMost() +
|
||||
border.bottom;
|
||||
}
|
||||
if (kidDesiredSize.mCombinedArea.YMost() > paddingEdgeY) {
|
||||
kidDesiredSize.height = kidDesiredSize.mCombinedArea.YMost() +
|
||||
border.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX It would be nice if this were also part of the reflow metrics...
|
||||
nsIAreaFrame* areaFrame;
|
||||
if (NS_SUCCEEDED(kidFrame->QueryInterface(kAreaFrameIID, (void**)&areaFrame))) {
|
||||
// Get the x-most and y-most of the absolutely positioned children
|
||||
nscoord positionedXMost, positionedYMost;
|
||||
areaFrame->GetPositionedInfo(positionedXMost, positionedYMost);
|
||||
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
// XXX It would be nice if this were also part of the reflow metrics...
|
||||
nsIAreaFrame* areaFrame;
|
||||
if (NS_SUCCEEDED(kidFrame->QueryInterface(kAreaFrameIID, (void**)&areaFrame))) {
|
||||
// Get the x-most and y-most of the absolutely positioned children
|
||||
nscoord positionedXMost, positionedYMost;
|
||||
areaFrame->GetPositionedInfo(positionedXMost, positionedYMost);
|
||||
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (positionedXMost > paddingEdgeX) {
|
||||
kidDesiredSize.width = positionedXMost + border.right;
|
||||
}
|
||||
if (positionedYMost > paddingEdgeY) {
|
||||
kidDesiredSize.height = positionedYMost + border.bottom;
|
||||
}
|
||||
if (positionedXMost > paddingEdgeX) {
|
||||
kidDesiredSize.width = positionedXMost + border.right;
|
||||
}
|
||||
|
||||
// If our height is fixed, then make sure the child frame plus its top and
|
||||
// bottom margin is at least that high as well...
|
||||
if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) {
|
||||
nscoord totalHeight = kidDesiredSize.height + kidReflowState.mComputedMargin.top +
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
|
||||
if (totalHeight < aReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height += aReflowState.mComputedHeight - totalHeight;
|
||||
}
|
||||
if (positionedYMost > paddingEdgeY) {
|
||||
kidDesiredSize.height = positionedYMost + border.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position and size the child frame
|
||||
nsRect rect(kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
// If our height is fixed, then make sure the child frame plus its top and
|
||||
// bottom margin is at least that high as well...
|
||||
if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) {
|
||||
nscoord totalHeight = kidDesiredSize.height + kidReflowState.mComputedMargin.top +
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
|
||||
// If the child frame was just inserted, then we're responsible for making sure
|
||||
// it repaints
|
||||
if (isDirtyChildReflow) {
|
||||
// Damage the area occupied by the deleted frame
|
||||
Invalidate(&aPresContext, rect, PR_FALSE);
|
||||
if (totalHeight < aReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height += aReflowState.mComputedHeight - totalHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Position and size the child frame
|
||||
nsRect rect(kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
|
||||
// If the child frame was just inserted, then we're responsible for making sure
|
||||
// it repaints
|
||||
if (isDirtyChildReflow) {
|
||||
// Damage the area occupied by the deleted frame
|
||||
Invalidate(&aPresContext, rect, PR_FALSE);
|
||||
}
|
||||
|
||||
// Return our desired size
|
||||
aDesiredSize.width = kidDesiredSize.width + kidReflowState.mComputedMargin.left +
|
||||
kidReflowState.mComputedMargin.right;
|
||||
|
@ -405,7 +402,7 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
|||
aDesiredSize.descent = 0;
|
||||
// XXX Don't completely ignore NS_FRAME_OUTSIDE_CHILDREN for child frames
|
||||
// that stick out on the left or top edges...
|
||||
|
||||
|
||||
// XXX Temporary hack. Remember this for later when our parent resizes us.
|
||||
// See SetRect()
|
||||
mNaturalHeight = aDesiredSize.height;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsHTMLReflowCommand.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -129,13 +128,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext,
|
|||
|
||||
nsHTMLReflowState reflowState(aPresContext, root, *this,
|
||||
&aRendContext, aMaxSize);
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsReflowStatus status;
|
||||
|
||||
if (NS_OK == root->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(aPresContext, aDesiredSize, reflowState, status);
|
||||
}
|
||||
root->Reflow(aPresContext, aDesiredSize, reflowState, status);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
@ -177,7 +176,7 @@ nsHTMLReflowState::Init(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
const nsHTMLReflowState*
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
while (nsnull != aParentRS) {
|
||||
if (nsnull != aParentRS->frame) {
|
||||
|
@ -186,7 +185,7 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
|||
// reflow state...
|
||||
nsresult rv = aParentRS->frame->IsPercentageBase(isContainingBlock);
|
||||
if (NS_SUCCEEDED(rv) && isContainingBlock) {
|
||||
return (const nsHTMLReflowState*) aParentRS;
|
||||
return aParentRS;
|
||||
}
|
||||
}
|
||||
aParentRS = aParentRS->parentReflowState;
|
||||
|
@ -195,20 +194,20 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
|||
}
|
||||
|
||||
const nsHTMLReflowState*
|
||||
nsHTMLReflowState::GetPageBoxReflowState(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetPageBoxReflowState(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
// XXX write me as soon as we can ask a frame if it's a page frame...
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
nscoord width = 0;
|
||||
const nsHTMLReflowState* rs =
|
||||
GetContainingBlockReflowState(aParentRS);
|
||||
if (nsnull != rs) {
|
||||
return ((nsHTMLReflowState*)aParentRS)->mComputedWidth;/* XXX cast */
|
||||
return aParentRS->mComputedWidth;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleStruct.h"
|
||||
#include "nsStyleCoord.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
|
@ -41,6 +43,9 @@ class nsAutoString;
|
|||
class nsString;
|
||||
class nsIFocusTracker;
|
||||
class nsStyleChangeList;
|
||||
class nsISpaceManager;
|
||||
class nsBlockFrame;
|
||||
class nsLineLayout;
|
||||
|
||||
struct nsPeekOffsetStruct;
|
||||
struct nsPoint;
|
||||
|
@ -49,6 +54,9 @@ struct nsStyleStruct;
|
|||
class nsIDOMRange;
|
||||
class nsICaret;
|
||||
struct PRLogModuleInfo;
|
||||
struct nsStyleDisplay;
|
||||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
// IID for the nsIFrame interface
|
||||
// a6cf9050-15b3-11d2-932e-00805f8add32
|
||||
|
@ -177,6 +185,489 @@ enum nsSpread {
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reflow metrics used to return the frame's desired size and alignment
|
||||
* information.
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
struct nsHTMLReflowMetrics {
|
||||
nscoord width, height; // [OUT] desired width and height
|
||||
nscoord ascent, descent; // [OUT] ascent and descent information
|
||||
|
||||
// Set this to null if you don't need to compute the max element size
|
||||
nsSize* maxElementSize; // [IN OUT]
|
||||
|
||||
// Carried out bottom margin values. This is the collapsed
|
||||
// (generational) bottom margin value.
|
||||
nscoord mCarriedOutBottomMargin;
|
||||
|
||||
// For frames that have children that stick outside their rect
|
||||
// (NS_FRAME_OUTSIDE_CHILDREN) this rectangle will contain the
|
||||
// absolute bounds of the frame. Since the frame doesn't know where
|
||||
// it is going to be positioned in its parent, the assumption is
|
||||
// that it is placed at 0,0 when computing this area.
|
||||
nsRect mCombinedArea;
|
||||
|
||||
nsHTMLReflowMetrics(nsSize* aMaxElementSize) {
|
||||
maxElementSize = aMaxElementSize;
|
||||
mCarriedOutBottomMargin = 0;
|
||||
mCombinedArea.x = 0;
|
||||
mCombinedArea.y = 0;
|
||||
mCombinedArea.width = 0;
|
||||
mCombinedArea.height = 0;
|
||||
|
||||
// XXX These are OUT parameters and so they shouldn't have to be
|
||||
// initialized, but there are some bad frame classes that aren't
|
||||
// properly setting them when returning from Reflow()...
|
||||
width = height = 0;
|
||||
ascent = descent = 0;
|
||||
}
|
||||
|
||||
void AddBorderPaddingToMaxElementSize(const nsMargin& aBorderPadding) {
|
||||
maxElementSize->width += aBorderPadding.left + aBorderPadding.right;
|
||||
maxElementSize->height += aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
};
|
||||
|
||||
// Carried out margin flags
|
||||
#define NS_CARRIED_TOP_MARGIN_IS_AUTO 0x1
|
||||
#define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
|
||||
|
||||
/**
|
||||
* Constant used to indicate an unconstrained size.
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
#define NS_UNCONSTRAINEDSIZE NS_MAXSIZE
|
||||
|
||||
/**
|
||||
* The reason the frame is being reflowed.
|
||||
*
|
||||
* XXX Should probably be a #define so it can be extended for specialized
|
||||
* reflow interfaces...
|
||||
*
|
||||
* @see nsReflowState
|
||||
*/
|
||||
enum nsReflowReason {
|
||||
eReflowReason_Initial = 0, // initial reflow of a newly created frame
|
||||
eReflowReason_Incremental = 1, // an incremental change has occured. see the reflow command for details
|
||||
eReflowReason_Resize = 2, // general request to determine a desired size
|
||||
eReflowReason_StyleChange = 3 // request to reflow because of a style change. Note: you must reflow
|
||||
// all your child frames
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CSS Frame type. Included as part of the reflow state.
|
||||
*/
|
||||
typedef PRUint32 nsCSSFrameType;
|
||||
|
||||
#define NS_CSS_FRAME_TYPE_UNKNOWN 0
|
||||
#define NS_CSS_FRAME_TYPE_INLINE 1
|
||||
#define NS_CSS_FRAME_TYPE_BLOCK 2 /* block-level in normal flow */
|
||||
#define NS_CSS_FRAME_TYPE_FLOATING 3
|
||||
#define NS_CSS_FRAME_TYPE_ABSOLUTE 4
|
||||
#define NS_CSS_FRAME_TYPE_INTERNAL_TABLE 5 /* row group frame, row frame, cell frame, ... */
|
||||
|
||||
/**
|
||||
* Bit-flag that indicates whether the element is replaced. Applies to inline,
|
||||
* block-level, floating, and absolutely positioned elements
|
||||
*/
|
||||
#define NS_CSS_FRAME_TYPE_REPLACED 0x8000
|
||||
|
||||
/**
|
||||
* Helper macros for telling whether items are replaced
|
||||
*/
|
||||
#define NS_FRAME_IS_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED == ((_ft) & NS_CSS_FRAME_TYPE_REPLACED))
|
||||
|
||||
#define NS_FRAME_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED | (_ft))
|
||||
|
||||
/**
|
||||
* A macro to extract the type. Masks off the 'replaced' bit-flag
|
||||
*/
|
||||
#define NS_FRAME_GET_TYPE(_ft) \
|
||||
((_ft) & ~NS_CSS_FRAME_TYPE_REPLACED)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define NS_INTRINSICSIZE NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOHEIGHT NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOMARGIN NS_UNCONSTRAINEDSIZE
|
||||
|
||||
/**
|
||||
* Reflow state passed to a frame during reflow. The reflow states are linked
|
||||
* together. The availableWidth and availableHeight represent the available
|
||||
* space in which to reflow your frame, and are computed based on the parent
|
||||
* frame's computed width and computed height. The available space is the total
|
||||
* space including margins, border, padding, and content area. A value of
|
||||
* NS_UNCONSTRAINEDSIZE means you can choose whatever size you want
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
struct nsHTMLReflowState {
|
||||
// pointer to parent's reflow state
|
||||
const nsHTMLReflowState* parentReflowState;
|
||||
|
||||
// the frame being reflowed
|
||||
nsIFrame* frame;
|
||||
|
||||
// the reason for the reflow
|
||||
nsReflowReason reason;
|
||||
|
||||
// the reflow command. only set for eReflowReason_Incremental
|
||||
nsIReflowCommand* reflowCommand;
|
||||
|
||||
// the available space in which to reflow
|
||||
nscoord availableWidth, availableHeight;
|
||||
|
||||
// rendering context to use for measurement
|
||||
nsIRenderingContext* rendContext;
|
||||
|
||||
// is the current context at the top of a page?
|
||||
PRPackedBool isTopOfPage;
|
||||
|
||||
// The type of frame, from css's perspective. This value is
|
||||
// initialized by the Init method below.
|
||||
nsCSSFrameType mFrameType;
|
||||
|
||||
nsISpaceManager* mSpaceManager;
|
||||
|
||||
// LineLayout object (only for inline reflow; set to NULL otherwise)
|
||||
nsLineLayout* mLineLayout;
|
||||
|
||||
// The computed width specifies the frame's content width, and it does not
|
||||
// apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic width as the computed width
|
||||
//
|
||||
// For block-level frames, the computed width is based on the width of the
|
||||
// containing block, the margin/border/padding areas, and the min/max width
|
||||
nscoord mComputedWidth;
|
||||
|
||||
// The computed height specifies the frame's content height, and it does
|
||||
// not apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic height as the computed height
|
||||
//
|
||||
// For non-replaced block-level frames in the flow and floated, a value of
|
||||
// NS_AUTOHEIGHT means you choose a height to shrink wrap around the normal
|
||||
// flow child frames. The height must be within the limit of the min/max
|
||||
// height if there is such a limit
|
||||
//
|
||||
// For replaced block-level frames, a value of NS_INTRINSICSIZE
|
||||
// means you use your intrinsic height as the computed height
|
||||
nscoord mComputedHeight;
|
||||
|
||||
// Computed margin values
|
||||
nsMargin mComputedMargin;
|
||||
|
||||
// Cached copy of the border values
|
||||
nsMargin mComputedBorderPadding;
|
||||
|
||||
// Computed padding values
|
||||
nsMargin mComputedPadding;
|
||||
|
||||
// Computed values for 'left/top/right/bottom' offsets. Only applies to
|
||||
// 'positioned' elements
|
||||
nsMargin mComputedOffsets;
|
||||
|
||||
// Computed values for 'min-width/max-width' and 'min-height/max-height'
|
||||
nscoord mComputedMinWidth, mComputedMaxWidth;
|
||||
nscoord mComputedMinHeight, mComputedMaxHeight;
|
||||
|
||||
// Compact margin available space
|
||||
nscoord mCompactMarginWidth;
|
||||
|
||||
// The following data members are relevant if nsStyleText.mTextAlign
|
||||
// == NS_STYLE_TEXT_ALIGN_CHAR
|
||||
|
||||
// distance from reference edge (as specified in nsStyleDisplay.mDirection)
|
||||
// to the align character (which will be specified in nsStyleTable)
|
||||
nscoord mAlignCharOffset;
|
||||
|
||||
// if true, the reflow honors alignCharOffset and does not
|
||||
// set it. if false, the reflow sets alignCharOffset
|
||||
PRPackedBool mUseAlignCharOffset;
|
||||
|
||||
// Cached pointers to the various style structs used during intialization
|
||||
const nsStyleDisplay* mStyleDisplay;
|
||||
const nsStylePosition* mStylePosition;
|
||||
const nsStyleSpacing* mStyleSpacing;
|
||||
|
||||
// This value keeps track of how deeply nested a given reflow state
|
||||
// is from the top of the frame tree.
|
||||
PRInt32 mReflowDepth;
|
||||
|
||||
// Note: The copy constructor is written by the compiler
|
||||
// automatically. You can use that and then override specific values
|
||||
// if you want, or you can call Init as desired...
|
||||
|
||||
// Initialize a <b>root</b> reflow state with a rendering context to
|
||||
// use for measuring things.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsReflowReason aReason,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a <b>root</b> reflow state for an <b>incremental</b>
|
||||
// reflow.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsIReflowCommand& aReflowCommand,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a reflow state for a child frames reflow. Some state
|
||||
// is copied from the parent reflow state; the remaining state is
|
||||
// computed.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nsReflowReason aReason);
|
||||
|
||||
// Same as the previous except that the reason is taken from the
|
||||
// parent's reflow state.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Used when you want to override the default containing block
|
||||
// width and height. Used by absolute positioning code
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
/**
|
||||
* Get the containing block reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetContainingBlockReflowState(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* First find the containing block's reflow state using
|
||||
* GetContainingBlockReflowState, then ask the containing block for
|
||||
* it's content width using GetContentWidth
|
||||
*/
|
||||
static nscoord
|
||||
GetContainingBlockContentWidth(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Get the page box reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetPageBoxReflowState(const nsHTMLReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Compute the border plus padding for <TT>aFrame</TT>. If a
|
||||
* percentage needs to be computed it will be computed by finding
|
||||
* the containing block, use GetContainingBlockReflowState.
|
||||
* aParentReflowState is aFrame's
|
||||
* parent's reflow state. The resulting computed border plus padding
|
||||
* is returned in aResult.
|
||||
*/
|
||||
static void ComputeBorderPaddingFor(nsIFrame* aFrame,
|
||||
const nsHTMLReflowState* aParentRS,
|
||||
nsMargin& aResult);
|
||||
|
||||
/**
|
||||
* Calculate the raw line-height property for the given frame. The return
|
||||
* value, if line-height was applied and is valid will be >= 0. Otherwise,
|
||||
* the return value will be <0 which is illegal (CSS2 spec: section 10.8.1).
|
||||
*/
|
||||
static nscoord CalcLineHeight(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIFrame* aFrame);
|
||||
|
||||
static PRBool UseComputedHeight();
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame);
|
||||
|
||||
void ComputeContainingBlockRectangle(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord& aContainingBlockWidth,
|
||||
nscoord& aContainingBlockHeight);
|
||||
|
||||
protected:
|
||||
// This method initializes various data members. It is automatically
|
||||
// called by the various constructors
|
||||
void Init(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth = -1,
|
||||
nscoord aContainingBlockHeight = -1);
|
||||
|
||||
void InitConstraints(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void InitAbsoluteConstraints(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeBlockBoxData(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nsStyleUnit aWidthUnit,
|
||||
nsStyleUnit aHeightUnit,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void CalculateBlockSideMargins(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord aComputedWidth);
|
||||
|
||||
void ComputeHorizontalValue(nscoord aContainingBlockWidth,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
void ComputeVerticalValue(nscoord aContainingBlockHeight,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame,
|
||||
const nsStylePosition* aPosition,
|
||||
const nsStyleDisplay* aDisplay);
|
||||
|
||||
// Computes margin values from the specified margin style information, and
|
||||
// fills in the mComputedMargin member
|
||||
void ComputeMargin(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Computes padding values from the specified padding style information, and
|
||||
// fills in the mComputedPadding member
|
||||
void ComputePadding(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Calculates the computed values for the 'min-Width', 'max-Width',
|
||||
// 'min-Height', and 'max-Height' properties, and stores them in the assorted
|
||||
// data members
|
||||
void ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
};
|
||||
|
||||
// For HTML reflow we rename with the different paint layers are
|
||||
// actually used for.
|
||||
#define NS_FRAME_PAINT_LAYER_BACKGROUND eFramePaintLayer_Underlay
|
||||
#define NS_FRAME_PAINT_LAYER_FLOATERS eFramePaintLayer_Content
|
||||
#define NS_FRAME_PAINT_LAYER_FOREGROUND eFramePaintLayer_Overlay
|
||||
#define NS_FRAME_PAINT_LAYER_DEBUG eFramePaintLayer_Overlay
|
||||
|
||||
/**
|
||||
* Reflow status returned by the reflow methods.
|
||||
*
|
||||
* NS_FRAME_NOT_COMPLETE bit flag means the frame does not map all its
|
||||
* content, and that the parent frame should create a continuing frame.
|
||||
* If this bit isn't set it means the frame does map all its content.
|
||||
*
|
||||
* NS_FRAME_REFLOW_NEXTINFLOW bit flag means that the next-in-flow is
|
||||
* dirty, and also needs to be reflowed. This status only makes sense
|
||||
* for a frame that is not complete, i.e. you wouldn't set both
|
||||
* NS_FRAME_COMPLETE and NS_FRAME_REFLOW_NEXTINFLOW
|
||||
*
|
||||
* The low 8 bits of the nsReflowStatus are reserved for future extensions;
|
||||
* the remaining 24 bits are zero (and available for extensions; however
|
||||
* API's that accept/return nsReflowStatus must not receive/return any
|
||||
* extension bits).
|
||||
*
|
||||
* @see #Reflow()
|
||||
*/
|
||||
typedef PRUint32 nsReflowStatus;
|
||||
|
||||
#define NS_FRAME_COMPLETE 0 // Note: not a bit!
|
||||
#define NS_FRAME_NOT_COMPLETE 0x1
|
||||
#define NS_FRAME_REFLOW_NEXTINFLOW 0x2
|
||||
|
||||
#define NS_FRAME_IS_COMPLETE(status) \
|
||||
(0 == ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
#define NS_FRAME_IS_NOT_COMPLETE(status) \
|
||||
(0 != ((status) & NS_FRAME_NOT_COMPLETE))
|
||||
|
||||
// This macro tests to see if an nsReflowStatus is an error value
|
||||
// or just a regular return value
|
||||
#define NS_IS_REFLOW_ERROR(_status) (PRInt32(_status) < 0)
|
||||
|
||||
/**
|
||||
* Extensions to the reflow status bits defined by nsIFrameReflow
|
||||
*/
|
||||
|
||||
// This bit is set, when a break is requested. This bit is orthogonal
|
||||
// to the nsIFrame::nsReflowStatus completion bits.
|
||||
#define NS_INLINE_BREAK 0x0100
|
||||
|
||||
// When a break is requested, this bit when set indicates that the
|
||||
// break should occur after the frame just reflowed; when the bit is
|
||||
// clear the break should occur before the frame just reflowed.
|
||||
#define NS_INLINE_BREAK_BEFORE 0x0000
|
||||
#define NS_INLINE_BREAK_AFTER 0x0200
|
||||
|
||||
// The type of break requested can be found in these bits.
|
||||
#define NS_INLINE_BREAK_TYPE_MASK 0xF000
|
||||
|
||||
//----------------------------------------
|
||||
// Macros that use those bits
|
||||
|
||||
#define NS_INLINE_IS_BREAK(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_AFTER(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK_AFTER))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_BEFORE(_status) \
|
||||
(NS_INLINE_BREAK == ((_status) & (NS_INLINE_BREAK|NS_INLINE_BREAK_AFTER)))
|
||||
|
||||
#define NS_INLINE_GET_BREAK_TYPE(_status) (((_status) >> 12) & 0xF)
|
||||
|
||||
#define NS_INLINE_MAKE_BREAK_TYPE(_type) ((_type) << 12)
|
||||
|
||||
// Construct a line-break-before status. Note that there is no
|
||||
// completion status for a line-break before because we *know* that
|
||||
// the frame will be reflowed later and hence it's current completion
|
||||
// status doesn't matter.
|
||||
#define NS_INLINE_LINE_BREAK_BEFORE() \
|
||||
(NS_INLINE_BREAK | NS_INLINE_BREAK_BEFORE | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
// Take a completion status and add to it the desire to have a
|
||||
// line-break after. For this macro we do need the completion status
|
||||
// because the user of the status will need to know whether to
|
||||
// continue the frame or not.
|
||||
#define NS_INLINE_LINE_BREAK_AFTER(_completionStatus) \
|
||||
((_completionStatus) | NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DidReflow status values.
|
||||
*/
|
||||
typedef PRBool nsDidReflowStatus;
|
||||
|
||||
#define NS_FRAME_REFLOW_NOT_FINISHED PR_FALSE
|
||||
#define NS_FRAME_REFLOW_FINISHED PR_TRUE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A frame in the layout model. This interface is supported by all frame
|
||||
* objects.
|
||||
|
@ -566,6 +1057,97 @@ public:
|
|||
NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0;
|
||||
NS_IMETHOD SetNextInFlow(nsIFrame*) = 0;
|
||||
|
||||
/**
|
||||
* Pre-reflow hook. Before a frame is reflowed this method will be called.
|
||||
* This call will always be invoked at least once before a subsequent Reflow
|
||||
* and DidReflow call. It may be called more than once, In general you will
|
||||
* receive on WillReflow notification before each Reflow request.
|
||||
*
|
||||
* XXX Is this really the semantics we want? Because we have the NS_FRAME_IN_REFLOW
|
||||
* bit we can ensure we don't call it more than once...
|
||||
*/
|
||||
NS_IMETHOD WillReflow(nsIPresContext& aPresContext) = 0;
|
||||
|
||||
/**
|
||||
* The frame is given a maximum size and asked for its desired size.
|
||||
* This is the frame's opportunity to reflow its children.
|
||||
*
|
||||
* @param aDesiredSize <i>out</i> parameter where you should return the
|
||||
* desired size and ascent/descent info. You should include any
|
||||
* space you want for border/padding in the desired size you return.
|
||||
*
|
||||
* It's okay to return a desired size that exceeds the max
|
||||
* size if that's the smallest you can be, i.e. it's your
|
||||
* minimum size.
|
||||
*
|
||||
* maxElementSize is an optional parameter for returning your
|
||||
* maximum element size. If may be null in which case you
|
||||
* don't have to compute a maximum element size. The
|
||||
* maximum element size must be less than or equal to your
|
||||
* desired size.
|
||||
*
|
||||
* For an incremental reflow you are responsible for invalidating
|
||||
* any area within your frame that needs repainting (including
|
||||
* borders). If your new desired size is different than your current
|
||||
* size, then your parent frame is responsible for making sure that
|
||||
* the difference between the two rects is repainted
|
||||
*
|
||||
* @param aReflowState information about your reflow including the reason
|
||||
* for the reflow and the available space in which to lay out. Each
|
||||
* dimension of the available space can either be constrained or
|
||||
* unconstrained (a value of NS_UNCONSTRAINEDSIZE). If constrained
|
||||
* you should choose a value that's less than or equal to the
|
||||
* constrained size. If unconstrained you can choose as
|
||||
* large a value as you like.
|
||||
*
|
||||
* Note that the available space can be negative. In this case you
|
||||
* still must return an accurate desired size. If you're a container
|
||||
* you must <b>always</b> reflow at least one frame regardless of the
|
||||
* available space
|
||||
*
|
||||
* @param aStatus a return value indicating whether the frame is complete
|
||||
* and whether the next-in-flow is dirty and needs to be reflowed
|
||||
*/
|
||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aReflowMetrics,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Post-reflow hook. After a frame is reflowed this method will be called
|
||||
* informing the frame that this reflow process is complete, and telling the
|
||||
* frame the status returned by the Reflow member function.
|
||||
*
|
||||
* This call may be invoked many times, while NS_FRAME_IN_REFLOW is set, before
|
||||
* it is finally called once with a NS_FRAME_REFLOW_COMPLETE value. When called
|
||||
* with a NS_FRAME_REFLOW_COMPLETE value the NS_FRAME_IN_REFLOW bit in the
|
||||
* frame state will be cleared.
|
||||
*
|
||||
* XXX This doesn't make sense. If the frame is reflowed but not complete, then
|
||||
* the status should be NS_FRAME_NOT_COMPLETE and not NS_FRAME_COMPLETE
|
||||
* XXX Don't we want the semantics to dictate that we only call this once for
|
||||
* a given reflow?
|
||||
*/
|
||||
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus) = 0;
|
||||
|
||||
// XXX Maybe these three should be a separate interface?
|
||||
|
||||
// Helper method used by block reflow to identify runs of text so that
|
||||
// proper word-breaking can be done.
|
||||
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout) = 0;
|
||||
|
||||
// Justification helper method used to distribute extra space in a
|
||||
// line to leaf frames. aUsedSpace is filled in with the amount of
|
||||
// space actually used.
|
||||
NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace) = 0;
|
||||
|
||||
// Justification helper method that is used to remove trailing
|
||||
// whitespace before justification.
|
||||
NS_IMETHOD TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRC,
|
||||
nscoord& aDeltaWidth) = 0;
|
||||
|
||||
/**
|
||||
* Accessor functions to get/set the associated view object
|
||||
*/
|
||||
|
|
|
@ -1331,11 +1331,7 @@ nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
else {
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
while (nsnull != frame) {
|
||||
nsIHTMLReflow* ihr;
|
||||
nsresult rv = frame->QueryInterface(kIHTMLReflowIID, (void**)&ihr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ihr->FindTextRuns(aLineLayout);
|
||||
}
|
||||
frame->FindTextRuns(aLineLayout);
|
||||
frame->GetNextSibling(&frame);
|
||||
}
|
||||
}
|
||||
|
@ -1353,9 +1349,6 @@ nsInlineFrame::DrainOverflow(nsIPresContext* aPresContext)
|
|||
if (prevOverflowFrames) {
|
||||
// When pushing and pulling frames we need to check for whether any
|
||||
// views need to be reparented.
|
||||
// XXX Doing it this way means an extra pass over the frames. We could
|
||||
// change InsertFrames() to do this, but that's a general purpose
|
||||
// function and it doesn't seem like this functionality belongs there...
|
||||
for (nsIFrame* f = prevOverflowFrames; f; f->GetNextSibling(&f)) {
|
||||
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
reason = eReflowReason_StyleChange;
|
||||
}
|
||||
else {
|
||||
const nsReflowState* rs = psd->mReflowState;
|
||||
const nsHTMLReflowState* rs = psd->mReflowState;
|
||||
if (rs->reason == eReflowReason_Incremental) {
|
||||
// If the incremental reflow command is a StyleChanged reflow and
|
||||
// it's target is the current span, then make sure we send
|
||||
|
@ -906,10 +906,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
// Let frame know that are reflowing it
|
||||
nscoord x = pfd->mBounds.x;
|
||||
nscoord y = pfd->mBounds.y;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
aFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
htmlReflow->WillReflow(mPresContext);
|
||||
aFrame->WillReflow(mPresContext);
|
||||
|
||||
// Adjust spacemanager coordinate system for the frame. The
|
||||
// spacemanager coordinates are <b>inside</b> the current spans
|
||||
|
@ -935,7 +933,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
nscoord tx = x - psd->mReflowState->mComputedBorderPadding.left;
|
||||
nscoord ty = y - psd->mReflowState->mComputedBorderPadding.top;
|
||||
mSpaceManager->Translate(tx, ty);
|
||||
htmlReflow->Reflow(mPresContext, metrics, reflowState, aReflowStatus);
|
||||
aFrame->Reflow(mPresContext, metrics, reflowState, aReflowStatus);
|
||||
|
||||
// XXX See if the frame is a placeholderFrame and if it is process
|
||||
// the floater.
|
||||
|
@ -2177,46 +2175,42 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd,
|
|||
}
|
||||
else if (pfd->mIsNonEmptyTextFrame) {
|
||||
nscoord deltaWidth = 0;
|
||||
nsIHTMLReflow* hr;
|
||||
nsresult rv = pfd->mFrame->QueryInterface(kIHTMLReflowIID, (void**)&hr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
hr->TrimTrailingWhiteSpace(&mPresContext,
|
||||
*mBlockReflowState->rendContext,
|
||||
deltaWidth);
|
||||
pfd->mFrame->TrimTrailingWhiteSpace(&mPresContext,
|
||||
*mBlockReflowState->rendContext,
|
||||
deltaWidth);
|
||||
#ifdef NOISY_TRIM
|
||||
nsFrame::ListTag(stdout, (psd == mRootSpan
|
||||
? mBlockReflowState->frame
|
||||
: psd->mFrame->mFrame));
|
||||
printf(": trim of ");
|
||||
nsFrame::ListTag(stdout, pfd->mFrame);
|
||||
printf(" returned %d\n", deltaWidth);
|
||||
nsFrame::ListTag(stdout, (psd == mRootSpan
|
||||
? mBlockReflowState->frame
|
||||
: psd->mFrame->mFrame));
|
||||
printf(": trim of ");
|
||||
nsFrame::ListTag(stdout, pfd->mFrame);
|
||||
printf(" returned %d\n", deltaWidth);
|
||||
#endif
|
||||
if (deltaWidth) {
|
||||
pfd->mBounds.width -= deltaWidth;
|
||||
pfd->mCombinedArea.width -= deltaWidth;
|
||||
if (0 == pfd->mBounds.width) {
|
||||
pfd->mMaxElementSize.width = 0;
|
||||
pfd->mMaxElementSize.height = 0;
|
||||
}
|
||||
if (deltaWidth) {
|
||||
pfd->mBounds.width -= deltaWidth;
|
||||
pfd->mCombinedArea.width -= deltaWidth;
|
||||
if (0 == pfd->mBounds.width) {
|
||||
pfd->mMaxElementSize.width = 0;
|
||||
pfd->mMaxElementSize.height = 0;
|
||||
}
|
||||
|
||||
// See if the text frame has already been placed in its parent
|
||||
if (psd != mRootSpan) {
|
||||
// The frame was already placed during psd's
|
||||
// reflow. Update the frames rectangle now.
|
||||
pfd->mFrame->SetRect(&mPresContext, pfd->mBounds);
|
||||
}
|
||||
// See if the text frame has already been placed in its parent
|
||||
if (psd != mRootSpan) {
|
||||
// The frame was already placed during psd's
|
||||
// reflow. Update the frames rectangle now.
|
||||
pfd->mFrame->SetRect(&mPresContext, pfd->mBounds);
|
||||
}
|
||||
|
||||
// Adjust containing span's right edge
|
||||
psd->mX -= deltaWidth;
|
||||
// Adjust containing span's right edge
|
||||
psd->mX -= deltaWidth;
|
||||
|
||||
// Slide any frames that follow the text frame over by the
|
||||
// right amount. The only thing that can follow the text
|
||||
// frame is empty stuff, so we are just making things
|
||||
// sensible (keeping the combined area honest).
|
||||
while (pfd->mNext) {
|
||||
pfd = pfd->mNext;
|
||||
pfd->mBounds.x -= deltaWidth;
|
||||
}
|
||||
// Slide any frames that follow the text frame over by the
|
||||
// right amount. The only thing that can follow the text
|
||||
// frame is empty stuff, so we are just making things
|
||||
// sensible (keeping the combined area honest).
|
||||
while (pfd->mNext) {
|
||||
pfd = pfd->mNext;
|
||||
pfd->mBounds.x -= deltaWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2226,6 +2220,7 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd,
|
|||
}
|
||||
pfd = pfd->mPrev;
|
||||
}
|
||||
|
||||
*aDeltaWidth = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -117,29 +117,26 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext,
|
|||
maxSize);
|
||||
kidReflowState.isTopOfPage = PR_TRUE;
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// Get the child's desired size
|
||||
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Make sure the child is at least as tall as our max size (the containing window)
|
||||
if (aDesiredSize.height < aReflowState.availableHeight) {
|
||||
aDesiredSize.height = aReflowState.availableHeight;
|
||||
}
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
frame->SetRect(&aPresContext, rect);
|
||||
// XXX Should we be sending the DidReflow?
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Is the frame complete?
|
||||
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
nsIFrame* childNextInFlow;
|
||||
|
||||
frame->GetNextInFlow(&childNextInFlow);
|
||||
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
|
||||
}
|
||||
// Get the child's desired size
|
||||
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Make sure the child is at least as tall as our max size (the containing window)
|
||||
if (aDesiredSize.height < aReflowState.availableHeight) {
|
||||
aDesiredSize.height = aReflowState.availableHeight;
|
||||
}
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
frame->SetRect(&aPresContext, rect);
|
||||
// XXX Should we be sending the DidReflow?
|
||||
frame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Is the frame complete?
|
||||
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
nsIFrame* childNextInFlow;
|
||||
|
||||
frame->GetNextInFlow(&childNextInFlow);
|
||||
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,42 +326,38 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext& aPresContext,
|
|||
nsReflowStatus& aStatus) const
|
||||
{
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv;
|
||||
nsresult rv;
|
||||
|
||||
rv = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize);
|
||||
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child
|
||||
nsRect rect(kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child
|
||||
nsRect rect(kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -507,20 +503,17 @@ ViewportFrame::Reflow(nsIPresContext& aPresContext,
|
|||
kidFrame, availableSpace);
|
||||
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
kidReflowState.mComputedHeight = aReflowState.availableHeight;
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
kidReflowState.mComputedHeight = aReflowState.availableHeight;
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
|
||||
nsRect rect(0, 0, kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
kidRect = rect;
|
||||
nsRect rect(0, 0, kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
kidRect = rect;
|
||||
|
||||
// XXX We should resolve the details of who/when DidReflow()
|
||||
// notifications are sent...
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
// XXX We should resolve the details of who/when DidReflow()
|
||||
// notifications are sent...
|
||||
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
|
||||
// If it's a 'initial', 'resize', or 'style change' reflow command (anything
|
||||
|
|
|
@ -256,118 +256,114 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
|
|||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
}
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
|
||||
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize, aContainingBlockWidth,
|
||||
aContainingBlockHeight);
|
||||
nsSize availSize(aReflowState.mComputedWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize, aContainingBlockWidth,
|
||||
aContainingBlockHeight);
|
||||
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Because we don't know the size of a replaced element until after we reflow
|
||||
// it 'auto' margins must be computed now, and we need to take into account
|
||||
// min-max information
|
||||
if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) {
|
||||
// Factor in any minimum and maximum size information
|
||||
if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMaxWidth;
|
||||
} else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMinWidth;
|
||||
}
|
||||
if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMaxHeight;
|
||||
} else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMinHeight;
|
||||
}
|
||||
|
||||
rv = htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
// Get the containing block width/height
|
||||
nscoord containingBlockWidth, containingBlockHeight;
|
||||
kidReflowState.ComputeContainingBlockRectangle(&aReflowState,
|
||||
containingBlockWidth,
|
||||
containingBlockHeight);
|
||||
|
||||
// Because we don't know the size of a replaced element until after we reflow
|
||||
// it 'auto' margins must be computed now, and we need to take into account
|
||||
// min-max information
|
||||
if (NS_FRAME_IS_REPLACED(kidReflowState.mFrameType)) {
|
||||
// Factor in any minimum and maximum size information
|
||||
if (kidDesiredSize.width > kidReflowState.mComputedMaxWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMaxWidth;
|
||||
} else if (kidDesiredSize.width < kidReflowState.mComputedMinWidth) {
|
||||
kidDesiredSize.width = kidReflowState.mComputedMinWidth;
|
||||
}
|
||||
if (kidDesiredSize.height > kidReflowState.mComputedMaxHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMaxHeight;
|
||||
} else if (kidDesiredSize.height < kidReflowState.mComputedMinHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedMinHeight;
|
||||
}
|
||||
// XXX This code belongs in nsHTMLReflowState...
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.right)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockWidth -
|
||||
kidReflowState.mComputedOffsets.left - kidReflowState.mComputedBorderPadding.left -
|
||||
kidDesiredSize.width - kidReflowState.mComputedBorderPadding.right -
|
||||
kidReflowState.mComputedOffsets.right;
|
||||
|
||||
// Get the containing block width/height
|
||||
nscoord containingBlockWidth, containingBlockHeight;
|
||||
kidReflowState.ComputeContainingBlockRectangle(&aReflowState,
|
||||
containingBlockWidth,
|
||||
containingBlockHeight);
|
||||
|
||||
// XXX This code belongs in nsHTMLReflowState...
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.right)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockWidth -
|
||||
kidReflowState.mComputedOffsets.left - kidReflowState.mComputedBorderPadding.left -
|
||||
kidDesiredSize.width - kidReflowState.mComputedBorderPadding.right -
|
||||
kidReflowState.mComputedOffsets.right;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.right) {
|
||||
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
} else {
|
||||
// Just 'margin-left' is 'auto'
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.right;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-right' is 'auto'
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.left) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.right) {
|
||||
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
}
|
||||
}
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockHeight -
|
||||
kidReflowState.mComputedOffsets.top - kidReflowState.mComputedBorderPadding.top -
|
||||
kidDesiredSize.height - kidReflowState.mComputedBorderPadding.bottom -
|
||||
kidReflowState.mComputedOffsets.bottom;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom) {
|
||||
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
} else {
|
||||
// Just 'margin-top' is 'auto'
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-bottom' is 'auto'
|
||||
// Just 'margin-left' is 'auto'
|
||||
kidReflowState.mComputedMargin.left = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.right;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-right' is 'auto'
|
||||
kidReflowState.mComputedMargin.right = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.left;
|
||||
}
|
||||
}
|
||||
if ((NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) ||
|
||||
(NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom)) {
|
||||
// Calculate the amount of space for margins
|
||||
nscoord availMarginSpace = containingBlockHeight -
|
||||
kidReflowState.mComputedOffsets.top - kidReflowState.mComputedBorderPadding.top -
|
||||
kidDesiredSize.height - kidReflowState.mComputedBorderPadding.bottom -
|
||||
kidReflowState.mComputedOffsets.bottom;
|
||||
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.top) {
|
||||
if (NS_AUTOMARGIN == kidReflowState.mComputedMargin.bottom) {
|
||||
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
|
||||
// equal values
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace / 2;
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
} else {
|
||||
// Just 'margin-top' is 'auto'
|
||||
kidReflowState.mComputedMargin.top = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
}
|
||||
} else {
|
||||
// Just 'margin-bottom' is 'auto'
|
||||
kidReflowState.mComputedMargin.bottom = availMarginSpace -
|
||||
kidReflowState.mComputedMargin.top;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child relative to our padding edge
|
||||
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
}
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child relative to our padding edge
|
||||
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define nsAbsoluteContainingBlock_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsFrameList.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsBlockBandData.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -221,12 +221,7 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
|
|||
mY = y;
|
||||
|
||||
// Let frame know that we are reflowing it
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = aFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
htmlReflow->WillReflow(*mPresContext);
|
||||
aFrame->WillReflow(*mPresContext);
|
||||
|
||||
#ifdef DEBUG
|
||||
mMetrics.width = nscoord(0xdeadbeef);
|
||||
|
@ -249,8 +244,8 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame,
|
|||
nscoord tx = x - mOuterReflowState.mComputedBorderPadding.left;
|
||||
nscoord ty = y - mOuterReflowState.mComputedBorderPadding.top;
|
||||
mOuterReflowState.mSpaceManager->Translate(tx, ty);
|
||||
rv = htmlReflow->Reflow(*mPresContext, mMetrics, reflowState,
|
||||
aFrameReflowStatus);
|
||||
rv = aFrame->Reflow(*mPresContext, mMetrics, reflowState,
|
||||
aFrameReflowStatus);
|
||||
mOuterReflowState.mSpaceManager->Translate(-tx, -ty);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef nsBlockReflowContext_h___
|
||||
#define nsBlockReflowContext_h___
|
||||
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsBlockFrame;
|
||||
class nsIFrame;
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -6380,14 +6380,10 @@ nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
|||
availSize.height = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState reflowState(*aState.mPresContext, aState.mReflowState,
|
||||
mBullet, availSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv = mBullet->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsReflowStatus status;
|
||||
htmlReflow->WillReflow(*aState.mPresContext);
|
||||
htmlReflow->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
htmlReflow->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
nsReflowStatus status;
|
||||
mBullet->WillReflow(*aState.mPresContext);
|
||||
mBullet->Reflow(*aState.mPresContext, aMetrics, reflowState, status);
|
||||
mBullet->DidReflow(*aState.mPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Place the bullet now; use its right margin to distance it
|
||||
// from the rest of the frames in the line
|
||||
|
@ -6452,12 +6448,9 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext)
|
|||
nsIFrame* frame = line->mFirstChild;
|
||||
PRInt32 n = line->GetChildCount();
|
||||
while (--n >= 0) {
|
||||
nsIHTMLReflow* hr;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&hr)) {
|
||||
nsresult rv = hr->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = frame->FindTextRuns(textRunThingy);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
// A frame that doesn't implement nsIHTMLReflow isn't text
|
||||
|
|
|
@ -111,12 +111,7 @@ nsContainerFrame::DidReflow(nsIPresContext& aPresContext,
|
|||
nsIFrame* kid;
|
||||
FirstChild(listName, &kid);
|
||||
while (nsnull != kid) {
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv;
|
||||
rv = kid->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->DidReflow(aPresContext, aStatus);
|
||||
}
|
||||
kid->DidReflow(aPresContext, aStatus);
|
||||
kid->GetNextSibling(&kid);
|
||||
}
|
||||
NS_IF_RELEASE(listName);
|
||||
|
@ -354,13 +349,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|||
{
|
||||
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
|
||||
|
||||
// Query for the nsIHTMLReflow interface
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult result;
|
||||
result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
nsresult result;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsSize* saveMaxElementSize = aDesiredSize.maxElementSize;
|
||||
|
@ -373,9 +362,9 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
|||
#endif
|
||||
|
||||
// Send the WillReflow notification, and reflow the child frame
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState,
|
||||
aStatus);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
result = aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState,
|
||||
aStatus);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (saveMaxElementSize != aDesiredSize.maxElementSize) {
|
||||
|
|
|
@ -153,11 +153,7 @@ nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
{
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
while (nsnull != frame) {
|
||||
nsIHTMLReflow* ihr;
|
||||
nsresult rv = frame->QueryInterface(kIHTMLReflowIID, (void**)&ihr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ihr->FindTextRuns(aLineLayout);
|
||||
}
|
||||
frame->FindTextRuns(aLineLayout);
|
||||
frame->GetNextSibling(&frame);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -209,13 +205,8 @@ nsFirstLetterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
rs.mLineLayout = ≪
|
||||
ll.SetFirstLetterStyleOK(PR_TRUE);
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
rv = kid->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
htmlReflow->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
||||
kid->WillReflow(aPresContext);
|
||||
kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
||||
|
||||
ll.EndLineReflow();
|
||||
}
|
||||
|
|
|
@ -220,10 +220,7 @@ nsresult nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, kIFrameIID);
|
||||
if (aIID.Equals(kIHTMLReflowIID)) {
|
||||
*aInstancePtr = (void*)(nsIHTMLReflow*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
||||
if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define nsFrame_h___
|
||||
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsString.h"
|
||||
#include "prlog.h"
|
||||
|
@ -93,7 +92,7 @@
|
|||
* Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default
|
||||
* behavior is to keep the frame and view position and size in sync.
|
||||
*/
|
||||
class nsFrame : public nsIFrame, public nsIHTMLReflow
|
||||
class nsFrame : public nsIFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -319,83 +319,80 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
|
||||
// The document element's background should cover the entire canvas, so
|
||||
// take into account the combined area and any space taken up by
|
||||
// absolutely positioned elements
|
||||
nsMargin border;
|
||||
nsFrameState kidState;
|
||||
// The document element's background should cover the entire canvas, so
|
||||
// take into account the combined area and any space taken up by
|
||||
// absolutely positioned elements
|
||||
nsMargin border;
|
||||
nsFrameState kidState;
|
||||
|
||||
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
|
||||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
if (!kidReflowState.mStyleSpacing->GetBorder(border)) {
|
||||
NS_NOTYETIMPLEMENTED("percentage border");
|
||||
}
|
||||
kidFrame->GetFrameState(&kidState);
|
||||
|
||||
// First check the combined area
|
||||
if (NS_FRAME_OUTSIDE_CHILDREN & kidState) {
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the child frame's padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (kidDesiredSize.mCombinedArea.XMost() > paddingEdgeX) {
|
||||
kidDesiredSize.width = kidDesiredSize.mCombinedArea.XMost() +
|
||||
border.right;
|
||||
}
|
||||
kidFrame->GetFrameState(&kidState);
|
||||
|
||||
// First check the combined area
|
||||
if (NS_FRAME_OUTSIDE_CHILDREN & kidState) {
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the child frame's padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (kidDesiredSize.mCombinedArea.XMost() > paddingEdgeX) {
|
||||
kidDesiredSize.width = kidDesiredSize.mCombinedArea.XMost() +
|
||||
border.right;
|
||||
}
|
||||
if (kidDesiredSize.mCombinedArea.YMost() > paddingEdgeY) {
|
||||
kidDesiredSize.height = kidDesiredSize.mCombinedArea.YMost() +
|
||||
border.bottom;
|
||||
}
|
||||
if (kidDesiredSize.mCombinedArea.YMost() > paddingEdgeY) {
|
||||
kidDesiredSize.height = kidDesiredSize.mCombinedArea.YMost() +
|
||||
border.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX It would be nice if this were also part of the reflow metrics...
|
||||
nsIAreaFrame* areaFrame;
|
||||
if (NS_SUCCEEDED(kidFrame->QueryInterface(kAreaFrameIID, (void**)&areaFrame))) {
|
||||
// Get the x-most and y-most of the absolutely positioned children
|
||||
nscoord positionedXMost, positionedYMost;
|
||||
areaFrame->GetPositionedInfo(positionedXMost, positionedYMost);
|
||||
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
// XXX It would be nice if this were also part of the reflow metrics...
|
||||
nsIAreaFrame* areaFrame;
|
||||
if (NS_SUCCEEDED(kidFrame->QueryInterface(kAreaFrameIID, (void**)&areaFrame))) {
|
||||
// Get the x-most and y-most of the absolutely positioned children
|
||||
nscoord positionedXMost, positionedYMost;
|
||||
areaFrame->GetPositionedInfo(positionedXMost, positionedYMost);
|
||||
|
||||
// The background covers the content area and padding area, so check
|
||||
// for children sticking outside the padding edge
|
||||
nscoord paddingEdgeX = kidDesiredSize.width - border.right;
|
||||
nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;
|
||||
|
||||
if (positionedXMost > paddingEdgeX) {
|
||||
kidDesiredSize.width = positionedXMost + border.right;
|
||||
}
|
||||
if (positionedYMost > paddingEdgeY) {
|
||||
kidDesiredSize.height = positionedYMost + border.bottom;
|
||||
}
|
||||
if (positionedXMost > paddingEdgeX) {
|
||||
kidDesiredSize.width = positionedXMost + border.right;
|
||||
}
|
||||
|
||||
// If our height is fixed, then make sure the child frame plus its top and
|
||||
// bottom margin is at least that high as well...
|
||||
if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) {
|
||||
nscoord totalHeight = kidDesiredSize.height + kidReflowState.mComputedMargin.top +
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
|
||||
if (totalHeight < aReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height += aReflowState.mComputedHeight - totalHeight;
|
||||
}
|
||||
if (positionedYMost > paddingEdgeY) {
|
||||
kidDesiredSize.height = positionedYMost + border.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position and size the child frame
|
||||
nsRect rect(kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
// If our height is fixed, then make sure the child frame plus its top and
|
||||
// bottom margin is at least that high as well...
|
||||
if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) {
|
||||
nscoord totalHeight = kidDesiredSize.height + kidReflowState.mComputedMargin.top +
|
||||
kidReflowState.mComputedMargin.bottom;
|
||||
|
||||
// If the child frame was just inserted, then we're responsible for making sure
|
||||
// it repaints
|
||||
if (isDirtyChildReflow) {
|
||||
// Damage the area occupied by the deleted frame
|
||||
Invalidate(&aPresContext, rect, PR_FALSE);
|
||||
if (totalHeight < aReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height += aReflowState.mComputedHeight - totalHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Position and size the child frame
|
||||
nsRect rect(kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
|
||||
// If the child frame was just inserted, then we're responsible for making sure
|
||||
// it repaints
|
||||
if (isDirtyChildReflow) {
|
||||
// Damage the area occupied by the deleted frame
|
||||
Invalidate(&aPresContext, rect, PR_FALSE);
|
||||
}
|
||||
|
||||
// Return our desired size
|
||||
aDesiredSize.width = kidDesiredSize.width + kidReflowState.mComputedMargin.left +
|
||||
kidReflowState.mComputedMargin.right;
|
||||
|
@ -405,7 +402,7 @@ RootFrame::Reflow(nsIPresContext& aPresContext,
|
|||
aDesiredSize.descent = 0;
|
||||
// XXX Don't completely ignore NS_FRAME_OUTSIDE_CHILDREN for child frames
|
||||
// that stick out on the left or top edges...
|
||||
|
||||
|
||||
// XXX Temporary hack. Remember this for later when our parent resizes us.
|
||||
// See SetRect()
|
||||
mNaturalHeight = aDesiredSize.height;
|
||||
|
|
|
@ -17,13 +17,11 @@
|
|||
*/
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIPageSequenceFrame.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIAreaFrame.h"
|
||||
|
||||
const nsIID kIHTMLContentIID = NS_IHTMLCONTENT_IID;
|
||||
const nsIID kIHTMLReflowIID = NS_IHTMLREFLOW_IID;
|
||||
const nsIID kIPageSequenceFrameIID = NS_IPAGESEQUENCEFRAME_IID;
|
||||
const nsIID kIStyledContentIID = NS_ISTYLEDCONTENT_IID;
|
||||
const nsIID kITextContentIID = NS_ITEXT_CONTENT_IID;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* Reserved.
|
||||
*/
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsHTMLReflowCommand.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -129,13 +128,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext,
|
|||
|
||||
nsHTMLReflowState reflowState(aPresContext, root, *this,
|
||||
&aRendContext, aMaxSize);
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsReflowStatus status;
|
||||
|
||||
if (NS_OK == root->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(aPresContext, aDesiredSize, reflowState, status);
|
||||
}
|
||||
root->Reflow(aPresContext, aDesiredSize, reflowState, status);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
@ -177,7 +176,7 @@ nsHTMLReflowState::Init(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
const nsHTMLReflowState*
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetContainingBlockReflowState(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
while (nsnull != aParentRS) {
|
||||
if (nsnull != aParentRS->frame) {
|
||||
|
@ -186,7 +185,7 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
|||
// reflow state...
|
||||
nsresult rv = aParentRS->frame->IsPercentageBase(isContainingBlock);
|
||||
if (NS_SUCCEEDED(rv) && isContainingBlock) {
|
||||
return (const nsHTMLReflowState*) aParentRS;
|
||||
return aParentRS;
|
||||
}
|
||||
}
|
||||
aParentRS = aParentRS->parentReflowState;
|
||||
|
@ -195,20 +194,20 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS)
|
|||
}
|
||||
|
||||
const nsHTMLReflowState*
|
||||
nsHTMLReflowState::GetPageBoxReflowState(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetPageBoxReflowState(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
// XXX write me as soon as we can ask a frame if it's a page frame...
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS)
|
||||
nsHTMLReflowState::GetContainingBlockContentWidth(const nsHTMLReflowState* aParentRS)
|
||||
{
|
||||
nscoord width = 0;
|
||||
const nsHTMLReflowState* rs =
|
||||
GetContainingBlockReflowState(aParentRS);
|
||||
if (nsnull != rs) {
|
||||
return ((nsHTMLReflowState*)aParentRS)->mComputedWidth;/* XXX cast */
|
||||
return aParentRS->mComputedWidth;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
|
|
@ -1,440 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsIHTMLReflow_h___
|
||||
#define nsIHTMLReflow_h___
|
||||
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleCoord.h"
|
||||
#include "nsRect.h"
|
||||
class nsISpaceManager;
|
||||
class nsBlockFrame;
|
||||
class nsLineLayout;
|
||||
struct nsStyleDisplay;
|
||||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
// IID for the nsIHTMLFrame interface
|
||||
// a6cf9069-15b3-11d2-932e-00805f8add32
|
||||
#define NS_IHTMLREFLOW_IID \
|
||||
{ 0xa6cf9069, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// For HTML reflow we rename with the different paint layers are
|
||||
// actually used for.
|
||||
#define NS_FRAME_PAINT_LAYER_BACKGROUND eFramePaintLayer_Underlay
|
||||
#define NS_FRAME_PAINT_LAYER_FLOATERS eFramePaintLayer_Content
|
||||
#define NS_FRAME_PAINT_LAYER_FOREGROUND eFramePaintLayer_Overlay
|
||||
#define NS_FRAME_PAINT_LAYER_DEBUG eFramePaintLayer_Overlay
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* HTML/CSS specific reflow metrics
|
||||
*/
|
||||
struct nsHTMLReflowMetrics : nsReflowMetrics {
|
||||
// Carried out bottom margin values. This is the collapsed
|
||||
// (generational) bottom margin value.
|
||||
nscoord mCarriedOutBottomMargin;
|
||||
|
||||
// For frames that have children that stick outside their rect
|
||||
// (NS_FRAME_OUTSIDE_CHILDREN) this rectangle will contain the
|
||||
// absolute bounds of the frame. Since the frame doesn't know where
|
||||
// it is going to be positioned in its parent, the assumption is
|
||||
// that it is placed at 0,0 when computing this area.
|
||||
nsRect mCombinedArea;
|
||||
|
||||
nsHTMLReflowMetrics(nsSize* aMaxElementSize)
|
||||
: nsReflowMetrics(aMaxElementSize)
|
||||
{
|
||||
mCarriedOutBottomMargin = 0;
|
||||
mCombinedArea.x = 0;
|
||||
mCombinedArea.y = 0;
|
||||
mCombinedArea.width = 0;
|
||||
mCombinedArea.height = 0;
|
||||
}
|
||||
|
||||
void AddBorderPaddingToMaxElementSize(const nsMargin& aBorderPadding) {
|
||||
maxElementSize->width += aBorderPadding.left + aBorderPadding.right;
|
||||
maxElementSize->height += aBorderPadding.top + aBorderPadding.bottom;
|
||||
}
|
||||
};
|
||||
|
||||
// Carried out margin flags
|
||||
#define NS_CARRIED_TOP_MARGIN_IS_AUTO 0x1
|
||||
#define NS_CARRIED_BOTTOM_MARGIN_IS_AUTO 0x2
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CSS Frame type. Included as part of the reflow state.
|
||||
*/
|
||||
typedef PRUint32 nsCSSFrameType;
|
||||
|
||||
#define NS_CSS_FRAME_TYPE_UNKNOWN 0
|
||||
#define NS_CSS_FRAME_TYPE_INLINE 1
|
||||
#define NS_CSS_FRAME_TYPE_BLOCK 2 /* block-level in normal flow */
|
||||
#define NS_CSS_FRAME_TYPE_FLOATING 3
|
||||
#define NS_CSS_FRAME_TYPE_ABSOLUTE 4
|
||||
#define NS_CSS_FRAME_TYPE_INTERNAL_TABLE 5 /* row group frame, row frame, cell frame, ... */
|
||||
|
||||
/**
|
||||
* Bit-flag that indicates whether the element is replaced. Applies to inline,
|
||||
* block-level, floating, and absolutely positioned elements
|
||||
*/
|
||||
#define NS_CSS_FRAME_TYPE_REPLACED 0x8000
|
||||
|
||||
/**
|
||||
* Helper macros for telling whether items are replaced
|
||||
*/
|
||||
#define NS_FRAME_IS_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED == ((_ft) & NS_CSS_FRAME_TYPE_REPLACED))
|
||||
|
||||
#define NS_FRAME_REPLACED(_ft) \
|
||||
(NS_CSS_FRAME_TYPE_REPLACED | (_ft))
|
||||
|
||||
/**
|
||||
* A macro to extract the type. Masks off the 'replaced' bit-flag
|
||||
*/
|
||||
#define NS_FRAME_GET_TYPE(_ft) \
|
||||
((_ft) & ~NS_CSS_FRAME_TYPE_REPLACED)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define NS_INTRINSICSIZE NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOHEIGHT NS_UNCONSTRAINEDSIZE
|
||||
#define NS_AUTOMARGIN NS_UNCONSTRAINEDSIZE
|
||||
|
||||
/**
|
||||
* HTML version of the reflow state.
|
||||
*
|
||||
* Note: the constructors are implemented inline later on in this file
|
||||
*/
|
||||
struct nsHTMLReflowState : nsReflowState {
|
||||
// The type of frame, from css's perspective. This value is
|
||||
// initialized by the Init method below.
|
||||
nsCSSFrameType mFrameType;
|
||||
|
||||
nsISpaceManager* mSpaceManager;
|
||||
|
||||
// LineLayout object (only for inline reflow; set to NULL otherwise)
|
||||
nsLineLayout* mLineLayout;
|
||||
|
||||
// The computed width specifies the frame's content width, and it does not
|
||||
// apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic width as the computed width
|
||||
//
|
||||
// For block-level frames, the computed width is based on the width of the
|
||||
// containing block, the margin/border/padding areas, and the min/max width
|
||||
nscoord mComputedWidth;
|
||||
|
||||
// The computed height specifies the frame's content height, and it does
|
||||
// not apply to inline non-replaced elements
|
||||
//
|
||||
// For replaced inline frames, a value of NS_INTRINSICSIZE means you should
|
||||
// use your intrinsic height as the computed height
|
||||
//
|
||||
// For non-replaced block-level frames in the flow and floated, a value of
|
||||
// NS_AUTOHEIGHT means you choose a height to shrink wrap around the normal
|
||||
// flow child frames. The height must be within the limit of the min/max
|
||||
// height if there is such a limit
|
||||
//
|
||||
// For replaced block-level frames, a value of NS_INTRINSICSIZE
|
||||
// means you use your intrinsic height as the computed height
|
||||
nscoord mComputedHeight;
|
||||
|
||||
// Computed margin values
|
||||
nsMargin mComputedMargin;
|
||||
|
||||
// Cached copy of the border values
|
||||
nsMargin mComputedBorderPadding;
|
||||
|
||||
// Computed padding values
|
||||
nsMargin mComputedPadding;
|
||||
|
||||
// Computed values for 'left/top/right/bottom' offsets. Only applies to
|
||||
// 'positioned' elements
|
||||
nsMargin mComputedOffsets;
|
||||
|
||||
// Computed values for 'min-width/max-width' and 'min-height/max-height'
|
||||
nscoord mComputedMinWidth, mComputedMaxWidth;
|
||||
nscoord mComputedMinHeight, mComputedMaxHeight;
|
||||
|
||||
// Compact margin available space
|
||||
nscoord mCompactMarginWidth;
|
||||
|
||||
// The following data members are relevant if nsStyleText.mTextAlign
|
||||
// == NS_STYLE_TEXT_ALIGN_CHAR
|
||||
|
||||
// distance from reference edge (as specified in nsStyleDisplay.mDirection)
|
||||
// to the align character (which will be specified in nsStyleTable)
|
||||
nscoord mAlignCharOffset;
|
||||
|
||||
// if true, the reflow honors alignCharOffset and does not
|
||||
// set it. if false, the reflow sets alignCharOffset
|
||||
PRPackedBool mUseAlignCharOffset;
|
||||
|
||||
// Cached pointers to the various style structs used during intialization
|
||||
const nsStyleDisplay* mStyleDisplay;
|
||||
const nsStylePosition* mStylePosition;
|
||||
const nsStyleSpacing* mStyleSpacing;
|
||||
|
||||
// This value keeps track of how deeply nested a given reflow state
|
||||
// is from the top of the frame tree.
|
||||
PRInt32 mReflowDepth;
|
||||
|
||||
// Note: The copy constructor is written by the compiler
|
||||
// automatically. You can use that and then override specific values
|
||||
// if you want, or you can call Init as desired...
|
||||
|
||||
// Initialize a <b>root</b> reflow state with a rendering context to
|
||||
// use for measuring things.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsReflowReason aReason,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a <b>root</b> reflow state for an <b>incremental</b>
|
||||
// reflow.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
nsIReflowCommand& aReflowCommand,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Initialize a reflow state for a child frames reflow. Some state
|
||||
// is copied from the parent reflow state; the remaining state is
|
||||
// computed.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nsReflowReason aReason);
|
||||
|
||||
// Same as the previous except that the reason is taken from the
|
||||
// parent's reflow state.
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace);
|
||||
|
||||
// Used when you want to override the default containing block
|
||||
// width and height. Used by absolute positioning code
|
||||
nsHTMLReflowState(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aParentReflowState,
|
||||
nsIFrame* aFrame,
|
||||
const nsSize& aAvailableSpace,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
/**
|
||||
* Get the containing block reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetContainingBlockReflowState(const nsReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* First find the containing block's reflow state using
|
||||
* GetContainingBlockReflowState, then ask the containing block for
|
||||
* it's content width using GetContentWidth
|
||||
*/
|
||||
static nscoord
|
||||
GetContainingBlockContentWidth(const nsReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Get the page box reflow state, starting from a frames
|
||||
* <B>parent</B> reflow state (the parent reflow state may or may not end
|
||||
* up being the containing block reflow state)
|
||||
*/
|
||||
static const nsHTMLReflowState*
|
||||
GetPageBoxReflowState(const nsReflowState* aParentRS);
|
||||
|
||||
/**
|
||||
* Compute the border plus padding for <TT>aFrame</TT>. If a
|
||||
* percentage needs to be computed it will be computed by finding
|
||||
* the containing block, use GetContainingBlockReflowState.
|
||||
* aParentReflowState is aFrame's
|
||||
* parent's reflow state. The resulting computed border plus padding
|
||||
* is returned in aResult.
|
||||
*/
|
||||
static void ComputeBorderPaddingFor(nsIFrame* aFrame,
|
||||
const nsReflowState* aParentRS,
|
||||
nsMargin& aResult);
|
||||
|
||||
/**
|
||||
* Calculate the raw line-height property for the given frame. The return
|
||||
* value, if line-height was applied and is valid will be >= 0. Otherwise,
|
||||
* the return value will be <0 which is illegal (CSS2 spec: section 10.8.1).
|
||||
*/
|
||||
static nscoord CalcLineHeight(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext* aRenderingContext,
|
||||
nsIFrame* aFrame);
|
||||
|
||||
static PRBool UseComputedHeight();
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame);
|
||||
|
||||
void ComputeContainingBlockRectangle(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord& aContainingBlockWidth,
|
||||
nscoord& aContainingBlockHeight);
|
||||
|
||||
protected:
|
||||
// This method initializes various data members. It is automatically
|
||||
// called by the various constructors
|
||||
void Init(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth = -1,
|
||||
nscoord aContainingBlockHeight = -1);
|
||||
|
||||
void InitConstraints(nsIPresContext& aPresContext,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void InitAbsoluteConstraints(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void ComputeBlockBoxData(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState* cbrs,
|
||||
nsStyleUnit aWidthUnit,
|
||||
nsStyleUnit aHeightUnit,
|
||||
nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight);
|
||||
|
||||
void CalculateBlockSideMargins(const nsHTMLReflowState* aContainingBlockRS,
|
||||
nscoord aComputedWidth);
|
||||
|
||||
void ComputeHorizontalValue(nscoord aContainingBlockWidth,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
void ComputeVerticalValue(nscoord aContainingBlockHeight,
|
||||
nsStyleUnit aUnit,
|
||||
const nsStyleCoord& aCoord,
|
||||
nscoord& aResult);
|
||||
|
||||
static nsCSSFrameType DetermineFrameType(nsIFrame* aFrame,
|
||||
const nsStylePosition* aPosition,
|
||||
const nsStyleDisplay* aDisplay);
|
||||
|
||||
// Computes margin values from the specified margin style information, and
|
||||
// fills in the mComputedMargin member
|
||||
void ComputeMargin(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Computes padding values from the specified padding style information, and
|
||||
// fills in the mComputedPadding member
|
||||
void ComputePadding(nscoord aContainingBlockWidth,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
// Calculates the computed values for the 'min-Width', 'max-Width',
|
||||
// 'min-Height', and 'max-Height' properties, and stores them in the assorted
|
||||
// data members
|
||||
void ComputeMinMaxValues(nscoord aContainingBlockWidth,
|
||||
nscoord aContainingBlockHeight,
|
||||
const nsHTMLReflowState* aContainingBlockRS);
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Extensions to the reflow status bits defined by nsIFrameReflow
|
||||
*/
|
||||
|
||||
// This bit is set, when a break is requested. This bit is orthogonal
|
||||
// to the nsIFrame::nsReflowStatus completion bits.
|
||||
#define NS_INLINE_BREAK 0x0100
|
||||
|
||||
// When a break is requested, this bit when set indicates that the
|
||||
// break should occur after the frame just reflowed; when the bit is
|
||||
// clear the break should occur before the frame just reflowed.
|
||||
#define NS_INLINE_BREAK_BEFORE 0x0000
|
||||
#define NS_INLINE_BREAK_AFTER 0x0200
|
||||
|
||||
// The type of break requested can be found in these bits.
|
||||
#define NS_INLINE_BREAK_TYPE_MASK 0xF000
|
||||
|
||||
//----------------------------------------
|
||||
// Macros that use those bits
|
||||
|
||||
#define NS_INLINE_IS_BREAK(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_AFTER(_status) \
|
||||
(0 != ((_status) & NS_INLINE_BREAK_AFTER))
|
||||
|
||||
#define NS_INLINE_IS_BREAK_BEFORE(_status) \
|
||||
(NS_INLINE_BREAK == ((_status) & (NS_INLINE_BREAK|NS_INLINE_BREAK_AFTER)))
|
||||
|
||||
#define NS_INLINE_GET_BREAK_TYPE(_status) (((_status) >> 12) & 0xF)
|
||||
|
||||
#define NS_INLINE_MAKE_BREAK_TYPE(_type) ((_type) << 12)
|
||||
|
||||
// Construct a line-break-before status. Note that there is no
|
||||
// completion status for a line-break before because we *know* that
|
||||
// the frame will be reflowed later and hence it's current completion
|
||||
// status doesn't matter.
|
||||
#define NS_INLINE_LINE_BREAK_BEFORE() \
|
||||
(NS_INLINE_BREAK | NS_INLINE_BREAK_BEFORE | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
// Take a completion status and add to it the desire to have a
|
||||
// line-break after. For this macro we do need the completion status
|
||||
// because the user of the status will need to know whether to
|
||||
// continue the frame or not.
|
||||
#define NS_INLINE_LINE_BREAK_AFTER(_completionStatus) \
|
||||
((_completionStatus) | NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER | \
|
||||
NS_INLINE_MAKE_BREAK_TYPE(NS_STYLE_CLEAR_LINE))
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate a reflow interface specific to HTML/CSS frame objects
|
||||
*/
|
||||
class nsIHTMLReflow : public nsIFrameReflow<nsHTMLReflowState, nsHTMLReflowMetrics>
|
||||
{
|
||||
public:
|
||||
// Helper method used by block reflow to identify runs of text so that
|
||||
// proper word-breaking can be done.
|
||||
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout) = 0;
|
||||
|
||||
// Justification helper method used to distribute extra space in a
|
||||
// line to leaf frames. aUsedSpace is filled in with the amount of
|
||||
// space actually used.
|
||||
NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace) = 0;
|
||||
|
||||
// Justification helper method that is used to remove trailing
|
||||
// whitespace before justification.
|
||||
NS_IMETHOD TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRC,
|
||||
nscoord& aDeltaWidth) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIHTMLReflow_h___ */
|
|
@ -1331,11 +1331,7 @@ nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|||
else {
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
while (nsnull != frame) {
|
||||
nsIHTMLReflow* ihr;
|
||||
nsresult rv = frame->QueryInterface(kIHTMLReflowIID, (void**)&ihr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ihr->FindTextRuns(aLineLayout);
|
||||
}
|
||||
frame->FindTextRuns(aLineLayout);
|
||||
frame->GetNextSibling(&frame);
|
||||
}
|
||||
}
|
||||
|
@ -1353,9 +1349,6 @@ nsInlineFrame::DrainOverflow(nsIPresContext* aPresContext)
|
|||
if (prevOverflowFrames) {
|
||||
// When pushing and pulling frames we need to check for whether any
|
||||
// views need to be reparented.
|
||||
// XXX Doing it this way means an extra pass over the frames. We could
|
||||
// change InsertFrames() to do this, but that's a general purpose
|
||||
// function and it doesn't seem like this functionality belongs there...
|
||||
for (nsIFrame* f = prevOverflowFrames; f; f->GetNextSibling(&f)) {
|
||||
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
reason = eReflowReason_StyleChange;
|
||||
}
|
||||
else {
|
||||
const nsReflowState* rs = psd->mReflowState;
|
||||
const nsHTMLReflowState* rs = psd->mReflowState;
|
||||
if (rs->reason == eReflowReason_Incremental) {
|
||||
// If the incremental reflow command is a StyleChanged reflow and
|
||||
// it's target is the current span, then make sure we send
|
||||
|
@ -906,10 +906,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
// Let frame know that are reflowing it
|
||||
nscoord x = pfd->mBounds.x;
|
||||
nscoord y = pfd->mBounds.y;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
aFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
htmlReflow->WillReflow(mPresContext);
|
||||
aFrame->WillReflow(mPresContext);
|
||||
|
||||
// Adjust spacemanager coordinate system for the frame. The
|
||||
// spacemanager coordinates are <b>inside</b> the current spans
|
||||
|
@ -935,7 +933,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
nscoord tx = x - psd->mReflowState->mComputedBorderPadding.left;
|
||||
nscoord ty = y - psd->mReflowState->mComputedBorderPadding.top;
|
||||
mSpaceManager->Translate(tx, ty);
|
||||
htmlReflow->Reflow(mPresContext, metrics, reflowState, aReflowStatus);
|
||||
aFrame->Reflow(mPresContext, metrics, reflowState, aReflowStatus);
|
||||
|
||||
// XXX See if the frame is a placeholderFrame and if it is process
|
||||
// the floater.
|
||||
|
@ -2177,46 +2175,42 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd,
|
|||
}
|
||||
else if (pfd->mIsNonEmptyTextFrame) {
|
||||
nscoord deltaWidth = 0;
|
||||
nsIHTMLReflow* hr;
|
||||
nsresult rv = pfd->mFrame->QueryInterface(kIHTMLReflowIID, (void**)&hr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
hr->TrimTrailingWhiteSpace(&mPresContext,
|
||||
*mBlockReflowState->rendContext,
|
||||
deltaWidth);
|
||||
pfd->mFrame->TrimTrailingWhiteSpace(&mPresContext,
|
||||
*mBlockReflowState->rendContext,
|
||||
deltaWidth);
|
||||
#ifdef NOISY_TRIM
|
||||
nsFrame::ListTag(stdout, (psd == mRootSpan
|
||||
? mBlockReflowState->frame
|
||||
: psd->mFrame->mFrame));
|
||||
printf(": trim of ");
|
||||
nsFrame::ListTag(stdout, pfd->mFrame);
|
||||
printf(" returned %d\n", deltaWidth);
|
||||
nsFrame::ListTag(stdout, (psd == mRootSpan
|
||||
? mBlockReflowState->frame
|
||||
: psd->mFrame->mFrame));
|
||||
printf(": trim of ");
|
||||
nsFrame::ListTag(stdout, pfd->mFrame);
|
||||
printf(" returned %d\n", deltaWidth);
|
||||
#endif
|
||||
if (deltaWidth) {
|
||||
pfd->mBounds.width -= deltaWidth;
|
||||
pfd->mCombinedArea.width -= deltaWidth;
|
||||
if (0 == pfd->mBounds.width) {
|
||||
pfd->mMaxElementSize.width = 0;
|
||||
pfd->mMaxElementSize.height = 0;
|
||||
}
|
||||
if (deltaWidth) {
|
||||
pfd->mBounds.width -= deltaWidth;
|
||||
pfd->mCombinedArea.width -= deltaWidth;
|
||||
if (0 == pfd->mBounds.width) {
|
||||
pfd->mMaxElementSize.width = 0;
|
||||
pfd->mMaxElementSize.height = 0;
|
||||
}
|
||||
|
||||
// See if the text frame has already been placed in its parent
|
||||
if (psd != mRootSpan) {
|
||||
// The frame was already placed during psd's
|
||||
// reflow. Update the frames rectangle now.
|
||||
pfd->mFrame->SetRect(&mPresContext, pfd->mBounds);
|
||||
}
|
||||
// See if the text frame has already been placed in its parent
|
||||
if (psd != mRootSpan) {
|
||||
// The frame was already placed during psd's
|
||||
// reflow. Update the frames rectangle now.
|
||||
pfd->mFrame->SetRect(&mPresContext, pfd->mBounds);
|
||||
}
|
||||
|
||||
// Adjust containing span's right edge
|
||||
psd->mX -= deltaWidth;
|
||||
// Adjust containing span's right edge
|
||||
psd->mX -= deltaWidth;
|
||||
|
||||
// Slide any frames that follow the text frame over by the
|
||||
// right amount. The only thing that can follow the text
|
||||
// frame is empty stuff, so we are just making things
|
||||
// sensible (keeping the combined area honest).
|
||||
while (pfd->mNext) {
|
||||
pfd = pfd->mNext;
|
||||
pfd->mBounds.x -= deltaWidth;
|
||||
}
|
||||
// Slide any frames that follow the text frame over by the
|
||||
// right amount. The only thing that can follow the text
|
||||
// frame is empty stuff, so we are just making things
|
||||
// sensible (keeping the combined area honest).
|
||||
while (pfd->mNext) {
|
||||
pfd = pfd->mNext;
|
||||
pfd->mBounds.x -= deltaWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2226,6 +2220,7 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd,
|
|||
}
|
||||
pfd = pfd->mPrev;
|
||||
}
|
||||
|
||||
*aDeltaWidth = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -117,29 +117,26 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext,
|
|||
maxSize);
|
||||
kidReflowState.isTopOfPage = PR_TRUE;
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// Get the child's desired size
|
||||
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Make sure the child is at least as tall as our max size (the containing window)
|
||||
if (aDesiredSize.height < aReflowState.availableHeight) {
|
||||
aDesiredSize.height = aReflowState.availableHeight;
|
||||
}
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
frame->SetRect(&aPresContext, rect);
|
||||
// XXX Should we be sending the DidReflow?
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Is the frame complete?
|
||||
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
nsIFrame* childNextInFlow;
|
||||
|
||||
frame->GetNextInFlow(&childNextInFlow);
|
||||
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
|
||||
}
|
||||
// Get the child's desired size
|
||||
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// Make sure the child is at least as tall as our max size (the containing window)
|
||||
if (aDesiredSize.height < aReflowState.availableHeight) {
|
||||
aDesiredSize.height = aReflowState.availableHeight;
|
||||
}
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
frame->SetRect(&aPresContext, rect);
|
||||
// XXX Should we be sending the DidReflow?
|
||||
frame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
// Is the frame complete?
|
||||
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
nsIFrame* childNextInFlow;
|
||||
|
||||
frame->GetNextInFlow(&childNextInFlow);
|
||||
NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -939,7 +939,6 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -947,18 +946,16 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Initial, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::InitialReflow"));
|
||||
RAPTOR_STOPWATCH_DEBUGTRACE(("Stop: Reflow: PresShell::InitialReflow(), this=%p\n", this));
|
||||
|
@ -1019,7 +1016,6 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -1027,16 +1023,14 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Resize, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::ResizeReflow"));
|
||||
|
||||
|
@ -1198,7 +1192,6 @@ PresShell::StyleChangeReflow()
|
|||
nsSize maxSize(bounds.width, bounds.height);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
nsReflowStatus status;
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
CreateRenderingContext(rootFrame, &rcx);
|
||||
|
@ -1207,16 +1200,14 @@ PresShell::StyleChangeReflow()
|
|||
nsHTMLReflowState reflowState(*mPresContext, rootFrame,
|
||||
eReflowReason_Resize, rcx, maxSize);
|
||||
|
||||
if (NS_OK == rootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
rootFrame->Reflow(*mPresContext, desiredSize, reflowState, status);
|
||||
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
|
||||
#ifdef NS_DEBUG
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
if (nsIFrame::GetVerifyTreeEnable()) {
|
||||
rootFrame->VerifyTree();
|
||||
}
|
||||
#endif
|
||||
VERIFY_STYLE_TREE;
|
||||
NS_IF_RELEASE(rcx);
|
||||
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("exit nsPresShell::StyleChangeReflow"));
|
||||
}
|
||||
|
|
|
@ -162,10 +162,8 @@ nsScrollFrame::DidReflow(nsIPresContext& aPresContext,
|
|||
|
||||
// Send the DidReflow notification to the scrolled frame's view
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
htmlReflow->DidReflow(aPresContext, aStatus);
|
||||
frame->DidReflow(aPresContext, aStatus);
|
||||
|
||||
// Size the scrolled frame's view. Leave its position alone
|
||||
nsSize size;
|
||||
|
|
|
@ -172,10 +172,8 @@ nsScrollPortFrame::DidReflow(nsIPresContext& aPresContext,
|
|||
|
||||
// Send the DidReflow notification to the scrolled frame's view
|
||||
nsIFrame* frame = mFrames.FirstChild();
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
htmlReflow->DidReflow(aPresContext, aStatus);
|
||||
frame->DidReflow(aPresContext, aStatus);
|
||||
|
||||
// Size the scrolled frame's view. Leave its position alone
|
||||
nsSize size;
|
||||
|
|
|
@ -326,42 +326,38 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext& aPresContext,
|
|||
nsReflowStatus& aStatus) const
|
||||
{
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv;
|
||||
nsresult rv;
|
||||
|
||||
rv = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
aKidFrame->WillReflow(aPresContext);
|
||||
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize);
|
||||
nsHTMLReflowMetrics kidDesiredSize(nsnull);
|
||||
nsSize availSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
|
||||
availSize);
|
||||
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
htmlReflow->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child
|
||||
nsRect rect(kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
// If it's the initial reflow, then override the reflow reason. This is
|
||||
// used when frames are inserted incrementally
|
||||
if (aInitialReflow) {
|
||||
kidReflowState.reason = eReflowReason_Initial;
|
||||
}
|
||||
|
||||
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
|
||||
|
||||
// XXX If the child had a fixed height, then make sure it respected it...
|
||||
if (NS_AUTOHEIGHT != kidReflowState.mComputedHeight) {
|
||||
if (kidDesiredSize.height < kidReflowState.mComputedHeight) {
|
||||
kidDesiredSize.height = kidReflowState.mComputedHeight;
|
||||
kidDesiredSize.height += kidReflowState.mComputedBorderPadding.top +
|
||||
kidReflowState.mComputedBorderPadding.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// Position the child
|
||||
nsRect rect(kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
|
||||
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
|
||||
kidDesiredSize.width, kidDesiredSize.height);
|
||||
aKidFrame->SetRect(&aPresContext, rect);
|
||||
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -507,20 +503,17 @@ ViewportFrame::Reflow(nsIPresContext& aPresContext,
|
|||
kidFrame, availableSpace);
|
||||
|
||||
// Reflow the frame
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
kidReflowState.mComputedHeight = aReflowState.availableHeight;
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
kidReflowState.mComputedHeight = aReflowState.availableHeight;
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
|
||||
nsRect rect(0, 0, kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
kidRect = rect;
|
||||
nsRect rect(0, 0, kidDesiredSize.width, kidDesiredSize.height);
|
||||
kidFrame->SetRect(&aPresContext, rect);
|
||||
kidRect = rect;
|
||||
|
||||
// XXX We should resolve the details of who/when DidReflow()
|
||||
// notifications are sent...
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
// XXX We should resolve the details of who/when DidReflow()
|
||||
// notifications are sent...
|
||||
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
}
|
||||
|
||||
// If it's a 'initial', 'resize', or 'style change' reflow command (anything
|
||||
|
|
|
@ -350,16 +350,12 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstChild,
|
||||
innerSize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == firstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(offset.x, offset.y, innerSize.width, innerSize.height);
|
||||
firstChild->SetRect(&aPresContext, rect);
|
||||
}
|
||||
// Place and size the child
|
||||
nsRect rect(offset.x, offset.y, innerSize.width, innerSize.height);
|
||||
firstChild->SetRect(&aPresContext, rect);
|
||||
|
||||
// XXX what should the max-element-size of an iframe be? Shouldn't
|
||||
// iframe's normally shrink wrap around their content when they
|
||||
|
|
|
@ -771,22 +771,19 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
|||
}
|
||||
|
||||
// reflow and place the child
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
||||
nsHTMLReflowMetrics metrics(nsnull);
|
||||
metrics.width = aSize.width;
|
||||
metrics.height= aSize.height;
|
||||
nsReflowStatus status;
|
||||
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
||||
nsHTMLReflowMetrics metrics(nsnull);
|
||||
metrics.width = aSize.width;
|
||||
metrics.height= aSize.height;
|
||||
nsReflowStatus status;
|
||||
|
||||
ReflowChild(aChild, aPresContext, metrics, reflowState, status);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
||||
ReflowChild(aChild, aPresContext, metrics, reflowState, status);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
||||
|
||||
// Place and size the child
|
||||
nsRect rect(aOffset.x, aOffset.y, aSize.width, aSize.height);
|
||||
aChild->SetRect(&aPresContext, rect);
|
||||
htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // this call is needed
|
||||
}
|
||||
// Place and size the child
|
||||
nsRect rect(aOffset.x, aOffset.y, aSize.width, aSize.height);
|
||||
aChild->SetRect(&aPresContext, rect);
|
||||
aChild->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); // this call is needed
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
@ -3805,7 +3805,7 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, const nsSty
|
|||
{
|
||||
PRBool result = PR_FALSE;
|
||||
// Walk up the reflow state chain until we find a cell or the root
|
||||
const nsReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
||||
const nsHTMLReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
||||
if (rs)
|
||||
rs = rs->parentReflowState; // and this is the parent of the outer frame
|
||||
while (nsnull != rs)
|
||||
|
@ -3923,7 +3923,7 @@ nsTableFrame::GetRowGroupFrameFor(nsIFrame* aFrame, const nsStyleDisplay* aDispl
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsTableFrame::IsFinalPass(const nsReflowState& aState)
|
||||
nsTableFrame::IsFinalPass(const nsHTMLReflowState& aState)
|
||||
{
|
||||
return (NS_UNCONSTRAINEDSIZE != aState.availableWidth) ||
|
||||
(NS_UNCONSTRAINEDSIZE != aState.availableHeight);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nsStyleCoord.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIFrameReflow.h" // for nsReflowReason enum
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
class nsCellMap;
|
||||
|
@ -315,7 +314,7 @@ public:
|
|||
|
||||
virtual void AddColumnFrame (nsTableColFrame *aColFrame);
|
||||
|
||||
static PRBool IsFinalPass(const nsReflowState& aReflowState);
|
||||
static PRBool IsFinalPass(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
nsTableCellFrame* GetCellInfoAt(PRInt32 aRowX,
|
||||
PRInt32 aColX,
|
||||
|
|
|
@ -588,16 +588,13 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
||||
nsSize(innerSize.width, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// reflow the caption
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
captionWasReflowed = PR_TRUE;
|
||||
if ((oldCaptionRect.height!=captionSize.height) ||
|
||||
(oldCaptionRect.width!=captionSize.width)) {
|
||||
captionDimChanged=PR_TRUE;
|
||||
}
|
||||
// reflow the caption
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
captionWasReflowed = PR_TRUE;
|
||||
if ((oldCaptionRect.height!=captionSize.height) ||
|
||||
(oldCaptionRect.width!=captionSize.width)) {
|
||||
captionDimChanged=PR_TRUE;
|
||||
}
|
||||
}
|
||||
// XXX: should just call SizeAndPlaceChildren regardless
|
||||
|
@ -680,42 +677,35 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
||||
nsSize(mRect.width, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Initial);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// initial reflow of the caption
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
// XXX: caption align = left|right ignored here!
|
||||
// if the caption's MES > table width, reflow the inner table
|
||||
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > mRect.width) {
|
||||
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
||||
nsSize(mMinCaptionWidth, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
||||
}
|
||||
else { // set innerSize as if the inner table were reflowed
|
||||
innerSize.height = mRect.height;
|
||||
innerSize.width = mRect.width;
|
||||
}
|
||||
// set maxElementSize width if requested
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
||||
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
||||
}
|
||||
}
|
||||
|
||||
rv = SizeAndPlaceChildren(&aPresContext,
|
||||
nsSize (innerSize.width, innerSize.height),
|
||||
nsSize (captionSize.width, captionSize.height),
|
||||
aReflowState);
|
||||
// initial reflow of the caption
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
// XXX: caption align = left|right ignored here!
|
||||
// if the caption's MES > table width, reflow the inner table
|
||||
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > mRect.width) {
|
||||
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
||||
nsSize(mMinCaptionWidth, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
||||
}
|
||||
else { // set innerSize as if the inner table were reflowed
|
||||
innerSize.height = mRect.height;
|
||||
innerSize.width = mRect.width;
|
||||
}
|
||||
// set maxElementSize width if requested
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
||||
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
||||
}
|
||||
}
|
||||
|
||||
rv = SizeAndPlaceChildren(&aPresContext,
|
||||
nsSize (innerSize.width, innerSize.height),
|
||||
nsSize (captionSize.width, captionSize.height),
|
||||
aReflowState);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -869,13 +859,10 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState, mCaptionFrame,
|
||||
nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
||||
eReflowReason_Initial);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
}
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -938,23 +925,20 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsSize(innerSize.width, NS_UNCONSTRAINEDSIZE),
|
||||
eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics captionSize(nsnull);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsRect captionRect(captionMargin.left, captionY, 0, 0);
|
||||
nsReflowStatus captionStatus;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
nsReflowStatus captionStatus;
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
htmlReflow->Reflow(aPresContext, captionSize, captionReflowState,
|
||||
captionStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(captionStatus), "unexpected reflow status");
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState,
|
||||
captionStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(captionStatus), "unexpected reflow status");
|
||||
|
||||
// XXX If the height is constrained then we need to check whether the inner
|
||||
// table still fits...
|
||||
// XXX If the height is constrained then we need to check whether the inner
|
||||
// table still fits...
|
||||
|
||||
// Place the caption
|
||||
captionRect.SizeTo(captionSize.width, captionSize.height);
|
||||
mCaptionFrame->SetRect(&aPresContext, captionRect);
|
||||
}
|
||||
// Place the caption
|
||||
captionRect.SizeTo(captionSize.width, captionSize.height);
|
||||
mCaptionFrame->SetRect(&aPresContext, captionRect);
|
||||
|
||||
// Place the inner table
|
||||
nscoord innerY;
|
||||
|
|
|
@ -826,11 +826,7 @@ nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresContex
|
|||
kidFrame->GetOrigin(origin);
|
||||
origin.y += aDeltaY;
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
}
|
||||
|
||||
kidFrame->WillReflow(aPresContext);
|
||||
kidFrame->MoveTo(&aPresContext, origin.x, origin.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -3805,7 +3805,7 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, const nsSty
|
|||
{
|
||||
PRBool result = PR_FALSE;
|
||||
// Walk up the reflow state chain until we find a cell or the root
|
||||
const nsReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
||||
const nsHTMLReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
||||
if (rs)
|
||||
rs = rs->parentReflowState; // and this is the parent of the outer frame
|
||||
while (nsnull != rs)
|
||||
|
@ -3923,7 +3923,7 @@ nsTableFrame::GetRowGroupFrameFor(nsIFrame* aFrame, const nsStyleDisplay* aDispl
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsTableFrame::IsFinalPass(const nsReflowState& aState)
|
||||
nsTableFrame::IsFinalPass(const nsHTMLReflowState& aState)
|
||||
{
|
||||
return (NS_UNCONSTRAINEDSIZE != aState.availableWidth) ||
|
||||
(NS_UNCONSTRAINEDSIZE != aState.availableHeight);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nsStyleCoord.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIFrameReflow.h" // for nsReflowReason enum
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
class nsCellMap;
|
||||
|
@ -315,7 +314,7 @@ public:
|
|||
|
||||
virtual void AddColumnFrame (nsTableColFrame *aColFrame);
|
||||
|
||||
static PRBool IsFinalPass(const nsReflowState& aReflowState);
|
||||
static PRBool IsFinalPass(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
nsTableCellFrame* GetCellInfoAt(PRInt32 aRowX,
|
||||
PRInt32 aColX,
|
||||
|
|
|
@ -588,16 +588,13 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
||||
nsSize(innerSize.width, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// reflow the caption
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
captionWasReflowed = PR_TRUE;
|
||||
if ((oldCaptionRect.height!=captionSize.height) ||
|
||||
(oldCaptionRect.width!=captionSize.width)) {
|
||||
captionDimChanged=PR_TRUE;
|
||||
}
|
||||
// reflow the caption
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
captionWasReflowed = PR_TRUE;
|
||||
if ((oldCaptionRect.height!=captionSize.height) ||
|
||||
(oldCaptionRect.width!=captionSize.width)) {
|
||||
captionDimChanged=PR_TRUE;
|
||||
}
|
||||
}
|
||||
// XXX: should just call SizeAndPlaceChildren regardless
|
||||
|
@ -680,42 +677,35 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
||||
nsSize(mRect.width, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Initial);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
// initial reflow of the caption
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
// XXX: caption align = left|right ignored here!
|
||||
// if the caption's MES > table width, reflow the inner table
|
||||
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > mRect.width) {
|
||||
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
||||
nsSize(mMinCaptionWidth, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
||||
}
|
||||
else { // set innerSize as if the inner table were reflowed
|
||||
innerSize.height = mRect.height;
|
||||
innerSize.width = mRect.width;
|
||||
}
|
||||
// set maxElementSize width if requested
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
||||
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
||||
}
|
||||
}
|
||||
|
||||
rv = SizeAndPlaceChildren(&aPresContext,
|
||||
nsSize (innerSize.width, innerSize.height),
|
||||
nsSize (captionSize.width, captionSize.height),
|
||||
aReflowState);
|
||||
// initial reflow of the caption
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
// XXX: caption align = left|right ignored here!
|
||||
// if the caption's MES > table width, reflow the inner table
|
||||
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > mRect.width) {
|
||||
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
||||
nsSize(mMinCaptionWidth, aReflowState.reflowState.availableHeight),
|
||||
eReflowReason_Resize);
|
||||
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
||||
}
|
||||
else { // set innerSize as if the inner table were reflowed
|
||||
innerSize.height = mRect.height;
|
||||
innerSize.width = mRect.width;
|
||||
}
|
||||
// set maxElementSize width if requested
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
||||
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
||||
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
||||
}
|
||||
}
|
||||
|
||||
rv = SizeAndPlaceChildren(&aPresContext,
|
||||
nsSize (innerSize.width, innerSize.height),
|
||||
nsSize (captionSize.width, captionSize.height),
|
||||
aReflowState);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -869,13 +859,10 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowState captionReflowState(aPresContext, aReflowState, mCaptionFrame,
|
||||
nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
||||
eReflowReason_Initial);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
}
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
rv = mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -938,23 +925,20 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsSize(innerSize.width, NS_UNCONSTRAINEDSIZE),
|
||||
eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics captionSize(nsnull);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsRect captionRect(captionMargin.left, captionY, 0, 0);
|
||||
nsReflowStatus captionStatus;
|
||||
|
||||
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
nsReflowStatus captionStatus;
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
htmlReflow->Reflow(aPresContext, captionSize, captionReflowState,
|
||||
captionStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(captionStatus), "unexpected reflow status");
|
||||
mCaptionFrame->WillReflow(aPresContext);
|
||||
mCaptionFrame->Reflow(aPresContext, captionSize, captionReflowState,
|
||||
captionStatus);
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(captionStatus), "unexpected reflow status");
|
||||
|
||||
// XXX If the height is constrained then we need to check whether the inner
|
||||
// table still fits...
|
||||
// XXX If the height is constrained then we need to check whether the inner
|
||||
// table still fits...
|
||||
|
||||
// Place the caption
|
||||
captionRect.SizeTo(captionSize.width, captionSize.height);
|
||||
mCaptionFrame->SetRect(&aPresContext, captionRect);
|
||||
}
|
||||
// Place the caption
|
||||
captionRect.SizeTo(captionSize.width, captionSize.height);
|
||||
mCaptionFrame->SetRect(&aPresContext, captionRect);
|
||||
|
||||
// Place the inner table
|
||||
nscoord innerY;
|
||||
|
|
|
@ -826,11 +826,7 @@ nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresContex
|
|||
kidFrame->GetOrigin(origin);
|
||||
origin.y += aDeltaY;
|
||||
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
}
|
||||
|
||||
kidFrame->WillReflow(aPresContext);
|
||||
kidFrame->MoveTo(&aPresContext, origin.x, origin.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -1119,13 +1119,8 @@ nsBoxFrame::FlowChildAt(nsIFrame* childFrame,
|
|||
printf("because (%s)\n", ch);
|
||||
#endif
|
||||
// do the flow
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
|
||||
rv = childFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
NS_ASSERTION(rv == NS_OK,"failed to get htmlReflow interface.");
|
||||
|
||||
htmlReflow->WillReflow(aPresContext);
|
||||
htmlReflow->Reflow(aPresContext, desiredSize, reflowState, aStatus);
|
||||
childFrame->WillReflow(aPresContext);
|
||||
childFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus);
|
||||
|
||||
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
||||
|
||||
|
|
|
@ -271,13 +271,7 @@ nsMenuPopupFrame::DidReflow(nsIPresContext& aPresContext,
|
|||
nsIFrame* kid;
|
||||
FirstChild(listName, &kid);
|
||||
while (nsnull != kid) {
|
||||
static NS_DEFINE_IID(kIHTMLReflowIID, NS_IHTMLREFLOW_IID);
|
||||
nsIHTMLReflow* htmlReflow;
|
||||
nsresult rv;
|
||||
rv = kid->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlReflow->DidReflow(aPresContext, aStatus);
|
||||
}
|
||||
kid->DidReflow(aPresContext, aStatus);
|
||||
kid->GetNextSibling(&kid);
|
||||
}
|
||||
NS_IF_RELEASE(listName);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsIHTMLReflow.h"
|
||||
#include "nsIReflowCommand.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIPresContext.h"
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsTreeFrame.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
#include "nsIDTD.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLElementFactory.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -112,6 +111,7 @@
|
|||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "prprf.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsplugin.h"
|
||||
#include "nsIFrame.h"
|
||||
//#include "nsPluginsCID.h"
|
||||
#include "nsIPluginManager.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -65,7 +66,6 @@
|
|||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "stopwatch.h"
|
||||
|
||||
#include "nsILocaleService.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче