diff --git a/content/shared/public/nsXULAtoms.h b/content/shared/public/nsXULAtoms.h index 1fff378681d7..a467d0645d95 100644 --- a/content/shared/public/nsXULAtoms.h +++ b/content/shared/public/nsXULAtoms.h @@ -75,6 +75,13 @@ public: static nsIAtom* box; static nsIAtom* flex; + static nsIAtom* deck; + static nsIAtom* tabcontrol; + static nsIAtom* tabbox; + static nsIAtom* tab; + static nsIAtom* tabpanel; + static nsIAtom* tabpage; + static nsIAtom* widget; static nsIAtom* window; }; diff --git a/content/shared/src/nsXULAtoms.cpp b/content/shared/src/nsXULAtoms.cpp index b9a512e6308a..7fcc19c13ff2 100644 --- a/content/shared/src/nsXULAtoms.cpp +++ b/content/shared/src/nsXULAtoms.cpp @@ -57,6 +57,14 @@ nsIAtom* nsXULAtoms::mode; nsIAtom* nsXULAtoms::box; nsIAtom* nsXULAtoms::flex; +nsIAtom* nsXULAtoms::tabcontrol; +nsIAtom* nsXULAtoms::tabbox; +nsIAtom* nsXULAtoms::tab; +nsIAtom* nsXULAtoms::tabpanel; +nsIAtom* nsXULAtoms::tabpage; +nsIAtom* nsXULAtoms::deck; + + nsIAtom* nsXULAtoms::widget; nsIAtom* nsXULAtoms::window; @@ -108,6 +116,14 @@ void nsXULAtoms::AddrefAtoms() { box = NS_NewAtom("box"); flex = NS_NewAtom("flex"); + deck = NS_NewAtom("deck"); + tabcontrol = NS_NewAtom("tabcontrol"); + tab = NS_NewAtom("tab"); + tabpanel = NS_NewAtom("tabpanel"); + tabpage = NS_NewAtom("tabpage"); + tabbox = NS_NewAtom("tabbox"); + + widget = NS_NewAtom("widget"); window = NS_NewAtom("window"); } @@ -150,6 +166,13 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(flex); + NS_RELEASE(deck); + NS_RELEASE(tabcontrol); + NS_RELEASE(tab); + NS_RELEASE(tabbox); + NS_RELEASE(tabpanel); + NS_RELEASE(tabpage); + NS_RELEASE(widget); NS_RELEASE(window); NS_IF_RELEASE(gNameSpaceManager); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index e26da9dc0c9b..e571f5b54150 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -74,6 +74,12 @@ #include "nsTreeIndentationFrame.h" #include "nsTreeCellFrame.h" +nsresult +NS_NewTabFrame ( nsIFrame*& aNewFrame ); + +nsresult +NS_NewDeckFrame ( nsIFrame*& aNewFrame ); + nsresult NS_NewProgressMeterFrame ( nsIFrame*& aNewFrame ); @@ -1578,7 +1584,11 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treeindentation == tag.get()) || (nsXULAtoms::toolbox == tag.get()) || (nsXULAtoms::toolbar == tag.get()) || - (nsXULAtoms::box == tag.get()) || + (nsXULAtoms::deck == tag.get()) || + (nsXULAtoms::tabcontrol == tag.get()) || + (nsXULAtoms::tabbox == tag.get()) || + (nsXULAtoms::tabpanel == tag.get()) || + (nsXULAtoms::tabpage == tag.get()) || (nsXULAtoms::progressmeter == tag.get() )) { return PR_TRUE; } @@ -2650,7 +2660,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // End of PROGRESS METER CONSTRUCTION logic // BOX CONSTRUCTION - else if (aTag == nsXULAtoms::box) { + else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox || aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) { processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewBoxFrame(newFrame); @@ -2665,6 +2675,22 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, } // End of TITLED BUTTON CONSTRUCTION logic + // DECK CONSTRUCTION + else if (aTag == nsXULAtoms::deck || aTag == nsXULAtoms::tabpanel) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewDeckFrame(newFrame); + } + // End of DECK CONSTRUCTION logic + + // TAB CONSTRUCTION + else if (aTag == nsXULAtoms::tab) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewTabFrame(newFrame); + } + // End of TAB CONSTRUCTION logic + } // If we succeeded in creating a frame then initialize it, process its diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index d751745489ba..ca731e04df20 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -15,6 +15,9 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +#include "nsHTMLButtonControlFrame.h" + #include "nsCOMPtr.h" #include "nsHTMLContainerFrame.h" #include "nsFormControlHelper.h" @@ -52,101 +55,6 @@ static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID); static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); -class nsHTMLButtonControlFrame : public nsHTMLContainerFrame, - public nsIFormControlFrame -{ -public: - nsHTMLButtonControlFrame(); - - - - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - NS_IMETHOD Paint(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - nsFramePaintLayer aWhichLayer); - - NS_IMETHOD Reflow(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus); - - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, - nsGUIEvent* aEvent, - nsEventStatus& aEventStatus); - - NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); - - NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - - NS_IMETHOD Init(nsIPresContext& aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* asPrevInFlow); - - NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) ; - - - - NS_IMETHOD GetFrameName(nsString& aResult) const { - return MakeFrameName("ButtonControl", aResult); - } - - virtual nsresult RequiresWidget(PRBool &aRequiresWidget); - - - virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter); - NS_IMETHOD GetType(PRInt32* aType) const; - NS_IMETHOD GetName(nsString* aName); - NS_IMETHOD GetValue(nsString* aName); - virtual PRInt32 GetMaxNumValues(); - virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, - nsString* aValues, nsString* aNames); - virtual void MouseClicked(nsIPresContext* aPresContext); - virtual void Reset() {}; - virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; } - - void SetFocus(PRBool aOn, PRBool aRepaint); - - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - nsFont& aFont); - - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalInsidePadding(float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - - void GetDefaultLabel(nsString& aLabel); - - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue); - -protected: - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - void GetTranslatedRect(nsRect& aRect); - - PRIntn GetSkipSides() const; - PRBool mInline; - nsFormFrame* mFormFrame; - nsCursor mPreviousCursor; - nsRect mTranslatedRect; - PRBool mDidInit; - nsButtonFrameRenderer mRenderer; -}; - nsresult NS_NewHTMLButtonControlFrame(nsIFrame*& aResult) { @@ -587,8 +495,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* nextFrame; // Remove the next frame from the reflow path - aReflowState.reflowCommand->GetNext(nextFrame); - NS_ASSERTION(nextFrame == firstKid, "unexpected next frame"); + aReflowState.reflowCommand->GetNext(nextFrame); } } diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h new file mode 100644 index 000000000000..a51107f7f8c4 --- /dev/null +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsHTMLButtonControlFrame_h___ +#define nsHTMLButtonControlFrame_h___ + +#include "nsCOMPtr.h" +#include "nsHTMLContainerFrame.h" +#include "nsFormControlHelper.h" +#include "nsIFormControlFrame.h" +#include "nsHTMLParts.h" +#include "nsIFormControl.h" +#include "nsFormFrame.h" + +#include "nsIRenderingContext.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIStyleContext.h" +#include "nsLeafFrame.h" +#include "nsCSSRendering.h" +#include "nsHTMLIIDs.h" +#include "nsISupports.h" +#include "nsHTMLAtoms.h" +#include "nsIImage.h" +#include "nsStyleUtil.h" +#include "nsDOMEvent.h" +#include "nsStyleConsts.h" +#include "nsIHTMLAttributes.h" +#include "nsGenericHTMLElement.h" +#include "nsIWidget.h" +#include "nsIComponentManager.h" +#include "nsIView.h" +#include "nsIViewManager.h" +#include "nsViewsCID.h" +#include "nsColor.h" +#include "nsIDocument.h" +#include "nsButtonFrameRenderer.h" + +class nsHTMLButtonControlFrame : public nsHTMLContainerFrame, + public nsIFormControlFrame +{ +public: + nsHTMLButtonControlFrame(); + + + + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer); + + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); + + NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + nsGUIEvent* aEvent, + nsEventStatus& aEventStatus); + + NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); + + NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, + nsIAtom* aListName, + nsIFrame* aChildList); + + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* asPrevInFlow); + + NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, + nsIStyleContext* aParentContext, + PRInt32 aParentChange, + nsStyleChangeList* aChangeList, + PRInt32* aLocalChange) ; + + + + NS_IMETHOD GetFrameName(nsString& aResult) const { + return MakeFrameName("ButtonControl", aResult); + } + + virtual nsresult RequiresWidget(PRBool &aRequiresWidget); + + + virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter); + NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD GetName(nsString* aName); + NS_IMETHOD GetValue(nsString* aName); + virtual PRInt32 GetMaxNumValues(); + virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, + nsString* aValues, nsString* aNames); + virtual void MouseClicked(nsIPresContext* aPresContext); + virtual void Reset() {}; + virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; } + + void SetFocus(PRBool aOn, PRBool aRepaint); + + NS_IMETHOD GetFont(nsIPresContext* aPresContext, + nsFont& aFont); + + NS_IMETHOD GetFormContent(nsIContent*& aContent) const; + virtual nscoord GetVerticalInsidePadding(float aPixToTwip, + nscoord aInnerHeight) const; + virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, + float aPixToTwip, + nscoord aInnerWidth, + nscoord aCharWidth) const; + + void GetDefaultLabel(nsString& aLabel); + + // nsIFormControlFrame + NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue); + NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue); + +protected: + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + void GetTranslatedRect(nsRect& aRect); + + PRIntn GetSkipSides() const; + PRBool mInline; + nsFormFrame* mFormFrame; + nsCursor mPreviousCursor; + nsRect mTranslatedRect; + PRBool mDidInit; + nsButtonFrameRenderer mRenderer; +}; + +#endif + + + + diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index d751745489ba..ca731e04df20 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -15,6 +15,9 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +#include "nsHTMLButtonControlFrame.h" + #include "nsCOMPtr.h" #include "nsHTMLContainerFrame.h" #include "nsFormControlHelper.h" @@ -52,101 +55,6 @@ static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID); static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); -class nsHTMLButtonControlFrame : public nsHTMLContainerFrame, - public nsIFormControlFrame -{ -public: - nsHTMLButtonControlFrame(); - - - - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - NS_IMETHOD Paint(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - nsFramePaintLayer aWhichLayer); - - NS_IMETHOD Reflow(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus); - - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, - nsGUIEvent* aEvent, - nsEventStatus& aEventStatus); - - NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); - - NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - - NS_IMETHOD Init(nsIPresContext& aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* asPrevInFlow); - - NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) ; - - - - NS_IMETHOD GetFrameName(nsString& aResult) const { - return MakeFrameName("ButtonControl", aResult); - } - - virtual nsresult RequiresWidget(PRBool &aRequiresWidget); - - - virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter); - NS_IMETHOD GetType(PRInt32* aType) const; - NS_IMETHOD GetName(nsString* aName); - NS_IMETHOD GetValue(nsString* aName); - virtual PRInt32 GetMaxNumValues(); - virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, - nsString* aValues, nsString* aNames); - virtual void MouseClicked(nsIPresContext* aPresContext); - virtual void Reset() {}; - virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; } - - void SetFocus(PRBool aOn, PRBool aRepaint); - - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - nsFont& aFont); - - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalInsidePadding(float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - - void GetDefaultLabel(nsString& aLabel); - - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue); - -protected: - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - void GetTranslatedRect(nsRect& aRect); - - PRIntn GetSkipSides() const; - PRBool mInline; - nsFormFrame* mFormFrame; - nsCursor mPreviousCursor; - nsRect mTranslatedRect; - PRBool mDidInit; - nsButtonFrameRenderer mRenderer; -}; - nsresult NS_NewHTMLButtonControlFrame(nsIFrame*& aResult) { @@ -587,8 +495,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* nextFrame; // Remove the next frame from the reflow path - aReflowState.reflowCommand->GetNext(nextFrame); - NS_ASSERTION(nextFrame == firstKid, "unexpected next frame"); + aReflowState.reflowCommand->GetNext(nextFrame); } } diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.h b/layout/html/forms/src/nsHTMLButtonControlFrame.h new file mode 100644 index 000000000000..a51107f7f8c4 --- /dev/null +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.h @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsHTMLButtonControlFrame_h___ +#define nsHTMLButtonControlFrame_h___ + +#include "nsCOMPtr.h" +#include "nsHTMLContainerFrame.h" +#include "nsFormControlHelper.h" +#include "nsIFormControlFrame.h" +#include "nsHTMLParts.h" +#include "nsIFormControl.h" +#include "nsFormFrame.h" + +#include "nsIRenderingContext.h" +#include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIStyleContext.h" +#include "nsLeafFrame.h" +#include "nsCSSRendering.h" +#include "nsHTMLIIDs.h" +#include "nsISupports.h" +#include "nsHTMLAtoms.h" +#include "nsIImage.h" +#include "nsStyleUtil.h" +#include "nsDOMEvent.h" +#include "nsStyleConsts.h" +#include "nsIHTMLAttributes.h" +#include "nsGenericHTMLElement.h" +#include "nsIWidget.h" +#include "nsIComponentManager.h" +#include "nsIView.h" +#include "nsIViewManager.h" +#include "nsViewsCID.h" +#include "nsColor.h" +#include "nsIDocument.h" +#include "nsButtonFrameRenderer.h" + +class nsHTMLButtonControlFrame : public nsHTMLContainerFrame, + public nsIFormControlFrame +{ +public: + nsHTMLButtonControlFrame(); + + + + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer); + + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); + + NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + nsGUIEvent* aEvent, + nsEventStatus& aEventStatus); + + NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); + + NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, + nsIAtom* aListName, + nsIFrame* aChildList); + + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* asPrevInFlow); + + NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, + nsIStyleContext* aParentContext, + PRInt32 aParentChange, + nsStyleChangeList* aChangeList, + PRInt32* aLocalChange) ; + + + + NS_IMETHOD GetFrameName(nsString& aResult) const { + return MakeFrameName("ButtonControl", aResult); + } + + virtual nsresult RequiresWidget(PRBool &aRequiresWidget); + + + virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter); + NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD GetName(nsString* aName); + NS_IMETHOD GetValue(nsString* aName); + virtual PRInt32 GetMaxNumValues(); + virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, + nsString* aValues, nsString* aNames); + virtual void MouseClicked(nsIPresContext* aPresContext); + virtual void Reset() {}; + virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; } + + void SetFocus(PRBool aOn, PRBool aRepaint); + + NS_IMETHOD GetFont(nsIPresContext* aPresContext, + nsFont& aFont); + + NS_IMETHOD GetFormContent(nsIContent*& aContent) const; + virtual nscoord GetVerticalInsidePadding(float aPixToTwip, + nscoord aInnerHeight) const; + virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, + float aPixToTwip, + nscoord aInnerWidth, + nscoord aCharWidth) const; + + void GetDefaultLabel(nsString& aLabel); + + // nsIFormControlFrame + NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue); + NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue); + +protected: + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + void GetTranslatedRect(nsRect& aRect); + + PRIntn GetSkipSides() const; + PRBool mInline; + nsFormFrame* mFormFrame; + nsCursor mPreviousCursor; + nsRect mTranslatedRect; + PRBool mDidInit; + nsButtonFrameRenderer mRenderer; +}; + +#endif + + + + diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index e26da9dc0c9b..e571f5b54150 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -74,6 +74,12 @@ #include "nsTreeIndentationFrame.h" #include "nsTreeCellFrame.h" +nsresult +NS_NewTabFrame ( nsIFrame*& aNewFrame ); + +nsresult +NS_NewDeckFrame ( nsIFrame*& aNewFrame ); + nsresult NS_NewProgressMeterFrame ( nsIFrame*& aNewFrame ); @@ -1578,7 +1584,11 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::treeindentation == tag.get()) || (nsXULAtoms::toolbox == tag.get()) || (nsXULAtoms::toolbar == tag.get()) || - (nsXULAtoms::box == tag.get()) || + (nsXULAtoms::deck == tag.get()) || + (nsXULAtoms::tabcontrol == tag.get()) || + (nsXULAtoms::tabbox == tag.get()) || + (nsXULAtoms::tabpanel == tag.get()) || + (nsXULAtoms::tabpage == tag.get()) || (nsXULAtoms::progressmeter == tag.get() )) { return PR_TRUE; } @@ -2650,7 +2660,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // End of PROGRESS METER CONSTRUCTION logic // BOX CONSTRUCTION - else if (aTag == nsXULAtoms::box) { + else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox || aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) { processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewBoxFrame(newFrame); @@ -2665,6 +2675,22 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, } // End of TITLED BUTTON CONSTRUCTION logic + // DECK CONSTRUCTION + else if (aTag == nsXULAtoms::deck || aTag == nsXULAtoms::tabpanel) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewDeckFrame(newFrame); + } + // End of DECK CONSTRUCTION logic + + // TAB CONSTRUCTION + else if (aTag == nsXULAtoms::tab) { + processChildren = PR_TRUE; + isReplaced = PR_TRUE; + rv = NS_NewTabFrame(newFrame); + } + // End of TAB CONSTRUCTION logic + } // If we succeeded in creating a frame then initialize it, process its diff --git a/layout/xul/base/src/Makefile.in b/layout/xul/base/src/Makefile.in index 6a98a37a3c34..7c93af502b33 100644 --- a/layout/xul/base/src/Makefile.in +++ b/layout/xul/base/src/Makefile.in @@ -31,10 +31,13 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../../html/base/src \ -I$(srcdir)/../../../html/forms/src \ -I$(srcdir)/../../content/src \ + -I$(srcdir)/../../../html/content/src \ $(NULL) # Note the sophisticated alphabetical ordering :-| CPPSRCS = \ + nsTabFrame.cpp \ + nsDeckFrame.cpp \ nsBoxFrame.cpp \ nsProgressMeterFrame.cpp \ nsTitledButtonFrame.cpp \ diff --git a/layout/xul/base/src/makefile.win b/layout/xul/base/src/makefile.win index 4eb9434a7c09..12598fccfd1b 100644 --- a/layout/xul/base/src/makefile.win +++ b/layout/xul/base/src/makefile.win @@ -24,6 +24,8 @@ REQUIRES=xpcom raptor pref DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ + nsTabFrame.cpp \ + nsDeckFrame.cpp \ nsBoxFrame.cpp \ nsProgressMeterFrame.cpp \ nsTitledButtonFrame.cpp \ @@ -41,6 +43,8 @@ CPPSRCS= \ $(NULL) CPP_OBJS= \ + .\$(OBJDIR)\nsTabFrame.obj \ + .\$(OBJDIR)\nsDeckFrame.obj \ .\$(OBJDIR)\nsBoxFrame.obj \ .\$(OBJDIR)\nsProgressMeterFrame.obj \ .\$(OBJDIR)\nsTitledButtonFrame.obj \ @@ -63,6 +67,7 @@ EXPORTS = \ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ -I..\..\..\html\style\src -I..\..\..\html\base\src -I$(PUBLIC)\dom \ -I..\..\..\html\document\src \ + -I..\..\..\html\content\src \ -I..\..\..\html\table\src \ -I..\..\content\src \ -I..\..\..\html\forms\src \ diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 4a1049d0b0bf..9999664bdf46 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -187,6 +187,11 @@ nsBoxFrame::FlowChildAt(nsIFrame* childFrame, nsReflowReason reason = aReflowState.reason; PRBool shouldReflow = PR_TRUE; + // if no incremental child. And we are incremental make us + // make our reflow reason resize. + if (nsnull == incrementalChild && reason == eReflowReason_Incremental) + reason = eReflowReason_Resize; + if (nsnull != incrementalChild && incrementalChild != childFrame) { // if we are flowing because of incremental and this is not // the child then see if the size is already what we want. @@ -215,8 +220,8 @@ nsBoxFrame::FlowChildAt(nsIFrame* childFrame, if (currentSize.width == size.width && currentSize.height == size.height) shouldReflow = PR_FALSE; else - reason = eReflowReason_StyleChange; - + reason = eReflowReason_Resize; + } if (shouldReflow) { @@ -330,7 +335,22 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext, // get the child and only reflow it nsIFrame* incrementalChild = nsnull; if ( aReflowState.reason == eReflowReason_Incremental ) { - aReflowState.reflowCommand->GetNext(incrementalChild); + nsIFrame* targetFrame; + + // See if it's targeted at us + aReflowState.reflowCommand->GetTarget(targetFrame); + + if (this == targetFrame) { + incrementalChild = this; + } else { + aReflowState.reflowCommand->GetNext(incrementalChild); + + // ensure that the child's parent is us. If its not + // something very bad has happened. + nsIFrame* parent; + incrementalChild->GetParent(&parent); + NS_ASSERTION(this == parent,"incremental reflow error!"); + } } // ------ first pass build springs ------- @@ -495,9 +515,10 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext, } // only flow if fixed and width or height was not set + if (springs[count].springConstant == 0.0 && (wunit != eStyleUnit_Coord || hunit != eStyleUnit_Coord)) { - FlowChildAt(childFrame,aPresContext, desiredSize, aReflowState, aStatus, flexSize, incrementalChild); + FlowChildAt(childFrame,aPresContext, desiredSize, aReflowState, aStatus, flexSize, nsnull); // if it got bigger that expected set that as our min size if (mHorizontal) { @@ -522,7 +543,7 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext, preferredSize.width = desiredSize.width; preferredSize.height = desiredSize.height; } - + // make sure the preferred size is not instrinic if (NS_INTRINSICSIZE == preferredSize.width) preferredSize.width = 0; diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp new file mode 100644 index 000000000000..12bd5fffdb5b --- /dev/null +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -0,0 +1,418 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "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/NPL/ + * + * 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 Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Eric Vaughan +// Netscape Communications +// +// See documentation in associated header file +// + +#include "nsDeckFrame.h" +#include "nsIStyleContext.h" +#include "nsIPresContext.h" +#include "nsIContent.h" +#include "nsCOMPtr.h" +#include "nsHTMLIIDs.h" +#include "nsUnitConversion.h" +#include "nsINameSpaceManager.h" +#include "nsHTMLAtoms.h" +#include "nsXULAtoms.h" +#include "nsIReflowCommand.h" + +nsresult +NS_NewDeckFrame ( nsIFrame*& aNewFrame ) +{ + nsDeckFrame* it = new nsDeckFrame; + if (nsnull == it) + return NS_ERROR_OUT_OF_MEMORY; + + aNewFrame = it; + return NS_OK; + +} // NS_NewDeckFrame + +/* +nsDeckFrame::nsDeckFrame() +{ +} +*/ + + +NS_IMETHODIMP +nsDeckFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + return rv; +} + + +NS_IMETHODIMP +nsDeckFrame::AttributeChanged(nsIPresContext* aPresContext, + nsIContent* aChild, + nsIAtom* aAttribute, + PRInt32 aHint) +{ + nsresult rv = nsHTMLContainerFrame::AttributeChanged(aPresContext, aChild, + aAttribute, aHint); + + // redraw if the index changed. + if (aAttribute == nsHTMLAtoms::value) { + nsRect rect(0, 0, mRect.width, mRect.height); + Invalidate(rect, PR_TRUE); + } + + if (NS_OK != rv) { + return rv; + } + + return NS_OK; +} + +nsIFrame* +nsDeckFrame::GetSelectedFrame() +{ + // ok we want to paint only the child that as at the given index + + // default index is 0 + int index = 0; + + // get the index attribute + nsAutoString value; + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value)) + { + PRInt32 error; + + // convert it to an integer + index = value.ToInteger(&error); + printf("index=%d\n",index); + } else { + printf("no index set\n"); + + } + + // get the child at that index. + nscoord count = 0; + nsIFrame* childFrame = mFrames.FirstChild(); + while (nsnull != childFrame) + { + if (count == index) + break; + + nsresult rv = childFrame->GetNextSibling(&childFrame); + count++; + } + + return childFrame; +} + + +NS_IMETHODIMP +nsDeckFrame::Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer) +{ + + nsIFrame* selectedFrame = GetSelectedFrame(); + + // draw nothing if the index is out of bounds + if (nsnull == selectedFrame) + return NS_OK; + + // paint the child + selectedFrame->Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + + return NS_OK; +} + + +NS_IMETHODIMP +nsDeckFrame::Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) +{ + + nsIFrame* incrementalChild = nsnull; + if ( aReflowState.reason == eReflowReason_Incremental ) { + nsIFrame* targetFrame; + + // See if it's targeted at us + aReflowState.reflowCommand->GetTarget(targetFrame); + + if (this == targetFrame) { + // if we are the target then we are done. + aDesiredSize.width = mRect.width; + aDesiredSize.height = mRect.height; + return NS_OK; + } else { + aReflowState.reflowCommand->GetNext(incrementalChild); + + // ensure that the child's parent is us. If its not + // something very bad has happened. + nsIFrame* parent; + incrementalChild->GetParent(&parent); + NS_ASSERTION(this == parent,"incremental reflow error!"); + } + } + + aDesiredSize.width = 0; + aDesiredSize.height = 0; + + // get our available size + nsSize availableSize(0,0); + + PRBool fixedWidthContent = aReflowState.HaveFixedContentWidth(); + if (NS_INTRINSICSIZE == aReflowState.computedWidth) { + fixedWidthContent = PR_FALSE; + } + + PRBool fixedHeightContent = aReflowState.HaveFixedContentHeight(); + if (NS_INTRINSICSIZE == aReflowState.computedHeight) { + fixedHeightContent = PR_FALSE; + } + + if (fixedWidthContent) { + availableSize.width = aReflowState.computedWidth; + } else + availableSize.width = aReflowState.availableWidth; + + if (fixedHeightContent) { + availableSize.height = aReflowState.computedHeight; + } else + availableSize.height = aReflowState.availableHeight; + + // iterate though each child + PRBool finished = PR_FALSE; + nsIFrame* changedChild = nsnull; + int passes = 0; + + while(!finished) + { + finished = PR_TRUE; + nscoord count = 0; + nsIFrame* childFrame = mFrames.FirstChild(); + while (nsnull != childFrame) + { + // if we hit the child that cause us to do a second pass + // then break. + if (changedChild == childFrame) + break; + + // make sure we make the child as big as we are + const nsStylePosition* pos; + childFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos); + + nsStyleCoord* w = (nsStyleCoord*)&pos->mWidth; + nsStyleCoord wcopy(*w); + *w = nsStyleCoord(); + w->SetPercentValue(1); + + nsStyleCoord* h = (nsStyleCoord*)&pos->mHeight; + nsStyleCoord hcopy(*h); + *h = nsStyleCoord(); + h->SetPercentValue(1); + + aDesiredSize.width = 0; + aDesiredSize.height = 0; + + // get its margin + const nsStyleSpacing* spacing; + nsresult rv = childFrame->GetStyleData(eStyleStruct_Spacing, + (const nsStyleStruct*&) spacing); + + nsMargin margin; + spacing->GetMargin(margin); + nsMargin border; + spacing->GetBorderPadding(border); + nsMargin total = margin + border; + + nsSize childSize(availableSize); + + // flow it + nsHTMLReflowState reflowState(aPresContext, aReflowState, childFrame, childSize); + + // if we are incremental + if (reflowState.reason == eReflowReason_Incremental) { + // if it is this child then reset the incrementalChild + if (incrementalChild == childFrame) { + incrementalChild = nsnull; + } else { + // if not our child reflow as a resize + reflowState.reason = eReflowReason_Resize; + } + } + + reflowState.computedWidth = childSize.width; + reflowState.computedHeight = childSize.height; + + // only subrtact margin and border if the size is not intrinsic + if (NS_INTRINSICSIZE != reflowState.computedWidth) + reflowState.computedWidth -= (total.left + total.right); + + + if (NS_INTRINSICSIZE != reflowState.computedHeight) + reflowState.computedHeight -= (total.top + total.bottom); + + nsIHTMLReflow* htmlReflow; + + rv = childFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); + NS_ASSERTION(rv == NS_OK,"failed to get htmlReflow interface."); + + htmlReflow->WillReflow(aPresContext); + htmlReflow->Reflow(aPresContext, aDesiredSize, reflowState, aStatus); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); + + *w = wcopy; + *h = hcopy; + + // set the rect + childFrame->SetRect(nsRect(margin.left,margin.right,aDesiredSize.width, aDesiredSize.height)); + + // add the margin back in. The child should add its border automatically + aDesiredSize.height += (margin.top + margin.bottom); + aDesiredSize.width += (margin.left + margin.right); + + // if the area returned is greater than our size + if (aDesiredSize.height > availableSize.height || aDesiredSize.width > availableSize.width) + { + // note the child that got bigger + changedChild = childFrame; + + // set our size to be the new size + availableSize.width = aDesiredSize.width; + availableSize.height = aDesiredSize.height; + + // indicate we need to start another pass + finished = PR_FALSE; + } + + // get the next child + rv = childFrame->GetNextSibling(&childFrame); + count++; + } + + // if we get over 10 passes something probably when wrong. + passes++; + if (passes > 5) + NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, + ("DeckFrame reflow bug")); + + NS_ASSERTION(passes <= 10,"DeckFrame: Error infinte loop too many passes"); + } + + // return the largest dimension + aDesiredSize.width = availableSize.width; + aDesiredSize.height = availableSize.height; + + // add in our border + const nsMargin& borderPadding = aReflowState.mComputedBorderPadding; + + aDesiredSize.width += borderPadding.left + borderPadding.right; + aDesiredSize.height += borderPadding.top + borderPadding.bottom; + aDesiredSize.ascent = aDesiredSize.height; + aDesiredSize.descent = 0; + + return NS_OK; +} + +/* +NS_IMETHODIMP +nsDeckFrame::HandleEvent(nsIPresContext& aPresContext, + nsGUIEvent* aEvent, + nsEventStatus& aEventStatus) +{ + + // send the event to the selected frame + nsIFrame* selectedFrame = GetSelectedFrame(); + + // if no selected frame we handle the event + if (nsnull == selectedFrame) + return nsHTMLContainerFrame::HandleEvent(aPresContext, aEvent, aEventStatus); + + return selectedFrame->HandleEvent(aPresContext, aEvent, aEventStatus); +} +*/ + +NS_IMETHODIMP nsDeckFrame::GetFrameForPoint(const nsPoint& aPoint, + nsIFrame** aFrame) +{ + // if its not in our child just return us. + *aFrame = this; + + // get the selected frame and see if the point is in it. + nsIFrame* selectedFrame = GetSelectedFrame(); + + if (nsnull != selectedFrame) + { + nsRect childRect; + selectedFrame->GetRect(childRect); + + if (childRect.Contains(aPoint)) { + // adjust the point + nsPoint p = aPoint; + p.x -= childRect.x; + p.y -= childRect.y; + return selectedFrame->GetFrameForPoint(p, aFrame); + } + } + + return NS_OK; +} + + + + +NS_IMETHODIMP +nsDeckFrame::RemoveFrame(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aOldFrame) +{ + // remove the child frame + nsresult rv = nsHTMLContainerFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame); + mFrames.DeleteFrame(aPresContext, aOldFrame); + return rv; +} + +NS_IMETHODIMP +nsDeckFrame::InsertFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aPrevFrame, + nsIFrame* aFrameList) +{ + mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); + return nsHTMLContainerFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList); +} + +NS_IMETHODIMP +nsDeckFrame::AppendFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aFrameList) +{ + mFrames.AppendFrames(nsnull, aFrameList); + return nsHTMLContainerFrame::AppendFrames(aPresContext, aPresShell, aListName, aFrameList); +} diff --git a/layout/xul/base/src/nsDeckFrame.h b/layout/xul/base/src/nsDeckFrame.h new file mode 100644 index 000000000000..0f0bdd772495 --- /dev/null +++ b/layout/xul/base/src/nsDeckFrame.h @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "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/NPL/ + * + * 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 Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +/** + + Eric D Vaughan + A frame that can have multiple children. Only one child may be displayed at one time. So the + can be flipped though like a deck of cards. + +**/ + +#ifndef nsDeckFrame_h___ +#define nsDeckFrame_h___ + +#include "nsHTMLContainerFrame.h" + + +class nsDeckFrame : public nsHTMLContainerFrame +{ +public: + + friend nsresult NS_NewDeckFrame(nsIFrame*& aNewFrame); + + + + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* asPrevInFlow); + + + NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, + nsIContent* aChild, + nsIAtom* aAttribute, + PRInt32 aHint); + + + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); + + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer); + + NS_IMETHOD AppendFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aFrameList); + + NS_IMETHOD InsertFrames(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aPrevFrame, + nsIFrame* aFrameList); + + NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext, + nsIPresShell& aPresShell, + nsIAtom* aListName, + nsIFrame* aOldFrame); +/* + NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, + nsGUIEvent* aEvent, + nsEventStatus& aEventStatus); +*/ + NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, + nsIFrame** aFrame); + + virtual PRIntn GetSkipSides() const { return 0; } + +protected: + + virtual nsIFrame* GetSelectedFrame(); + +}; // class nsDeckFrame + + + +#endif + diff --git a/layout/xul/base/src/nsTabFrame.cpp b/layout/xul/base/src/nsTabFrame.cpp new file mode 100644 index 000000000000..e0896337b3d1 --- /dev/null +++ b/layout/xul/base/src/nsTabFrame.cpp @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "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/NPL/ + * + * 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 Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Eric Vaughan +// Netscape Communications +// +// See documentation in associated header file +// + +#include "nsTabFrame.h" +#include "nsIStyleContext.h" +#include "nsIPresContext.h" +#include "nsIContent.h" +#include "nsCOMPtr.h" +#include "nsHTMLIIDs.h" +#include "nsUnitConversion.h" +#include "nsINameSpaceManager.h" +#include "nsHTMLAtoms.h" +#include "nsXULAtoms.h" +#include "nsIReflowCommand.h" + +// +// NS_NewToolbarFrame +// +// Creates a new Toolbar frame and returns it in |aNewFrame| +// +nsresult +NS_NewTabFrame ( nsIFrame*& aNewFrame ) +{ + nsTabFrame* it = new nsTabFrame; + if (nsnull == it) + return NS_ERROR_OUT_OF_MEMORY; + + aNewFrame = it; + return NS_OK; + +} // NS_NewTabFrame + +/* +nsTabFrame::nsTabFrame() +{ +} +*/ + +void +nsTabFrame::MouseClicked(nsIPresContext* aPresContext) +{ + // get our index + PRInt32 index = 0; + GetIndexInParent(mContent, index); + + // get the tab control + nsIContent* tabcontrol = nsnull; + GetTabControl(mContent, tabcontrol); + + // get the tab panel + nsIContent* tabpanel = nsnull; + GetChildWithTag(nsXULAtoms::tabpanel, tabcontrol, tabpanel); + + // set the panels index + char value[100]; + itoa(index, value, 100); + + tabpanel->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value, PR_TRUE); +} + +nsresult +nsTabFrame::GetChildWithTag(nsIAtom* atom, nsIContent* start, nsIContent*& tabpanel) +{ + // recursively search our children + PRInt32 count = 0; + start->ChildCount(count); + for (PRInt32 i = 0; i < count; i++) + { + nsIContent* child = nsnull; + start->ChildAt(i,child); + + // see if it is the child + nsIAtom* tag = nsnull; + child->GetTag(tag); + if (tag == atom) + { + tabpanel = child; + return NS_OK; + } + + // recursive search the child + nsIContent* found = nsnull; + GetChildWithTag(atom, child, found); + if (found != nsnull) { + tabpanel = found; + return NS_OK; + } + } + + tabpanel = nsnull; + return NS_OK; +} + +nsresult +nsTabFrame::GetTabControl(nsIContent* content, nsIContent*& tabcontrol) +{ + while(nsnull != content) + { + content->GetParent(content); + + if (content) { + nsIAtom* atom; + if (content->GetTag(atom) == NS_OK && atom == nsXULAtoms::tabcontrol) { + tabcontrol = content; + return NS_OK; + } + } + } + + tabcontrol = nsnull; + return NS_OK; +} + +nsresult +nsTabFrame::GetIndexInParent(nsIContent* content, PRInt32& index) +{ + nsIContent* parent; + content->GetParent(parent); + return parent->IndexOf(content, index); +} + diff --git a/layout/xul/base/src/nsTabFrame.h b/layout/xul/base/src/nsTabFrame.h new file mode 100644 index 000000000000..fa2a55481b35 --- /dev/null +++ b/layout/xul/base/src/nsTabFrame.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "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/NPL/ + * + * 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 Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +/** + + Eric D Vaughan + This class lays out its children either vertically or horizontally + +**/ + +#ifndef nsTabFrame_h___ +#define nsTabFrame_h___ + +#include "nsHTMLButtonControlFrame.h" + +class nsTabControlFrame; + +class nsTabFrame : public nsHTMLButtonControlFrame +{ +public: + + friend nsresult NS_NewTabFrame(nsIFrame*& aNewFrame); + + + virtual void MouseClicked(nsIPresContext* aPresContext); + +protected: + + virtual nsresult GetChildWithTag(nsIAtom* atom, nsIContent* start, nsIContent*& tabpanel); + virtual nsresult GetTabControl(nsIContent* content, nsIContent*& tabcontrol); + virtual nsresult GetIndexInParent(nsIContent* content, PRInt32& index); + +private: + + nsTabControlFrame* mTabControlFrame; + +}; // class nsTabFrame + + + +#endif + diff --git a/layout/xul/content/src/nsXULAtoms.cpp b/layout/xul/content/src/nsXULAtoms.cpp index b9a512e6308a..7fcc19c13ff2 100644 --- a/layout/xul/content/src/nsXULAtoms.cpp +++ b/layout/xul/content/src/nsXULAtoms.cpp @@ -57,6 +57,14 @@ nsIAtom* nsXULAtoms::mode; nsIAtom* nsXULAtoms::box; nsIAtom* nsXULAtoms::flex; +nsIAtom* nsXULAtoms::tabcontrol; +nsIAtom* nsXULAtoms::tabbox; +nsIAtom* nsXULAtoms::tab; +nsIAtom* nsXULAtoms::tabpanel; +nsIAtom* nsXULAtoms::tabpage; +nsIAtom* nsXULAtoms::deck; + + nsIAtom* nsXULAtoms::widget; nsIAtom* nsXULAtoms::window; @@ -108,6 +116,14 @@ void nsXULAtoms::AddrefAtoms() { box = NS_NewAtom("box"); flex = NS_NewAtom("flex"); + deck = NS_NewAtom("deck"); + tabcontrol = NS_NewAtom("tabcontrol"); + tab = NS_NewAtom("tab"); + tabpanel = NS_NewAtom("tabpanel"); + tabpage = NS_NewAtom("tabpage"); + tabbox = NS_NewAtom("tabbox"); + + widget = NS_NewAtom("widget"); window = NS_NewAtom("window"); } @@ -150,6 +166,13 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(flex); + NS_RELEASE(deck); + NS_RELEASE(tabcontrol); + NS_RELEASE(tab); + NS_RELEASE(tabbox); + NS_RELEASE(tabpanel); + NS_RELEASE(tabpage); + NS_RELEASE(widget); NS_RELEASE(window); NS_IF_RELEASE(gNameSpaceManager); diff --git a/layout/xul/content/src/nsXULAtoms.h b/layout/xul/content/src/nsXULAtoms.h index 1fff378681d7..a467d0645d95 100644 --- a/layout/xul/content/src/nsXULAtoms.h +++ b/layout/xul/content/src/nsXULAtoms.h @@ -75,6 +75,13 @@ public: static nsIAtom* box; static nsIAtom* flex; + static nsIAtom* deck; + static nsIAtom* tabcontrol; + static nsIAtom* tabbox; + static nsIAtom* tab; + static nsIAtom* tabpanel; + static nsIAtom* tabpage; + static nsIAtom* widget; static nsIAtom* window; }; diff --git a/xpfe/browser/src/xul.css b/xpfe/browser/src/xul.css index 86251a0c9cc2..489d5cc59579 100644 --- a/xpfe/browser/src/xul.css +++ b/xpfe/browser/src/xul.css @@ -213,3 +213,79 @@ tristatecheckbox[depress] { background: darkGray; border: 1px inset black; } + +tab { + display: inline; + cursor: default; + + border: 2px outset gray; + //-moz-border-radius: 90; + + color:black; +} + +tabcontrol[align="vertical"] tabpanel + tabbox[align="horizontal"] tab { + + border-left: 2px outset gray; + border-right: 2px outset gray; + border-top: none; + border-bottom: 2px outset gray; + + margin-right: 1px; + margin-left: 1px; + margin-top: none; + margin-bottom: none; +} + +tabcontrol[align="vertical"] tabbox[align="horizontal"] tab { + border-left: 2px outset gray; + border-right: 2px outset gray; + border-top: 2px outset gray; + border-bottom: none; + + margin-right: 1px; + margin-left: 1px; + margin-top: none; + margin-bottom: none; + +} + +tabcontrol[align="horizontal"] tabbox[align="vertical"] tab { + border-left: 2px outset gray; + border-right: none; + border-top: 2px outset gray; + border-bottom: 2px outset gray; + + margin-right: none; + margin-left: none; + margin-top: 1px; + margin-bottom: 1px; +} + +tabcontrol[align="horizontal"] tabpanel + tabbox[align="vertical"] tab { + border-left: none; + border-right: 2px outset gray; + border-top: 2px outset gray; + border-bottom: 2px outset gray; + + margin-right: none; + margin-left: none; + margin-top: 1px; + margin-bottom: 1px; +} + + +tab[pseudoclass~="hover"] { + background-color: rgb(230, 207, 206); +} + +tabcontrol { + display: block; + cursor: default; + + border: 2px outset gray; + padding: 10px; + + background-color: rgb(206, 207, 206); + color:black; +}