Fixed problem where buttons where causing reflows when entering and exiting.

Removed outline border style and fixed style context parentage of buttons.
bug 17892; r=buster@netscape.com
This commit is contained in:
kmcclusk%netscape.com 1999-11-12 01:45:53 +00:00
Родитель 226efe3505
Коммит 199bc6a632
10 изменённых файлов: 140 добавлений и 156 удалений

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

@ -912,21 +912,26 @@ nsresult
nsCSSFrameConstructor::CreateInputFrame(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsIStyleContext *aStyleContext)
nsIStyleContext *aStyleContext,
PRBool &aIsButton)
{
nsresult rv;
aIsButton = PR_FALSE;
// Figure out which type of input frame to create
nsAutoString val;
if (NS_OK == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, val)) {
if (val.EqualsIgnoreCase("submit")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("reset")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("button")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("checkbox")) {
rv = ConstructCheckboxControlFrame(aPresContext, aFrame);
@ -2730,6 +2735,23 @@ nsCSSFrameConstructor::ConstructButtonLabelFrame(nsIPresContext *aPresContext,
return rv;
}
nsresult
nsCSSFrameConstructor::ConstructButtonFrames(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems)
{
// Construct button label frame using generated content
// Get the first area frame to insert the button as a child.
nsIFrame* areaFrame = nsnull;
aFrame->FirstChild(nsnull, &areaFrame);
NS_ASSERTION(areaFrame != nsnull, "Button does not have an area frame");
nsresult rv = ConstructButtonLabelFrame(aPresContext, aContent, areaFrame, aState, aFrameItems);
return rv;
}
nsresult
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresContext* aPresContext,
@ -3090,6 +3112,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
PRBool isReplaced = PR_FALSE;
PRBool addToHashTable = PR_TRUE;
nsresult rv = NS_OK;
PRBool isButton = PR_FALSE;
if (nsLayoutAtoms::textTagName == aTag) {
rv = NS_NewTextFrame(&newFrame);
@ -3143,7 +3166,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
}
else if (nsHTMLAtoms::input == aTag) {
isReplaced = PR_TRUE;
rv = CreateInputFrame(aPresContext, aContent, newFrame, aStyleContext);
rv = CreateInputFrame(aPresContext, aContent, newFrame, aStyleContext, isButton);
}
else if (nsHTMLAtoms::textarea == aTag) {
isReplaced = PR_TRUE;
@ -3249,11 +3272,16 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
PR_TRUE, childItems, PR_FALSE);
}
if (nsHTMLAtoms::input == aTag) {
// Construct button label frame using generated content
ConstructButtonLabelFrame(aPresContext, aContent, newFrame, aState, childItems);
}
// Create button label frames.
// This must be done after the Init so
// the button label frames get the proper
// parent style context.
// XXX: Need to reorganize nsCSSFrameConstructor
// so we don't have to special case buttons here.
if (isButton) {
rv = ConstructButtonFrames(aPresContext, aContent, newFrame, aState, childItems);
}
// if there are any anonymous children create frames for them
CreateAnonymousFrames(aPresContext, aTag, aState, aContent, newFrame,
childItems);

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

@ -428,6 +428,11 @@ protected:
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems);
nsresult ConstructButtonFrames(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems);
nsresult ConstructButtonControlFrame(nsIPresContext* aPresContext,
nsIFrame*& aNewFrame);
@ -527,7 +532,8 @@ protected:
nsresult CreateInputFrame(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsIStyleContext *aStyleContext);
nsIStyleContext *aStyleContext,
PRBool &aIsButton);
nsresult RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
nsIPresShell * aPresShell,

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

