Unify box and frame trees by moving nsIBox methods onto nsIFrame. XUL-box frames can call the superclass nsBox implementation, all other frames get the nsFrame implementation of the box methods, which acts like nsBoxToBlockAdaptor used to. Bug 258513, r+sr=roc.

This commit is contained in:
bryner%brianryner.com 2004-09-28 18:37:50 +00:00
parent 47313eb59a
commit f67d250152
73 changed files with 3590 additions and 3643 deletions

View File

@ -99,6 +99,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../html \
-I$(srcdir)/../xul \
-I$(srcdir)/../../../layout/html/base/src \
-I$(srcdir)/../../../layout/xul/base/src \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)

View File

@ -80,4 +80,5 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = \
-I$(srcdir)/../base \
-I$(srcdir)/../../../layout/html/base/src \
-I$(srcdir)/../../../layout/xul/base/src \
$(NULL)

View File

@ -131,6 +131,7 @@ LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(boxMetricsProperty, "BoxMetricsProperty") // nsBoxLayoutMetrics*
LAYOUT_ATOM(changeListProperty, "ChangeListProperty") // void*
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") // nsPoint*
LAYOUT_ATOM(computedOffsetProperty, "ComputedOffsetProperty") // nsPoint*

View File

@ -113,6 +113,7 @@
#include "nsScrollPortFrame.h"
#include "nsXULAtoms.h"
#include "nsBoxFrame.h"
#include "nsIBoxLayout.h"
#ifdef MOZ_ENABLE_CAIRO
#include "nsCanvasFrame.h"
#endif
@ -5817,11 +5818,9 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
nsRefPtr<nsStyleContext> contentStyle = aContentStyle;
if (!gfxScrollFrame) {
nsCOMPtr<nsIBox> box = do_QueryInterface(aParentFrame);
// Build a XULScrollFrame when the parent is a box, because XULScrollFrames
// do box layout well. Otherwise build an HTMLScrollFrame.
if (box) {
if (aParentFrame->IsBoxFrame()) {
NS_NewXULScrollFrame(aPresShell, &gfxScrollFrame, aIsRoot);
} else {
NS_NewHTMLScrollFrame(aPresShell, &gfxScrollFrame, aIsRoot);
@ -9816,12 +9815,9 @@ nsCSSFrameConstructor::StyleChangeReflow(nsPresContext* aPresContext,
#endif
// Is it a box? If so we can coelesce.
nsresult rv;
nsIBox *box;
rv = CallQueryInterface(aFrame, &box);
if (NS_SUCCEEDED(rv) && box) {
if (aFrame->IsBoxFrame()) {
nsBoxLayoutState state(aPresContext);
box->MarkStyleChange(state);
aFrame->MarkStyleChange(state);
}
else {
// If the frame is part of a split block-in-inline hierarchy, then
@ -9833,10 +9829,10 @@ nsCSSFrameConstructor::StyleChangeReflow(nsPresContext* aPresContext,
// Target a style-change reflow at the frame.
nsHTMLReflowCommand *reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged,
nsnull,
aAttribute);
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged,
nsnull,
aAttribute);
if (NS_SUCCEEDED(rv))
aPresContext->PresShell()->AppendReflowCommand(reflowCmd);

View File

@ -131,6 +131,7 @@ LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(boxMetricsProperty, "BoxMetricsProperty") // nsBoxLayoutMetrics*
LAYOUT_ATOM(changeListProperty, "ChangeListProperty") // void*
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") // nsPoint*
LAYOUT_ATOM(computedOffsetProperty, "ComputedOffsetProperty") // nsPoint*

View File

@ -79,6 +79,8 @@ class nsIView;
class nsIWidget;
class nsIDOMRange;
class nsISelectionController;
class nsBoxLayoutState;
class nsIBoxLayout;
#ifdef ACCESSIBILITY
class nsIAccessible;
#endif
@ -89,10 +91,12 @@ struct nsRect;
struct nsSize;
struct nsMargin;
typedef class nsIFrame nsIBox;
// IID for the nsIFrame interface
// a6cf9050-15b3-11d2-932e-00805f8add32
// 7a243690-a766-4394-bc13-788b1bf63ef1
#define NS_IFRAME_IID \
{ 0xa6cf9050, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
{ 0x7a243690, 0xa766, 0x4394,{0xbc, 0x13, 0x78, 0x8b, 0x1b, 0xf6, 0x3e, 0xf1}}
/**
* Indication of how the frame can be split. This is used when doing runaround
@ -159,6 +163,10 @@ typedef PRUint32 nsFrameState;
// If this bit is set, then the frame corresponds to generated content
#define NS_FRAME_GENERATED_CONTENT 0x00000040
// If this bit is set, then the frame uses XUL flexible box layout
// for its children.
#define NS_FRAME_IS_BOX 0x00000080
// If this bit is set, then the frame has been moved out of the flow,
// e.g., it is absolutely positioned or floated
#define NS_FRAME_OUT_OF_FLOW 0x00000100
@ -214,6 +222,10 @@ typedef PRUint32 nsFrameState;
// implementations.
#define NS_FRAME_IMPL_RESERVED 0xFFF00000
// Box layout bits
#define NS_STATE_IS_HORIZONTAL 0x00400000
#define NS_STATE_IS_DIRECTION_NORMAL 0x80000000
//----------------------------------------------------------------------
enum nsFramePaintLayer {
@ -1261,6 +1273,113 @@ NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::embeddingLevel))
*/
PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
// BOX LAYOUT METHODS
// These methods have been migrated from nsIBox and are in the process of
// being refactored. DO NOT USE OUTSIDE OF XUL.
PRBool IsBoxFrame() const { return (mState & NS_FRAME_IS_BOX) != 0; }
PRBool IsBoxWrapped() const
{ return (!IsBoxFrame() && mParent && mParent->IsBoxFrame()); }
enum Halignment {
hAlign_Left,
hAlign_Right,
hAlign_Center
};
enum Valignment {
vAlign_Top,
vAlign_Middle,
vAlign_BaseLine,
vAlign_Bottom
};
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex)=0;
NS_HIDDEN_(nsresult)
GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)=0;
NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed)=0;
// This does not alter the overflow area. If the caller is changing
// the box size, the caller is responsible for updating the overflow
// area. It's enough to just call Layout or SyncLayout on the
// box. You can pass PR_TRUE to aRemoveOverflowArea as a
// convenience.
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
PRBool aRemoveOverflowArea = PR_FALSE)=0;
NS_HIDDEN_(nsresult) Layout(nsBoxLayoutState& aBoxLayoutState);
nsresult IsDirty(PRBool& aIsDirty) { aIsDirty = (mState & NS_FRAME_IS_DIRTY) != 0; return NS_OK; }
nsresult HasDirtyChildren(PRBool& aIsDirty) { aIsDirty = (mState & NS_FRAME_HAS_DIRTY_CHILDREN) != 0; return NS_OK; }
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState)=0;
NS_HIDDEN_(nsresult) MarkDirtyChildren(nsBoxLayoutState& aState);
nsresult GetChildBox(nsIBox** aBox)
{
// box layout ends at box-wrapped frames, so don't allow these frames
// to report child boxes.
*aBox = IsBoxFrame() ? GetFirstChild(nsnull) : nsnull;
return NS_OK;
}
nsresult GetNextBox(nsIBox** aBox)
{
*aBox = (mParent && mParent->IsBoxFrame()) ? mNextSibling : nsnull;
return NS_OK;
}
nsresult SetNextBox(nsIBox* aBox) { return NS_OK; }
NS_HIDDEN_(nsresult) GetParentBox(nsIBox** aParent);
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding)=0;
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding)=0;
#ifdef DEBUG_LAYOUT
NS_IMETHOD GetInset(nsMargin& aInset)=0;
#else
nsresult GetInset(nsMargin& aInset) { aInset.SizeTo(0, 0, 0, 0); return NS_OK; }
#endif
NS_IMETHOD GetMargin(nsMargin& aMargin)=0;
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout)=0;
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout)=0;
NS_HIDDEN_(nsresult) GetContentRect(nsRect& aContentRect);
NS_HIDDEN_(nsresult) GetClientRect(nsRect& aContentRect);
NS_IMETHOD GetVAlign(Valignment& aAlign) = 0;
NS_IMETHOD GetHAlign(Halignment& aAlign) = 0;
PRBool IsHorizontal() const { return (mState & NS_STATE_IS_HORIZONTAL) != 0; }
nsresult GetOrientation(PRBool& aIsHorizontal) /// XXX to be removed
{ aIsHorizontal = IsHorizontal(); return NS_OK; }
PRBool IsNormalDirection() const { return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0; }
nsresult GetDirection(PRBool& aIsNormal) /// XXX to be removed
{ aIsNormal = IsNormalDirection(); return NS_OK; }
NS_HIDDEN_(nsresult) Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nsnull, PRBool aImmediate = PR_FALSE);
NS_IMETHOD NeedsRecalc()=0;
NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough)=0;
NS_IMETHOD MarkChildrenStyleChange()=0;
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0;
#ifdef DEBUG_LAYOUT
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug)=0;
NS_IMETHOD GetDebug(PRBool& aDebug)=0;
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox)=0;
NS_IMETHOD DumpBox(FILE* out)=0;
#endif
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust) const=0;
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex)=0;
static PRBool AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex);
static PRBool AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollapsed);
static PRBool AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal);
// END OF BOX LAYOUT METHODS
// The above methods have been migrated from nsIBox and are in the process of
// being refactored. DO NOT USE OUTSIDE OF XUL.
protected:
// Members
nsRect mRect;

View File

@ -45,7 +45,6 @@
#include "nsPresContext.h"
class nsIFrame;
class nsIBox;
class nsBoxLayoutState;
// IID for the nsIScrollableFrame interface

View File

@ -6202,6 +6202,10 @@ nsBlockFrame::Init(nsPresContext* aPresContext,
nsresult rv = nsBlockFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
if (IsBoxWrapped())
mState |= NS_BLOCK_SPACE_MGR;
return rv;
}
@ -6593,6 +6597,19 @@ nsBlockFrame::BuildFloatList(nsBlockReflowState& aState)
}
}
NS_IMETHODIMP
nsBlockFrame::SetParent(const nsIFrame* aParent)
{
nsresult rv = nsBlockFrameSuper::SetParent(aParent);
if (IsBoxWrapped())
mState |= NS_BLOCK_SPACE_MGR;
// XXX should we clear NS_BLOCK_SPACE_MGR if we were the child of a box
// but no longer are?
return rv;
}
// XXX keep the text-run data in the first-in-flow of the block
#ifdef DEBUG

View File

@ -128,6 +128,7 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
NS_IMETHOD SetParent(const nsIFrame* aParent);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
NS_IMETHOD Destroy(nsPresContext* aPresContext);
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#ifndef nsFrame_h___
#define nsFrame_h___
#include "nsIFrame.h"
#include "nsBox.h"
#include "nsRect.h"
#include "nsString.h"
#include "prlog.h"
@ -116,6 +116,8 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
//----------------------------------------------------------------------
struct nsBoxLayoutMetrics;
/**
* Implementation of a simple frame that's not splittable and has no
* child frames.
@ -123,7 +125,7 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
* 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
class nsFrame : public nsBox
#ifdef NS_DEBUG
, public nsIFrameDebug
#endif
@ -145,6 +147,10 @@ public:
// deal with it.
void operator delete(void* aPtr, size_t sz);
// We compute and store the HTML content's overflow area. So don't
// try to compute it in the box code.
virtual PRBool ComputesOwnOverflowArea() { return PR_TRUE; }
private:
// The normal operator new is disallowed on nsFrames.
void* operator new(size_t sz) CPP_THROW_NEW { return nsnull; };
@ -186,6 +192,7 @@ public:
virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
virtual void SetAdditionalStyleContext(PRInt32 aIndex,
nsStyleContext* aStyleContext);
NS_IMETHOD SetParent(const nsIFrame* aParent);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
NS_IMETHOD Paint(nsPresContext* aPresContext,
@ -325,6 +332,16 @@ public:
PRBool aJumpLines);
// Box layout methods
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD SetIncludeOverflow(PRBool aInclude);
NS_IMETHOD GetOverflow(nsSize& aOverflow);
NS_IMETHOD NeedsRecalc();
//--------------------------------------------------
// Additional methods
@ -500,6 +517,47 @@ protected:
// applies to its situation.
void SetOverflowClipRect(nsIRenderingContext& aRenderingContext);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
#endif
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
void InitBoxMetrics(PRBool aClear);
nsBoxLayoutMetrics* BoxMetrics() const;
private:
nsresult BoxReflow(nsBoxLayoutState& aState,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nscoord aX,
nscoord aY,
nscoord aWidth,
nscoord aHeight,
PRBool aMoveFrame = PR_TRUE);
void HandleIncrementalReflow(nsBoxLayoutState& aState,
const nsHTMLReflowState& aReflowState,
nsReflowReason& aReason,
nsReflowPath** aReflowPath,
PRBool& aRedrawNow,
PRBool& aNeedReflow,
PRBool& aRedrawAfterReflow,
PRBool& aMoveFrame);
PRBool CanSetMaxElementWidth(nsBoxLayoutState& aState,
nsReflowReason& aReason,
nsReflowPath **aReflowPath);
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
protected:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

View File

@ -135,13 +135,11 @@ nsHTMLScrollFrame::GetScrollbarStyles() const {
}
nsMargin nsHTMLScrollFrame::GetActualScrollbarSizes() const {
nsRect bounds = GetRect();
nsRect scrollArea;
mInner.mScrollAreaBox->GetBounds(scrollArea);
nsRect scrollArea(mInner.mScrollAreaBox->GetRect());
return nsMargin(scrollArea.x, scrollArea.y,
bounds.width - scrollArea.XMost(),
bounds.height - scrollArea.YMost());
mRect.width - scrollArea.XMost(),
mRect.height - scrollArea.YMost());
}
nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
@ -291,8 +289,6 @@ nsHTMLScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsIFrame* frame = nsnull;
mInner.mScrollAreaBox->GetFrame(&frame);
nsPoint point(aPoint);
//we need to translate the coordinates to the inner
nsIView *view = GetClosestView();
@ -306,7 +302,7 @@ nsHTMLScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
innerView = innerView->GetParent();
}
return frame->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
return mInner.mScrollAreaBox->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
}
PRIntn
@ -669,13 +665,11 @@ nsXULScrollFrame::GetScrollbarStyles() const {
}
nsMargin nsXULScrollFrame::GetActualScrollbarSizes() const {
nsRect bounds = GetRect();
nsRect scrollArea;
mInner.mScrollAreaBox->GetBounds(scrollArea);
nsRect scrollArea(mInner.mScrollAreaBox->GetRect());
return nsMargin(scrollArea.x, scrollArea.y,
bounds.width - scrollArea.XMost(),
bounds.height - scrollArea.YMost());
mRect.width - scrollArea.XMost(),
mRect.height - scrollArea.YMost());
}
nsMargin nsXULScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
@ -825,8 +819,6 @@ nsXULScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsIFrame* frame = nsnull;
mInner.mScrollAreaBox->GetFrame(&frame);
nsPoint point(aPoint);
//we need to translate the coordinates to the inner
nsIView *view = GetClosestView();
@ -840,7 +832,7 @@ nsXULScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
innerView = innerView->GetParent();
}
return frame->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
return mInner.mScrollAreaBox->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
}
PRIntn
@ -1285,12 +1277,10 @@ nsGfxScrollFrameInner::ReloadChildFrames()
while (frame) {
PRBool understood = PR_FALSE;
nsIBox* box = nsnull;
frame->QueryInterface(NS_GET_IID(nsIBox), (void**)&box);
if (box) {
if (frame->IsBoxFrame()) {
if (frame->GetType() == nsLayoutAtoms::scrollFrame) {
NS_ASSERTION(!mScrollAreaBox, "Found multiple scroll areas?");
mScrollAreaBox = box;
mScrollAreaBox = frame;
understood = PR_TRUE;
} else {
nsIContent* content = frame->GetContent();
@ -1301,16 +1291,16 @@ nsGfxScrollFrameInner::ReloadChildFrames()
// probably a scrollbar then
if (value.LowerCaseEqualsLiteral("horizontal")) {
NS_ASSERTION(!mHScrollbarBox, "Found multiple horizontal scrollbars?");
mHScrollbarBox = box;
mHScrollbarBox = frame;
} else {
NS_ASSERTION(!mVScrollbarBox, "Found multiple vertical scrollbars?");
mVScrollbarBox = box;
mVScrollbarBox = frame;
}
understood = PR_TRUE;
} else {
// probably a scrollcorner
NS_ASSERTION(!mScrollCornerBox, "Found multiple scrollcorners");
mScrollCornerBox = box;
mScrollCornerBox = frame;
understood = PR_TRUE;
}
}
@ -1458,16 +1448,8 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32
// and other terrors.
if (mViewInitiatedScroll || mFrameInitiatedScroll) return;
nsIFrame* hframe = nsnull;
if (mHScrollbarBox)
mHScrollbarBox->GetFrame(&hframe);
nsIFrame* vframe = nsnull;
if (mVScrollbarBox)
mVScrollbarBox->GetFrame(&vframe);
nsIContent* vcontent = vframe ? vframe->GetContent() : nsnull;
nsIContent* hcontent = hframe ? hframe->GetContent() : nsnull;
nsIContent* vcontent = mVScrollbarBox ? mVScrollbarBox->GetContent() : nsnull;
nsIContent* hcontent = mHScrollbarBox ? mHScrollbarBox->GetContent() : nsnull;
if (hcontent == aContent || vcontent == aContent)
{
@ -1529,7 +1511,7 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32
// likewise for vcontent and vframe. Thus targetFrame will always
// be non-null in here.
nsIFrame* targetFrame =
hcontent == aContent ? hframe : vframe;
hcontent == aContent ? mHScrollbarBox : mVScrollbarBox;
presShell->HandleEventWithTarget(&event, targetFrame,
aContent,
NS_EVENT_FLAG_INIT, &status);
@ -1545,9 +1527,7 @@ nsGfxScrollFrameInner::GetScrollableView() const
return nsnull;
}
nsIFrame* frame = nsnull;
mScrollAreaBox->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = mScrollAreaBox->GetView();
if (!view) return nsnull;
nsIScrollableView* scrollingView;
@ -1787,9 +1767,6 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
nsHTMLReflowState* reflowState = (nsHTMLReflowState*)aState.GetReflowState();
#endif // IBMBIDI
nsIFrame* frame = nsnull;
mOuter->GetFrame(&frame);
// get the content rect
nsRect clientRect(0,0,0,0);
mOuter->GetClientRect(clientRect);
@ -1910,7 +1887,7 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
}
#ifdef IBMBIDI
const nsStyleVisibility* ourVis = frame->GetStyleVisibility();
const nsStyleVisibility* ourVis = mOuter->GetStyleVisibility();
if (NS_STYLE_DIRECTION_RTL == ourVis->mDirection) {
nsCOMPtr<nsITextControlFrame> textControl =
@ -2115,10 +2092,8 @@ nsGfxScrollFrameInner::ScrollbarChanged(nsPresContext* aPresContext, nscoord aX,
void
nsGfxScrollFrameInner::SetScrollbarEnabled(nsIBox* aBox, nscoord aMaxPos, PRBool aReflow)
{
nsIFrame* frame;
aBox->GetFrame(&frame);
mOuter->GetPresContext()->PresShell()->PostAttributeChange(
frame->GetContent(),
aBox->GetContent(),
kNameSpaceID_None,
nsHTMLAtoms::disabled,
NS_LITERAL_STRING("true"),
@ -2140,11 +2115,9 @@ nsGfxScrollFrameInner::SetAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize,
PRInt32 current = GetIntegerAttribute(aBox, aAtom, -1);
if (current != aSize)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsAutoString newValue;
newValue.AppendInt(aSize);
frame->GetContent()->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow);
aBox->GetContent()->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow);
return PR_TRUE;
}
@ -2163,9 +2136,7 @@ nsGfxScrollFrameInner::GetScrolledSize(nsPresContext* aPresContext,
// our scrolled size is the size of our scrolled view.
nsIBox* child = nsnull;
mScrollAreaBox->GetChildBox(&child);
nsIFrame* frame;
child->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = child->GetView();
NS_ASSERTION(view,"Scrolled frame must have a view!!!");
nsRect rect = view->GetBounds();
@ -2202,10 +2173,7 @@ nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisibl
PRInt32
nsGfxScrollFrameInner::GetIntegerAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 defaultValue)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsIContent* content = frame->GetContent();
nsIContent* content = aBox->GetContent();
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, atom, value))

View File

@ -117,11 +117,9 @@ public:
void RestoreState(nsIPresState* aState);
nsIFrame* GetScrolledFrame() const {
nsIBox* childBox;
nsIFrame* frame;
nsIFrame* childBox;
mScrollAreaBox->GetChildBox(&childBox);
childBox->GetFrame(&frame);
return frame;
return childBox;
}
void ScrollbarChanged(nsPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);

View File

@ -79,6 +79,8 @@ class nsIView;
class nsIWidget;
class nsIDOMRange;
class nsISelectionController;
class nsBoxLayoutState;
class nsIBoxLayout;
#ifdef ACCESSIBILITY
class nsIAccessible;
#endif
@ -89,10 +91,12 @@ struct nsRect;
struct nsSize;
struct nsMargin;
typedef class nsIFrame nsIBox;
// IID for the nsIFrame interface
// a6cf9050-15b3-11d2-932e-00805f8add32
// 7a243690-a766-4394-bc13-788b1bf63ef1
#define NS_IFRAME_IID \
{ 0xa6cf9050, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
{ 0x7a243690, 0xa766, 0x4394,{0xbc, 0x13, 0x78, 0x8b, 0x1b, 0xf6, 0x3e, 0xf1}}
/**
* Indication of how the frame can be split. This is used when doing runaround
@ -159,6 +163,10 @@ typedef PRUint32 nsFrameState;
// If this bit is set, then the frame corresponds to generated content
#define NS_FRAME_GENERATED_CONTENT 0x00000040
// If this bit is set, then the frame uses XUL flexible box layout
// for its children.
#define NS_FRAME_IS_BOX 0x00000080
// If this bit is set, then the frame has been moved out of the flow,
// e.g., it is absolutely positioned or floated
#define NS_FRAME_OUT_OF_FLOW 0x00000100
@ -214,6 +222,10 @@ typedef PRUint32 nsFrameState;
// implementations.
#define NS_FRAME_IMPL_RESERVED 0xFFF00000
// Box layout bits
#define NS_STATE_IS_HORIZONTAL 0x00400000
#define NS_STATE_IS_DIRECTION_NORMAL 0x80000000
//----------------------------------------------------------------------
enum nsFramePaintLayer {
@ -1261,6 +1273,113 @@ NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::embeddingLevel))
*/
PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
// BOX LAYOUT METHODS
// These methods have been migrated from nsIBox and are in the process of
// being refactored. DO NOT USE OUTSIDE OF XUL.
PRBool IsBoxFrame() const { return (mState & NS_FRAME_IS_BOX) != 0; }
PRBool IsBoxWrapped() const
{ return (!IsBoxFrame() && mParent && mParent->IsBoxFrame()); }
enum Halignment {
hAlign_Left,
hAlign_Right,
hAlign_Center
};
enum Valignment {
vAlign_Top,
vAlign_Middle,
vAlign_BaseLine,
vAlign_Bottom
};
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex)=0;
NS_HIDDEN_(nsresult)
GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)=0;
NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed)=0;
// This does not alter the overflow area. If the caller is changing
// the box size, the caller is responsible for updating the overflow
// area. It's enough to just call Layout or SyncLayout on the
// box. You can pass PR_TRUE to aRemoveOverflowArea as a
// convenience.
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
PRBool aRemoveOverflowArea = PR_FALSE)=0;
NS_HIDDEN_(nsresult) Layout(nsBoxLayoutState& aBoxLayoutState);
nsresult IsDirty(PRBool& aIsDirty) { aIsDirty = (mState & NS_FRAME_IS_DIRTY) != 0; return NS_OK; }
nsresult HasDirtyChildren(PRBool& aIsDirty) { aIsDirty = (mState & NS_FRAME_HAS_DIRTY_CHILDREN) != 0; return NS_OK; }
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState)=0;
NS_HIDDEN_(nsresult) MarkDirtyChildren(nsBoxLayoutState& aState);
nsresult GetChildBox(nsIBox** aBox)
{
// box layout ends at box-wrapped frames, so don't allow these frames
// to report child boxes.
*aBox = IsBoxFrame() ? GetFirstChild(nsnull) : nsnull;
return NS_OK;
}
nsresult GetNextBox(nsIBox** aBox)
{
*aBox = (mParent && mParent->IsBoxFrame()) ? mNextSibling : nsnull;
return NS_OK;
}
nsresult SetNextBox(nsIBox* aBox) { return NS_OK; }
NS_HIDDEN_(nsresult) GetParentBox(nsIBox** aParent);
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding)=0;
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding)=0;
#ifdef DEBUG_LAYOUT
NS_IMETHOD GetInset(nsMargin& aInset)=0;
#else
nsresult GetInset(nsMargin& aInset) { aInset.SizeTo(0, 0, 0, 0); return NS_OK; }
#endif
NS_IMETHOD GetMargin(nsMargin& aMargin)=0;
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout)=0;
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout)=0;
NS_HIDDEN_(nsresult) GetContentRect(nsRect& aContentRect);
NS_HIDDEN_(nsresult) GetClientRect(nsRect& aContentRect);
NS_IMETHOD GetVAlign(Valignment& aAlign) = 0;
NS_IMETHOD GetHAlign(Halignment& aAlign) = 0;
PRBool IsHorizontal() const { return (mState & NS_STATE_IS_HORIZONTAL) != 0; }
nsresult GetOrientation(PRBool& aIsHorizontal) /// XXX to be removed
{ aIsHorizontal = IsHorizontal(); return NS_OK; }
PRBool IsNormalDirection() const { return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0; }
nsresult GetDirection(PRBool& aIsNormal) /// XXX to be removed
{ aIsNormal = IsNormalDirection(); return NS_OK; }
NS_HIDDEN_(nsresult) Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nsnull, PRBool aImmediate = PR_FALSE);
NS_IMETHOD NeedsRecalc()=0;
NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough)=0;
NS_IMETHOD MarkChildrenStyleChange()=0;
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0;
#ifdef DEBUG_LAYOUT
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug)=0;
NS_IMETHOD GetDebug(PRBool& aDebug)=0;
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox)=0;
NS_IMETHOD DumpBox(FILE* out)=0;
#endif
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust) const=0;
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex)=0;
static PRBool AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex);
static PRBool AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollapsed);
static PRBool AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal);
// END OF BOX LAYOUT METHODS
// The above methods have been migrated from nsIBox and are in the process of
// being refactored. DO NOT USE OUTSIDE OF XUL.
protected:
// Members
nsRect mRect;

