author | Mats Palmgren <mats@mozilla.com> |
Thu, 09 Feb 2017 21:22:40 +0100 (2017-02-09) | |
changeset 341707 | cad4365c7898c0bff7f68ed8ec50091cf8a63f47 |
parent 341706 | a7000da4b6e2a79c5750dad71095865bdf75be04 |
child 341708 | c9c62dffd9170562895698d61de6a27997371815 |
push id | 31341 |
push user | kwierso@gmail.com |
push date | Fri, 10 Feb 2017 01:01:45 +0000 (2017-02-10) |
treeherder | mozilla-central@25a94c1047e7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dholbert |
bugs | 605985 |
milestone | 54.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/forms/nsFormControlFrame.cpp +++ b/layout/forms/nsFormControlFrame.cpp @@ -44,61 +44,50 @@ NS_QUERYFRAME_HEAD(nsFormControlFrame) NS_QUERYFRAME_ENTRY(nsIFormControlFrame) NS_QUERYFRAME_TAIL_INHERITING(nsAtomicContainerFrame) /* virtual */ nscoord nsFormControlFrame::GetMinISize(nsRenderingContext *aRenderingContext) { nscoord result; DISPLAY_MIN_WIDTH(this, result); - result = GetIntrinsicISize(); + result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize(); return result; } /* virtual */ nscoord nsFormControlFrame::GetPrefISize(nsRenderingContext *aRenderingContext) { nscoord result; DISPLAY_PREF_WIDTH(this, result); - result = GetIntrinsicISize(); + result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize(); return result; } /* virtual */ LogicalSize -nsFormControlFrame::ComputeAutoSize(nsRenderingContext* aRenderingContext, +nsFormControlFrame::ComputeAutoSize(nsRenderingContext* aRC, WritingMode aWM, const LogicalSize& aCBSize, nscoord aAvailableISize, const LogicalSize& aMargin, const LogicalSize& aBorder, const LogicalSize& aPadding, ComputeSizeFlags aFlags) { - const WritingMode wm = GetWritingMode(); - LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize()); - return result.ConvertTo(aWM, wm); -} - -nscoord -nsFormControlFrame::GetIntrinsicISize() -{ - // Provide a reasonable default for sites that use an "auto" height. - // Note that if you change this, you should change the values in forms.css - // as well. This is the 13px default width minus the 2px default border. - return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2); -} - -nscoord -nsFormControlFrame::GetIntrinsicBSize() -{ - // Provide a reasonable default for sites that use an "auto" height. - // Note that if you change this, you should change the values in forms.css - // as well. This is the 13px default width minus the 2px default border. - return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2); + LogicalSize size(aWM, 0, 0); + if (StyleDisplay()->mAppearance == NS_THEME_NONE) { + return size; + } + // Note: this call always set the BSize to NS_UNCONSTRAINEDSIZE. + size = nsAtomicContainerFrame::ComputeAutoSize(aRC, aWM, aCBSize, + aAvailableISize, aMargin, + aBorder, aPadding, aFlags); + size.BSize(aWM) = DefaultSize(); + return size; } nscoord nsFormControlFrame::GetLogicalBaseline(WritingMode aWritingMode) const { NS_ASSERTION(!NS_SUBTREE_DIRTY(this), "frame must not be dirty");
--- a/layout/forms/nsFormControlFrame.h +++ b/layout/forms/nsFormControlFrame.h @@ -103,27 +103,26 @@ public: * draw dropdowns. */ static nsRect GetUsableScreenRect(nsPresContext* aPresContext); protected: virtual ~nsFormControlFrame(); - nscoord GetIntrinsicISize(); - nscoord GetIntrinsicBSize(); + static nscoord DefaultSize() + { + // XXXmats We have traditionally always returned 9px for GetMin/PrefISize + // but we might want to factor in what the theme says, something like: + // GetMinimumWidgetSize - GetWidgetPadding - GetWidgetBorder. + return nsPresContext::CSSPixelsToAppUnits(9); + } -// -//------------------------------------------------------------------------------------- -// Utility methods for managing checkboxes and radiobuttons -//------------------------------------------------------------------------------------- -// - /** - * Get the state of the checked attribute. - * @param aState set to true if the checked attribute is set, - * false if the checked attribute has been removed - */ - + /** + * Get the state of the checked attribute. + * @param aState set to true if the checked attribute is set, + * false if the checked attribute has been removed + */ void GetCurrentCheckState(bool* aState); }; #endif
--- a/layout/style/res/forms.css +++ b/layout/style/res/forms.css @@ -546,72 +546,91 @@ input[type="file"]:dir(rtl) > xul|label /* radio buttons */ input[type="radio"] { -moz-appearance: radio; margin-block-start: 3px; margin-block-end: 0px; margin-inline-start: 5px; margin-inline-end: 3px; - border-radius: 100%; } /* check boxes */ input[type="checkbox"] { -moz-appearance: checkbox; margin-block-start: 3px; margin-block-end: 3px; margin-inline-start: 4px; margin-inline-end: 3px; - border-radius: 0; } /* common features of radio buttons and check boxes */ +input[type="radio"], +input[type="checkbox"] { + box-sizing: border-box; + cursor: default; + /* unset some values from the general 'input' rule above: */ + padding: unset; + -moz-binding: unset; + border: unset; + background-color: unset; +} + +input[type="radio"]:disabled, +input[type="radio"]:disabled:active, +input[type="radio"]:disabled:hover, +input[type="radio"]:disabled:hover:active, +input[type="checkbox"]:disabled, +input[type="checkbox"]:disabled:active, +input[type="checkbox"]:disabled:hover, +input[type="checkbox"]:disabled:hover:active { + cursor: inherit; +} + +%if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) +/* + * These platforms doesn't have any theming support and thus appearance:none + * is the same as any other appearance value. + * XXX This is not web-compatible and should be fixed. + */ +input[type="radio"] { + border-radius: 100%; +} + +input[type="checkbox"] { + border-radius: 0; +} + /* NOTE: The width, height, border-width, and padding here must all add up the way nsFormControlFrame::GetIntrinsic(Width|Height) expects them to, or they will not come out with total width equal to total height on sites that set their 'width' or 'height' to 'auto'. (Should we maybe set !important on width and height, then?) */ input[type="radio"], input[type="checkbox"] { - box-sizing: border-box; inline-size: 13px; block-size: 13px; - cursor: default; - padding: 0; - -moz-binding: none; border: 2px inset ThreeDLightShadow; background-repeat: no-repeat; background-position: center; } input[type="radio"]:disabled, input[type="radio"]:disabled:active, input[type="radio"]:disabled:hover, input[type="radio"]:disabled:hover:active, input[type="checkbox"]:disabled, input[type="checkbox"]:disabled:active, input[type="checkbox"]:disabled:hover, input[type="checkbox"]:disabled:hover:active { padding: 1px; border: 1px inset ThreeDShadow; - cursor: inherit; } -% On Mac, the native theme takes care of this. -% See nsNativeThemeCocoa::ThemeDrawsFocusForWidget. -%ifndef XP_MACOSX -input[type="checkbox"]:-moz-focusring, -input[type="radio"]:-moz-focusring { - /* Don't specify the outline-color, we should always use initial value. */ - outline: 1px dotted; -} -%endif - input[type="checkbox"]:hover:active, input[type="radio"]:hover:active { background-color: ThreeDFace; border-style: inset; } input[type="radio"] { background-size: calc(100% - 4px) calc(100% - 4px); @@ -640,16 +659,28 @@ input[type="checkbox"]:disabled:checked input[type="checkbox"]:indeterminate { background-image: url(indeterminate-checkmark.svg); } input[type="checkbox"]:indeterminate:disabled { background-image: url(indeterminate-checkmark.svg#disabled); } +%endif /* defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) */ + +% On Mac, the native theme takes care of this. +% See nsNativeThemeCocoa::ThemeDrawsFocusForWidget. +%ifndef XP_MACOSX +input[type="checkbox"]:-moz-focusring, +input[type="radio"]:-moz-focusring { + /* Don't specify the outline-color, we should always use initial value. */ + outline: 1px dotted; +} +%endif + input[type="search"] { box-sizing: border-box; } /* buttons */ /* Note: Values in nsNativeTheme IsWidgetStyled function need to match button background/border values here */