@ -162,29 +162,6 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext& aPresContext,
}
}
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer)
{
/*
if (mOutlineStyle) {
GetButtonOutlineRect(aRect, rect);
mOutlineRect = rect;
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
// set the clipping area so we can draw outside our bounds.
aRenderingContext.PushState();
PRBool clipEmpty;
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOutlineStyle, 0);
aRenderingContext.PopState(clipEmpty);
}
*/
}
}
@ -331,15 +308,6 @@ nsMargin
nsButtonFrameRenderer::GetButtonOutlineBorderAndPadding()
{
nsMargin borderAndPadding(0,0,0,0);
if (mOutlineStyle) {
// get the outline border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
return borderAndPadding;
}
@ -370,14 +338,9 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext& aPresContext)
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
// style that draw an outline around the button
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-outline")) );
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOutlineStyle));
// style for the inner such as a dotted line (Windows)
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
nsCOMPtr<nsIAtom> atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mInnerFocusStyle));
@ -399,10 +362,7 @@ nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleC
}
*aStyleContext = nsnull;
switch (aIndex) {
case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX:
*aStyleContext = mOutlineStyle;
NS_IF_ADDREF(*aStyleContext);
break;
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
*aStyleContext = mInnerFocusStyle;
NS_IF_ADDREF(*aStyleContext);
@ -424,9 +384,7 @@ nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleCo
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;

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

@ -35,9 +35,9 @@
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_FOCUS_INNER_CONTEXT_INDEX 0
#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1
#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX
class nsButtonFrameRenderer {
@ -103,7 +103,6 @@ private:
nsCOMPtr<nsIStyleContext> mBorderStyle;
nsCOMPtr<nsIStyleContext> mInnerFocusStyle;
nsCOMPtr<nsIStyleContext> mOuterFocusStyle;
nsCOMPtr<nsIStyleContext> mOutlineStyle;
PRInt32 mNameSpace;
nsFrame* mFrame;

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

@ -101,6 +101,27 @@ nsHTMLButtonControlFrame::Init(nsIPresContext& aPresContext,
{
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
mRenderer.SetFrame(this,aPresContext);
// cache our display type
const nsStyleDisplay* styleDisplay;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
PRUint32 flags = NS_BLOCK_SPACE_MGR;
if (mInline) {
flags |= NS_BLOCK_SHRINK_WRAP;
}
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame, flags);
mFrames.SetFrames(areaFrame);
// Resolve style and initialize the frame
nsIStyleContext* styleContext;
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::buttonContentPseudo,
mStyleContext, PR_FALSE,
&styleContext);
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
NS_RELEASE(styleContext);
return rv;
}
@ -382,27 +403,7 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
// add ourself as an nsIFormControlFrame
nsFormFrame::AddFormControlFrame(aPresContext, *this);
// cache our display type
const nsStyleDisplay* styleDisplay;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
PRUint32 flags = NS_BLOCK_SPACE_MGR;
if (mInline) {
flags |= NS_BLOCK_SHRINK_WRAP;
}
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame, flags);
mFrames.SetFrames(areaFrame);
// Resolve style and initialize the frame
nsIStyleContext* styleContext;
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::buttonContentPseudo,
mStyleContext, PR_FALSE,
&styleContext);
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
NS_RELEASE(styleContext);
// Set the parent for each of the child frames
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) {
frame->SetParent(mFrames.FirstChild());

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

@ -162,29 +162,6 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext& aPresContext,
}
}
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer)
{
/*
if (mOutlineStyle) {
GetButtonOutlineRect(aRect, rect);
mOutlineRect = rect;
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
// set the clipping area so we can draw outside our bounds.
aRenderingContext.PushState();
PRBool clipEmpty;
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOutlineStyle, 0);
aRenderingContext.PopState(clipEmpty);
}
*/
}
}
@ -331,15 +308,6 @@ nsMargin
nsButtonFrameRenderer::GetButtonOutlineBorderAndPadding()
{
nsMargin borderAndPadding(0,0,0,0);
if (mOutlineStyle) {
// get the outline border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
return borderAndPadding;
}
@ -370,14 +338,9 @@ nsButtonFrameRenderer::ReResolveStyles(nsIPresContext& aPresContext)
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
// style that draw an outline around the button
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-outline")) );
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOutlineStyle));
// style for the inner such as a dotted line (Windows)
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
nsCOMPtr<nsIAtom> atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mInnerFocusStyle));
@ -399,10 +362,7 @@ nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleC
}
*aStyleContext = nsnull;
switch (aIndex) {
case NS_BUTTON_RENDERER_OUTLINE_CONTEXT_INDEX:
*aStyleContext = mOutlineStyle;
NS_IF_ADDREF(*aStyleContext);
break;
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
*aStyleContext = mInnerFocusStyle;
NS_IF_ADDREF(*aStyleContext);
@ -424,9 +384,7 @@ nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleCo
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;

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

@ -35,9 +35,9 @@
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_FOCUS_INNER_CONTEXT_INDEX 0
#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1
#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX
class nsButtonFrameRenderer {
@ -103,7 +103,6 @@ private:
nsCOMPtr<nsIStyleContext> mBorderStyle;
nsCOMPtr<nsIStyleContext> mInnerFocusStyle;
nsCOMPtr<nsIStyleContext> mOuterFocusStyle;
nsCOMPtr<nsIStyleContext> mOutlineStyle;
PRInt32 mNameSpace;
nsFrame* mFrame;

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

@ -101,6 +101,27 @@ nsHTMLButtonControlFrame::Init(nsIPresContext& aPresContext,
{
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
mRenderer.SetFrame(this,aPresContext);
// cache our display type
const nsStyleDisplay* styleDisplay;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
PRUint32 flags = NS_BLOCK_SPACE_MGR;
if (mInline) {
flags |= NS_BLOCK_SHRINK_WRAP;
}
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame, flags);
mFrames.SetFrames(areaFrame);
// Resolve style and initialize the frame
nsIStyleContext* styleContext;
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::buttonContentPseudo,
mStyleContext, PR_FALSE,
&styleContext);
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
NS_RELEASE(styleContext);
return rv;
}
@ -382,27 +403,7 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
// add ourself as an nsIFormControlFrame
nsFormFrame::AddFormControlFrame(aPresContext, *this);
// cache our display type
const nsStyleDisplay* styleDisplay;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
PRUint32 flags = NS_BLOCK_SPACE_MGR;
if (mInline) {
flags |= NS_BLOCK_SHRINK_WRAP;
}
nsIFrame* areaFrame;
NS_NewAreaFrame(&areaFrame, flags);
mFrames.SetFrames(areaFrame);
// Resolve style and initialize the frame
nsIStyleContext* styleContext;
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::buttonContentPseudo,
mStyleContext, PR_FALSE,
&styleContext);
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
NS_RELEASE(styleContext);
// Set the parent for each of the child frames
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) {
frame->SetParent(mFrames.FirstChild());

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

@ -912,21 +912,26 @@ nsresult
nsCSSFrameConstructor::CreateInputFrame(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsIStyleContext *aStyleContext)
nsIStyleContext *aStyleContext,
PRBool &aIsButton)
{
nsresult rv;
aIsButton = PR_FALSE;
// Figure out which type of input frame to create
nsAutoString val;
if (NS_OK == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, val)) {
if (val.EqualsIgnoreCase("submit")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("reset")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("button")) {
rv = ConstructButtonControlFrame(aPresContext, aFrame);
aIsButton = PR_TRUE;
}
else if (val.EqualsIgnoreCase("checkbox")) {
rv = ConstructCheckboxControlFrame(aPresContext, aFrame);
@ -2730,6 +2735,23 @@ nsCSSFrameConstructor::ConstructButtonLabelFrame(nsIPresContext *aPresContext,
return rv;
}
nsresult
nsCSSFrameConstructor::ConstructButtonFrames(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems)
{
// Construct button label frame using generated content
// Get the first area frame to insert the button as a child.
nsIFrame* areaFrame = nsnull;
aFrame->FirstChild(nsnull, &areaFrame);
NS_ASSERTION(areaFrame != nsnull, "Button does not have an area frame");
nsresult rv = ConstructButtonLabelFrame(aPresContext, aContent, areaFrame, aState, aFrameItems);
return rv;
}
nsresult
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresContext* aPresContext,
@ -3090,6 +3112,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
PRBool isReplaced = PR_FALSE;
PRBool addToHashTable = PR_TRUE;
nsresult rv = NS_OK;
PRBool isButton = PR_FALSE;
if (nsLayoutAtoms::textTagName == aTag) {
rv = NS_NewTextFrame(&newFrame);
@ -3143,7 +3166,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
}
else if (nsHTMLAtoms::input == aTag) {
isReplaced = PR_TRUE;
rv = CreateInputFrame(aPresContext, aContent, newFrame, aStyleContext);
rv = CreateInputFrame(aPresContext, aContent, newFrame, aStyleContext, isButton);
}
else if (nsHTMLAtoms::textarea == aTag) {
isReplaced = PR_TRUE;
@ -3249,11 +3272,16 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext
PR_TRUE, childItems, PR_FALSE);
}
if (nsHTMLAtoms::input == aTag) {
// Construct button label frame using generated content
ConstructButtonLabelFrame(aPresContext, aContent, newFrame, aState, childItems);
}
// Create button label frames.
// This must be done after the Init so
// the button label frames get the proper
// parent style context.
// XXX: Need to reorganize nsCSSFrameConstructor
// so we don't have to special case buttons here.
if (isButton) {
rv = ConstructButtonFrames(aPresContext, aContent, newFrame, aState, childItems);
}
// if there are any anonymous children create frames for them
CreateAnonymousFrames(aPresContext, aTag, aState, aContent, newFrame,
childItems);

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

@ -428,6 +428,11 @@ protected:
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems);
nsresult ConstructButtonFrames(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsFrameConstructorState& aState,
nsFrameItems& aFrameItems);
nsresult ConstructButtonControlFrame(nsIPresContext* aPresContext,
nsIFrame*& aNewFrame);
@ -527,7 +532,8 @@ protected:
nsresult CreateInputFrame(nsIPresContext *aPresContext,
nsIContent *aContent,
nsIFrame *&aFrame,
nsIStyleContext *aStyleContext);
nsIStyleContext *aStyleContext,
PRBool &aIsButton);
nsresult RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
nsIPresShell * aPresShell,