From 92c173e493e448bc9f8a41576060d79d18d210e9 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Thu, 18 Feb 1999 22:07:23 +0000 Subject: [PATCH] Fixed call to ProbePseudoStyleContext in nsButtonControlFrame so it will compile when NS_GFX_RENDER_FORM_ELEMENTS is defined. Added checks to nsFileControlFrame::Reflow to make sure the pseudo styles actually could be loaded. If they can't be loaded it uses the file upload elements style. Changed file-buttonstyle to file-button and file-textstyle to file-text in ua.css git-svn-id: svn://10.0.0.236/trunk@21195 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/html/content/src/nsHTMLAtoms.cpp | 4 +- mozilla/content/shared/src/nsHTMLAtoms.cpp | 4 +- mozilla/layout/forms/nsFileControlFrame.cpp | 39 +++++++++---------- mozilla/layout/forms/nsFormControlFrame.h | 2 +- mozilla/layout/html/base/src/nsHTMLAtoms.cpp | 4 +- mozilla/layout/html/document/src/ua.css | 4 +- .../html/forms/src/nsButtonControlFrame.cpp | 3 +- .../html/forms/src/nsCheckboxControlFrame.cpp | 1 - .../html/forms/src/nsFileControlFrame.cpp | 39 +++++++++---------- .../html/forms/src/nsFormControlFrame.h | 2 +- mozilla/layout/style/ua.css | 4 +- 11 files changed, 50 insertions(+), 56 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index 04801d1f9f9..a039e55d9f8 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -354,8 +354,8 @@ void nsHTMLAtoms::AddrefAtoms() face = NS_NewAtom("face"); fieldset = NS_NewAtom("fieldset"); fieldsetContentPseudo = NS_NewAtom(":fieldset-content"); - fileButtonStylePseudo = NS_NewAtom(":file-buttonstyle"); - fileTextStylePseudo = NS_NewAtom(":file-textstyle"); + fileButtonStylePseudo = NS_NewAtom(":file-button"); + fileTextStylePseudo = NS_NewAtom(":file-text"); firstLetterPseudo = NS_NewAtom(":first-letter"); firstLinePseudo = NS_NewAtom(":first-line"); diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index 04801d1f9f9..a039e55d9f8 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -354,8 +354,8 @@ void nsHTMLAtoms::AddrefAtoms() face = NS_NewAtom("face"); fieldset = NS_NewAtom("fieldset"); fieldsetContentPseudo = NS_NewAtom(":fieldset-content"); - fileButtonStylePseudo = NS_NewAtom(":file-buttonstyle"); - fileTextStylePseudo = NS_NewAtom(":file-textstyle"); + fileButtonStylePseudo = NS_NewAtom(":file-button"); + fileTextStylePseudo = NS_NewAtom(":file-text"); firstLetterPseudo = NS_NewAtom(":first-letter"); firstLinePseudo = NS_NewAtom(":first-line"); diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 549467b3e4d..3393441d2c8 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -200,15 +200,20 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, } NS_NewTextControlFrame(childFrame); - + //XXX: This style should be cached, rather than resolved each time. // Get pseudo style for the text field nsCOMPtr textFieldStyleContext; nsresult rv = aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::fileTextStylePseudo, mStyleContext, PR_FALSE, getter_AddRefs(textFieldStyleContext)); - - childFrame->Init(aPresContext, text, this, textFieldStyleContext); + if (NS_SUCCEEDED(rv)) { + // Found the pseudo style for the text field + childFrame->Init(aPresContext, text, this, textFieldStyleContext); + } else { + // Can't find pseduo style so use the style set for the file updload element + childFrame->Init(aPresContext, mContent, this, mStyleContext); + } mTextFrame = (nsTextControlFrame*)childFrame; mFrames.SetFrames(childFrame); @@ -223,13 +228,19 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, ((nsButtonControlFrame*)childFrame)->SetMouseListener((nsIFormControlFrame*)this); mBrowseFrame = (nsButtonControlFrame*)childFrame; - // Get pseudo style for the button + //XXX: This style should be cached, rather than resolved each time. + // Get pseudo style for the button nsCOMPtr buttonStyleContext; rv = aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::fileButtonStylePseudo, mStyleContext, PR_FALSE, getter_AddRefs(buttonStyleContext)); - - childFrame->Init(aPresContext, browse, this, buttonStyleContext); + if (NS_SUCCEEDED(rv)) { + // Found pseduo style for the button + childFrame->Init(aPresContext, browse, this, buttonStyleContext); + } else { + // Can't find pseudo style for the button so use the style set for the file upload element + childFrame->Init(aPresContext, mContent, this, mStyleContext); + } mFrames.FirstChild()->SetNextSibling(childFrame); @@ -438,25 +449,11 @@ nsFileControlFrame::Paint(nsIPresContext& aPresContext, if (HasWidget()) return NS_OK; -#if 0 -//XXX: TODO Get style for button and text box using pseduo classes - nsCOMPtr fileButtonStyle(mStyleContext); - nsCOMPtr fileButtonAtom (NS_NewAtom(":file-button")); - aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext, - PR_FALSE, - getter_AddRefs(fileButtonStyle)); - - nsCOMPtr fileTextFieldStyle(mStyleContext); - nsCOMPtr fileButtonAtom (NS_NewAtom(":file-textfield")); - aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext, - PR_FALSE, - getter_AddRefs(fileTextFieldStyle)); -#endif nsAutoString browse("Browse..."); nsRect rect; mBrowseFrame->GetRect(rect); mBrowseFrame->PaintButton(aPresContext, aRenderingContext, aDirtyRect, - browse, rect /*, fileButtonStyle */); + browse, rect); mTextFrame->PaintTextControlBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index d6dab78827f..f5498ef817d 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -40,7 +40,7 @@ class nsFormFrame; // using GFX calls, rather than creating a widget. Undefining it // causes widgets to be used for form elements. @see RequiresWidget method // to see which widgets will obey this directive. -#undef NS_GFX_RENDER_FORM_ELEMENTS +#define NS_GFX_RENDER_FORM_ELEMENTS /** * nsFormControlFrame is the base class for frames of form controls. It diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index 04801d1f9f9..a039e55d9f8 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -354,8 +354,8 @@ void nsHTMLAtoms::AddrefAtoms() face = NS_NewAtom("face"); fieldset = NS_NewAtom("fieldset"); fieldsetContentPseudo = NS_NewAtom(":fieldset-content"); - fileButtonStylePseudo = NS_NewAtom(":file-buttonstyle"); - fileTextStylePseudo = NS_NewAtom(":file-textstyle"); + fileButtonStylePseudo = NS_NewAtom(":file-button"); + fileTextStylePseudo = NS_NewAtom(":file-text"); firstLetterPseudo = NS_NewAtom(":first-letter"); firstLinePseudo = NS_NewAtom(":first-line"); diff --git a/mozilla/layout/html/document/src/ua.css b/mozilla/layout/html/document/src/ua.css index f1a870c40d6..9e24217cb69 100644 --- a/mozilla/layout/html/document/src/ua.css +++ b/mozilla/layout/html/document/src/ua.css @@ -490,13 +490,13 @@ input[type=file] { color:black; } -:file-buttonstyle { +:file-button { border: 2px outset rgb(192, 192, 192); color:black; background-color: rgb(192, 192, 192); } -:file-textstyle { +:file-text { border: 2px inset rgb(192, 192, 192); margin-right:10px; background-color: white; diff --git a/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp index a7f8f4cb410..d5aec978a45 100644 --- a/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp @@ -330,7 +330,8 @@ nsButtonControlFrame::GetDesiredSize(nsIPresContext* aPresContext, #ifdef NS_GFX_RENDER_FORM_ELEMENTS nsCOMPtr outlineStyle(mStyleContext); nsCOMPtr sbAtom (NS_NewAtom(":button-outline")); - outlineStyle = aPresContext->ProbePseudoStyleContextFor(mContent, sbAtom, mStyleContext); + aPresContext->ProbePseudoStyleContextFor(mContent, sbAtom, mStyleContext, PR_FALSE, getter_AddRefs(outlineStyle)); + const nsStyleSpacing* outline = (const nsStyleSpacing*)outlineStyle->GetStyleData(eStyleStruct_Spacing); nsMargin outlineBorder; diff --git a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp index 1610e7f3ffc..be9a98b89ac 100644 --- a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp @@ -310,7 +310,6 @@ nsCheckboxControlFrame::PaintCheckBox(nsIPresContext& aPresContext, { aRenderingContext.PushState(); - float p2t; aPresContext.GetScaledPixelsToTwips(&p2t); diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 549467b3e4d..3393441d2c8 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -200,15 +200,20 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, } NS_NewTextControlFrame(childFrame); - + //XXX: This style should be cached, rather than resolved each time. // Get pseudo style for the text field nsCOMPtr textFieldStyleContext; nsresult rv = aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::fileTextStylePseudo, mStyleContext, PR_FALSE, getter_AddRefs(textFieldStyleContext)); - - childFrame->Init(aPresContext, text, this, textFieldStyleContext); + if (NS_SUCCEEDED(rv)) { + // Found the pseudo style for the text field + childFrame->Init(aPresContext, text, this, textFieldStyleContext); + } else { + // Can't find pseduo style so use the style set for the file updload element + childFrame->Init(aPresContext, mContent, this, mStyleContext); + } mTextFrame = (nsTextControlFrame*)childFrame; mFrames.SetFrames(childFrame); @@ -223,13 +228,19 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, ((nsButtonControlFrame*)childFrame)->SetMouseListener((nsIFormControlFrame*)this); mBrowseFrame = (nsButtonControlFrame*)childFrame; - // Get pseudo style for the button + //XXX: This style should be cached, rather than resolved each time. + // Get pseudo style for the button nsCOMPtr buttonStyleContext; rv = aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::fileButtonStylePseudo, mStyleContext, PR_FALSE, getter_AddRefs(buttonStyleContext)); - - childFrame->Init(aPresContext, browse, this, buttonStyleContext); + if (NS_SUCCEEDED(rv)) { + // Found pseduo style for the button + childFrame->Init(aPresContext, browse, this, buttonStyleContext); + } else { + // Can't find pseudo style for the button so use the style set for the file upload element + childFrame->Init(aPresContext, mContent, this, mStyleContext); + } mFrames.FirstChild()->SetNextSibling(childFrame); @@ -438,25 +449,11 @@ nsFileControlFrame::Paint(nsIPresContext& aPresContext, if (HasWidget()) return NS_OK; -#if 0 -//XXX: TODO Get style for button and text box using pseduo classes - nsCOMPtr fileButtonStyle(mStyleContext); - nsCOMPtr fileButtonAtom (NS_NewAtom(":file-button")); - aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext, - PR_FALSE, - getter_AddRefs(fileButtonStyle)); - - nsCOMPtr fileTextFieldStyle(mStyleContext); - nsCOMPtr fileButtonAtom (NS_NewAtom(":file-textfield")); - aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext, - PR_FALSE, - getter_AddRefs(fileTextFieldStyle)); -#endif nsAutoString browse("Browse..."); nsRect rect; mBrowseFrame->GetRect(rect); mBrowseFrame->PaintButton(aPresContext, aRenderingContext, aDirtyRect, - browse, rect /*, fileButtonStyle */); + browse, rect); mTextFrame->PaintTextControlBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.h b/mozilla/layout/html/forms/src/nsFormControlFrame.h index d6dab78827f..f5498ef817d 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.h +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.h @@ -40,7 +40,7 @@ class nsFormFrame; // using GFX calls, rather than creating a widget. Undefining it // causes widgets to be used for form elements. @see RequiresWidget method // to see which widgets will obey this directive. -#undef NS_GFX_RENDER_FORM_ELEMENTS +#define NS_GFX_RENDER_FORM_ELEMENTS /** * nsFormControlFrame is the base class for frames of form controls. It diff --git a/mozilla/layout/style/ua.css b/mozilla/layout/style/ua.css index f1a870c40d6..9e24217cb69 100644 --- a/mozilla/layout/style/ua.css +++ b/mozilla/layout/style/ua.css @@ -490,13 +490,13 @@ input[type=file] { color:black; } -:file-buttonstyle { +:file-button { border: 2px outset rgb(192, 192, 192); color:black; background-color: rgb(192, 192, 192); } -:file-textstyle { +:file-text { border: 2px inset rgb(192, 192, 192); margin-right:10px; background-color: white;