зеркало из https://github.com/mozilla/pjs.git
Disabling Quirks sizing for form controls, it can be put back in via a pref
and uncommenting a line in quirk.css Bug 91602 r=dcone sr=attinasi
This commit is contained in:
Родитель
fc4702dcbe
Коммит
974b9579d7
|
@ -33,6 +33,10 @@
|
|||
#include "nsStyleUtil.h"
|
||||
#include "nsCSSAtoms.h"
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class nsShellISupportsKey : public nsHashKey {
|
||||
public:
|
||||
nsISupports* mKey;
|
||||
|
@ -1239,8 +1243,22 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
|
|||
case NS_STYLE_FONT_FIELD: sysID = eSystemAttr_Font_Field; break;
|
||||
}
|
||||
|
||||
nsCompatibility mode;
|
||||
nsCompatibility mode = eCompatibility_Standard;
|
||||
|
||||
if (sysID == eSystemAttr_Font_Field ||
|
||||
sysID == eSystemAttr_Font_List ||
|
||||
sysID == eSystemAttr_Font_Button) {
|
||||
nsCOMPtr<nsIPref> prefService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefService) {
|
||||
PRBool useEitherMode;
|
||||
if (NS_SUCCEEDED(prefService->GetBoolPref("layout.forms.use_standard_or_quirks", &useEitherMode))) {
|
||||
if (useEitherMode) {
|
||||
mPresContext->GetCompatibilityMode(&mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
mPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
if (dc) {
|
||||
|
|
|
@ -81,6 +81,10 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|||
// it a synonym for "soft"
|
||||
#define kTextControl_Wrap_Off "OFF"
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
#include "nsIPref.h"
|
||||
PRPackedBool nsFormControlHelper::mCompatFirstTime = PR_TRUE;
|
||||
PRPackedBool nsFormControlHelper::mUseEitherMode = PR_FALSE;
|
||||
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsFormControlHelper)
|
||||
|
@ -147,7 +151,7 @@ nsCompatibility
|
|||
nsFormControlHelper::GetRepChars(nsIPresContext* aPresContext, char& char1, char& char2)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_Standard == mode) {
|
||||
char1 = 'W';
|
||||
char2 = 'w';
|
||||
|
@ -464,7 +468,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
|
|||
#endif
|
||||
|
||||
nsCompatibility qMode;
|
||||
aPresContext->GetCompatibilityMode(&qMode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, qMode);
|
||||
|
||||
// determine the width, char height, row height
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width
|
||||
|
@ -599,7 +603,7 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
|
|||
}
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
|
||||
if (eCompatibility_Standard == mode) {
|
||||
aFont = &styleFont->mFont;
|
||||
|
@ -1003,3 +1007,27 @@ nsFormControlHelper::DoManualSubmitOrReset(nsIPresContext* aPresContext,
|
|||
return result;
|
||||
}
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
//
|
||||
void nsFormControlHelper::GetFormCompatibilityMode(nsIPresContext* aPresContext,
|
||||
nsCompatibility& aCompatMode)
|
||||
{
|
||||
if (mCompatFirstTime) {
|
||||
nsCOMPtr<nsIPref> prefService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefService) {
|
||||
PRBool useEitherMode;
|
||||
if (NS_SUCCEEDED(prefService->GetBoolPref("layout.forms.use_standard_or_quirks", &useEitherMode))) {
|
||||
if (useEitherMode) {
|
||||
mUseEitherMode = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
mCompatFirstTime = PR_FALSE;
|
||||
}
|
||||
|
||||
if (mUseEitherMode) {
|
||||
aPresContext->GetCompatibilityMode(&aCompatMode);
|
||||
} else {
|
||||
aCompatMode = eCompatibility_Standard;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,11 +334,15 @@ public:
|
|||
nsIStyleContext* aStyleContext, nsString& aLabel,
|
||||
nsIFrame* aForFrame);
|
||||
|
||||
static void GetFormCompatibilityMode(nsIPresContext* aPresContext, nsCompatibility& mCompatMode);
|
||||
|
||||
protected:
|
||||
nsFormControlHelper();
|
||||
virtual ~nsFormControlHelper();
|
||||
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
static PRPackedBool mCompatFirstTime;
|
||||
static PRPackedBool mUseEitherMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -628,7 +628,7 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
} else { // Normal reflow.
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
|
||||
if (mode == eCompatibility_NavQuirks) {
|
||||
// nsHTMLButtonControlFrame::Reflow registers it for Standard Mode
|
||||
|
|
|
@ -322,7 +322,7 @@ PRBool
|
|||
nsHTMLButtonControlFrame::IsSubmit(nsIPresContext* aPresContext, PRInt32 type)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_Standard == mode && mContent != nsnull) {
|
||||
// The default type for a html4 button is NS_FORM_BUTTON_BUTTON,
|
||||
// but that does not mean that the type was actually set to "button"
|
||||
|
|
|
@ -265,6 +265,7 @@ input[type="radio"] {
|
|||
vertical-align: baseline;
|
||||
-moz-border-radius: 100%;
|
||||
-moz-binding: none;
|
||||
margin: 3px 3px 0px 5px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
@ -278,7 +279,7 @@ input[type="checkbox"] {
|
|||
cursor: default;
|
||||
vertical-align: text-bottom;
|
||||
-moz-binding: none;
|
||||
margin: 3px 4px 3px 4px;
|
||||
margin: 3px 3px 3px 4px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,30 +155,22 @@ pre[wrap], pre[cols], pre[width] {
|
|||
}
|
||||
|
||||
|
||||
/* Quirk: no bottom padding */
|
||||
/* Temporary - Test of full time Standard mode for forms Bug 91602
|
||||
input[type="text"] {
|
||||
background-color: blue;
|
||||
padding: 1px 0 0 0;
|
||||
}
|
||||
|
||||
|
||||
/* Quirk: text inputs and textareas have special font (b=44656) */
|
||||
/* dealt with at the code level */
|
||||
|
||||
|
||||
/* Quirk: special margins for radio buttons */
|
||||
input[type="radio"] {
|
||||
margin: 2px 5px 4px 3px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
|
||||
/* Quirk: special margins for check boxes */
|
||||
input[type="checkbox"] {
|
||||
margin: 3px 4px 3px 3px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
|
||||
button,
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
|
@ -186,8 +178,6 @@ input[type="submit"] {
|
|||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
/* Quirk: special top and bottom margins for inputs in tables */
|
||||
|
||||
td select[size] {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 1px;
|
||||
|
@ -212,6 +202,7 @@ td textarea {
|
|||
margin-top: 1px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Quirk: HRs avoid floats (b=18754) */
|
||||
|
||||
|
|
|
@ -81,6 +81,10 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|||
// it a synonym for "soft"
|
||||
#define kTextControl_Wrap_Off "OFF"
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
#include "nsIPref.h"
|
||||
PRPackedBool nsFormControlHelper::mCompatFirstTime = PR_TRUE;
|
||||
PRPackedBool nsFormControlHelper::mUseEitherMode = PR_FALSE;
|
||||
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsFormControlHelper)
|
||||
|
@ -147,7 +151,7 @@ nsCompatibility
|
|||
nsFormControlHelper::GetRepChars(nsIPresContext* aPresContext, char& char1, char& char2)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_Standard == mode) {
|
||||
char1 = 'W';
|
||||
char2 = 'w';
|
||||
|
@ -464,7 +468,7 @@ nsFormControlHelper::CalculateSize (nsIPresContext* aPresContext,
|
|||
#endif
|
||||
|
||||
nsCompatibility qMode;
|
||||
aPresContext->GetCompatibilityMode(&qMode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, qMode);
|
||||
|
||||
// determine the width, char height, row height
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width
|
||||
|
@ -599,7 +603,7 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
|
|||
}
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
|
||||
if (eCompatibility_Standard == mode) {
|
||||
aFont = &styleFont->mFont;
|
||||
|
@ -1003,3 +1007,27 @@ nsFormControlHelper::DoManualSubmitOrReset(nsIPresContext* aPresContext,
|
|||
return result;
|
||||
}
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
//
|
||||
void nsFormControlHelper::GetFormCompatibilityMode(nsIPresContext* aPresContext,
|
||||
nsCompatibility& aCompatMode)
|
||||
{
|
||||
if (mCompatFirstTime) {
|
||||
nsCOMPtr<nsIPref> prefService(do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefService) {
|
||||
PRBool useEitherMode;
|
||||
if (NS_SUCCEEDED(prefService->GetBoolPref("layout.forms.use_standard_or_quirks", &useEitherMode))) {
|
||||
if (useEitherMode) {
|
||||
mUseEitherMode = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
mCompatFirstTime = PR_FALSE;
|
||||
}
|
||||
|
||||
if (mUseEitherMode) {
|
||||
aPresContext->GetCompatibilityMode(&aCompatMode);
|
||||
} else {
|
||||
aCompatMode = eCompatibility_Standard;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,11 +334,15 @@ public:
|
|||
nsIStyleContext* aStyleContext, nsString& aLabel,
|
||||
nsIFrame* aForFrame);
|
||||
|
||||
static void GetFormCompatibilityMode(nsIPresContext* aPresContext, nsCompatibility& mCompatMode);
|
||||
|
||||
protected:
|
||||
nsFormControlHelper();
|
||||
virtual ~nsFormControlHelper();
|
||||
|
||||
|
||||
// Temporary - Test of full time Standard mode for forms (Bug 91602)
|
||||
static PRPackedBool mCompatFirstTime;
|
||||
static PRPackedBool mUseEitherMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -373,7 +373,7 @@ void nsFormFrame::DoDefaultSelection(nsIPresContext* aPresContext,
|
|||
// If in standard mode, then a radio group MUST default
|
||||
// to the first item in the group (it must be selected)
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_Standard == mode) {
|
||||
// first find out if any have a default selection
|
||||
PRInt32 i;
|
||||
|
|
|
@ -628,7 +628,7 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
} else { // Normal reflow.
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
|
||||
if (mode == eCompatibility_NavQuirks) {
|
||||
// nsHTMLButtonControlFrame::Reflow registers it for Standard Mode
|
||||
|
|
|
@ -1569,6 +1569,9 @@ nsGfxTextControlFrame2::CalculateSizeStandard (nsIPresContext* aPresContex
|
|||
aDesiredSize.height = GUESS_INPUT_SIZE; // punt
|
||||
}
|
||||
|
||||
// Internal padding is necessary for better matching IE's width
|
||||
nscoord internalPadding = 0;
|
||||
|
||||
// Get the Average char width to calc the min width and
|
||||
// pref width. Pref Width is calced by multiplying the size times avecharwidth
|
||||
//
|
||||
|
@ -1578,6 +1581,15 @@ nsGfxTextControlFrame2::CalculateSizeStandard (nsIPresContext* aPresContex
|
|||
// the platforms and ports.
|
||||
#if defined(_WIN32) || defined(XP_OS2)
|
||||
fontMet->GetAveCharWidth(charWidth);
|
||||
|
||||
// Get frame font
|
||||
const nsFont * font = nsnull;
|
||||
if (NS_SUCCEEDED(aFrame->GetFont(aPresContext, font))) {
|
||||
// To better match IE, take the size (in twips) and remove 4 pixels
|
||||
// add this on as additional padding
|
||||
internalPadding = PR_MAX(font->size - NSToCoordRound(4 * p2t), 0);
|
||||
}
|
||||
|
||||
#else
|
||||
// XP implementation of AveCharWidth
|
||||
nsAutoString aveStr;
|
||||
|
@ -1608,6 +1620,9 @@ nsGfxTextControlFrame2::CalculateSizeStandard (nsIPresContext* aPresContex
|
|||
aDesiredSize.width = aSpec.mColDefaultSize * charWidth;
|
||||
}
|
||||
|
||||
// Now add the extra internal padding on
|
||||
aDesiredSize.width += internalPadding;
|
||||
|
||||
aRowHeight = aDesiredSize.height;
|
||||
aMinSize.height = aDesiredSize.height;
|
||||
PRInt32 numRows = 0;
|
||||
|
@ -2274,7 +2289,7 @@ nsGfxTextControlFrame2::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|||
mNotifyOnInput = PR_TRUE;//its ok to notify now. all has been prepared.
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
PRBool navQuirksMode = eCompatibility_NavQuirks == mode && nameSpaceID == kNameSpaceID_HTML;
|
||||
|
||||
nsReflowStatus aStatus;
|
||||
|
@ -2409,7 +2424,7 @@ nsGfxTextControlFrame2::GetSizeFromContent(PRInt32* aSize) const
|
|||
// then we can check the compatibility mode
|
||||
#ifdef FUTURE_ADDITIONAL_FIX_FOR_46224
|
||||
nsCompatibility mode;
|
||||
mPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
*aSize = 1;
|
||||
} else {
|
||||
|
|
|
@ -322,7 +322,7 @@ PRBool
|
|||
nsHTMLButtonControlFrame::IsSubmit(nsIPresContext* aPresContext, PRInt32 type)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(&mode);
|
||||
nsFormControlHelper::GetFormCompatibilityMode(aPresContext, mode);
|
||||
if (eCompatibility_Standard == mode && mContent != nsnull) {
|
||||
// The default type for a html4 button is NS_FORM_BUTTON_BUTTON,
|
||||
// but that does not mean that the type was actually set to "button"
|
||||
|
|
|
@ -265,6 +265,7 @@ input[type="radio"] {
|
|||
vertical-align: baseline;
|
||||
-moz-border-radius: 100%;
|
||||
-moz-binding: none;
|
||||
margin: 3px 3px 0px 5px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
@ -278,7 +279,7 @@ input[type="checkbox"] {
|
|||
cursor: default;
|
||||
vertical-align: text-bottom;
|
||||
-moz-binding: none;
|
||||
margin: 3px 4px 3px 4px;
|
||||
margin: 3px 3px 3px 4px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,30 +155,22 @@ pre[wrap], pre[cols], pre[width] {
|
|||
}
|
||||
|
||||
|
||||
/* Quirk: no bottom padding */
|
||||
/* Temporary - Test of full time Standard mode for forms Bug 91602
|
||||
input[type="text"] {
|
||||
background-color: blue;
|
||||
padding: 1px 0 0 0;
|
||||
}
|
||||
|
||||
|
||||
/* Quirk: text inputs and textareas have special font (b=44656) */
|
||||
/* dealt with at the code level */
|
||||
|
||||
|
||||
/* Quirk: special margins for radio buttons */
|
||||
input[type="radio"] {
|
||||
margin: 2px 5px 4px 3px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
|
||||
/* Quirk: special margins for check boxes */
|
||||
input[type="checkbox"] {
|
||||
margin: 3px 4px 3px 3px;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
|
||||
button,
|
||||
input[type="reset"],
|
||||
input[type="button"],
|
||||
|
@ -186,8 +178,6 @@ input[type="submit"] {
|
|||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
/* Quirk: special top and bottom margins for inputs in tables */
|
||||
|
||||
td select[size] {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 1px;
|
||||
|
@ -212,6 +202,7 @@ td textarea {
|
|||
margin-top: 1px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Quirk: HRs avoid floats (b=18754) */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче