Landing changes to wrap XUL windows in a box frame so that we can support

intrinsic sizing of windows.  (Unlike HTML and XML, we are no longer wrapped
in an area frame. We are instead wrapped in a box frame.)

Also included is a patch for the table code, since it crashes inside boxes
because of a bug in its incremental reflow code.

nsISpaceManager was touched to give it a GetIID method so that it could be
used with nsCOMPtrs.
This commit is contained in:
hyatt%netscape.com 1999-07-02 05:28:32 +00:00
Родитель f260c11c18
Коммит 9b9522ae73
7 изменённых файлов: 96 добавлений и 15 удалений

Просмотреть файл

@ -93,7 +93,7 @@ nsresult
NS_NewTitledButtonFrame ( nsIFrame** aNewFrame );
nsresult
NS_NewBoxFrame ( nsIFrame** aNewFrame );
NS_NewBoxFrame ( nsIFrame** aNewFrame, PRUint32 aFlags );
nsresult
NS_NewSliderFrame ( nsIFrame** aNewFrame );
@ -1807,7 +1807,8 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext,
(nsXULAtoms::tabbox == tag.get()) ||
(nsXULAtoms::tabpanel == tag.get()) ||
(nsXULAtoms::tabpage == tag.get()) ||
(nsXULAtoms::progressmeter == tag.get() )) {
(nsXULAtoms::progressmeter == tag.get()) ||
(nsXULAtoms::window == tag.get())) {
return PR_TRUE;
}
#endif
@ -1928,7 +1929,15 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// Create an area frame for the document element
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame);
PRInt32 nameSpaceID;
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
nameSpaceID == nsXULAtoms::nameSpaceID) {
NS_NewBoxFrame(&areaFrame);
}
else {
NS_NewAreaFrame(&areaFrame);
}
areaFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
styleContext, PR_FALSE);
@ -1996,9 +2005,20 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// XXX Until we clean up how painting damage is handled, we need to use the
// flag that says that this is the body...
NS_NewDocumentElementFrame(&areaFrame);
PRInt32 nameSpaceID;
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
nameSpaceID == nsXULAtoms::nameSpaceID) {
NS_NewBoxFrame(&areaFrame, NS_BLOCK_DOCUMENT_ROOT);
}
else {
NS_NewDocumentElementFrame(&areaFrame);
}
areaFrame->Init(*aPresContext, aDocElement, parFrame, styleContext, nsnull);
// Add a mapping from content object to frame. The primary frame is the scroll
// frame, because it contains the area frame
presShell->SetPrimaryFrameFor(aDocElement, scrollFrame ? scrollFrame : areaFrame);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
@ -3051,7 +3071,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext,
#endif // XP_MENUS
// BOX CONSTRUCTION
else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox || aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) {
else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox ||
aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) {
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewBoxFrame(&newFrame);

Просмотреть файл

@ -80,6 +80,8 @@ struct nsBandData {
*/
class nsISpaceManager : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_ISPACEMANAGER_IID; return iid; }
/**
* Get the frame that's associated with the space manager. This frame created
* the space manager, and the world coordinate space is relative to this frame.

Просмотреть файл

@ -93,7 +93,7 @@ nsresult
NS_NewTitledButtonFrame ( nsIFrame** aNewFrame );
nsresult
NS_NewBoxFrame ( nsIFrame** aNewFrame );
NS_NewBoxFrame ( nsIFrame** aNewFrame, PRUint32 aFlags );
nsresult
NS_NewSliderFrame ( nsIFrame** aNewFrame );
@ -1807,7 +1807,8 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext,
(nsXULAtoms::tabbox == tag.get()) ||
(nsXULAtoms::tabpanel == tag.get()) ||
(nsXULAtoms::tabpage == tag.get()) ||
(nsXULAtoms::progressmeter == tag.get() )) {
(nsXULAtoms::progressmeter == tag.get()) ||
(nsXULAtoms::window == tag.get())) {
return PR_TRUE;
}
#endif
@ -1928,7 +1929,15 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// Create an area frame for the document element
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame);
PRInt32 nameSpaceID;
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
nameSpaceID == nsXULAtoms::nameSpaceID) {
NS_NewBoxFrame(&areaFrame);
}
else {
NS_NewAreaFrame(&areaFrame);
}
areaFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
styleContext, PR_FALSE);
@ -1996,9 +2005,20 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// XXX Until we clean up how painting damage is handled, we need to use the
// flag that says that this is the body...
NS_NewDocumentElementFrame(&areaFrame);
PRInt32 nameSpaceID;
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
nameSpaceID == nsXULAtoms::nameSpaceID) {
NS_NewBoxFrame(&areaFrame, NS_BLOCK_DOCUMENT_ROOT);
}
else {
NS_NewDocumentElementFrame(&areaFrame);
}
areaFrame->Init(*aPresContext, aDocElement, parFrame, styleContext, nsnull);
// Add a mapping from content object to frame. The primary frame is the scroll
// frame, because it contains the area frame
presShell->SetPrimaryFrameFor(aDocElement, scrollFrame ? scrollFrame : areaFrame);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
@ -3051,7 +3071,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext,
#endif // XP_MENUS
// BOX CONSTRUCTION
else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox || aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) {
else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox ||
aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) {
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
rv = NS_NewBoxFrame(&newFrame);

Просмотреть файл

@ -320,6 +320,9 @@ nsresult nsTableOuterFrame::IR_TargetIsChild(nsIPresContext& aPresContext
{
TDBG_S(gsDebugIR,"TOF IR: IR_TargetIsChild\n");
nsresult rv;
if (!aNextFrame)
return NS_OK;
if (aNextFrame == mInnerTableFrame) {
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
}

Просмотреть файл

@ -320,6 +320,9 @@ nsresult nsTableOuterFrame::IR_TargetIsChild(nsIPresContext& aPresContext
{
TDBG_S(gsDebugIR,"TOF IR: IR_TargetIsChild\n");
nsresult rv;
if (!aNextFrame)
return NS_OK;
if (aNextFrame == mInnerTableFrame) {
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
}

Просмотреть файл

@ -35,18 +35,20 @@
#include "nsXULAtoms.h"
#include "nsIReflowCommand.h"
#include "nsIContent.h"
#include "nsSpaceManager.h"
#include "nsHTMLParts.h"
#include "nsIViewManager.h"
#define CONSTANT float(0.0)
nsresult
NS_NewBoxFrame ( nsIFrame** aNewFrame )
NS_NewBoxFrame ( nsIFrame** aNewFrame, PRUint32 aFlags )
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsBoxFrame* it = new nsBoxFrame;
nsBoxFrame* it = new nsBoxFrame(aFlags);
if (nsnull == it)
return NS_ERROR_OUT_OF_MEMORY;
@ -55,10 +57,11 @@ NS_NewBoxFrame ( nsIFrame** aNewFrame )
} // NS_NewBoxFrame
nsBoxFrame::nsBoxFrame()
nsBoxFrame::nsBoxFrame(PRUint32 aFlags)
{
// if not otherwise specified boxes by default are horizontal.
mHorizontal = PR_TRUE;
mFlags = aFlags;
}
/**
@ -81,6 +84,9 @@ nsBoxFrame::Init(nsIPresContext& aPresContext,
else if (value.EqualsIgnoreCase("horizontal"))
mHorizontal = PR_TRUE;
nsSpaceManager* spaceManager = new nsSpaceManager(this);
mSpaceManager = spaceManager;
return rv;
}
@ -198,6 +204,16 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// If we have a space manager, then set it in the reflow state
if (mSpaceManager) {
// Modify the reflow state and set the space manager
nsHTMLReflowState& reflowState = (nsHTMLReflowState&)aReflowState;
reflowState.spaceManager = mSpaceManager;
// Clear the spacemanager's regions.
mSpaceManager->ClearRegions();
}
//--------------------------------------------------------------------
//-------------- figure out the rect we need to fit into -------------
//--------------------------------------------------------------------
@ -284,6 +300,15 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext,
aStatus = NS_FRAME_COMPLETE;
nsRect damageArea(0,0,0,0);
damageArea.y = 0;
damageArea.height = aDesiredSize.height;
damageArea.width = aDesiredSize.width;
if ((NS_BLOCK_DOCUMENT_ROOT & mFlags) && !damageArea.IsEmpty()) {
Invalidate(damageArea);
}
return NS_OK;
}

Просмотреть файл

@ -28,8 +28,11 @@
#ifndef nsBoxFrame_h___
#define nsBoxFrame_h___
#include "nsCOMPtr.h"
#include "nsHTMLContainerFrame.h"
#include "nsIBox.h"
#include "nsISpaceManager.h"
class nsHTMLReflowCommand;
class nsCalculatedBoxInfo : public nsBoxInfo {
@ -49,7 +52,7 @@ class nsBoxFrame : public nsHTMLContainerFrame, public nsIBox
{
public:
friend nsresult NS_NewBoxFrame(nsIFrame** aNewFrame);
friend nsresult NS_NewBoxFrame(nsIFrame** aNewFrame, PRUint32 aFlags = 0);
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
@ -100,7 +103,7 @@ public:
protected:
nsBoxFrame();
nsBoxFrame(PRUint32 aFlags = 0);
virtual void GetRedefinedMinPrefMax(nsIFrame* aFrame, nsBoxInfo& aSize);
virtual nsresult GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsBoxInfo& aSize);
@ -149,6 +152,9 @@ private:
// Should use a dynamic array.
nsCalculatedBoxInfo mSprings[100];
nscoord mSpringCount;
nsCOMPtr<nsISpaceManager> mSpaceManager; // We own this [OWNER].
PRUint32 mFlags;
}; // class nsBoxFrame