View File

@ -45,7 +45,6 @@
#include "nsPresContext.h"
class nsIFrame;
class nsIBox;
class nsBoxLayoutState;
// IID for the nsIScrollableFrame interface

View File

@ -6202,6 +6202,10 @@ nsBlockFrame::Init(nsPresContext* aPresContext,
nsresult rv = nsBlockFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
if (IsBoxWrapped())
mState |= NS_BLOCK_SPACE_MGR;
return rv;
}
@ -6593,6 +6597,19 @@ nsBlockFrame::BuildFloatList(nsBlockReflowState& aState)
}
}
NS_IMETHODIMP
nsBlockFrame::SetParent(const nsIFrame* aParent)
{
nsresult rv = nsBlockFrameSuper::SetParent(aParent);
if (IsBoxWrapped())
mState |= NS_BLOCK_SPACE_MGR;
// XXX should we clear NS_BLOCK_SPACE_MGR if we were the child of a box
// but no longer are?
return rv;
}
// XXX keep the text-run data in the first-in-flow of the block
#ifdef DEBUG

View File

@ -128,6 +128,7 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
NS_IMETHOD SetParent(const nsIFrame* aParent);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
NS_IMETHOD Destroy(nsPresContext* aPresContext);
NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const;

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#ifndef nsFrame_h___
#define nsFrame_h___
#include "nsIFrame.h"
#include "nsBox.h"
#include "nsRect.h"
#include "nsString.h"
#include "prlog.h"
@ -116,6 +116,8 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
//----------------------------------------------------------------------
struct nsBoxLayoutMetrics;
/**
* Implementation of a simple frame that's not splittable and has no
* child frames.
@ -123,7 +125,7 @@ void SetFontFromStyle(nsIRenderingContext* aRC, nsStyleContext* aSC);
* 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
class nsFrame : public nsBox
#ifdef NS_DEBUG
, public nsIFrameDebug
#endif
@ -145,6 +147,10 @@ public:
// deal with it.
void operator delete(void* aPtr, size_t sz);
// We compute and store the HTML content's overflow area. So don't
// try to compute it in the box code.
virtual PRBool ComputesOwnOverflowArea() { return PR_TRUE; }
private:
// The normal operator new is disallowed on nsFrames.
void* operator new(size_t sz) CPP_THROW_NEW { return nsnull; };
@ -186,6 +192,7 @@ public:
virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
virtual void SetAdditionalStyleContext(PRInt32 aIndex,
nsStyleContext* aStyleContext);
NS_IMETHOD SetParent(const nsIFrame* aParent);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
NS_IMETHOD Paint(nsPresContext* aPresContext,
@ -325,6 +332,16 @@ public:
PRBool aJumpLines);
// Box layout methods
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD SetIncludeOverflow(PRBool aInclude);
NS_IMETHOD GetOverflow(nsSize& aOverflow);
NS_IMETHOD NeedsRecalc();
//--------------------------------------------------
// Additional methods
@ -500,6 +517,47 @@ protected:
// applies to its situation.
void SetOverflowClipRect(nsIRenderingContext& aRenderingContext);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
#endif
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
void InitBoxMetrics(PRBool aClear);
nsBoxLayoutMetrics* BoxMetrics() const;
private:
nsresult BoxReflow(nsBoxLayoutState& aState,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nscoord aX,
nscoord aY,
nscoord aWidth,
nscoord aHeight,
PRBool aMoveFrame = PR_TRUE);
void HandleIncrementalReflow(nsBoxLayoutState& aState,
const nsHTMLReflowState& aReflowState,
nsReflowReason& aReason,
nsReflowPath** aReflowPath,
PRBool& aRedrawNow,
PRBool& aNeedReflow,
PRBool& aRedrawAfterReflow,
PRBool& aMoveFrame);
PRBool CanSetMaxElementWidth(nsBoxLayoutState& aState,
nsReflowReason& aReason,
nsReflowPath **aReflowPath);
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
protected:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

View File

@ -135,13 +135,11 @@ nsHTMLScrollFrame::GetScrollbarStyles() const {
}
nsMargin nsHTMLScrollFrame::GetActualScrollbarSizes() const {
nsRect bounds = GetRect();
nsRect scrollArea;
mInner.mScrollAreaBox->GetBounds(scrollArea);
nsRect scrollArea(mInner.mScrollAreaBox->GetRect());
return nsMargin(scrollArea.x, scrollArea.y,
bounds.width - scrollArea.XMost(),
bounds.height - scrollArea.YMost());
mRect.width - scrollArea.XMost(),
mRect.height - scrollArea.YMost());
}
nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
@ -291,8 +289,6 @@ nsHTMLScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsIFrame* frame = nsnull;
mInner.mScrollAreaBox->GetFrame(&frame);
nsPoint point(aPoint);
//we need to translate the coordinates to the inner
nsIView *view = GetClosestView();
@ -306,7 +302,7 @@ nsHTMLScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
innerView = innerView->GetParent();
}
return frame->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
return mInner.mScrollAreaBox->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
}
PRIntn
@ -669,13 +665,11 @@ nsXULScrollFrame::GetScrollbarStyles() const {
}
nsMargin nsXULScrollFrame::GetActualScrollbarSizes() const {
nsRect bounds = GetRect();
nsRect scrollArea;
mInner.mScrollAreaBox->GetBounds(scrollArea);
nsRect scrollArea(mInner.mScrollAreaBox->GetRect());
return nsMargin(scrollArea.x, scrollArea.y,
bounds.width - scrollArea.XMost(),
bounds.height - scrollArea.YMost());
mRect.width - scrollArea.XMost(),
mRect.height - scrollArea.YMost());
}
nsMargin nsXULScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
@ -825,8 +819,6 @@ nsXULScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsIFrame* frame = nsnull;
mInner.mScrollAreaBox->GetFrame(&frame);
nsPoint point(aPoint);
//we need to translate the coordinates to the inner
nsIView *view = GetClosestView();
@ -840,7 +832,7 @@ nsXULScrollFrame::GetContentAndOffsetsFromPoint(nsPresContext* aCX,
innerView = innerView->GetParent();
}
return frame->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
return mInner.mScrollAreaBox->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
}
PRIntn
@ -1285,12 +1277,10 @@ nsGfxScrollFrameInner::ReloadChildFrames()
while (frame) {
PRBool understood = PR_FALSE;
nsIBox* box = nsnull;
frame->QueryInterface(NS_GET_IID(nsIBox), (void**)&box);
if (box) {
if (frame->IsBoxFrame()) {
if (frame->GetType() == nsLayoutAtoms::scrollFrame) {
NS_ASSERTION(!mScrollAreaBox, "Found multiple scroll areas?");
mScrollAreaBox = box;
mScrollAreaBox = frame;
understood = PR_TRUE;
} else {
nsIContent* content = frame->GetContent();
@ -1301,16 +1291,16 @@ nsGfxScrollFrameInner::ReloadChildFrames()
// probably a scrollbar then
if (value.LowerCaseEqualsLiteral("horizontal")) {
NS_ASSERTION(!mHScrollbarBox, "Found multiple horizontal scrollbars?");
mHScrollbarBox = box;
mHScrollbarBox = frame;
} else {
NS_ASSERTION(!mVScrollbarBox, "Found multiple vertical scrollbars?");
mVScrollbarBox = box;
mVScrollbarBox = frame;
}
understood = PR_TRUE;
} else {
// probably a scrollcorner
NS_ASSERTION(!mScrollCornerBox, "Found multiple scrollcorners");
mScrollCornerBox = box;
mScrollCornerBox = frame;
understood = PR_TRUE;
}
}
@ -1458,16 +1448,8 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32
// and other terrors.
if (mViewInitiatedScroll || mFrameInitiatedScroll) return;
nsIFrame* hframe = nsnull;
if (mHScrollbarBox)
mHScrollbarBox->GetFrame(&hframe);
nsIFrame* vframe = nsnull;
if (mVScrollbarBox)
mVScrollbarBox->GetFrame(&vframe);
nsIContent* vcontent = vframe ? vframe->GetContent() : nsnull;
nsIContent* hcontent = hframe ? hframe->GetContent() : nsnull;
nsIContent* vcontent = mVScrollbarBox ? mVScrollbarBox->GetContent() : nsnull;
nsIContent* hcontent = mHScrollbarBox ? mHScrollbarBox->GetContent() : nsnull;
if (hcontent == aContent || vcontent == aContent)
{
@ -1529,7 +1511,7 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32
// likewise for vcontent and vframe. Thus targetFrame will always
// be non-null in here.
nsIFrame* targetFrame =
hcontent == aContent ? hframe : vframe;
hcontent == aContent ? mHScrollbarBox : mVScrollbarBox;
presShell->HandleEventWithTarget(&event, targetFrame,
aContent,
NS_EVENT_FLAG_INIT, &status);
@ -1545,9 +1527,7 @@ nsGfxScrollFrameInner::GetScrollableView() const
return nsnull;
}
nsIFrame* frame = nsnull;
mScrollAreaBox->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = mScrollAreaBox->GetView();
if (!view) return nsnull;
nsIScrollableView* scrollingView;
@ -1787,9 +1767,6 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
nsHTMLReflowState* reflowState = (nsHTMLReflowState*)aState.GetReflowState();
#endif // IBMBIDI
nsIFrame* frame = nsnull;
mOuter->GetFrame(&frame);
// get the content rect
nsRect clientRect(0,0,0,0);
mOuter->GetClientRect(clientRect);
@ -1910,7 +1887,7 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
}
#ifdef IBMBIDI
const nsStyleVisibility* ourVis = frame->GetStyleVisibility();
const nsStyleVisibility* ourVis = mOuter->GetStyleVisibility();
if (NS_STYLE_DIRECTION_RTL == ourVis->mDirection) {
nsCOMPtr<nsITextControlFrame> textControl =
@ -2115,10 +2092,8 @@ nsGfxScrollFrameInner::ScrollbarChanged(nsPresContext* aPresContext, nscoord aX,
void
nsGfxScrollFrameInner::SetScrollbarEnabled(nsIBox* aBox, nscoord aMaxPos, PRBool aReflow)
{
nsIFrame* frame;
aBox->GetFrame(&frame);
mOuter->GetPresContext()->PresShell()->PostAttributeChange(
frame->GetContent(),
aBox->GetContent(),
kNameSpaceID_None,
nsHTMLAtoms::disabled,
NS_LITERAL_STRING("true"),
@ -2140,11 +2115,9 @@ nsGfxScrollFrameInner::SetAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize,
PRInt32 current = GetIntegerAttribute(aBox, aAtom, -1);
if (current != aSize)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsAutoString newValue;
newValue.AppendInt(aSize);
frame->GetContent()->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow);
aBox->GetContent()->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow);
return PR_TRUE;
}
@ -2163,9 +2136,7 @@ nsGfxScrollFrameInner::GetScrolledSize(nsPresContext* aPresContext,
// our scrolled size is the size of our scrolled view.
nsIBox* child = nsnull;
mScrollAreaBox->GetChildBox(&child);
nsIFrame* frame;
child->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = child->GetView();
NS_ASSERTION(view,"Scrolled frame must have a view!!!");
nsRect rect = view->GetBounds();
@ -2202,10 +2173,7 @@ nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisibl
PRInt32
nsGfxScrollFrameInner::GetIntegerAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 defaultValue)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsIContent* content = frame->GetContent();
nsIContent* content = aBox->GetContent();
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, atom, value))

View File

@ -117,11 +117,9 @@ public:
void RestoreState(nsIPresState* aState);
nsIFrame* GetScrolledFrame() const {
nsIBox* childBox;
nsIFrame* frame;
nsIFrame* childBox;
mScrollAreaBox->GetChildBox(&childBox);
childBox->GetFrame(&frame);
return frame;
return childBox;
}
void ScrollbarChanged(nsPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);

View File

@ -80,6 +80,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../base/src \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../content/src \
-I$(srcdir)/../../../xul/base/src \
$(NULL)
_FILES = \

View File

@ -113,6 +113,7 @@
#include "nsScrollPortFrame.h"
#include "nsXULAtoms.h"
#include "nsBoxFrame.h"
#include "nsIBoxLayout.h"
#ifdef MOZ_ENABLE_CAIRO
#include "nsCanvasFrame.h"
#endif
@ -5817,11 +5818,9 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
nsRefPtr<nsStyleContext> contentStyle = aContentStyle;
if (!gfxScrollFrame) {
nsCOMPtr<nsIBox> box = do_QueryInterface(aParentFrame);
// Build a XULScrollFrame when the parent is a box, because XULScrollFrames
// do box layout well. Otherwise build an HTMLScrollFrame.
if (box) {
if (aParentFrame->IsBoxFrame()) {
NS_NewXULScrollFrame(aPresShell, &gfxScrollFrame, aIsRoot);
} else {
NS_NewHTMLScrollFrame(aPresShell, &gfxScrollFrame, aIsRoot);
@ -9816,12 +9815,9 @@ nsCSSFrameConstructor::StyleChangeReflow(nsPresContext* aPresContext,
#endif
// Is it a box? If so we can coelesce.
nsresult rv;
nsIBox *box;
rv = CallQueryInterface(aFrame, &box);
if (NS_SUCCEEDED(rv) && box) {
if (aFrame->IsBoxFrame()) {
nsBoxLayoutState state(aPresContext);
box->MarkStyleChange(state);
aFrame->MarkStyleChange(state);
}
else {
// If the frame is part of a split block-in-inline hierarchy, then
@ -9833,10 +9829,10 @@ nsCSSFrameConstructor::StyleChangeReflow(nsPresContext* aPresContext,
// Target a style-change reflow at the frame.
nsHTMLReflowCommand *reflowCmd;
rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged,
nsnull,
aAttribute);
nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame,
eReflowType_StyleChanged,
nsnull,
aAttribute);
if (NS_SUCCEEDED(rv))
aPresContext->PresShell()->AppendReflowCommand(reflowCmd);

View File

@ -83,5 +83,6 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../style/src \
-I$(srcdir)/../../content/src \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../xul/base/src \
$(NULL)

View File

@ -72,6 +72,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../html/table/src \
-I$(srcdir)/../../content/src \
-I$(srcdir)/../../../xul/base/src \
$(NULL)
CPPSRCS = nsMathMLChar.cpp \

View File

@ -75,8 +75,6 @@ CPPSRCS = \
nsBox.cpp \
nsBoxFrame.cpp \
nsBoxLayoutState.cpp \
nsBoxToBlockAdaptor.cpp \
nsContainerBox.cpp \
nsSprocketLayout.cpp \
nsStackFrame.cpp \
nsStackLayout.cpp \

View File

@ -1460,9 +1460,7 @@ nsGrid::GetScrolledBox(nsIBox* aChild)
if (scrollFrame) {
nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
nsIBox *box = nsnull;
CallQueryInterface(scrolledFrame, &box);
return box;
return scrolledFrame->IsBoxFrame() ? scrolledFrame : nsnull;
}
return aChild;

View File

@ -43,7 +43,7 @@
#include "nsStackLayout.h"
#include "nsIGridPart.h"
#include "nsCOMPtr.h"
#include "nsIBox.h"
#include "nsIFrame.h"
class nsGridRowGroupLayout;
class nsGridRowLayout;

View File

@ -44,7 +44,6 @@
#include "nsGridCell.h"
#include "nsFrame.h"
#include "nsIBox.h"
#include "nsBox.h"
#include "nsStackLayout.h"

View File

@ -49,7 +49,6 @@
class nsBoxLayoutState;
struct nsSize;
class nsIBox;
/*
* Grid cell is what makes up the cellmap in the grid. Each GridCell contains

View File

@ -43,7 +43,7 @@
#include "nsStackLayout.h"
#include "nsIGridPart.h"
#include "nsCOMPtr.h"
#include "nsIBox.h"
#include "nsIFrame.h"
#include "nsGrid.h"
class nsGridRowGroupLayout;

View File

@ -43,7 +43,7 @@
//
#include "nsGridRow.h"
#include "nsIBox.h"
#include "nsIFrame.h"
nsGridRow::nsGridRow():mIsBogus(PR_FALSE),
mBox(nsnull),

View File

@ -47,7 +47,6 @@
#include "nsIFrame.h"
class nsIBox;
class nsGridLayout2;
class nsBoxLayoutState;

View File

@ -48,7 +48,6 @@
*/
#include "nsGridRowGroupLayout.h"
#include "nsIBox.h"
#include "nsCOMPtr.h"
#include "nsIScrollableFrame.h"
#include "nsBoxLayoutState.h"

