Bug 1352238 Part 1 - Make box construction and layout for radio/checkbox elements work the same on Android as on other platforms. r?mats
MozReview-Commit-ID: NmWepjKDVj
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3831,29 +3831,24 @@ nsCSSFrameConstructor::FindInputData(Ele
// display (in practice, none).
};
nsCOMPtr<nsIFormControl> control = do_QueryInterface(aElement);
NS_ASSERTION(control, "input doesn't implement nsIFormControl?");
auto controlType = control->ControlType();
- // Note that Android widgets don't have theming support and thus
- // appearance:none is the same as any other appearance value.
- // So this chunk doesn't apply there:
-#if !defined(MOZ_WIDGET_ANDROID)
// radio and checkbox inputs with appearance:none should be constructed
// by display type. (Note that we're not checking that appearance is
// not (respectively) NS_THEME_RADIO and NS_THEME_CHECKBOX.)
if ((controlType == NS_FORM_INPUT_CHECKBOX ||
controlType == NS_FORM_INPUT_RADIO) &&
aStyleContext->StyleDisplay()->mAppearance == NS_THEME_NONE) {
return nullptr;
}
-#endif
return FindDataByInt(controlType, aElement, aStyleContext,
sInputData, ArrayLength(sInputData));
}
/* static */
const nsCSSFrameConstructor::FrameConstructionData*
nsCSSFrameConstructor::FindObjectData(Element* aElement,
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -39,78 +39,64 @@ NS_QUERYFRAME_HEAD(nsFormControlFrame)
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsAtomicContainerFrame)
/* virtual */ nscoord
nsFormControlFrame::GetMinISize(gfxContext *aRenderingContext)
{
nscoord result;
DISPLAY_MIN_WIDTH(this, result);
-#if !defined(MOZ_WIDGET_ANDROID)
result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize();
-#else
- result = DefaultSize();
-#endif
return result;
}
/* virtual */ nscoord
nsFormControlFrame::GetPrefISize(gfxContext *aRenderingContext)
{
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
-#if !defined(MOZ_WIDGET_ANDROID)
result = StyleDisplay()->mAppearance == NS_THEME_NONE ? 0 : DefaultSize();
-#else
- result = DefaultSize();
-#endif
return result;
}
/* virtual */
LogicalSize
nsFormControlFrame::ComputeAutoSize(gfxContext* aRC,
WritingMode aWM,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
const LogicalSize& aMargin,
const LogicalSize& aBorder,
const LogicalSize& aPadding,
ComputeSizeFlags aFlags)
{
LogicalSize size(aWM, 0, 0);
-#if !defined(MOZ_WIDGET_ANDROID)
if (StyleDisplay()->mAppearance == NS_THEME_NONE) {
return size;
}
-#endif
+
// 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");
-// NOTE: on Android we use appearance:none by default for checkbox/radio,
-// so the different layout for appearance:none we have on other platforms
-// doesn't work there. *shrug*
-#if !defined(MOZ_WIDGET_ANDROID)
// For appearance:none we use a standard CSS baseline, i.e. synthesized from
// our margin-box.
if (StyleDisplay()->mAppearance == NS_THEME_NONE) {
return nsAtomicContainerFrame::GetLogicalBaseline(aWritingMode);
}
-#endif
// This is for compatibility with Chrome, Safari and Edge (Dec 2016).
// Treat radio buttons and checkboxes as having an intrinsic baseline
// at the block-end of the control (use the block-end content edge rather
// than the margin edge).
// For "inverted" lines (typically in writing-mode:vertical-lr), use the
// block-start end instead.
return aWritingMode.IsLineInverted()