From 94339ec788ccb2d15dbbfe4271d12a4e0d379838 Mon Sep 17 00:00:00 2001 From: "peterl%netscape.com" Date: Fri, 3 Sep 1999 23:36:32 +0000 Subject: [PATCH] added accessors for additional style contexts git-svn-id: svn://10.0.0.236/trunk@45966 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/forms/nsButtonFrameRenderer.cpp | 45 +++++++++++++++++++ mozilla/layout/forms/nsButtonFrameRenderer.h | 7 +++ .../layout/forms/nsComboboxControlFrame.cpp | 28 ------------ mozilla/layout/forms/nsComboboxControlFrame.h | 6 --- .../layout/forms/nsGfxRadioControlFrame.cpp | 35 +++++++++++++++ mozilla/layout/forms/nsGfxRadioControlFrame.h | 9 ++++ .../layout/forms/nsHTMLButtonControlFrame.cpp | 14 ++++++ .../layout/forms/nsHTMLButtonControlFrame.h | 4 ++ .../html/forms/src/nsButtonFrameRenderer.cpp | 45 +++++++++++++++++++ .../html/forms/src/nsButtonFrameRenderer.h | 7 +++ .../html/forms/src/nsComboboxControlFrame.cpp | 28 ------------ .../html/forms/src/nsComboboxControlFrame.h | 6 --- .../html/forms/src/nsGfxRadioControlFrame.cpp | 35 +++++++++++++++ .../html/forms/src/nsGfxRadioControlFrame.h | 9 ++++ .../forms/src/nsHTMLButtonControlFrame.cpp | 14 ++++++ .../html/forms/src/nsHTMLButtonControlFrame.h | 4 ++ 16 files changed, 228 insertions(+), 68 deletions(-) diff --git a/mozilla/layout/forms/nsButtonFrameRenderer.cpp b/mozilla/layout/forms/nsButtonFrameRenderer.cpp index bc4ed668c29..9be44657264 100644 --- a/mozilla/layout/forms/nsButtonFrameRenderer.cpp +++ b/mozilla/layout/forms/nsButtonFrameRenderer.cpp @@ -376,3 +376,48 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext& aPresContext, aParentChange, aChangeList, aLocalChange); } } + +nsresult +nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const +{ + NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + *aStyleContext = nsnull; + switch (aIndex) { + case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX: + *aStyleContext = mOutlineStyle; + NS_ADDREF(*aStyleContext); + break; + case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: + *aStyleContext = mInnerFocusStyle; + NS_ADDREF(*aStyleContext); + break; + case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: + *aStyleContext = mOuterFocusStyle; + NS_ADDREF(*aStyleContext); + break; + } + return NS_OK; +} + +nsresult +nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext) +{ + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + switch (aIndex) { + case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX: + mOutlineStyle = aStyleContext; + break; + case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: + mInnerFocusStyle = aStyleContext; + break; + case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: + mOuterFocusStyle = aStyleContext; + break; + } + return NS_OK; +} diff --git a/mozilla/layout/forms/nsButtonFrameRenderer.h b/mozilla/layout/forms/nsButtonFrameRenderer.h index ba20d5a1232..3a55486303c 100644 --- a/mozilla/layout/forms/nsButtonFrameRenderer.h +++ b/mozilla/layout/forms/nsButtonFrameRenderer.h @@ -32,6 +32,11 @@ class nsStyleChangeList; +#define NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX 0 +#define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 1 +#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 2 +#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX + class nsButtonFrameRenderer { public: @@ -78,6 +83,8 @@ public: virtual nsMargin GetFullButtonBorderAndPadding(); virtual nsMargin GetAddedButtonBorderAndPadding(); + virtual nsresult GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const; + virtual nsresult SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext); virtual void ReResolveStyles(nsIPresContext& aPresContext, PRInt32 aParentChange, nsStyleChangeList* aChangeList, diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 9fc3cb32de0..1eb6e20d6ac 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -868,34 +868,6 @@ nsComboboxControlFrame::GetFrameName(nsString& aResult) const -NS_IMETHODIMP -nsComboboxControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) -{ - PRInt32 ourChange = aParentChange; - nsresult rv = nsAreaFrame::ReResolveStyleContext(aPresContext, aParentContext, aParentChange, aChangeList, aLocalChange); - - if (NS_FAILED(rv)) { - return rv; - } - - if (aLocalChange) { - *aLocalChange = ourChange; - } - - if (NS_COMFALSE != rv) { - PRInt32 childChange; - // Update child list - nsIFrame* dropdownFrame = GetDropdownFrame(); - dropdownFrame->ReResolveStyleContext(aPresContext, mStyleContext, ourChange, aChangeList, &childChange); - } - - return rv; -} - //---------------------------------------------------------------------- // nsIDOMMouseListener //---------------------------------------------------------------------- diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index 34539e60562..8d12e99c3d0 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -74,12 +74,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange); - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsEventStatus& aEventStatus); diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp index 4a0ccd007b3..52e0481598a 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp @@ -58,6 +58,41 @@ nsGfxRadioControlFrame::~nsGfxRadioControlFrame() //-------------------------------------------------------------- +NS_IMETHODIMP +nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const +{ + NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + *aStyleContext = nsnull; + switch (aIndex) { + case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: + *aStyleContext = mRadioButtonFaceStyle; + NS_ADDREF(*aStyleContext); + break; + } + return NS_OK; +} + +NS_IMETHODIMP +nsGfxRadioControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext) +{ + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + switch (aIndex) { + case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: + NS_IF_RELEASE(mRadioButtonFaceStyle); + mRadioButtonFaceStyle = aStyleContext; + NS_IF_ADDREF(aStyleContext); + break; + } + return NS_OK; +} + NS_IMETHODIMP nsGfxRadioControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext, diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.h b/mozilla/layout/forms/nsGfxRadioControlFrame.h index 5c2ecf727d3..3a3bd312f07 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.h +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.h @@ -23,6 +23,9 @@ // nsGfxRadioControlFrame +#define NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX 0 // for additional style contexts +#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0 + class nsGfxRadioControlFrame : public nsRadioControlFrame { private: @@ -35,6 +38,12 @@ public: //nsIRadioControlFrame methods NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext); + NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const; + NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext); + + NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aParentContext, PRInt32 aParentChange, diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index b7df9c7272d..9c0ef83b631 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -598,6 +598,20 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsString& aV return NS_OK; } +NS_IMETHODIMP +nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const +{ + return mRenderer.GetStyleContext(aIndex, aStyleContext); +} + +NS_IMETHODIMP +nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext) +{ + return mRenderer.SetStyleContext(aIndex, aStyleContext); +} + // // ReResolveStyleContext // diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.h b/mozilla/layout/forms/nsHTMLButtonControlFrame.h index 279ea071eae..7b67174f8fa 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.h +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.h @@ -87,6 +87,10 @@ public: nsIStyleContext* aContext, nsIFrame* asPrevInFlow); + NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const; + NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext); NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext, PRInt32 aParentChange, diff --git a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp index bc4ed668c29..9be44657264 100644 --- a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp +++ b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.cpp @@ -376,3 +376,48 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext& aPresContext, aParentChange, aChangeList, aLocalChange); } } + +nsresult +nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const +{ + NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + *aStyleContext = nsnull; + switch (aIndex) { + case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX: + *aStyleContext = mOutlineStyle; + NS_ADDREF(*aStyleContext); + break; + case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: + *aStyleContext = mInnerFocusStyle; + NS_ADDREF(*aStyleContext); + break; + case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: + *aStyleContext = mOuterFocusStyle; + NS_ADDREF(*aStyleContext); + break; + } + return NS_OK; +} + +nsresult +nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext) +{ + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + switch (aIndex) { + case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX: + mOutlineStyle = aStyleContext; + break; + case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: + mInnerFocusStyle = aStyleContext; + break; + case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: + mOuterFocusStyle = aStyleContext; + break; + } + return NS_OK; +} diff --git a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h index ba20d5a1232..3a55486303c 100644 --- a/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h +++ b/mozilla/layout/html/forms/src/nsButtonFrameRenderer.h @@ -32,6 +32,11 @@ class nsStyleChangeList; +#define NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX 0 +#define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 1 +#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 2 +#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX + class nsButtonFrameRenderer { public: @@ -78,6 +83,8 @@ public: virtual nsMargin GetFullButtonBorderAndPadding(); virtual nsMargin GetAddedButtonBorderAndPadding(); + virtual nsresult GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const; + virtual nsresult SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext); virtual void ReResolveStyles(nsIPresContext& aPresContext, PRInt32 aParentChange, nsStyleChangeList* aChangeList, diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 9fc3cb32de0..1eb6e20d6ac 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -868,34 +868,6 @@ nsComboboxControlFrame::GetFrameName(nsString& aResult) const -NS_IMETHODIMP -nsComboboxControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) -{ - PRInt32 ourChange = aParentChange; - nsresult rv = nsAreaFrame::ReResolveStyleContext(aPresContext, aParentContext, aParentChange, aChangeList, aLocalChange); - - if (NS_FAILED(rv)) { - return rv; - } - - if (aLocalChange) { - *aLocalChange = ourChange; - } - - if (NS_COMFALSE != rv) { - PRInt32 childChange; - // Update child list - nsIFrame* dropdownFrame = GetDropdownFrame(); - dropdownFrame->ReResolveStyleContext(aPresContext, mStyleContext, ourChange, aChangeList, &childChange); - } - - return rv; -} - //---------------------------------------------------------------------- // nsIDOMMouseListener //---------------------------------------------------------------------- diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h index 34539e60562..8d12e99c3d0 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.h +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.h @@ -74,12 +74,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange); - NS_IMETHOD HandleEvent(nsIPresContext& aPresContext, nsGUIEvent* aEvent, nsEventStatus& aEventStatus); diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp index 4a0ccd007b3..52e0481598a 100644 --- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp @@ -58,6 +58,41 @@ nsGfxRadioControlFrame::~nsGfxRadioControlFrame() //-------------------------------------------------------------- +NS_IMETHODIMP +nsGfxRadioControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const +{ + NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer"); + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + *aStyleContext = nsnull; + switch (aIndex) { + case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: + *aStyleContext = mRadioButtonFaceStyle; + NS_ADDREF(*aStyleContext); + break; + } + return NS_OK; +} + +NS_IMETHODIMP +nsGfxRadioControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext) +{ + if (aIndex < 0) { + return NS_ERROR_INVALID_ARG; + } + switch (aIndex) { + case NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX: + NS_IF_RELEASE(mRadioButtonFaceStyle); + mRadioButtonFaceStyle = aStyleContext; + NS_IF_ADDREF(aStyleContext); + break; + } + return NS_OK; +} + NS_IMETHODIMP nsGfxRadioControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h index 5c2ecf727d3..3a3bd312f07 100644 --- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h @@ -23,6 +23,9 @@ // nsGfxRadioControlFrame +#define NS_GFX_RADIO_CONTROL_FRAME_FACE_CONTEXT_INDEX 0 // for additional style contexts +#define NS_GFX_RADIO_CONTROL_FRAME_LAST_CONTEXT_INDEX 0 + class nsGfxRadioControlFrame : public nsRadioControlFrame { private: @@ -35,6 +38,12 @@ public: //nsIRadioControlFrame methods NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext); + NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const; + NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext); + + NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aParentContext, PRInt32 aParentChange, diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index b7df9c7272d..9c0ef83b631 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -598,6 +598,20 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsString& aV return NS_OK; } +NS_IMETHODIMP +nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const +{ + return mRenderer.GetStyleContext(aIndex, aStyleContext); +} + +NS_IMETHODIMP +nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext) +{ + return mRenderer.SetStyleContext(aIndex, aStyleContext); +} + // // ReResolveStyleContext // diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h index 279ea071eae..7b67174f8fa 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.h @@ -87,6 +87,10 @@ public: nsIStyleContext* aContext, nsIFrame* asPrevInFlow); + NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext** aStyleContext) const; + NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex, + nsIStyleContext* aStyleContext); NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext, PRInt32 aParentChange,