View File

@ -44,7 +44,6 @@
#include "nsGridRowLayout.h"
#include "nsBoxLayoutState.h"
#include "nsIBox.h"
#include "nsIScrollableFrame.h"
#include "nsBox.h"
#include "nsStackLayout.h"

View File

@ -71,8 +71,8 @@ nsGridRowLeafFrame::nsGridRowLeafFrame(nsIPresShell* aPresShell, PRBool aIsRoot,
}
/*
* Our border and padding could be affected by our columns or rows
* Lets go check it out.
* Our border and padding could be affected by our columns or rows.
* Let's go check it out.
*/
NS_IMETHODIMP
nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)

View File

@ -324,9 +324,8 @@ nsGridRowLeafLayout::ComputeChildSizes(nsIBox* aBox,
if (scrollable) {
nsMargin scrollbarSizes = scrollable->GetActualScrollbarSizes();
nsRect ourRect;
nsRect ourRect(scrollbox->GetRect());
nsMargin padding(0,0,0,0);
scrollbox->GetBounds(ourRect);
scrollbox->GetBorderAndPadding(padding);
ourRect.Deflate(padding);
scrollbox->GetInset(padding);

View File

@ -40,7 +40,6 @@
#include "nsISupports.h"
#include "nsFrame.h"
#include "nsIBox.h"
class nsGridRowGroupLayout;
class nsGrid;

File diff suppressed because it is too large Load Diff

View File

@ -38,105 +38,99 @@
#ifndef nsBox_h___
#define nsBox_h___
#include "nsIBox.h"
#include "nsIFrame.h"
class nsITheme;
class nsBox : public nsIBox {
#define DEFAULT_ORDINAL_GROUP 1
#define NS_STATE_IS_ROOT 0x01000000
#define NS_STATE_SET_TO_DEBUG 0x04000000
#define NS_STATE_DEBUG_WAS_SET 0x08000000
#define NS_STATE_STYLE_CHANGE 0x20000000
class nsBox : public nsIFrame {
public:
friend class nsIFrame;
static void Shutdown();
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetChildBox(nsIBox** aBox);
NS_IMETHOD GetNextBox(nsIBox** aBox);
NS_IMETHOD SetNextBox(nsIBox* aBox);
NS_IMETHOD GetParentBox(nsIBox** aParent);
NS_IMETHOD SetParentBox(nsIBox* aParent);
NS_IMETHOD IsDirty(PRBool& aIsDirty);
NS_IMETHOD HasDirtyChildren(PRBool& aIsDirty);
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState);
NS_IMETHOD MarkDirtyChildren(nsBoxLayoutState& aState);
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
PRBool aRemoveOverflowArea = PR_FALSE);
NS_IMETHOD GetBounds(nsRect& aRect);
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding);
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding);
NS_IMETHOD GetMargin(nsMargin& aMargin);
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout);
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout);
NS_IMETHOD GetContentRect(nsRect& aContentRect);
NS_IMETHOD GetClientRect(nsRect& aContentRect);
NS_IMETHOD GetVAlign(Valignment& aAlign);
NS_IMETHOD GetHAlign(Halignment& aAlign);
NS_IMETHOD GetInset(nsMargin& aInset);
NS_IMETHOD GetOrientation(PRBool& aIsHorizontal);
NS_IMETHOD GetDirection(PRBool& aIsNormal);
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex);
NS_IMETHOD GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed);
NS_IMETHOD Collapse(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD UnCollapse(nsBoxLayoutState& aBoxLayoutState);
// do not redefine this. Either create a new layout manager or redefine DoLayout below.
NS_IMETHOD Layout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
PRBool aRemoveOverflowArea = PR_FALSE);
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState);
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding);
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding);
NS_IMETHOD GetMargin(nsMargin& aMargin);
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout);
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout);
NS_IMETHOD GetVAlign(Valignment& aAlign);
NS_IMETHOD GetHAlign(Halignment& aAlign);
NS_IMETHOD Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nsnull, PRBool aImmediate = PR_FALSE);
NS_IMETHOD NeedsRecalc();
NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
NS_IMETHOD MarkChildrenStyleChange();
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState);
#ifdef DEBUG_LAYOUT
NS_IMETHOD GetInset(nsMargin& aInset);
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox);
NS_IMETHOD GetDebug(PRBool& aDebug);
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug);
NS_IMETHOD DumpBox(FILE* out);
NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
#endif
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust);
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust) const;
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex);
nsBox(nsIPresShell* aShell);
nsBox();
virtual ~nsBox();
/**
* Returns PR_TRUE if this box clips its children, e.g., if this box is an scrollbox.
*/
* Returns PR_TRUE if this box clips its children, e.g., if this box is an sc
rollbox.
*/
virtual PRBool DoesClipChildren() { return PR_FALSE; }
virtual PRBool ComputesOwnOverflowArea() { return PR_FALSE; }
virtual PRBool ComputesOwnOverflowArea() = 0;
virtual nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
NS_HIDDEN_(nsresult) SyncLayout(nsBoxLayoutState& aBoxLayoutState);
virtual PRBool DoesNeedRecalc(const nsSize& aSize);
virtual PRBool DoesNeedRecalc(nscoord aCoord);
virtual void SizeNeedsRecalc(nsSize& aSize);
virtual void CoordNeedsRecalc(nscoord& aCoord);
PRBool DoesNeedRecalc(const nsSize& aSize);
PRBool DoesNeedRecalc(nscoord aCoord);
void SizeNeedsRecalc(nsSize& aSize);
void CoordNeedsRecalc(nscoord& aCoord);
virtual void AddBorderAndPadding(nsSize& aSize);
virtual void AddInset(nsSize& aSize);
virtual void AddMargin(nsSize& aSize);
void AddBorderAndPadding(nsSize& aSize);
void AddInset(nsSize& aSize) { AddInset(this, aSize); }
void AddMargin(nsSize& aSize);
static void AddBorderAndPadding(nsIBox* aBox, nsSize& aSize);
#ifdef DEBUG_LAYOUT
static void AddInset(nsIBox* aBox, nsSize& aSize);
#else
static void AddInset(nsIBox* aBox, nsSize& aSize) {}
#endif
static void AddMargin(nsIBox* aChild, nsSize& aSize);
static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
static nsresult UnCollapseChild(nsBoxLayoutState& aState, nsIBox* aFrame);
static nsresult CollapseChild(nsBoxLayoutState& aState, nsIFrame* aFrame, PRBool aHide);
static void BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize);
static void BoundsCheck(nscoord& aMinSize, nscoord& aPrefSize, nscoord& aMaxSize);
@ -156,12 +150,13 @@ protected:
virtual PRBool GetDefaultFlex(PRInt32& aFlex);
virtual void GetLayoutFlags(PRUint32& aFlags);
NS_IMETHOD BeginLayout(nsBoxLayoutState& aState);
NS_HIDDEN_(nsresult) BeginLayout(nsBoxLayoutState& aState);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD EndLayout(nsBoxLayoutState& aState);
NS_HIDDEN_(nsresult) EndLayout(nsBoxLayoutState& aState);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
#endif
static PRBool gGotTheme;
@ -173,11 +168,8 @@ protected:
always
};
eMouseThrough mMouseThrough;
private:
nsIBox* mNextChild;
nsIBox* mParentBox;
//nscoord mX;
//nscoord mY;
};

View File

