Bug 1689603 - Return 2px border for most widgets in nsNativeBasicTheme. r=spohl

This is slightly unfortunate on one hand because we're technically lying
(but so is chromium and our GTK theme, on the other hand).

It is nice because it means that themed and unthemed controls have the
same size by default though, which seems desirable.

So I'm a bit on the edge here, but I think this is probably the less bad
option to grow our form controls if we want to do it.

Differential Revision: https://phabricator.services.mozilla.com/D103477
This commit is contained in:
Emilio Cobos Álvarez 2021-01-29 21:18:54 +00:00
Родитель eebe62f30e
Коммит a091ae7d29
1 изменённых файлов: 16 добавлений и 13 удалений

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

@ -1277,26 +1277,29 @@ aManager, nsIFrame* aFrame, StyleAppearance aAppearance, const nsRect& aRect)
LayoutDeviceIntMargin nsNativeBasicTheme::GetWidgetBorder(
nsDeviceContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance) {
DPIRatio dpiRatio = GetDPIRatio(aFrame, aAppearance);
switch (aAppearance) {
case StyleAppearance::Textfield:
case StyleAppearance::Textarea:
case StyleAppearance::NumberInput: {
LayoutDeviceIntCoord w = SnapBorderWidth(kTextFieldBorderWidth, dpiRatio);
return LayoutDeviceIntMargin(w, w, w, w);
}
case StyleAppearance::NumberInput:
case StyleAppearance::Listbox:
case StyleAppearance::Menulist:
case StyleAppearance::MenulistButton: {
LayoutDeviceIntCoord w = SnapBorderWidth(kMenulistBorderWidth, dpiRatio);
return LayoutDeviceIntMargin(w, w, w, w);
}
case StyleAppearance::Button: {
LayoutDeviceIntCoord w = SnapBorderWidth(kButtonBorderWidth, dpiRatio);
return LayoutDeviceIntMargin(w, w, w, w);
}
case StyleAppearance::MenulistButton:
case StyleAppearance::Button:
// Return the border size from the UA sheet, even though what we paint
// doesn't actually match that. We know this is the UA sheet border
// because we disable native theming when different border widths are
// specified by authors, see nsNativeBasicTheme::IsWidgetStyled.
//
// The Rounded() bit is technically redundant, but needed to appease the
// type system, we should always end up with full device pixels due to
// round_border_to_device_pixels at style time.
return LayoutDeviceIntMargin::FromAppUnits(
aFrame->StyleBorder()->GetComputedBorder(),
aFrame->PresContext()->AppUnitsPerDevPixel())
.Rounded();
case StyleAppearance::Checkbox:
case StyleAppearance::Radio: {
DPIRatio dpiRatio = GetDPIRatio(aFrame, aAppearance);
LayoutDeviceIntCoord w =
SnapBorderWidth(kCheckboxRadioBorderWidth, dpiRatio);
return LayoutDeviceIntMargin(w, w, w, w);