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
This commit is contained in:
kmcclusk%netscape.com 1999-02-18 22:07:23 +00:00
Родитель d611203194
Коммит 602be9dfc4
11 изменённых файлов: 50 добавлений и 56 удалений

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

@ -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");

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

@ -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");

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

@ -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<nsIStyleContext> 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<nsIStyleContext> 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<nsIStyleContext> fileButtonStyle(mStyleContext);
nsCOMPtr<nsIAtom> fileButtonAtom (NS_NewAtom(":file-button"));
aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext,
PR_FALSE,
getter_AddRefs(fileButtonStyle));
nsCOMPtr<nsIStyleContext> fileTextFieldStyle(mStyleContext);
nsCOMPtr<nsIAtom> 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);

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

@ -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

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

@ -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");

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

@ -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;

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

@ -330,7 +330,8 @@ nsButtonControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
#ifdef NS_GFX_RENDER_FORM_ELEMENTS
nsCOMPtr<nsIStyleContext> outlineStyle(mStyleContext);
nsCOMPtr<nsIAtom> 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;

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

@ -310,7 +310,6 @@ nsCheckboxControlFrame::PaintCheckBox(nsIPresContext& aPresContext,
{
aRenderingContext.PushState();
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);

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

@ -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<nsIStyleContext> 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<nsIStyleContext> 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<nsIStyleContext> fileButtonStyle(mStyleContext);
nsCOMPtr<nsIAtom> fileButtonAtom (NS_NewAtom(":file-button"));
aPresContext.ProbePseudoStyleContextFor(mContent, fileButtonAtom, mStyleContext,
PR_FALSE,
getter_AddRefs(fileButtonStyle));
nsCOMPtr<nsIStyleContext> fileTextFieldStyle(mStyleContext);
nsCOMPtr<nsIAtom> 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);

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

@ -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

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

@ -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;