@ -81,7 +81,6 @@
#include "nsFrameNavigator.h"
#include "nsCSSRendering.h"
#include "nsIServiceManager.h"
#include "nsBoxToBlockAdaptor.h"
#include "nsIBoxLayout.h"
#include "nsSprocketLayout.h"
#include "nsIDocument.h"
@ -147,8 +146,9 @@ NS_NewBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot, n
} // NS_NewBoxFrame
nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot, nsIBoxLayout* aLayoutManager)
:nsContainerBox(aPresShell)
: mMouseThrough(unset)
{
mState |= NS_FRAME_IS_BOX;
mState |= NS_STATE_IS_HORIZONTAL;
mState |= NS_STATE_AUTO_STRETCH;
@ -174,28 +174,6 @@ nsBoxFrame::~nsBoxFrame()
{
}
NS_IMETHODIMP nsBoxFrame::SetParent(const nsIFrame* aParent)
{
nsresult rv = nsContainerFrame::SetParent(aParent);
// our box parent can only be a box. Make sure its a box and set it
// if its not a box then its nsnull
// cast away const so we can call QueryInterface.
nsIFrame* parent = (nsIFrame*)aParent;
// don't use com ptr. Frames don't support ADDREF or RELEASE;
nsIBox* boxParent = nsnull;
if (parent)
parent->QueryInterface(NS_GET_IID(nsIBox), (void**)&boxParent);
nsBox::SetParentBox(boxParent);
return rv;
}
NS_IMETHODIMP
nsBoxFrame::GetVAlign(Valignment& aAlign)
{
@ -215,35 +193,20 @@ nsBoxFrame::SetInitialChildList(nsPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
SanityCheck(mFrames);
nsresult r = nsContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList);
if (r == NS_OK) {
// initialize our list of infos.
nsBoxLayoutState state(aPresContext->PresShell());
InitChildren(state, aChildList);
CheckFrameOrder();
CheckBoxOrder(state);
if (mLayoutManager)
mLayoutManager->ChildrenSet(this, state, mFrames.FirstChild());
} else {
NS_WARNING("Warning add child failed!!\n");
}
SanityCheck(mFrames);
return r;
}
PRBool
nsBoxFrame::IsHorizontal() const
{
return mState & NS_STATE_IS_HORIZONTAL;
}
PRBool
nsBoxFrame::IsNormalDirection() const
{
return mState & NS_STATE_IS_DIRECTION_NORMAL;
}
/**
* Initialize us. This is a good time to get the alignment of the box
*/
@ -261,10 +224,9 @@ nsBoxFrame::Init(nsPresContext* aPresContext,
nsresult rv = nsContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// see if we need a widget. Get our parent. Querty interface the parent we are given.
nsIBox *parent;
if (aParent && NS_SUCCEEDED(CallQueryInterface(aParent, &parent))) {
if (aParent && aParent->IsBoxFrame()) {
PRBool needsWidget = PR_FALSE;
parent->ChildrenMustHaveWidgets(needsWidget);
aParent->ChildrenMustHaveWidgets(needsWidget);
if (needsWidget) {
nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE);
@ -306,6 +268,31 @@ void nsBoxFrame::UpdateMouseThrough()
}
}
NS_IMETHODIMP
nsBoxFrame::GetMouseThrough(PRBool& aMouseThrough)
{
switch(mMouseThrough)
{
case always:
aMouseThrough = PR_TRUE;
return NS_OK;
case never:
aMouseThrough = PR_FALSE;
return NS_OK;
case unset:
{
if (mParent && mParent->IsBoxFrame())
return mParent->GetMouseThrough(aMouseThrough);
else {
aMouseThrough = PR_FALSE;
return NS_OK;
}
}
}
return NS_ERROR_FAILURE;
}
void
nsBoxFrame::CacheAttributes()
{
@ -697,9 +684,7 @@ nsBoxFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
GetChildBox(&box);
while (box)
{
nsIFrame* frame = nsnull;
box->GetFrame(&frame);
if (frame == aChild) {
if (box == aChild) {
box->MarkDirty(state);
return RelayoutDirtyChild(state, box);
}
@ -866,10 +851,9 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
Layout(state);
// ok our child could have gotten bigger. So lets get its bounds
GetBounds(r);
// get the ascent
nscoord ascent = r.height;
nscoord ascent = mRect.height;
// getting the ascent could be a lot of work. Don't get it if
// we are the root. The viewport doesn't care about it.
@ -885,10 +869,10 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
}
}
aDesiredSize.width = r.width;
aDesiredSize.height = r.height;
aDesiredSize.width = mRect.width;
aDesiredSize.height = mRect.height;
aDesiredSize.ascent = ascent;
aDesiredSize.descent = r.height - ascent;
aDesiredSize.descent = mRect.height - ascent;
// NS_FRAME_OUTSIDE_CHILDREN is set in SetBounds() above
if (mState & NS_FRAME_OUTSIDE_CHILDREN) {
@ -941,9 +925,35 @@ nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
#endif
nsresult rv = NS_OK;
rv = nsContainerBox::GetPrefSize(aBoxLayoutState, mPrefSize);
aSize.width = 0;
aSize.height = 0;
aSize = mPrefSize;
PRBool collapsed = PR_FALSE;
IsCollapsed(aBoxLayoutState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSPrefSize(aBoxLayoutState, this, aSize))
{
aSize.width = 0;
aSize.height = 0;
if (mLayoutManager) {
rv = mLayoutManager->GetPrefSize(this, aBoxLayoutState, aSize);
nsIBox::AddCSSPrefSize(aBoxLayoutState, this, aSize);
} else
rv = nsBox::GetPrefSize(aBoxLayoutState, aSize);
}
nsSize minSize(0,0);
nsSize maxSize(0,0);
GetMinSize(aBoxLayoutState, minSize);
GetMaxSize(aBoxLayoutState, maxSize);
BoundsCheck(minSize, aSize, maxSize);
mPrefSize = aSize;
return rv;
}
@ -961,9 +971,19 @@ nsBoxFrame::GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)
#endif
nsresult rv = NS_OK;
rv = nsContainerBox::GetAscent(aBoxLayoutState, mAscent);
aAscent = 0;
aAscent = mAscent;
PRBool collapsed = PR_FALSE;
IsCollapsed(aBoxLayoutState, collapsed);
if (collapsed)
return NS_OK;
if (mLayoutManager)
rv = mLayoutManager->GetAscent(this, aBoxLayoutState, aAscent);
else
rv = nsBox::GetAscent(aBoxLayoutState, aAscent);
mAscent = aAscent;
return rv;
}
@ -982,10 +1002,28 @@ nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
nsresult rv = NS_OK;
mMinSize.SizeTo(0,0);
rv = nsContainerBox::GetMinSize(aBoxLayoutState, mMinSize);
aSize.SizeTo(0, 0);
PRBool collapsed = PR_FALSE;
IsCollapsed(aBoxLayoutState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSMinSize(aBoxLayoutState, this, aSize))
{
aSize.width = 0;
aSize.height = 0;
if (mLayoutManager) {
rv = mLayoutManager->GetMinSize(this, aBoxLayoutState, aSize);
nsIBox::AddCSSMinSize(aBoxLayoutState, this, aSize);
} else {
rv = nsBox::GetMinSize(aBoxLayoutState, aSize);
}
}
aSize = mMinSize;
mMinSize = aSize;
return rv;
}
@ -1004,10 +1042,28 @@ nsBoxFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
nsresult rv = NS_OK;
mMaxSize.SizeTo(0,0);
nsContainerBox::GetMaxSize(aBoxLayoutState, mMaxSize);
aSize = mMaxSize;
aSize.SizeTo(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
PRBool collapsed = PR_FALSE;
IsCollapsed(aBoxLayoutState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSMaxSize(aBoxLayoutState, this, aSize))
{
aSize.width = NS_INTRINSICSIZE;
aSize.height = NS_INTRINSICSIZE;
if (mLayoutManager) {
rv = mLayoutManager->GetMaxSize(this, aBoxLayoutState, aSize);
nsIBox::AddCSSMaxSize(aBoxLayoutState, this, aSize);
} else {
rv = nsBox::GetMaxSize(aBoxLayoutState, aSize);
}
}
mMaxSize = aSize;
return rv;
}
@ -1023,44 +1079,12 @@ nsBoxFrame::GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex)
nsresult rv = NS_OK;
mFlex = 0;
rv = nsContainerBox::GetFlex(aBoxLayoutState, mFlex);
rv = nsBox::GetFlex(aBoxLayoutState, mFlex);
aFlex = mFlex;
return rv;
}
#ifdef DEBUG_LAYOUT
void
nsBoxFrame::PropagateDebug(nsBoxLayoutState& aState)
{
// propagate debug information
if (mState & NS_STATE_DEBUG_WAS_SET) {
if (mState & NS_STATE_SET_TO_DEBUG)
SetDebug(aState, PR_TRUE);
else
SetDebug(aState, PR_FALSE);
} else if (mState & NS_STATE_IS_ROOT) {
SetDebug(aState, gDebug);
}
}
#endif
NS_IMETHODIMP
nsBoxFrame::BeginLayout(nsBoxLayoutState& aState)
{
nsresult rv = nsContainerBox::BeginLayout(aState);
// mark ourselves as dirty so no child under us
// can post an incremental layout.
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
#ifdef DEBUG_LAYOUT
PropagateDebug(aState);
#endif
return rv;
}
/**
* If subclassing please subclass this method not layout.
* layout will call this method.
@ -1068,7 +1092,16 @@ nsBoxFrame::BeginLayout(nsBoxLayoutState& aState)
NS_IMETHODIMP
nsBoxFrame::DoLayout(nsBoxLayoutState& aState)
{
return nsContainerBox::DoLayout(aState);
PRUint32 oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(0);
nsresult rv = NS_OK;
if (mLayoutManager)
rv = mLayoutManager->Layout(this, aState);
aState.SetLayoutFlags(oldFlags);
return rv;
}
NS_IMETHODIMP
@ -1078,8 +1111,7 @@ nsBoxFrame::Destroy(nsPresContext* aPresContext)
RegUnregAccessKey(aPresContext, PR_FALSE);
// clean up the container box's layout manager and child boxes
nsBoxLayoutState state(aPresContext);
nsContainerBox::Destroy(state);
SetLayoutManager(nsnull);
return nsContainerFrame::Destroy(aPresContext);
}
@ -1127,16 +1159,17 @@ nsBoxFrame::RemoveFrame(nsPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
SanityCheck(mFrames);
// remove child from our info list
nsBoxLayoutState state(aPresContext);
Remove(state, aOldFrame);
// remove the child frame
mFrames.DestroyFrame(aPresContext, aOldFrame);
mFrames.RemoveFrame(aOldFrame);
SanityCheck(mFrames);
// notify the layout manager
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, state, aOldFrame);
// destroy the child frame
aOldFrame->Destroy(aPresContext);
// mark us dirty and generate a reflow command
MarkDirtyChildren(state);
@ -1151,32 +1184,21 @@ nsBoxFrame::InsertFrames(nsPresContext* aPresContext,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
SanityCheck(mFrames);
nsIBox* prevBox = GetBox(aPrevFrame);
if (prevBox == nsnull && aPrevFrame != nsnull) {
#ifdef DEBUG
printf("Warning prev sibling is not in our list!!!\n");
#endif
aPrevFrame = nsnull;
}
// insert the frames to our info list
nsBoxLayoutState state(aPresContext);
Insert(state, aPrevFrame, aFrameList);
// insert the frames in out regular frame list
// insert the child frames
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
// notify the layout manager
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, aFrameList);
#ifdef DEBUG_LAYOUT
// if we are in debug make sure our children are in debug as well.
if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
SetDebugOnChildList(state, mFirstChild, PR_TRUE);
SetDebugOnChildList(state, mFrames.FirstChild(), PR_TRUE);
#endif
CheckFrameOrder();
SanityCheck(mFrames);
// mark us dirty and generate a reflow command
MarkDirtyChildren(state);
MarkDirty(state);
@ -1190,24 +1212,21 @@ nsBoxFrame::AppendFrames(nsPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
SanityCheck(mFrames);
// append them after
nsBoxLayoutState state(aPresContext);
Append(state,aFrameList);
// append in regular frames
mFrames.AppendFrames(this, aFrameList);
// append the new frames
mFrames.AppendFrames(this, aFrameList);
// notify the layout manager
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, state, aFrameList);
#ifdef DEBUG_LAYOUT
// if we are in debug make sure our children are in debug as well.
if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
SetDebugOnChildList(state, mFirstChild, PR_TRUE);
SetDebugOnChildList(state, mFrames.FirstChild(), PR_TRUE);
#endif
CheckFrameOrder();
SanityCheck(mFrames);
MarkDirtyChildren(state);
MarkDirty(state);
return NS_OK;
@ -1329,11 +1348,6 @@ nsBoxFrame::AttributeChanged(nsPresContext* aPresContext,
nsIBox* parent;
GetParentBox(&parent);
parent->RelayoutChildAtOrdinal(state, this);
nsIFrame* parentFrame;
parent->GetFrame(&parentFrame);
nsBoxFrame* parentBoxFrame = (nsBoxFrame*) parentFrame;
if (parentBoxFrame)
parentBoxFrame->CheckFrameOrder();
parent->MarkDirty(state);
}
// If the accesskey changed, register for the new value
@ -1345,30 +1359,6 @@ nsBoxFrame::AttributeChanged(nsPresContext* aPresContext,
return rv;
}
NS_IMETHODIMP
nsBoxFrame::GetInset(nsMargin& margin)
{
margin.SizeTo(0,0,0,0);
#ifdef DEBUG_LAYOUT
if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
nsMargin debugMargin(0,0,0,0);
nsMargin debugBorder(0,0,0,0);
nsMargin debugPadding(0,0,0,0);
GetDebugBorder(debugBorder);
PixelMarginToTwips(mPresContext, debugBorder);
GetDebugMargin(debugMargin);
PixelMarginToTwips(mPresContext, debugMargin);
GetDebugMargin(debugPadding);
PixelMarginToTwips(mPresContext, debugPadding);
margin += debugBorder;
margin += debugMargin;
margin += debugPadding;
}
#endif
return NS_OK;
}
#ifdef DEBUG_COELESCED
static PRInt32 StyleCoelesced = 0;
@ -1391,42 +1381,6 @@ nsBoxFrame::SetStyleChangeFlag(PRBool aDirty)
mState &= ~NS_STATE_STYLE_CHANGE;
}
nsresult
nsBoxFrame::SyncLayout(nsBoxLayoutState& aState)
{
nsresult rv = nsBox::SyncLayout(aState);
mState &= ~(NS_STATE_STYLE_CHANGE);
return rv;
}
void
nsBoxFrame::CheckFrameOrder()
{
if (mOrderBoxes) {
// synchronize the frame order with the box order by simply walking
// the box list and linking each frame as its box is linked
nsIBox* box = mFirstChild;
nsIFrame* frame1;
box->GetFrame(&frame1);
nsIBox* box2;
nsIFrame* frame;
nsIFrame* frame2;
while (box) {
box->GetNextBox(&box2);
box->GetFrame(&frame);
if (box2)
box2->GetFrame(&frame2);
else
frame2 = nsnull;
frame->SetNextSibling(frame2);
box = box2;
}
mFrames.SetFrames(frame1);
}
}
#ifdef DEBUG_LAYOUT
void
nsBoxFrame::GetDebugPref(nsPresContext* aPresContext)
@ -1638,25 +1592,20 @@ nsBoxFrame::PaintChildren(nsPresContext* aPresContext,
nsIBox* kid = nsnull;
GetChildBox(&kid);
while (nsnull != kid) {
nsIFrame* frame = nsnull;
kid->GetFrame(&frame);
if (!hasClipped && NS_STYLE_OVERFLOW_CLIP == disp->mOverflowX) {
// if we haven't already clipped and we should
// check to see if the child is in out bounds. If not then
// we begin clipping.
nsRect cr(0,0,0,0);
kid->GetBounds(cr);
// if our rect does not contain the childs then begin clipping
if (!r.Contains(cr)) {
if (!r.Contains(kid->GetRect())) {
aRenderingContext.PushState();
aRenderingContext.SetClipRect(r, nsClipCombine_kIntersect);
hasClipped = PR_TRUE;
}
}
PaintChild(aPresContext, aRenderingContext, aDirtyRect, frame, aWhichLayer);
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer);
kid->GetNextBox(&kid);
}
@ -1684,11 +1633,9 @@ nsBoxFrame::PaintChildren(nsPresContext* aPresContext,
// if we haven't already clipped and we should
// check to see if the child is in out bounds. If not then
// we begin clipping.
nsRect cr(0,0,0,0);
kid->GetBounds(cr);
// if our rect does not contain the childs then begin clipping
if (!r.Contains(cr)) {
if (!r.Contains(kid->mRect)) {
aRenderingContext.PushState();
aRenderingContext.SetClipRect(r, nsClipCombine_kIntersect);
hasClipped = PR_TRUE;
@ -1698,8 +1645,7 @@ nsBoxFrame::PaintChildren(nsPresContext* aPresContext,
nscoord x, y, borderSize, spacerSize;
nsRect cr(0,0,0,0);
kid->GetBounds(cr);
nsRect cr(kid->mRect);
nsMargin margin;
kid->GetMargin(margin);
cr.Inflate(margin);
@ -1765,13 +1711,6 @@ NS_INTERFACE_MAP_BEGIN(nsBoxFrame)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBox)
NS_INTERFACE_MAP_END_INHERITING(nsContainerFrame)
NS_IMETHODIMP
nsBoxFrame::GetFrame(nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
}
#ifdef DEBUG_LAYOUT
void
nsBoxFrame::GetBoxName(nsAutoString& aName)
@ -1830,9 +1769,7 @@ nsBoxFrame::GetFrameForPoint(nsPresContext* aPresContext,
PRBool isDebug = PR_FALSE;
box->GetDebug(isDebug);
if (isDebug) {
nsIFrame* frame = nsnull;
box->GetFrame(&frame);
*aFrame = frame;
*aFrame = box;
return NS_OK;
}
}
@ -1851,9 +1788,7 @@ nsBoxFrame::GetFrameForPoint(nsPresContext* aPresContext,
nsIBox* kid = nsnull;
GetChildBox(&kid);
while (nsnull != kid) {
nsIFrame* frame = nsnull;
kid->GetFrame(&frame);
GetFrameForPointChild(aPresContext, tmp, aWhichLayer, frame, hit != nsnull, &hit);
GetFrameForPointChild(aPresContext, tmp, aWhichLayer, kid, hit != nsnull, &hit);
kid->GetNextBox(&kid);
}
if (hit)
@ -1913,37 +1848,10 @@ nsBoxFrame::GetFrameForPointChild(nsPresContext* aPresContext,
nsIBox*
nsBoxFrame::GetBoxForFrame(nsIFrame* aFrame, PRBool& aIsAdaptor)
{
if (aFrame == nsnull)
return nsnull;
nsIBox* ibox = nsnull;
if (NS_FAILED(aFrame->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox))) {
if (aFrame && !aFrame->IsBoxFrame())
aIsAdaptor = PR_TRUE;
// if we hit a non box. Find the box in out last container
// and clear its cache.
nsIBox* parentBox = nsnull;
if (NS_FAILED(aFrame->GetParent()->
QueryInterface(NS_GET_IID(nsIBox), (void**)&parentBox)))
return nsnull;
if (parentBox) {
nsIBox* start = nsnull;
parentBox->GetChildBox(&start);
while (start) {
nsIFrame* frame = nsnull;
start->GetFrame(&frame);
if (frame == aFrame) {
ibox = start;
break;
}
start->GetNextBox(&start);
}
}
}
return ibox;
return aFrame;
}
/*
@ -2037,9 +1945,7 @@ nsresult
nsBoxFrame::GetContentOf(nsIContent** aContent)
{
// If we don't have a content node find a parent that does.
nsIFrame* frame;
GetFrame(&frame);
nsIFrame *frame = this;
while (frame) {
*aContent = frame->GetContent();
if (*aContent) {
@ -2259,6 +2165,29 @@ nsBoxFrame::GetDebugPadding(nsMargin& aPadding)
{
aPadding.SizeTo(2,2,2,2);
}
NS_IMETHODIMP
nsBoxFrame::GetInset(nsMargin& margin)
{
margin.SizeTo(0,0,0,0);
if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
nsMargin debugMargin(0,0,0,0);
nsMargin debugBorder(0,0,0,0);
nsMargin debugPadding(0,0,0,0);
GetDebugBorder(debugBorder);
PixelMarginToTwips(mPresContext, debugBorder);
GetDebugMargin(debugMargin);
PixelMarginToTwips(mPresContext, debugMargin);
GetDebugMargin(debugPadding);
PixelMarginToTwips(mPresContext, debugPadding);
margin += debugBorder;
margin += debugMargin;
margin += debugPadding;
}
return NS_OK;
}
#endif
void
@ -2317,9 +2246,6 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* aBox,
nscoord x = aPoint.x;
nscoord y = aPoint.y;
nsIFrame* ourFrame = nsnull;
aBox->GetFrame(&ourFrame);
// get the area inside our border but not our debug margins.
nsRect insideBorder;
aBox->GetContentRect(insideBorder);
@ -2352,11 +2278,8 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* aBox,
(!isHorizontal && x < insideBorder.x + m.left)) {
//printf("**** inside debug border *******\n");
while (child)
{
nsRect r;
child->GetBounds(r);
nsIFrame* childFrame = nsnull;
child->GetFrame(&childFrame);
{
const nsRect& r = child->mRect;
// if we are not in the child. But in the spacer above the child.
if ((isHorizontal && x >= r.x && x < r.x + r.width) ||
@ -2366,13 +2289,13 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* aBox,
if (mDebugChild == child)
return NS_OK;
if (ourFrame->GetContent()) {
if (aBox->GetContent()) {
printf("---------------\n");
DumpBox(stdout);
printf("\n");
}
if (childFrame->GetContent()) {
if (child->GetContent()) {
printf("child #%d: ", count);
child->DumpBox(stdout);
printf("\n");
@ -2444,13 +2367,24 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* aBox,
return NS_OK;
}
void
nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug)
{
nsIBox* child = nsnull;
GetChildBox(&child);
while (child)
{
child->SetDebug(aState, aDebug);
child->GetNextBox(&child);
}
}
#endif
nsresult
nsBoxFrame::GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize)
{
nsRect rect(0,0,0,0);
aBox->GetBounds(rect);
nsRect rect(aBox->GetRect());
nsMargin margin(0,0,0,0);
aBox->GetMargin(margin);
rect.Inflate(margin);
@ -2661,3 +2595,207 @@ nsBoxFrame::FireDOMEvent(nsPresContext *aPresContext, const nsAString& aDOMEvent
}
}
void
nsBoxFrame::CheckBoxOrder(nsBoxLayoutState& aState)
{
// Run through our list of children and check whether we
// need to sort them. Count up the children at the same
// time, since we're already traversing the list.
PRBool orderBoxes = PR_FALSE;
PRInt32 childCount = 0;
nsIFrame *child = mFrames.FirstChild();
while (child) {
++childCount;
PRUint32 ordinal;
child->GetOrdinal(aState, ordinal);
if (ordinal != DEFAULT_ORDINAL_GROUP)
orderBoxes = PR_TRUE;
child = child->GetNextSibling();
}
if (!orderBoxes || childCount < 2)
return;
// Turn the child list into an array for sorting.
nsIFrame** boxes = new nsIFrame*[childCount];
nsIFrame* box = mFrames.FirstChild();
nsIFrame** boxPtr = boxes;
while (box) {
*boxPtr++ = box;
box = box->GetNextSibling();
}
// sort the array by ordinal group, selection sort
// XXX this could use a more efficient sort
PRInt32 i, j, min;
PRUint32 minOrd, jOrd;
for(i = 0; i < childCount; i++) {
min = i;
boxes[min]->GetOrdinal(aState, minOrd);
for(j = i + 1; j < childCount; j++) {
boxes[j]->GetOrdinal(aState, jOrd);
if (jOrd < minOrd) {
min = j;
minOrd = jOrd;
}
}
box = boxes[min];
boxes[min] = boxes[i];
boxes[i] = box;
}
// turn the array back into linked list, with first and last cached
mFrames.SetFrames(boxes[0]);
for (i = 0; i < childCount - 1; ++i)
boxes[i]->SetNextSibling(boxes[i+1]);
boxes[childCount-1]->SetNextSibling(nsnull);
delete [] boxes;
}
NS_IMETHODIMP
nsBoxFrame::SetLayoutManager(nsIBoxLayout* aLayout)
{
mLayoutManager = aLayout;
return NS_OK;
}
NS_IMETHODIMP
nsBoxFrame::GetLayoutManager(nsIBoxLayout** aLayout)
{
*aLayout = mLayoutManager;
NS_IF_ADDREF(*aLayout);
return NS_OK;
}
nsresult
nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect)
{
// get the current rect
nsRect oldRect(aBox->GetRect());
aBox->SetBounds(aState, aRect);
PRBool dirty = PR_FALSE;
PRBool dirtyChildren = PR_FALSE;
aBox->IsDirty(dirty);
aBox->HasDirtyChildren(dirtyChildren);
PRBool layout = PR_TRUE;
if (!(dirty || dirtyChildren) && aState.LayoutReason() != nsBoxLayoutState::Initial)
layout = PR_FALSE;
if (layout || (oldRect.width != aRect.width || oldRect.height != aRect.height)) {
return aBox->Layout(aState);
}
return NS_OK;
}
NS_IMETHODIMP
nsBoxFrame::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)
{
PRUint32 ord;
aChild->GetOrdinal(aState, ord);
PRUint32 ordCmp;
nsIFrame *firstChild = mFrames.FirstChild();
nsIBox* box = firstChild;
nsIBox* newPrevSib = firstChild;
box->GetOrdinal(aState, ordCmp);
if (ord < ordCmp) {
// new ordinal is lower than the lowest current ordinal, so it will not
// have a previous sibling
newPrevSib = nsnull;
} else {
// search for the box after which we will insert this box
while (box) {
box->GetOrdinal(aState, ordCmp);
if (newPrevSib && ordCmp > ord)
break;
newPrevSib = box;
box->GetNextBox(&box);
}
}
// look for the previous sibling of |aChild|
nsIBox* oldPrevSib = firstChild;
while (oldPrevSib) {
nsIBox* me;
oldPrevSib->GetNextBox(&me);
if (aChild == me) {
break;
}
oldPrevSib = me;
}
// if we are moving |mFirstChild|, we'll have to update the |mFirstChild|
// value later on
PRBool firstChildMoved = PR_FALSE;
if (aChild == firstChild)
firstChildMoved = PR_TRUE;
nsIBox* newNextSib;
if (newPrevSib) {
// insert |aChild| between |newPrevSib| and its next sibling
newPrevSib->GetNextBox(&newNextSib);
newPrevSib->SetNextBox(aChild);
} else {
// no |newPrevSib| found, so this box will become |mFirstChild|
newNextSib = firstChild;
firstChild = aChild;
}
// link up our new next sibling
nsIBox* oldNextSib;
aChild->GetNextBox(&oldNextSib);
aChild->SetNextBox(newNextSib);
// link |oldPrevSib| with |oldNextSib| to fill the gap left behind
if (oldPrevSib)
oldPrevSib->SetNextBox(oldNextSib);
if (firstChildMoved)
firstChild = oldNextSib;
mFrames.SetFrames(firstChild);
return NS_OK;
}
NS_IMETHODIMP
nsBoxFrame::GetIndexOf(nsIBox* aBox, PRInt32* aIndex)
{
nsIBox* child = mFrames.FirstChild();
PRInt32 count = 0;
while (child)
{
if (aBox == child) {
*aIndex = count;
return NS_OK;
}
child->GetNextBox(&child);
count++;
}
*aIndex = -1;
return NS_OK;
}
PRBool
nsBoxFrame::GetWasCollapsed(nsBoxLayoutState& aState)
{
return nsBox::GetWasCollapsed(aState);
}
void
nsBoxFrame::SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas)
{
nsBox::SetWasCollapsed(aState, aWas);
}

View File

@ -48,7 +48,6 @@
#include "nsCOMPtr.h"
#include "nsContainerFrame.h"
#include "nsContainerBox.h"
class nsBoxLayoutState;
class nsHTMLReflowCommand;
@ -58,29 +57,28 @@ class nsHTMLInfo;
#define NS_FRAME_BOX_SIZE_VALID 0x0001
#define NS_FRAME_BOX_IS_COLLAPSED 0x0002
#define NS_FRAME_BOX_NEEDS_RECALC 0x0004
#define NS_FRAME_IS_BOX 0x0008
// flags from box
#define NS_STATE_BOX_CHILD_RESERVED 0x00100000
#define NS_STATE_STACK_NOT_POSITIONED 0x00200000
#define NS_STATE_IS_HORIZONTAL 0x00400000
//#define NS_STATE_IS_HORIZONTAL 0x00400000 moved to nsIFrame.h
#define NS_STATE_AUTO_STRETCH 0x00800000
#define NS_STATE_IS_ROOT 0x01000000
//#define NS_STATE_IS_ROOT 0x01000000 moved to nsIFrame.h
#define NS_STATE_CURRENTLY_IN_DEBUG 0x02000000
#define NS_STATE_SET_TO_DEBUG 0x04000000
#define NS_STATE_DEBUG_WAS_SET 0x08000000
//#define NS_STATE_SET_TO_DEBUG 0x04000000 moved to nsIFrame.h
//#define NS_STATE_DEBUG_WAS_SET 0x08000000 moved to nsIFrame.h
#define NS_STATE_IS_COLLAPSED 0x10000000
#define NS_STATE_STYLE_CHANGE 0x20000000
//#define NS_STATE_STYLE_CHANGE 0x20000000 moved to nsIFrame.h
#define NS_STATE_EQUAL_SIZE 0x40000000
#define NS_STATE_IS_DIRECTION_NORMAL 0x80000000
//#define NS_STATE_IS_DIRECTION_NORMAL 0x80000000 moved to nsIFrame.h
nsresult NS_NewBoxFrame(nsIPresShell* aPresShell,
nsIFrame** aNewFrame,
PRBool aIsRoot = PR_FALSE,
nsIBoxLayout* aLayoutManager = nsnull);
class nsBoxFrame : public nsContainerFrame, public nsContainerBox
class nsBoxFrame : public nsContainerFrame
{
public:
@ -97,6 +95,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// ------ nsIBox -------------
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout);
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout);
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex);
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
@ -106,17 +108,16 @@ public:
#ifdef DEBUG_LAYOUT
NS_IMETHOD SetDebug(nsBoxLayoutState& aBoxLayoutState, PRBool aDebug);
NS_IMETHOD GetDebug(PRBool& aDebug);
NS_IMETHOD GetInset(nsMargin& aInset);
#endif
NS_IMETHOD GetFrame(nsIFrame** aFrame);
NS_IMETHOD GetVAlign(Valignment& aAlign);
NS_IMETHOD GetHAlign(Halignment& aAlign);
NS_IMETHOD NeedsRecalc();
NS_IMETHOD GetInset(nsMargin& aInset);
NS_IMETHOD BeginLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD SetParent(const nsIFrame* aParent);
//NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
virtual PRBool ComputesOwnOverflowArea() { return PR_FALSE; }
// ----- child and sibling operations ---
@ -182,14 +183,9 @@ public:
const nsHTMLReflowState* aReflowState,
nsDidReflowStatus aStatus);
virtual PRBool IsHorizontal() const;
virtual PRBool IsNormalDirection() const;
virtual ~nsBoxFrame();
virtual nsresult GetContentOf(nsIContent** aContent);
virtual nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
virtual void CheckFrameOrder();
nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot = nsnull, nsIBoxLayout* aLayoutManager = nsnull);
@ -204,19 +200,29 @@ public:
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags = 0);
// returns true if it is an Initial Reflow and doing Print Preview
static PRBool IsInitialReflowForPrintPreview(nsBoxLayoutState& aState, PRBool& aIsChrome);
nsIBox* GetBoxAt(PRInt32 aIndex) { return mFrames.FrameAt(aIndex); }
PRInt32 GetChildCount() { return mFrames.GetLength(); }
#ifdef DEBUG_LAYOUT
virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug);
#endif
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
protected:
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
virtual void PropagateDebug(nsBoxLayoutState& aState);
#endif
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
// Paint one child frame
@ -248,6 +254,8 @@ protected:
nscoord mFlex;
nscoord mAscent;
nsCOMPtr<nsIBoxLayout> mLayoutManager;
protected:
nsresult RegUnregAccessKey(nsPresContext* aPresContext,
PRBool aDoReg);
@ -259,6 +267,8 @@ protected:
PRBool aCheckMouseThrough,
nsIFrame** aFrame);
NS_HIDDEN_(void) CheckBoxOrder(nsBoxLayoutState& aState);
private:
// helper methods
@ -308,6 +318,8 @@ private:
Halignment mHalign;
Valignment mValign;
eMouseThrough mMouseThrough;
nsPresContext* mPresContext;
#ifdef DEBUG_LAYOUT

View File

@ -177,10 +177,7 @@ nsBoxLayoutState::Unwind(nsReflowPath* aReflowPath, nsIBox* aRootBox)
// It's nested HTML. Mark the root box's frame with
// NS_FRAME_HAS_DIRTY_CHILDREN so MarkDirty won't walk off the
// top of the box hierarchy and schedule another reflow command.
nsIFrame* frame;
aRootBox->GetFrame(&frame);
frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
aRootBox->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
// Clear the frame's dirty bit so that MarkDirty doesn't
// optimize the layout away.
@ -201,10 +198,7 @@ nsBoxLayoutState::Unwind(nsReflowPath* aReflowPath, nsIBox* aRootBox)
// Mark the root box's frame with NS_FRAME_HAS_DIRTY_CHILDREN so
// that MarkDirty won't walk off the top of the box hierarchy
// and schedule another reflow command.
nsIFrame* frame;
aRootBox->GetFrame(&frame);
frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
aRootBox->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
// The target is a box. Mark it dirty, generating a new reflow
// command targeted at us and coelesce out this one.
@ -225,9 +219,7 @@ nsBoxLayoutState::Unwind(nsReflowPath* aReflowPath, nsIBox* aRootBox)
nsIBox* parent;
ibox->GetParentBox(&parent);
if (parent) {
nsIFrame* parentFrame;
parent->GetFrame(&parentFrame);
parentFrame->AddStateBits(NS_FRAME_IS_DIRTY);
parent->AddStateBits(NS_FRAME_IS_DIRTY);
}
}
@ -243,37 +235,10 @@ nsBoxLayoutState::Unwind(nsReflowPath* aReflowPath, nsIBox* aRootBox)
nsIBox*
nsBoxLayoutState::GetBoxForFrame(nsIFrame* aFrame, PRBool& aIsAdaptor)
{
if (aFrame == nsnull)
return nsnull;
nsIBox* ibox = nsnull;
if (NS_FAILED(aFrame->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox))) {
if (aFrame && !aFrame->IsBoxFrame())
aIsAdaptor = PR_TRUE;
// if we hit a non box. Find the box in out last container
// and clear its cache.
nsIFrame* parent = aFrame->GetParent();
nsIBox* parentBox = nsnull;
if (NS_FAILED(parent->QueryInterface(NS_GET_IID(nsIBox), (void**)&parentBox)))
return nsnull;
if (parentBox) {
nsIBox* start = nsnull;
parentBox->GetChildBox(&start);
while (start) {
nsIFrame* frame = nsnull;
start->GetFrame(&frame);
if (frame == aFrame) {
ibox = start;
break;
}
start->GetNextBox(&start);
}
}
}
return ibox;
return aFrame;
}
/*

View File

@ -55,7 +55,6 @@ class nsReflowState;
class nsCalculatedBoxInfo;
struct nsHTMLReflowMetrics;
class nsString;
class nsIBox;
class nsHTMLReflowCommand;
class nsBoxLayoutState

View File

@ -55,7 +55,7 @@
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsIDOMXULElement.h"
#include "nsIBox.h"
#include "nsIFrame.h"
// Static IIDs/CIDs. Try to minimize these.
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);

File diff suppressed because it is too large Load Diff

View File

@ -1,133 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsBoxToBlockAdaptor_h___
#define nsBoxToBlockAdaptor_h___
#include "nsIBoxToBlockAdaptor.h"
#include "nsBox.h"
class nsBoxToBlockAdaptor : public nsBox, public nsIBoxToBlockAdaptor {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD GetFrame(nsIFrame** aFrame);
NS_IMETHOD SetIncludeOverflow(PRBool aInclude);
NS_IMETHOD GetOverflow(nsSize& aOverflow);
NS_IMETHOD NeedsRecalc();
NS_IMETHOD SetParentBox(nsIBox* aParent);
NS_IMETHOD Recycle(nsIPresShell* aPresShell);
void* operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW;
void operator delete(void* aPtr, size_t sz);
// We compute and store the HTML content's overflow area. So don't
// try to compute it in the box code.
virtual PRBool ComputesOwnOverflowArea() { return PR_TRUE; }
nsBoxToBlockAdaptor(nsIPresShell* aShell, nsIFrame* aFrame);
virtual ~nsBoxToBlockAdaptor();
protected:
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
#endif
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
private:
nsresult Reflow(nsBoxLayoutState& aState,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nscoord aX,
nscoord aY,
nscoord aWidth,
nscoord aHeight,
PRBool aMoveFrame = PR_TRUE);
void HandleIncrementalReflow(nsBoxLayoutState& aState,
const nsHTMLReflowState& aReflowState,
nsReflowReason& aReason,
nsReflowPath** aReflowPath,
PRBool& aRedrawNow,
PRBool& aNeedReflow,
PRBool& aRedrawAfterReflow,
PRBool& aMoveFrame);
PRBool CanSetMaxElementWidth(nsBoxLayoutState& aState, nsReflowReason& aReason, nsReflowPath **aReflowPath);
NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState);
nsIFrame* mFrame;
nsSize mPrefSize;
nsSize mMinSize;
nsSize mMaxSize;
nsSize mBlockMinSize;
nsSize mBlockPrefSize;
nscoord mBlockAscent;
nscoord mFlex;
nscoord mAscent;
nsSize mLastSize;
nsSize mOverflow;
nsIPresShell* mPresShell;
PRPackedBool mIncludeOverflow;
PRPackedBool mWasCollapsed;
PRPackedBool mStyleChange;
};
#endif

View File

@ -1,747 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//
// Eric Vaughan
// Netscape Communications
//
// See documentation in associated header file
//
#include "nsBoxLayoutState.h"
#include "nsBox.h"
#include "nsPresContext.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
#include "nsIViewManager.h"
#include "nsIView.h"
#include "nsIPresShell.h"
#include "nsHTMLContainerFrame.h"
#include "nsBoxToBlockAdaptor.h"
#include "nsBoxLayoutState.h"
#include "nsBoxFrame.h"
#include "nsPresContext.h"
#include "nsCOMPtr.h"
#include "nsUnitConversion.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsIContent.h"
#include "nsHTMLParts.h"
#include "nsIViewManager.h"
#include "nsIView.h"
#include "nsIPresShell.h"
#include "nsFrameNavigator.h"
#include "nsCSSRendering.h"
#include "nsIServiceManager.h"
#include "nsContainerBox.h"
nsContainerBox::nsContainerBox(nsIPresShell* aShell):nsBox(aShell)
{
mFirstChild = nsnull;
mLastChild = nsnull;
mChildCount = 0;
mOrderBoxes = PR_FALSE;
}
nsContainerBox::~nsContainerBox()
{
}
void
nsContainerBox::Destroy(nsBoxLayoutState& aState)
{
SetLayoutManager(nsnull);
ClearChildren(aState);
}
#ifdef DEBUG_LAYOUT
void
nsContainerBox::GetBoxName(nsAutoString& aName)
{
aName.AssignLiteral("ContainerBox");
}
#endif
NS_IMETHODIMP
nsContainerBox::GetChildBox(nsIBox** aBox)
{
*aBox = mFirstChild;
return NS_OK;
}
PRInt32
nsContainerBox::GetChildCount()
{
return mChildCount;
}
PRInt32
nsContainerBox::CreateBoxList(nsBoxLayoutState& aState, nsIFrame* aFrameList, nsIBox*& aFirst, nsIBox*& aLast)
{
nsIPresShell *shell = aState.PresShell();
PRInt32 count = 0;
if (aFrameList) {
nsIBox* ibox = nsnull;
if (NS_SUCCEEDED(aFrameList->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox)) && ibox)
aFirst = ibox;
else
aFirst = new (shell) nsBoxToBlockAdaptor(shell, aFrameList);
aFirst->SetParentBox(this);
count++;
aLast = aFirst;
aFrameList = aFrameList->GetNextSibling();
nsIBox* last = aLast;
while(aFrameList) {
if (NS_SUCCEEDED(aFrameList->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox)) && ibox)
aLast = ibox;
else
aLast = new (shell) nsBoxToBlockAdaptor(shell, aFrameList);
aLast->SetParentBox(this);
// check if this box is in a different ordinal group, and requires sorting
PRUint32 ordinal;
aLast->GetOrdinal(aState, ordinal);
if (ordinal != DEFAULT_ORDINAL_GROUP)
mOrderBoxes = PR_TRUE;
last->SetNextBox(aLast);
last = aLast;
aFrameList = aFrameList->GetNextSibling();
count++;
}
}
return count;
}
nsIBox*
nsContainerBox::GetPrevious(nsIFrame* aFrame)
{
if (aFrame == nsnull)
return nsnull;
// find the frame to remove
nsIBox* box = mFirstChild;
nsIBox* prev = nsnull;
while (box)
{
nsIFrame* frame = nsnull;
box->GetFrame(&frame);
if (frame == aFrame) {
return prev;
}
prev = box;
box->GetNextBox(&box);
}
return nsnull;
}
nsIBox*
nsContainerBox::GetBox(nsIFrame* aFrame)
{
if (aFrame == nsnull)
return nsnull;
// recycle adaptors
// nsIBox* ibox = nsnull;
// if (NS_SUCCEEDED(aFrame->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox)) && ibox)
// return ibox;
// find the frame to remove
nsIBox* box = mFirstChild;
while (box)
{
nsIFrame* frame = nsnull;
box->GetFrame(&frame);
if (frame == aFrame) {
return box;
}
box->GetNextBox(&box);
}
return nsnull;
}
nsIBox*
nsContainerBox::GetBoxAt(PRInt32 aIndex)
{
// find the frame to remove
nsIBox* child = mFirstChild;
PRInt32 count = 0;
while (child)
{
if (count == aIndex) {
return child;
}
child->GetNextBox(&child);
count++;
}
return nsnull;
}
void
nsContainerBox::Remove(nsBoxLayoutState& aState, nsIFrame* aFrame)
{
// get the info before the frame
nsIBox* prevBox = GetPrevious(aFrame);
RemoveAfter(aState, prevBox);
}
void
nsContainerBox::Insert(nsBoxLayoutState& aState, nsIFrame* aPrevFrame, nsIFrame* aFrameList)
{
nsIBox* prevBox = GetBox(aPrevFrame);
NS_ASSERTION(aPrevFrame == nsnull || prevBox,"Error! The previous frame given is not in our list!");
// find the frame before this one
// if no previous frame then we are inserting in front
if (prevBox == nsnull) {
// prepend them
Prepend(aState, aFrameList);
} else {
// insert insert after previous info
InsertAfter(aState, prevBox, aFrameList);
}
}
void
nsContainerBox::RemoveAfter(nsBoxLayoutState& aState, nsIBox* aPrevious)
{
nsIBox* toDelete = nsnull;
if (aPrevious == nsnull)
{
NS_ASSERTION(mFirstChild,"Can't find first child");
toDelete = mFirstChild;
if (mLastChild == mFirstChild) {
nsIBox* next = nsnull;
mFirstChild->GetNextBox(&next);
mLastChild = next;
}
mFirstChild->GetNextBox(&mFirstChild);
} else {
aPrevious->GetNextBox(&toDelete);
NS_ASSERTION(toDelete,"Can't find child to delete");
nsIBox* next = nsnull;
toDelete->GetNextBox(&next);
aPrevious->SetNextBox(next);
if (mLastChild == toDelete)
mLastChild = aPrevious;
}
// recycle adaptors
nsIBoxToBlockAdaptor* adaptor = nsnull;
if (NS_SUCCEEDED(toDelete->QueryInterface(NS_GET_IID(nsIBoxToBlockAdaptor), (void**)&adaptor)) && adaptor) {
adaptor->Recycle(aState.PresShell());
}
mChildCount--;
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, toDelete);
}
void
nsContainerBox::ClearChildren(nsBoxLayoutState& aState)
{
if (mFirstChild && mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, mFirstChild);
nsIBox* box = mFirstChild;
while(box) {
nsIBox* it = box;
box->GetNextBox(&box);
// recycle adaptors
nsIBoxToBlockAdaptor* adaptor = nsnull;
if (NS_SUCCEEDED(it->QueryInterface(NS_GET_IID(nsIBoxToBlockAdaptor), (void**)&adaptor)) && adaptor) {
adaptor->Recycle(aState.PresShell());
}
}
mFirstChild= nsnull;
mLastChild= nsnull;
mChildCount = 0;
}
void
nsContainerBox::Prepend(nsBoxLayoutState& aState, nsIFrame* aList)
{
nsIBox* first;
nsIBox* last;
mChildCount += CreateBoxList(aState, aList, first, last);
if (!mFirstChild)
mFirstChild= mLastChild= first;
else {
last->SetNextBox(mFirstChild);
mFirstChild= first;
}
CheckBoxOrder(aState);
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, aState, nsnull, first);
}
void
nsContainerBox::Append(nsBoxLayoutState& aState, nsIFrame* aList)
{
nsIBox* first;
nsIBox* last;
mChildCount += CreateBoxList(aState, aList, first, last);
if (!mFirstChild)
mFirstChild= first;
else
mLastChild->SetNextBox(first);
mLastChild= last;
CheckBoxOrder(aState);
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, aState, first);
}
void
nsContainerBox::InsertAfter(nsBoxLayoutState& aState, nsIBox* aPrev, nsIFrame* aList)
{
nsIBox* first = nsnull;
nsIBox* last = nsnull;
mChildCount += CreateBoxList(aState, aList, first, last);
nsIBox* next = nsnull;
aPrev->GetNextBox(&next);
last->SetNextBox(next);
aPrev->SetNextBox(first);
if (aPrev == mLastChild)
mLastChild = last;
CheckBoxOrder(aState);
if (mLayoutManager) {
mLayoutManager->ChildrenInserted(this, aState, aPrev, first);
}
}
void
nsContainerBox::InitChildren(nsBoxLayoutState& aState, nsIFrame* aList)
{
ClearChildren(aState);
mChildCount += CreateBoxList(aState, aList, mFirstChild, mLastChild);
CheckBoxOrder(aState);
if (mLayoutManager)
mLayoutManager->ChildrenSet(this, aState, mFirstChild);
}
#ifdef DEBUG_LAYOUT
void
nsContainerBox::SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug)
{
nsIBox* child = nsnull;
GetChildBox(&child);
while (child)
{
child->SetDebug(aState, aDebug);
child->GetNextBox(&child);
}
}
#endif
void
nsContainerBox::SanityCheck(nsFrameList& aFrameList)
{
#ifdef DEBUG
// make sure the length match
PRInt32 length = aFrameList.GetLength();
NS_ASSERTION(length == mChildCount,"nsBox::ERROR!! Box info list count does not match frame count!!");
// make sure last makes sense
nsIBox* next = nsnull;
NS_ASSERTION(mLastChild == nsnull || (NS_SUCCEEDED(mLastChild->GetNextBox(&next)) && next == nsnull),"nsBox::ERROR!! The last child is not really the last!!!");
nsIFrame* child = aFrameList.FirstChild();
nsIBox* box = mFirstChild;
PRInt32 count = 0;
while(box)
{
NS_ASSERTION(count <= mChildCount,"too many children!!!");
nsIFrame* frame = nsnull;
nsIBox* parent = nsnull;
NS_ASSERTION(NS_SUCCEEDED(box->GetFrame(&frame)) && frame == child,"nsBox::ERROR!! box info list and child info lists don't match!!!");
NS_ASSERTION(NS_SUCCEEDED(box->GetParentBox(&parent)) && parent == this,"nsBox::ERROR!! parent's don't match!!!");
box->GetNextBox(&box);
child = child->GetNextSibling();
count++;
}
#endif
}
void
nsContainerBox::CheckBoxOrder(nsBoxLayoutState& aState)
{
if (mOrderBoxes) {
nsIBox** boxes = new nsIBox*[mChildCount];
// turn linked list into array for quick sort
nsIBox* box = mFirstChild;
nsIBox** boxPtr = boxes;
while (box) {
*boxPtr = box;
box->GetNextBox(&box);
++boxPtr;
}
// sort the array by ordinal group, selection sort
PRInt32 i, j, min;
PRUint32 minOrd, jOrd;
for(i = 0; i < mChildCount; i++) {
min = i;
boxes[min]->GetOrdinal(aState, minOrd);
for(j = i + 1; j < mChildCount; j++) {
boxes[j]->GetOrdinal(aState, jOrd);
if (jOrd < minOrd) {
min = j;
minOrd = jOrd;
}
}
box = boxes[min];
boxes[min] = boxes[i];
boxes[i] = box;
}
// turn the array back into linked list, with first and last cached
mFirstChild = boxes[0];
mLastChild = boxes[mChildCount-1];
for (i = 0; i < mChildCount; ++i) {
if (i <= mChildCount-2)
boxes[i]->SetNextBox(boxes[i+1]);
else
boxes[i]->SetNextBox(nsnull);
}
delete [] boxes;
}
}
NS_IMETHODIMP
nsContainerBox::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
{
nsresult rv = NS_OK;
aSize.width = 0;
aSize.height = 0;
PRBool collapsed = PR_FALSE;
IsCollapsed(aState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSPrefSize(aState, this, aSize))
{
aSize.width = 0;
aSize.height = 0;
if (mLayoutManager) {
rv = mLayoutManager->GetPrefSize(this, aState, aSize);
nsIBox::AddCSSPrefSize(aState, this, aSize);
} else
rv = nsBox::GetPrefSize(aState, aSize);
}
nsSize minSize(0,0);
nsSize maxSize(0,0);
GetMinSize(aState, minSize);
GetMaxSize(aState, maxSize);
BoundsCheck(minSize, aSize, maxSize);
return rv;
}
NS_IMETHODIMP
nsContainerBox::GetMinSize(nsBoxLayoutState& aState, nsSize& aSize)
{
nsresult rv = NS_OK;
aSize.width = 0;
aSize.height = 0;
PRBool collapsed = PR_FALSE;
IsCollapsed(aState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSMinSize(aState, this, aSize))
{
aSize.width = 0;
aSize.height = 0;
if (mLayoutManager) {
rv = mLayoutManager->GetMinSize(this, aState, aSize);
nsIBox::AddCSSMinSize(aState, this, aSize);
} else {
rv = nsBox::GetMinSize(aState, aSize);
}
}
return rv;
}
NS_IMETHODIMP
nsContainerBox::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
{
nsresult rv = NS_OK;
aSize.width = NS_INTRINSICSIZE;
aSize.height = NS_INTRINSICSIZE;
PRBool collapsed = PR_FALSE;
IsCollapsed(aState, collapsed);
if (collapsed)
return NS_OK;
// if the size was not completely redefined in CSS then ask our children
if (!nsIBox::AddCSSMaxSize(aState, this, aSize))
{
aSize.width = NS_INTRINSICSIZE;
aSize.height = NS_INTRINSICSIZE;
if (mLayoutManager) {
rv = mLayoutManager->GetMaxSize(this, aState, aSize);
nsIBox::AddCSSMaxSize(aState, this, aSize);
} else {
rv = nsBox::GetMaxSize(aState, aSize);
}
}
return rv;
}
NS_IMETHODIMP
nsContainerBox::GetAscent(nsBoxLayoutState& aState, nscoord& aAscent)
{
nsresult rv = NS_OK;
aAscent = 0;
PRBool collapsed = PR_FALSE;
IsCollapsed(aState, collapsed);
if (collapsed)
return NS_OK;
if (mLayoutManager)
rv = mLayoutManager->GetAscent(this, aState, aAscent);
else
rv = nsBox::GetAscent(aState, aAscent);
return rv;
}
NS_IMETHODIMP
nsContainerBox::DoLayout(nsBoxLayoutState& aState)
{
PRUint32 oldFlags = aState.LayoutFlags();
aState.SetLayoutFlags(0);
nsresult rv = NS_OK;
if (mLayoutManager)
rv = mLayoutManager->Layout(this, aState);
aState.SetLayoutFlags(oldFlags);
return rv;
}
NS_IMETHODIMP
nsContainerBox::SetLayoutManager(nsIBoxLayout* aLayout)
{
mLayoutManager = aLayout;
return NS_OK;
}
NS_IMETHODIMP
nsContainerBox::GetLayoutManager(nsIBoxLayout** aLayout)
{
*aLayout = mLayoutManager;
NS_IF_ADDREF(*aLayout);
return NS_OK;
}
nsresult
nsContainerBox::LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect)
{
// get the current rect
nsRect oldRect(0,0,0,0);
aBox->GetBounds(oldRect);
aBox->SetBounds(aState, aRect);
PRBool dirty = PR_FALSE;
PRBool dirtyChildren = PR_FALSE;
aBox->IsDirty(dirty);
aBox->HasDirtyChildren(dirtyChildren);
PRBool layout = PR_TRUE;
if (!(dirty || dirtyChildren) && aState.LayoutReason() != nsBoxLayoutState::Initial)
layout = PR_FALSE;
if (layout || (oldRect.width != aRect.width || oldRect.height != aRect.height)) {
return aBox->Layout(aState);
}
return NS_OK;
}
NS_IMETHODIMP
nsContainerBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)
{
mOrderBoxes = PR_TRUE;
PRUint32 ord;
aChild->GetOrdinal(aState, ord);
PRUint32 ordCmp;
nsIBox* box = mFirstChild;
nsIBox* newPrevSib = mFirstChild;
box->GetOrdinal(aState, ordCmp);
if (ord < ordCmp) {
// new ordinal is lower than the lowest current ordinal, so it will not
// have a previous sibling
newPrevSib = nsnull;
} else {
// search for the box after which we will insert this box
while (box) {
box->GetOrdinal(aState, ordCmp);
if (newPrevSib && ordCmp > ord)
break;
newPrevSib = box;
box->GetNextBox(&box);
}
}
// look for the previous sibling of |aChild|
nsIBox* oldPrevSib = mFirstChild;
while (oldPrevSib) {
nsIBox* me;
oldPrevSib->GetNextBox(&me);
if (aChild == me) {
break;
}
oldPrevSib = me;
}
// if we are moving |mFirstChild|, we'll have to update the |mFirstChild|
// value later on
PRBool firstChildMoved = PR_FALSE;
if (aChild == mFirstChild)
firstChildMoved = PR_TRUE;
nsIBox* newNextSib;
if (newPrevSib) {
// insert |aChild| between |newPrevSib| and its next sibling
newPrevSib->GetNextBox(&newNextSib);
newPrevSib->SetNextBox(aChild);
} else {
// no |newPrevSib| found, so this box will become |mFirstChild|
newNextSib = mFirstChild;
mFirstChild = aChild;
}
// link up our new next sibling
nsIBox* oldNextSib;
aChild->GetNextBox(&oldNextSib);
aChild->SetNextBox(newNextSib);
// link |oldPrevSib| with |oldNextSib| to fill the gap left behind
if (oldPrevSib)
oldPrevSib->SetNextBox(oldNextSib);
// if |newPrevSib| was the last child, then aChild is the new last child
if (newPrevSib == mLastChild)
mLastChild = aChild;
if (firstChildMoved)
mFirstChild = oldNextSib;
return NS_OK;
}
NS_IMETHODIMP
nsContainerBox::GetIndexOf(nsIBox* aBox, PRInt32* aIndex)
{
nsIBox* child = mFirstChild;
PRInt32 count = 0;
while (child)
{
if (aBox == child) {
*aIndex = count;
return NS_OK;
}
child->GetNextBox(&child);
count++;
}
*aIndex = -1;
return NS_OK;
}

View File

@ -1,106 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsContainerBox_h___
#define nsContainerBox_h___
#include "nsBox.h"
#include "nsCOMPtr.h"
#include "nsIBoxLayout.h"
class nsFrameList;
class nsContainerBox : public nsBox {
public:
NS_IMETHOD GetChildBox(nsIBox** aBox);
nsContainerBox(nsIPresShell* aShell);
virtual ~nsContainerBox();
void Destroy(nsBoxLayoutState& aState);
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout);
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout);
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex);
virtual nsIBox* GetBoxAt(PRInt32 aIndex);
virtual nsIBox* GetBox(nsIFrame* aFrame);
virtual PRInt32 GetChildCount();
virtual void ClearChildren(nsBoxLayoutState& aState);
virtual PRInt32 CreateBoxList(nsBoxLayoutState& aState, nsIFrame* aList, nsIBox*& first, nsIBox*& last);
virtual void RemoveAfter(nsBoxLayoutState& aState, nsIBox* aPrev);
virtual void Remove(nsBoxLayoutState& aState, nsIFrame* aChild);
virtual void Prepend(nsBoxLayoutState& aState, nsIFrame* aList);
virtual void Append(nsBoxLayoutState& aState, nsIFrame* aList);
virtual void Insert(nsBoxLayoutState& aState, nsIFrame* aPrevFrame, nsIFrame* aList);
virtual void InsertAfter(nsBoxLayoutState& aState, nsIBox* aPrev, nsIFrame* aList);
virtual void InitChildren(nsBoxLayoutState& aState, nsIFrame* aList);
virtual nsIBox* GetPrevious(nsIFrame* aChild);
virtual void SanityCheck(nsFrameList& aFrameList);
#ifdef DEBUG_LAYOUT
virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug);
#endif
virtual void CheckBoxOrder(nsBoxLayoutState& aState);
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
protected:
//virtual nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect, PRUint32 aFlags);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
#endif
nsIBox* mFirstChild;
nsIBox* mLastChild;
PRInt32 mChildCount;
PRBool mOrderBoxes;
nsCOMPtr<nsIBoxLayout> mLayoutManager;
};
#endif

View File

@ -93,7 +93,7 @@ nsDeckFrame::nsDeckFrame(nsIPresShell* aPresShell,
* Hack for deck who requires that all its children has widgets
*/
NS_IMETHODIMP
nsDeckFrame::ChildrenMustHaveWidgets(PRBool& aMust)
nsDeckFrame::ChildrenMustHaveWidgets(PRBool& aMust) const
{
aMust = PR_TRUE;
return NS_OK;
@ -138,10 +138,7 @@ nsDeckFrame::Init(nsPresContext* aPresContext,
void
nsDeckFrame::HideBox(nsPresContext* aPresContext, nsIBox* aBox)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = aBox->GetView();
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
@ -153,11 +150,8 @@ nsDeckFrame::HideBox(nsPresContext* aPresContext, nsIBox* aBox)
void
nsDeckFrame::ShowBox(nsPresContext* aPresContext, nsIBox* aBox)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsRect rect = frame->GetRect();
nsIView* view = frame->GetView();
nsRect rect = aBox->GetRect();
nsIView* view = aBox->GetView();
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
rect.x = rect.y = 0;
@ -240,11 +234,7 @@ nsDeckFrame::Paint(nsPresContext* aPresContext,
// only paint the seleced box
nsIBox* box = GetSelectedBox();
if (box) {
nsIFrame* frame = nsnull;
box->GetFrame(&frame);
if (frame)
PaintChild(aPresContext, aRenderingContext, aDirtyRect, frame, aWhichLayer);
PaintChild(aPresContext, aRenderingContext, aDirtyRect, box, aWhichLayer);
}
return NS_OK;
@ -266,13 +256,10 @@ nsDeckFrame::GetFrameForPoint(nsPresContext* aPresContext,
// get the selected frame and see if the point is in it.
nsIBox* selectedBox = GetSelectedBox();
if (selectedBox) {
nsIFrame* selectedFrame = nsnull;
selectedBox->GetFrame(&selectedFrame);
nsPoint tmp(aPoint.x - mRect.x, aPoint.y - mRect.y);
if (NS_SUCCEEDED(selectedFrame->GetFrameForPoint(aPresContext, tmp,
aWhichLayer, aFrame)))
if (NS_SUCCEEDED(selectedBox->GetFrameForPoint(aPresContext, tmp,
aWhichLayer, aFrame)))
return NS_OK;
}

View File

@ -82,7 +82,7 @@ public:
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust);
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust) const;
#ifdef NS_DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const

View File

@ -45,7 +45,7 @@
#include "nsFrameNavigator.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
#include "nsIBox.h"
#include "nsIFrame.h"
nsIBox*
nsFrameNavigator::GetChildBeforeAfter(nsPresContext* aPresContext,

View File

@ -48,7 +48,6 @@
#include "nsIFrame.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
class nsIBox;
class nsFrameNavigator
{

View File

@ -139,14 +139,11 @@ nsGroupBoxFrame::Paint(nsPresContext* aPresContext,
nsIBox* groupBox = GetCaptionBox(aPresContext, groupRect);
if (groupBox) {
nsIFrame* groupFrame;
groupBox->GetFrame(&groupFrame);
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
nsMargin groupMargin;
groupFrame->GetStyleMargin()->GetMargin(groupMargin);
groupBox->GetStyleMargin()->GetMargin(groupMargin);
groupRect.Inflate(groupMargin);
if (border.top < groupRect.height)
@ -254,9 +251,8 @@ nsGroupBoxFrame::GetCaptionBox(nsPresContext* aPresContext, nsRect& aCaptionRect
if (child) {
// convert to our coordinates.
nsRect parentRect;
box->GetBounds(parentRect);
child->GetBounds(aCaptionRect);
nsRect parentRect(box->GetRect());
aCaptionRect = child->GetRect();
aCaptionRect.x += parentRect.x;
aCaptionRect.y += parentRect.y;
}

View File

@ -1,156 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Hyatt (hyatt@netscape.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
Eric D Vaughan
nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
It lays them out according to a min max or preferred size.
nsIBox is implemented on frames and thus should not be refcounted.
Eventually it should not inherit from nsISupports.
**/
#ifndef nsIBox_h___
#define nsIBox_h___
#include "nsISupports.h"
#include "nsIBoxLayout.h"
// turn on to spew box state
//#define DEBUG_LAYOUT
class nsBoxLayoutState;
struct nsRect;
struct nsSize;
// {b29f0101-eb3c-4f66-804e-58faf9dbb380}
#define NS_IBOX_IID { 0xb29f0101, 0xeb3c, 0x4f66, { 0x80, 0x4e, 0x58, 0xfa, 0xf9, 0xdb, 0xb3, 0x80 } }
#define DEFAULT_ORDINAL_GROUP 1
class nsIBox : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBOX_IID)
enum Halignment {
hAlign_Left,
hAlign_Right,
hAlign_Center
};
enum Valignment {
vAlign_Top,
vAlign_Middle,
vAlign_BaseLine,
vAlign_Bottom
};
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)=0;
NS_IMETHOD GetFlex(nsBoxLayoutState& aBoxLayoutState, nscoord& aFlex)=0;
NS_IMETHOD GetOrdinal(nsBoxLayoutState& aBoxLayoutState, PRUint32& aOrdinal)=0;
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)=0;
NS_IMETHOD IsCollapsed(nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed)=0;
NS_IMETHOD Collapse(nsBoxLayoutState& aBoxLayoutState)=0;
NS_IMETHOD UnCollapse(nsBoxLayoutState& aBoxLayoutState)=0;
// This does not alter the overflow area. If the caller is changing
// the box size, the caller is responsible for updating the overflow
// area. It's enough to just call Layout or SyncLayout on the
// box. You can pass PR_TRUE to aRemoveOverflowArea as a
// convenience.
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
PRBool aRemoveOverflowArea = PR_FALSE)=0;
NS_IMETHOD GetBounds(nsRect& aRect)=0;
NS_IMETHOD Layout(nsBoxLayoutState& aBoxLayoutState)=0;
NS_IMETHOD IsDirty(PRBool& aIsDirty)=0;
NS_IMETHOD HasDirtyChildren(PRBool& aIsDirty)=0;
NS_IMETHOD MarkDirty(nsBoxLayoutState& aState)=0;
NS_IMETHOD MarkDirtyChildren(nsBoxLayoutState& aState)=0;
NS_IMETHOD GetChildBox(nsIBox** aBox)=0;
NS_IMETHOD GetNextBox(nsIBox** aBox)=0;
NS_IMETHOD SetNextBox(nsIBox* aBox)=0;
NS_IMETHOD GetParentBox(nsIBox** aParent)=0;
NS_IMETHOD SetParentBox(nsIBox* aParent)=0;
NS_IMETHOD GetFrame(nsIFrame** aFrame)=0;
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding)=0;
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding)=0;
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding)=0;
NS_IMETHOD GetInset(nsMargin& aInset)=0;
NS_IMETHOD GetMargin(nsMargin& aMargin)=0;
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout)=0;
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout)=0;
NS_IMETHOD GetContentRect(nsRect& aContentRect) = 0;
NS_IMETHOD GetClientRect(nsRect& aContentRect) = 0;
NS_IMETHOD GetVAlign(Valignment& aAlign) = 0;
NS_IMETHOD GetHAlign(Halignment& aAlign) = 0;
NS_IMETHOD GetOrientation(PRBool& aIsHorizontal)=0;
NS_IMETHOD GetDirection(PRBool& aIsNormal)=0;
NS_IMETHOD Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nsnull, PRBool aImmediate = PR_FALSE)=0;
NS_IMETHOD NeedsRecalc()=0;
NS_IMETHOD RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough)=0;
NS_IMETHOD MarkChildrenStyleChange()=0;
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0;
#ifdef DEBUG_LAYOUT
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, PRBool aDebug)=0;
NS_IMETHOD GetDebug(PRBool& aDebug)=0;
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox)=0;
NS_IMETHOD DumpBox(FILE* out)=0;
#endif
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust)=0;
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex)=0;
static PRBool AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex);
static PRBool AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollapsed);
static PRBool AddCSSOrdinal(nsBoxLayoutState& aState, nsIBox* aBox, PRUint32& aOrdinal);
};
#endif

View File

@ -42,7 +42,6 @@
#include "nsIFrame.h"
class nsPresContext;
class nsIBox;
class nsBoxLayout;
class nsBoxLayoutState;
class nsIRenderingContext;

View File

@ -83,8 +83,10 @@ NS_NewLeafBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
} // NS_NewTextFrame
nsLeafBoxFrame::nsLeafBoxFrame(nsIPresShell* aShell):nsBox(aShell)
nsLeafBoxFrame::nsLeafBoxFrame(nsIPresShell* aShell)
: mMouseThrough(unset)
{
mState |= NS_FRAME_IS_BOX;
}
#ifdef DEBUG_LAYOUT
@ -109,10 +111,9 @@ nsLeafBoxFrame::Init(nsPresContext* aPresContext,
nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// see if we need a widget
nsIBox *parent;
if (aParent && NS_SUCCEEDED(CallQueryInterface(aParent, &parent))) {
if (aParent && aParent->IsBoxFrame()) {
PRBool needsWidget = PR_FALSE;
parent->ChildrenMustHaveWidgets(needsWidget);
aParent->ChildrenMustHaveWidgets(needsWidget);
if (needsWidget) {
nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE);
nsIView* view = GetView();
@ -160,6 +161,30 @@ void nsLeafBoxFrame::UpdateMouseThrough()
}
}
NS_IMETHODIMP
nsLeafBoxFrame::GetMouseThrough(PRBool& aMouseThrough)
{
switch (mMouseThrough)
{
case always:
aMouseThrough = PR_TRUE;
return NS_OK;
case never:
aMouseThrough = PR_FALSE;
return NS_OK;
case unset:
{
if (mParent && mParent->IsBoxFrame())
return mParent->GetMouseThrough(aMouseThrough);
else {
aMouseThrough = PR_FALSE;
return NS_OK;
}
}
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsLeafBoxFrame::GetFrameForPoint(nsPresContext* aPresContext,
@ -177,13 +202,6 @@ nsLeafBoxFrame::GetFrameForPoint(nsPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
nsLeafBoxFrame::GetFrame(nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
}
NS_IMETHODIMP
nsLeafBoxFrame::DidReflow(nsPresContext* aPresContext,
const nsHTMLReflowState* aReflowState,
@ -315,10 +333,9 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
Layout(state);
// ok our child could have gotten bigger. So lets get its bounds
GetBounds(r);
// get the ascent
nscoord ascent = r.height;
nscoord ascent = mRect.height;
// Only call GetAscent when not doing Initial reflow while in PP
// or when it is Initial reflow while in PP and a chrome doc
@ -330,8 +347,8 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
GetAscent(state, ascent);
}
aDesiredSize.width = r.width;
aDesiredSize.height = r.height;
aDesiredSize.width = mRect.width;
aDesiredSize.height = mRect.height;
aDesiredSize.ascent = ascent;
aDesiredSize.descent = 0;
@ -405,6 +422,71 @@ nsLeafBoxFrame::CharacterDataChanged(nsPresContext* aPresContext,
return nsLeafFrame::CharacterDataChanged(aPresContext, aChild, aAppend);
}
NS_IMETHODIMP
nsLeafBoxFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
{
return nsBox::GetPrefSize(aState, aSize);
}
NS_IMETHODIMP
nsLeafBoxFrame::GetMinSize(nsBoxLayoutState& aState, nsSize& aSize)
{
return nsBox::GetMinSize(aState, aSize);
}
NS_IMETHODIMP
nsLeafBoxFrame::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
{
return nsBox::GetMaxSize(aState, aSize);
}
NS_IMETHODIMP
nsLeafBoxFrame::GetFlex(nsBoxLayoutState& aState, nscoord& aFlex)
{
return nsBox::GetFlex(aState, aFlex);
}
NS_IMETHODIMP
nsLeafBoxFrame::GetAscent(nsBoxLayoutState& aState, nscoord& aAscent)
{
return nsBox::GetAscent(aState, aAscent);
}
NS_IMETHODIMP
nsLeafBoxFrame::NeedsRecalc()
{
return nsBox::NeedsRecalc();
}
NS_IMETHODIMP
nsLeafBoxFrame::DoLayout(nsBoxLayoutState& aState)
{
return nsBox::DoLayout(aState);
}
PRBool
nsLeafBoxFrame::HasStyleChange()
{
return nsBox::HasStyleChange();
}
void
nsLeafBoxFrame::SetStyleChangeFlag(PRBool aDirty)
{
nsBox::SetStyleChangeFlag(aDirty);
}
PRBool
nsLeafBoxFrame::GetWasCollapsed(nsBoxLayoutState& aState)
{
return nsBox::GetWasCollapsed(aState);
}
void
nsLeafBoxFrame::SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas)
{
nsBox::SetWasCollapsed(aState, aWas);
}
NS_INTERFACE_MAP_BEGIN(nsLeafBoxFrame)
NS_INTERFACE_MAP_ENTRY(nsIBox)

View File

@ -42,7 +42,7 @@
class nsAccessKeyInfo;
class nsLeafBoxFrame : public nsLeafFrame, public nsBox
class nsLeafBoxFrame : public nsLeafFrame
{
public:
@ -51,7 +51,12 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIBox frame interface
NS_IMETHOD GetFrame(nsIFrame** aFrame);
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize);
NS_IMETHOD GetMinSize(nsBoxLayoutState& aState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize);
NS_IMETHOD GetFlex(nsBoxLayoutState& aState, nscoord& aFlex);
NS_IMETHOD GetAscent(nsBoxLayoutState& aState, nscoord& aAscent);
NS_IMETHOD NeedsRecalc();
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
@ -88,8 +93,19 @@ public:
nsIAtom* aAttribute,
PRInt32 aModType);
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
virtual PRBool ComputesOwnOverflowArea() { return PR_FALSE; }
protected:
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
virtual PRBool GetWasCollapsed(nsBoxLayoutState& aState);
virtual void SetWasCollapsed(nsBoxLayoutState& aState, PRBool aWas);
NS_IMETHOD DoLayout(nsBoxLayoutState& aState);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
#endif
@ -100,6 +116,8 @@ protected:
nsLeafBoxFrame(nsIPresShell* aShell);
protected:
eMouseThrough mMouseThrough;
private:

View File

@ -877,6 +877,8 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a
if (aDelta == 0)
return NS_OK;
nsBoxLayoutState state(mPresContext);
// begin timing how long it takes to scroll a row
PRTime start = PR_Now();
@ -903,17 +905,10 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a
else {
// We have scrolled so much that all of our current frames will
// go off screen, so blow them all away. Weeee!
nsIBox* currBox;
GetChildBox(&currBox);
nsBoxLayoutState state(mPresContext);
nsIFrame *currBox = mFrames.FirstChild();
while (currBox) {
nsIBox* nextBox;
currBox->GetNextBox(&nextBox);
nsIFrame* frame;
currBox->QueryInterface(NS_GET_IID(nsIFrame), (void**)&frame);
mFrameConstructor->RemoveMappingsForFrameSubtree(mPresContext, frame, nsnull);
Remove(state, frame);
mFrames.DestroyFrame(mPresContext, frame);
nsIFrame *nextBox = currBox->GetNextSibling();
RemoveChildFrame(state, currBox);
currBox = nextBox;
}
}
@ -922,7 +917,6 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a
mTopFrame = mBottomFrame = nsnull;
mYPosition = mCurrentIndex*mRowHeight;
nsBoxLayoutState state(mPresContext);
mScrolling = PR_TRUE;
MarkDirtyChildren(state);
// Flush calls CreateRows
@ -1054,19 +1048,18 @@ nsListBoxBodyFrame::DestroyRows(PRInt32& aRowsToLose)
// We need to destroy frames until our row count has been properly
// reduced. A reflow will then pick up and create the new frames.
nsIFrame* childFrame = GetFirstFrame();
nsBoxLayoutState state(mPresContext);
while (childFrame && aRowsToLose > 0) {
--aRowsToLose;
nsIFrame* nextFrame = childFrame->GetNextSibling();
mFrameConstructor->RemoveMappingsForFrameSubtree(mPresContext, childFrame, nsnull);
nsBoxLayoutState state(mPresContext);
Remove(state, childFrame);
mFrames.DestroyFrame(mPresContext, childFrame);
MarkDirtyChildren(state);
nsIFrame* nextFrame = childFrame->GetNextSibling();
RemoveChildFrame(state, childFrame);
mTopFrame = childFrame = nextFrame;
}
MarkDirtyChildren(state);
}
void
@ -1075,20 +1068,19 @@ nsListBoxBodyFrame::ReverseDestroyRows(PRInt32& aRowsToLose)
// We need to destroy frames until our row count has been properly
// reduced. A reflow will then pick up and create the new frames.
nsIFrame* childFrame = GetLastFrame();
nsBoxLayoutState state(mPresContext);
while (childFrame && aRowsToLose > 0) {
--aRowsToLose;
nsIFrame* prevFrame;
prevFrame = mFrames.GetPrevSiblingFor(childFrame);
mFrameConstructor->RemoveMappingsForFrameSubtree(mPresContext, childFrame, nsnull);
nsBoxLayoutState state(mPresContext);
Remove(state, childFrame);
mFrames.DestroyFrame(mPresContext, childFrame);
MarkDirtyChildren(state);
RemoveChildFrame(state, childFrame);
mBottomFrame = childFrame = prevFrame;
}
MarkDirtyChildren(state);
}
//
@ -1105,9 +1097,7 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated)
mBottomFrame = mTopFrame;
if (mTopFrame) {
nsIBox *box;
CallQueryInterface(mTopFrame, &box);
return box;
return mTopFrame->IsBoxFrame() ? mTopFrame : nsnull;
}
// top frame was cleared out
@ -1115,9 +1105,7 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated)
mBottomFrame = mTopFrame;
if (mTopFrame && mRowsToPrepend <= 0) {
nsIBox *box;
CallQueryInterface(mTopFrame, &box);
return box;
return mTopFrame->IsBoxFrame() ? mTopFrame : nsnull;
}
// At this point, we either have no frames at all,
@ -1155,9 +1143,7 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated)
mBottomFrame = mTopFrame;
nsIBox *box;
CallQueryInterface(mTopFrame, &box);
return box;
return mTopFrame->IsBoxFrame() ? mTopFrame : nsnull;
} else
return GetFirstItemBox(++aOffset, 0);
}
@ -1176,13 +1162,11 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
if (aCreated)
*aCreated = PR_FALSE;
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsIFrame* result = frame->GetNextSibling();
nsIFrame* result = aBox->GetNextSibling();
if (!result || result == mLinkupFrame || mRowsToPrepend > 0) {
// No result found. See if there's a content node that wants a frame.
nsIContent* prevContent = frame->GetContent();
nsIContent* prevContent = aBox->GetContent();
nsIContent* parentContent = prevContent->GetParent();
PRInt32 i = parentContent->IndexOf(prevContent);
@ -1194,7 +1178,7 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
// Either append the new frame, or insert it after the current frame
PRBool isAppend = result != mLinkupFrame && mRowsToPrepend <= 0;
nsIFrame* prevFrame = isAppend ? nsnull : frame;
nsIFrame* prevFrame = isAppend ? nsnull : aBox;
mFrameConstructor->CreateListBoxContent(mPresContext, this, prevFrame,
nextContent, &result, isAppend,
PR_FALSE, nsnull);
@ -1214,9 +1198,7 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
mBottomFrame = result;
nsIBox *box;
CallQueryInterface(result, &box);
return box;
return result->IsBoxFrame() ? result : nsnull;
}
PRBool
@ -1238,12 +1220,7 @@ nsListBoxBodyFrame::ContinueReflow(nscoord height)
while (currFrame) {
nsIFrame* nextFrame = currFrame->GetNextSibling();
mFrameConstructor->RemoveMappingsForFrameSubtree(mPresContext, currFrame, nsnull);
Remove(state, currFrame);
mFrames.DestroyFrame(mPresContext, currFrame);
RemoveChildFrame(state, currFrame);
currFrame = nextFrame;
}
@ -1260,8 +1237,9 @@ nsListBoxBodyFrame::ListBoxAppendFrames(nsIFrame* aFrameList)
{
// append them after
nsBoxLayoutState state(mPresContext);
Append(state,aFrameList);
mFrames.AppendFrames(nsnull, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, state, aFrameList);
MarkDirtyChildren(state);
return NS_OK;
@ -1272,8 +1250,9 @@ nsListBoxBodyFrame::ListBoxInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameLi
{
// insert the frames to our info list
nsBoxLayoutState state(mPresContext);
Insert(state, aPrevFrame, aFrameList);
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, aFrameList);
MarkDirtyChildren(state);
return NS_OK;
@ -1382,10 +1361,8 @@ nsListBoxBodyFrame::OnContentRemoved(nsPresContext* aPresContext, nsIFrame* aChi
// Go ahead and delete the frame.
nsBoxLayoutState state(aPresContext);
if (aChildFrame) {
mFrameConstructor->RemoveMappingsForFrameSubtree(aPresContext, aChildFrame, nsnull);
Remove(state, aChildFrame);
mFrames.DestroyFrame(aPresContext, aChildFrame);
RemoveChildFrame(state, aChildFrame);
aChildFrame->Destroy(mPresContext);
}
MarkDirtyChildren(state);
@ -1441,6 +1418,18 @@ nsListBoxBodyFrame::GetListItemNextSibling(nsIContent* aListItem, nsIContent** a
aSiblingIndex = -1; // no match, so there is no next sibling
}
void
nsListBoxBodyFrame::RemoveChildFrame(nsBoxLayoutState &aState,
nsIFrame *aFrame)
{
mFrameConstructor->RemoveMappingsForFrameSubtree(mPresContext, aFrame, nsnull);
mFrames.RemoveFrame(aFrame);
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, aFrame);
aFrame->Destroy(mPresContext);
}
//////////////////////////////////////////////////////////////////////////
///// nsListboxScrollPortFrame

View File

@ -138,6 +138,7 @@ public:
protected:
void ComputeTotalRowCount();
void RemoveChildFrame(nsBoxLayoutState &aState, nsIFrame *aChild);
// We don't own this. (No addref/release allowed, punk.)
nsCSSFrameConstructor* mFrameConstructor;

View File

@ -40,7 +40,7 @@
#include "nsListBoxLayout.h"
#include "nsListBoxBodyFrame.h"
#include "nsIBox.h"
#include "nsIFrame.h"
#include "nsBox.h"
#include "nsBoxLayoutState.h"
#include "nsIScrollableFrame.h"
@ -207,8 +207,7 @@ nsListBoxLayout::LayoutInternal(nsIBox* aBox, nsBoxLayoutState& aState)
box->IsDirty(dirty);
box->HasDirtyChildren(dirtyChildren);
nsRect childRect;
box->GetBounds(childRect);
nsRect childRect(box->GetRect());
box->GetMargin(margin);
// relayout if we must or we are dirty or some of our children are dirty
@ -261,8 +260,7 @@ nsListBoxLayout::LayoutInternal(nsIBox* aBox, nsBoxLayoutState& aState)
// before them then redraw everything under the inserted rows. The inserted
// rows will automatically be redrawn because the were marked dirty on insertion.
if (redrawStart > -1) {
nsRect bounds;
aBox->GetBounds(bounds);
nsRect bounds(aBox->GetRect());
nsRect tempRect(0,redrawStart,bounds.width, bounds.height - redrawStart);
aBox->Redraw(aState, &tempRect);
}

View File

@ -41,8 +41,8 @@
#define nsListBoxLayout_h___
#include "nsGridRowGroupLayout.h"
#include "nsIFrame.h"
class nsIBox;
class nsBoxLayoutState;
class nsListBoxLayout : public nsGridRowGroupLayout

View File

@ -804,9 +804,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
nsRect curRect;
menuPopup->GetBounds(curRect);
nsRect curRect(menuPopup->GetRect());
menuPopup->SetBounds(state, nsRect(0,0,mLastPref.width, mLastPref.height));
nsIView* view = menuPopup->GetView();
@ -815,11 +813,10 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
vm->SetViewVisibility(view, nsViewVisibility_kHide);
}
menuPopup->SyncViewWithFrame(mPresContext, popupAnchor, popupAlign, this, -1, -1);
nsRect rect;
menuPopup->GetBounds(rect);
nscoord newHeight = menuPopup->GetRect().height;
// if the height is different then reflow. It might need scrollbars force a reflow
if (curRect.height != rect.height || mLastPref.height != rect.height)
if (curRect.height != newHeight || mLastPref.height != newHeight)
{
menuPopup->MarkDirty(state);
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
@ -973,18 +970,17 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
if (popupChild) {
PRBool sizeToPopup = IsSizedToPopup(mContent, PR_FALSE);
nsIBox* ibox = nsnull;
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
NS_ASSERTION(popupChild->IsBoxFrame(), "popupChild is not box!!");
// then get its preferred size
nsSize prefSize(0,0);
nsSize minSize(0,0);
nsSize maxSize(0,0);
ibox->GetPrefSize(aState, prefSize);
ibox->GetMinSize(aState, minSize);
ibox->GetMaxSize(aState, maxSize);
popupChild->GetPrefSize(aState, prefSize);
popupChild->GetMinSize(aState, minSize);
popupChild->GetMaxSize(aState, maxSize);
BoundsCheck(minSize, prefSize, maxSize);
@ -994,37 +990,36 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
// if the pref size changed then set bounds to be the pref size
// and sync the view. And set new pref size.
if (mLastPref != prefSize) {
ibox->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
popupChild->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
RePositionPopup(aState);
mLastPref = prefSize;
}
// is the new size too small? Make sure we handle scrollbars correctly
nsIBox* child;
ibox->GetChildBox(&child);
popupChild->GetChildBox(&child);
nsRect bounds(0,0,0,0);
ibox->GetBounds(bounds);
nsRect bounds(popupChild->GetRect());
nsCOMPtr<nsIScrollableFrame> scrollframe(do_QueryInterface(child));
if (scrollframe &&
scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
popupChild->Layout(aState);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
popupChild->SetBounds(aState, bounds);
}
}
}
// layout the child
ibox->Layout(aState);
popupChild->Layout(aState);
// Only size the popups view if open.
if (mMenuOpen) {
@ -1050,11 +1045,8 @@ nsMenuFrame::MarkChildrenStyleChange()
nsIFrame* popupChild = mPopupFrames.FirstChild();
if (popupChild) {
nsIBox* ibox = nsnull;
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
return ibox->MarkChildrenStyleChange();
NS_ASSERTION(popupChild->IsBoxFrame(), "popupChild is not box!!");
return popupChild->MarkChildrenStyleChange();
}
return rv;
@ -1085,12 +1077,10 @@ nsMenuFrame::SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDebug)
return NS_OK;
while (aList) {
nsIBox* ibox = nsnull;
if (NS_SUCCEEDED(aList->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox)) && ibox) {
ibox->SetDebug(aState, aDebug);
}
if (aList->IsBoxFrame())
aList->SetDebug(aState, aDebug);
aList = aList->GetNextSibling();
aList = aList->GetNextSibling();
}
return NS_OK;
@ -1842,10 +1832,7 @@ nsMenuFrame::InsertFrames(nsPresContext* aPresContext,
nsIMenuParent *menuPar;
if (aFrameList && NS_SUCCEEDED(CallQueryInterface(aFrameList, &menuPar))) {
nsIBox *menupopup;
CallQueryInterface(aFrameList, &menupopup);
NS_ASSERTION(menupopup,"Popup is not a box!!!");
menupopup->SetParentBox(this);
NS_ASSERTION(aFrameList->IsBoxFrame(),"Popup is not a box!!!");
mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList);
nsBoxLayoutState state(aPresContext);
@ -1873,10 +1860,7 @@ nsMenuFrame::AppendFrames(nsPresContext* aPresContext,
nsIMenuParent *menuPar;
if (aFrameList && NS_SUCCEEDED(CallQueryInterface(aFrameList, &menuPar))) {
nsIBox *menupopup;
CallQueryInterface(aFrameList, &menupopup);
NS_ASSERTION(menupopup,"Popup is not a box!!!");
menupopup->SetParentBox(this);
NS_ASSERTION(aFrameList->IsBoxFrame(),"Popup is not a box!!!");
mPopupFrames.AppendFrames(nsnull, aFrameList);
nsBoxLayoutState state(aPresContext);
@ -1928,11 +1912,9 @@ nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
if (!frame) return NS_OK;
}
nsIBox* ibox = nsnull;
nsresult rv2 = frame->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
NS_ASSERTION(frame->IsBoxFrame(), "popupChild is not box!!");
ibox->GetPrefSize(aState, tmpSize);
frame->GetPrefSize(aState, tmpSize);
aSize.width = tmpSize.width;
// We now need to ensure that aSize is within the min size - max size range.
@ -2040,10 +2022,8 @@ nsMenuFrame::GetBoxInfo(nsPresContext* aPresContext, const nsHTMLReflowState& aR
frame = mPopupFrames.FirstChild();
}
nsIBox *box;
CallQueryInterface(frame, &box);
nsCalculatedBoxInfo childInfo(frame);
box->GetBoxInfo(aPresContext, aReflowState, childInfo);
frame->GetBoxInfo(aPresContext, aReflowState, childInfo);
GetRedefinedMinPrefMax(aPresContext, this, childInfo);
aSize.prefSize.width = childInfo.prefSize.width;
}

View File

@ -74,6 +74,7 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsCSSFrameConstructor.h"
#include "nsIBoxLayout.h"
#ifdef XP_WIN
#include "nsISound.h"
#endif
@ -262,15 +263,14 @@ nsMenuPopupFrame::MarkStyleChange(nsBoxLayoutState& aState)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsIBox *box;
if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) {
nsIFrame *frame;
CallQueryInterface(popupSet, &frame);
if (frame && frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
nsIFrame* frame = nsnull;
GetFrame(&frame);
return frame->GetParent()->ReflowDirtyChild(aState.PresShell(), frame);
return GetParent()->ReflowDirtyChild(aState.PresShell(), frame);
}
}
return NS_OK;
@ -281,25 +281,22 @@ nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState)
{
NeedsRecalc();
nsIFrame* frame;
GetFrame(&frame);
// only reflow if we aren't already dirty.
if (frame->GetStateBits() & NS_FRAME_IS_DIRTY) {
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
#ifdef DEBUG_COELESCED
Coelesced();
#endif
return NS_OK;
}
frame->AddStateBits(NS_FRAME_IS_DIRTY);
AddStateBits(NS_FRAME_IS_DIRTY);
nsCOMPtr<nsIBoxLayout> layout;
GetLayoutManager(getter_AddRefs(layout));
if (layout)
layout->BecameDirty(this, aState);
if (frame->GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN) {
if (GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN) {
#ifdef DEBUG_COELESCED
Coelesced();
#endif
@ -315,10 +312,11 @@ nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsIBox *box;
if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) {
nsIFrame *frame;
CallQueryInterface(popupSet, &frame);
if (frame && frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
return frame->GetParent()->ReflowDirtyChild(aState.PresShell(), frame);
@ -331,9 +329,6 @@ nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState)
NS_IMETHODIMP
nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
{
nsIFrame* frame;
GetFrame(&frame);
if (aChild != nsnull) {
nsCOMPtr<nsIBoxLayout> layout;
GetLayoutManager(getter_AddRefs(layout));
@ -342,9 +337,9 @@ nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
}
// if we are not dirty mark ourselves dirty and tell our parent we are dirty too.
if (!(frame->GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN)) {
if (!(GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN)) {
// Mark yourself as dirty and needing to be recalculated
frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
NeedsRecalc();
nsIBox* parentBox = nsnull;
@ -356,10 +351,11 @@ nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
return parentBox->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsIBox *box;
if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) {
nsIFrame *frame;
CallQueryInterface(popupSet, &frame);
if (frame && frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
box->MarkDirtyChildren(state); // Mark the popupset as dirty.
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else
return nsBox::RelayoutDirtyChild(aState, aChild);

View File

@ -221,35 +221,32 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
while (currEntry) {
nsIFrame* popupChild = currEntry->mPopupFrame;
if (popupChild) {
nsIBox* ibox = nsnull;
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
NS_ASSERTION(popupChild->IsBoxFrame(), "popupChild is not box!!");
// then get its preferred size
nsSize prefSize(0,0);
nsSize minSize(0,0);
nsSize maxSize(0,0);
ibox->GetPrefSize(aState, prefSize);
ibox->GetMinSize(aState, minSize);
ibox->GetMaxSize(aState, maxSize);
popupChild->GetPrefSize(aState, prefSize);
popupChild->GetMinSize(aState, minSize);
popupChild->GetMaxSize(aState, maxSize);
BoundsCheck(minSize, prefSize, maxSize);
// if the pref size changed then set bounds to be the pref size
// and sync the view. Also set new pref size.
// if (currEntry->mLastPref != prefSize) {
ibox->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
popupChild->SetBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
RepositionPopup(currEntry, aState);
currEntry->mLastPref = prefSize;
// }
// is the new size too small? Make sure we handle scrollbars correctly
nsIBox* child;
ibox->GetChildBox(&child);
popupChild->GetChildBox(&child);
nsRect bounds(0,0,0,0);
ibox->GetBounds(bounds);
nsRect bounds(popupChild->GetRect());
nsCOMPtr<nsIScrollableFrame> scrollframe = do_QueryInterface(child);
if (scrollframe &&
@ -257,20 +254,20 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
ibox->Layout(aState);
popupChild->Layout(aState);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
//printf("Width=%d\n",width);
ibox->SetBounds(aState, bounds);
popupChild->SetBounds(aState, bounds);
}
}
}
// layout the child
ibox->Layout(aState);
popupChild->Layout(aState);
// only size popup if open
if (currEntry->mCreateHandlerSucceeded) {
@ -315,12 +312,10 @@ nsPopupSetFrame::SetDebug(nsBoxLayoutState& aState, nsIFrame* aList, PRBool aDeb
return NS_OK;
while (aList) {
nsIBox* ibox = nsnull;
if (NS_SUCCEEDED(aList->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox)) && ibox) {
ibox->SetDebug(aState, aDebug);
}
if (aList->IsBoxFrame())
aList->SetDebug(aState, aDebug);
aList = aList->GetNextSibling();
aList = aList->GetNextSibling();
}
return NS_OK;

View File

@ -122,9 +122,6 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
mLastPoint = aEvent->refPoint;
aEvent->widget->GetScreenBounds(mWidgetRect);
nsRect bounds;
aEvent->widget->GetBounds(bounds);
*aEventStatus = nsEventStatus_eConsumeNoDefault;
doDefault = PR_FALSE;
}

View File

@ -52,7 +52,6 @@
#include "nsWidgetsCID.h"
#include "nsScrollBoxFrame.h"
#include "nsLayoutAtoms.h"
#include "nsIBox.h"
#include "nsBoxLayoutState.h"
#include "nsIBoxToBlockAdaptor.h"
#include "nsIScrollbarMediator.h"
@ -337,7 +336,7 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
kid->SetBounds(aState, childRect);
kid->Layout(aState);
kid->GetBounds(childRect);
childRect = kid->GetRect();
clientRect.Inflate(margin);
@ -369,12 +368,9 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
SyncLayout(aState);
if (adaptor) {
nsIFrame* frame;
kid->GetFrame(&frame);
nsRect r(0, 0, childRect.width, childRect.height);
nsContainerFrame::SyncFrameViewAfterReflow(presContext, frame,
frame->GetView(), &r, NS_FRAME_NO_MOVE_VIEW);
nsContainerFrame::SyncFrameViewAfterReflow(presContext, kid,
kid->GetView(), &r, NS_FRAME_NO_MOVE_VIEW);
}
nsIView* view = GetView();
@ -383,29 +379,26 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
scrollingView->ComputeScrollOffsets(PR_TRUE);
}
nsRect scrollPort;
GetBounds(scrollPort);
kid->GetBounds(childRect);
childRect = kid->GetRect();
// first see what changed
PRBool vertChanged = PR_FALSE;
PRBool horizChanged = PR_FALSE;
if (mVerticalOverflow && childRect.height <= scrollPort.height) {
if (mVerticalOverflow && childRect.height <= mRect.height) {
mVerticalOverflow = PR_FALSE;
vertChanged = PR_TRUE;
} else if (childRect.height > scrollPort.height) {
} else if (childRect.height > mRect.height) {
if (!mVerticalOverflow) {
mVerticalOverflow = PR_TRUE;
}
vertChanged = PR_TRUE;
}
if (mHorizontalOverflow && childRect.width <= scrollPort.width) {
if (mHorizontalOverflow && childRect.width <= mRect.width) {
mHorizontalOverflow = PR_FALSE;
horizChanged = PR_TRUE;
} else if (childRect.width > scrollPort.width) {
} else if (childRect.width > mRect.width) {
if (!mHorizontalOverflow) {
mHorizontalOverflow = PR_TRUE;
}

View File

@ -48,7 +48,6 @@
#include "nsIFrame.h"
#include "nsIScrollableView.h"
#include "nsIScrollableFrame.h"
#include "nsIBox.h"
class nsScrollBoxObject : public nsIScrollBoxObject, public nsBoxObject
@ -116,7 +115,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByLine(PRInt32 dlines)
// with 'overflow:hidden', the boxobject's frame is an nsXULScrollFrame,
// the <scrollbox>'s box frame is the scrollframe's "scrolled frame", and
// the <scrollbox>'s child box is a child of that.
static nsIBox* GetScrolledBox(nsBoxObject* aScrollBox) {
static nsIFrame* GetScrolledBox(nsBoxObject* aScrollBox) {
nsIFrame* frame = aScrollBox->GetFrame();
if (!frame)
return nsnull;
@ -128,11 +127,8 @@ static nsIBox* GetScrolledBox(nsBoxObject* aScrollBox) {
nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
if (!scrolledFrame)
return nsnull;
nsIBox* scrollBox;
if (NS_FAILED(CallQueryInterface(scrolledFrame, &scrollBox)))
return nsnull;
nsIBox* scrolledBox;
if (NS_FAILED(scrollBox->GetChildBox(&scrolledBox)))
if (NS_FAILED(scrolledFrame->GetChildBox(&scrolledBox)))
return nsnull;
return scrolledBox;
}
@ -143,12 +139,12 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes)
nsIScrollableView* scrollableView = GetScrollableView();
if (!scrollableView)
return NS_ERROR_FAILURE;
nsIBox* scrolledBox = GetScrolledBox(this);
nsIFrame* scrolledBox = GetScrolledBox(this);
if (!scrolledBox)
return NS_ERROR_FAILURE;
nsRect rect;
nsIBox* child;
nsIFrame* child;
// now get the scrolled boxes first child.
scrolledBox->GetChildBox(&child);
@ -162,7 +158,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes)
// first find out what index we are currently at
while(child) {
child->GetBounds(rect);
rect = child->GetRect();
if (horiz) {
diff = rect.x + rect.width/2; // use the center, to avoid rounding errors
if (diff > cp.x) {
@ -187,7 +183,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes)
while(child) {
child->GetNextBox(&child);
if (child)
child->GetBounds(rect);
rect = child->GetRect();
count++;
if (count >= dindexes)
break;
@ -196,7 +192,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes)
} else if (dindexes < 0) {
scrolledBox->GetChildBox(&child);
while(child) {
child->GetBounds(rect);
rect = child->GetRect();
if (count >= curIndex + dindexes)
break;
@ -238,7 +234,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child)
float pixelsToTwips = 0.0;
pixelsToTwips = mPresShell->GetPresContext()->PixelsToTwips();
nsIBox* scrolledBox = GetScrolledBox(this);
nsIFrame* scrolledBox = GetScrolledBox(this);
if (!scrolledBox)
return NS_ERROR_FAILURE;
@ -319,7 +315,7 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child)
float pixelsToTwips = 0.0;
pixelsToTwips = mPresShell->GetPresContext()->PixelsToTwips();
nsIBox* scrolledBox = GetScrolledBox(this);
nsIFrame* scrolledBox = GetScrolledBox(this);
if (!scrolledBox)
return NS_ERROR_FAILURE;

View File

@ -87,9 +87,7 @@ PRInt32 nsSliderFrame::gSnapMultiplier = 6;
static already_AddRefed<nsIContent>
GetContentOfBox(nsIBox *aBox)
{
nsIFrame *frame;
aBox->GetFrame(&frame);
nsIContent* content = frame->GetContent();
nsIContent* content = aBox->GetContent();
NS_IF_ADDREF(content);
return content;
}
@ -301,8 +299,7 @@ nsSliderFrame::Paint(nsPresContext* aPresContext,
GetChildBox(&thumb);
if (thumb) {
nsRect thumbRect;
thumb->GetBounds(thumbRect);
nsRect thumbRect(thumb->GetRect());
nsMargin m;
thumb->GetMargin(m);
thumbRect.Inflate(m);
@ -420,8 +417,7 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
else
thumbRect.y += pos;
nsRect oldThumbRect;
thumbBox->GetBounds(oldThumbRect);
nsRect oldThumbRect(thumbBox->GetRect());
LayoutChildAt(aState, thumbBox, thumbRect);
@ -584,13 +580,7 @@ nsSliderFrame::GetScrollbar()
if (scrollbar == nsnull)
return this;
nsIBox* ibox = nsnull;
scrollbar->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
if (ibox == nsnull)
return this;
return ibox;
return scrollbar->IsBoxFrame() ? scrollbar : this;
}
void
@ -1012,10 +1002,7 @@ nsSliderFrame::EnsureOrient()
{
nsIBox* scrollbarBox = GetScrollbar();
nsIFrame* frame = nsnull;
scrollbarBox->GetFrame(&frame);
PRBool isHorizontal = frame->GetStateBits() & NS_STATE_IS_HORIZONTAL;
PRBool isHorizontal = (scrollbarBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
if (isHorizontal)
mState |= NS_STATE_IS_HORIZONTAL;
else

View File

@ -339,14 +339,11 @@ nsSplitterFrame::Init(nsPresContext* aPresContext,
// determine orientation of parent, and if vertical, set orient to vertical
// on splitter content, then re-resolve style
nsIBox* boxParent;
if (aParent)
CallQueryInterface(aParent, &boxParent);
// |newContext| to Release the reference after the call to nsBoxFrame::Init
nsRefPtr<nsStyleContext> newContext;
if (boxParent) {
if (aParent && aParent->IsBoxFrame()) {
PRBool isHorizontal;
boxParent->GetOrientation(isHorizontal);
aParent->GetOrientation(isHorizontal);
if (!isHorizontal) {
nsAutoString str;
aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::orient, str);
@ -390,10 +387,7 @@ nsSplitterFrame::Init(nsPresContext* aPresContext,
NS_IMETHODIMP
nsSplitterFrame::DoLayout(nsBoxLayoutState& aState)
{
nsIFrame* frame;
GetFrame(&frame);
if (frame->GetStateBits() & NS_FRAME_FIRST_REFLOW)
if (GetStateBits() & NS_FRAME_FIRST_REFLOW)
{
GetParentBox(&mInner->mParentBox);
mInner->UpdateState();
@ -648,8 +642,6 @@ nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent)
void
nsSplitterFrameInner::AddListener(nsPresContext* aPresContext)
{
nsIFrame* thumbFrame = mOuter->GetFirstChild(nsnull);
nsCOMPtr<nsIDOMEventReceiver>
receiver(do_QueryInterface(mOuter->GetContent()));
@ -784,10 +776,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
while (nsnull != childBox)
{
nsIFrame* childFrame = nsnull;
childBox->GetFrame(&childFrame);
nsIContent* content = childFrame->GetContent();
nsIContent* content = childBox->GetContent();
nsCOMPtr<nsIAtom> atom;
nsresult rv;
nsCOMPtr<nsIXBLService> xblService =
@ -819,8 +808,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
nsMargin margin(0,0,0,0);
childBox->GetMargin(margin);
nsRect r(0,0,0,0);
childBox->GetBounds(r);
nsRect r(childBox->GetRect());
r.Inflate(margin);
nsAutoString fixed, hidden;
@ -986,9 +974,7 @@ nsSplitterFrameInner::UpdateState()
nsFrameNavigator::GetChildBeforeAfter(mOuter->mPresContext, splitter,
(direction == Before));
if (splitterSibling) {
nsIFrame* splitterSiblingFrame = nsnull;
splitterSibling->GetFrame(&splitterSiblingFrame);
nsIContent* sibling = splitterSiblingFrame->GetContent();
nsIContent* sibling = splitterSibling->GetContent();
if (sibling) {
if (mState == Collapsed) {
// Collapsed -> Open
@ -1011,10 +997,7 @@ nsSplitterFrameInner::UpdateState()
void
nsSplitterFrameInner::EnsureOrient()
{
nsIFrame* frame = nsnull;
mParentBox->GetFrame(&frame);
PRBool isHorizontal = !(frame->GetStateBits() & NS_STATE_IS_HORIZONTAL);
PRBool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
if (isHorizontal)
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
else
@ -1035,14 +1018,11 @@ nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext)
if (realTimeDrag) {
nsIFrame* frame = nsnull;
mParentBox->GetFrame(&frame);
nsIView* view = frame->GetView();
nsIView* view = mParentBox->GetView();
if (!view) {
nsPoint offset;
frame->GetOffsetFromView(aPresContext, offset, &view);
mParentBox->GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
}
aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
@ -1088,8 +1068,7 @@ nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildB
nscoord current = 0;
nsRect rect(0,0,0,0);
aChildBox->GetBounds(rect);
nsRect rect(aChildBox->GetRect());
if (aIsHorizontal)
current = rect.width;
else
@ -1120,10 +1099,7 @@ nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildB
attribute = nsHTMLAtoms::height;
}
nsIFrame* childFrame = nsnull;
aChildBox->GetFrame(&childFrame);
nsIContent* content = childFrame->GetContent();
nsIContent* content = aChildBox->GetContent();
// set its preferred size.
nsAutoString prefValue;

View File

@ -92,25 +92,19 @@ nsSprocketLayout::nsSprocketLayout()
PRBool
nsSprocketLayout::IsHorizontal(nsIBox* aBox)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
return frame->GetStateBits() & NS_STATE_IS_HORIZONTAL;
return (aBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
}
void
nsSprocketLayout::GetFrameState(nsIBox* aBox, nsFrameState& aState)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
aState = frame->GetStateBits();
aState = aBox->GetStateBits();
}
static PRUint8
GetFrameDirection(nsIBox* aBox)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
return frame->GetStyleVisibility()->mDirection;
return aBox->GetStyleVisibility()->mDirection;
}
static void
@ -223,7 +217,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
aBox->GetChildBox(&child);
while(child)
{
nsContainerBox::LayoutChildAt(aState, child, nsRect(0,0,0,0));
nsBoxFrame::LayoutChildAt(aState, child, nsRect(0,0,0,0));
child->GetNextBox(&child);
}
return NS_OK;
@ -509,10 +503,9 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
// We computed a childRect. Now we want to set the bounds of the child to be that rect.
// If our old rect is different, then we know our size changed and we cache that fact
// in the |sizeChanged| variable.
nsRect oldRect(0,0,0,0);
nsRect oldRect(child->GetRect());
PRBool sizeChanged = PR_FALSE;
child->GetBounds(oldRect);
child->SetBounds(aState, childRect);
sizeChanged = (childRect.width != oldRect.width || childRect.height != oldRect.height);
@ -549,8 +542,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
// If the child was a block or inline (e.g., HTML) it may have changed its rect *during* layout.
// We have to check for this.
nsRect newChildRect;
child->GetBounds(newChildRect);
nsRect newChildRect(child->GetRect());
if (newChildRect != childRect) {
#ifdef DEBUG_GROW
@ -669,8 +661,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
if (tmpClientRect.width > contentRect.width || tmpClientRect.height > contentRect.height)
{
// if it did reset our bounds.
nsRect bounds(0,0,0,0);
aBox->GetBounds(bounds);
nsRect bounds(aBox->GetRect());
if (tmpClientRect.width > contentRect.width)
bounds.width = tmpClientRect.width;
@ -695,8 +686,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
while (child)
{
nsRect childRect;
child->GetBounds(childRect);
nsRect childRect(child->GetRect());
childRect.x += (x - origX);
childRect.y += (y - origY);
child->SetBounds(aState, childRect);

View File

@ -191,16 +191,14 @@ nsStackLayout::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize
nsSize offset(0,0);
// get the left and top offsets
nsIFrame* frame;
aChild->GetFrame(&frame);
// As an optimization, we cache the fact that we are not positioned to avoid
// wasting time fetching attributes and checking style data.
if (frame->GetStateBits() & NS_STATE_STACK_NOT_POSITIONED)
if (aChild->GetStateBits() & NS_STATE_STACK_NOT_POSITIONED)
return PR_FALSE;
PRBool offsetSpecified = PR_FALSE;
const nsStylePosition* pos = frame->GetStylePosition();
const nsStylePosition* pos = aChild->GetStylePosition();
if (eStyleUnit_Coord == pos->mOffset.GetLeftUnit()) {
nsStyleCoord left = 0;
pos->mOffset.GetLeft(left);
@ -215,7 +213,7 @@ nsStackLayout::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize
offsetSpecified = PR_TRUE;
}
nsIContent* content = frame->GetContent();
nsIContent* content = aChild->GetContent();
if (content) {
nsPresContext* presContext = aState.PresContext();
@ -242,9 +240,9 @@ nsStackLayout::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize
if (!offsetSpecified) {
// If no offset was specified at all, then we cache this fact to avoid requerying
// CSS or the content model.
frame->AddStateBits(NS_STATE_STACK_NOT_POSITIONED);
aChild->AddStateBits(NS_STATE_STACK_NOT_POSITIONED);
}
return offsetSpecified;
}
@ -275,9 +273,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
if (childRect.height < 0)
childRect.height = 0;
nsRect oldRect;
child->GetBounds(oldRect);
nsRect oldRect(child->GetRect());
PRBool sizeChanged = (oldRect != childRect);
// only lay out dirty children or children whose sizes have changed
@ -317,7 +313,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
child->Layout(aState);
// Get the child's new rect.
child->GetBounds(childRect);
childRect = child->GetRect();
childRect.Inflate(margin);
// Did the child push back on us and get bigger?
@ -355,8 +351,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
// if some HTML inside us got bigger we need to force ourselves to
// get bigger
nsRect bounds;
aBox->GetBounds(bounds);
nsRect bounds(aBox->GetRect());
nsMargin bp;
aBox->GetBorderAndPadding(bp);
clientRect.Inflate(bp);

View File

@ -43,7 +43,6 @@
#include "nsIDOMElement.h"
#include "nsIBoxObject.h"
#include "nsIDocument.h"
#include "nsIBox.h"
#include "nsTreeColumns.h"
#include "nsTreeUtils.h"
#include "nsStyleContext.h"
@ -512,23 +511,18 @@ nsTreeColumns::EnsureColumns()
if (!colsFrame)
return;
nsIBox* colsBox;
CallQueryInterface(colsFrame, &colsBox);
nsIBox* colBox = nsnull;
colsBox->GetChildBox(&colBox);
colsFrame->GetChildBox(&colBox);
NS_IF_RELEASE(mFirstColumn);
nsTreeColumn* currCol = nsnull;
while (colBox) {
nsIFrame* colFrame = nsnull;
colBox->GetFrame(&colFrame);
nsIContent* colContent = colFrame->GetContent();
nsIContent* colContent = colBox->GetContent();
nsINodeInfo *ni = colContent->GetNodeInfo();
if (ni && ni->Equals(nsXULAtoms::treecol, kNameSpaceID_XUL)) {
// Create a new column structure.
nsTreeColumn* col = new nsTreeColumn(this, colFrame);
nsTreeColumn* col = new nsTreeColumn(this, colBox);
if (!col)
return;