зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1646558 - Remove the old android "native" theme. r=geckoview-reviewers,agi
We've had nsNativeBasicTheme enabled since 75, and all reported issues were fixed real soon (and I haven't heard of any of them recently). Given the non-native theme is likely changing in the future, I'd rather not maintain three themes for Android :) Differential Revision: https://phabricator.services.mozilla.com/D80105
This commit is contained in:
Родитель
f3b96a236f
Коммит
8ca5b42689
|
@ -2811,12 +2811,6 @@ void Document::FillStyleSetUserAndUASheets() {
|
|||
mStyleSet->AppendStyleSheet(*cache->ScrollbarsSheet());
|
||||
mStyleSet->AppendStyleSheet(*cache->PluginProblemSheet());
|
||||
|
||||
if (StyleSheet* sheet = cache->GetGeckoViewSheet()) {
|
||||
if (!StaticPrefs::widget_disable_native_theme_for_content()) {
|
||||
mStyleSet->AppendStyleSheet(*sheet);
|
||||
}
|
||||
}
|
||||
|
||||
for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
mStyleSet->AppendStyleSheet(*sheet);
|
||||
}
|
||||
|
|
|
@ -46,14 +46,6 @@ class GlobalStyleSheetCache final : public nsIObserver,
|
|||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
StyleSheet* GetGeckoViewSheet() {
|
||||
#ifdef ANDROID
|
||||
return GeckoViewSheet();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
StyleSheet* GetUserContentSheet();
|
||||
StyleSheet* GetUserChromeSheet();
|
||||
StyleSheet* ChromePreferenceSheet();
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
STYLE_SHEET(ContentEditable, "resource://gre/res/contenteditable.css", true)
|
||||
STYLE_SHEET(CounterStyles, "resource://gre-resources/counterstyles.css", true)
|
||||
STYLE_SHEET(DesignMode, "resource://gre/res/designmode.css", true)
|
||||
#ifdef ANDROID
|
||||
STYLE_SHEET(GeckoView, "resource://gre-resources/geckoview.css", true)
|
||||
#endif
|
||||
STYLE_SHEET(Forms, "resource://gre-resources/forms.css", true)
|
||||
STYLE_SHEET(HTML, "resource://gre-resources/html.css", true)
|
||||
STYLE_SHEET(MathML, "resource://gre-resources/mathml.css", true)
|
||||
|
|
|
@ -11,9 +11,6 @@ toolkit.jar:
|
|||
res/noframes.css (res/noframes.css)
|
||||
* res/forms.css (res/forms.css)
|
||||
res/pluginproblem.css (res/pluginproblem.css)
|
||||
#ifdef ANDROID
|
||||
res/geckoview.css (res/geckoview.css)
|
||||
#endif
|
||||
res/arrow.gif (res/arrow.gif)
|
||||
res/arrow-left.gif (res/arrow-left.gif)
|
||||
res/arrow-right.gif (res/arrow-right.gif)
|
||||
|
|
|
@ -1,226 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@namespace url("http://www.w3.org/1999/xhtml");
|
||||
@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
@namespace svg url("http://www.w3.org/2000/svg");
|
||||
|
||||
/* Override inverse OS themes */
|
||||
textarea,
|
||||
button,
|
||||
xul|button,
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
|
||||
-moz-appearance: none !important; /* See bug 598421 for fixing the platform */
|
||||
-moz-default-appearance: none !important;
|
||||
}
|
||||
|
||||
textarea,
|
||||
button,
|
||||
xul|button,
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"], [type="range"])) {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
select[size],
|
||||
select[multiple],
|
||||
select[size][multiple],
|
||||
textarea,
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"], [type="range"])) {
|
||||
border-style: solid;
|
||||
border-color: #bfbfbf;
|
||||
color: #363b40;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
select:not([size]):not([multiple]),
|
||||
select[size="0"],
|
||||
select[size="1"],
|
||||
* > input[type="button"],
|
||||
* > input[type="submit"],
|
||||
* > input[type="reset"],
|
||||
button {
|
||||
border-style: solid;
|
||||
border-color: #bfbfbf;
|
||||
color: #363b40;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
select {
|
||||
border-width: 1px;
|
||||
padding: 1px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
select:not([size]):not([multiple]),
|
||||
select[size="0"],
|
||||
select[size="1"] {
|
||||
padding: 0 1px 0 1px;
|
||||
}
|
||||
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
|
||||
border-width: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
border-width: 1px;
|
||||
padding-inline-start: 1px;
|
||||
padding-inline-end: 1px;
|
||||
padding-block-start: 2px;
|
||||
padding-block-end: 2px;
|
||||
}
|
||||
|
||||
input[type="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"],
|
||||
input[type="color"],
|
||||
button {
|
||||
border-width: 1px;
|
||||
padding-inline-start: 7px;
|
||||
padding-inline-end: 7px;
|
||||
padding-block-start: 0;
|
||||
padding-block-end: 0;
|
||||
}
|
||||
|
||||
select > button {
|
||||
border-width: 0px !important;
|
||||
margin: 0px !important;
|
||||
padding: 0px !important;
|
||||
border-radius: 0;
|
||||
color: #414141;
|
||||
|
||||
background-size: auto auto;
|
||||
background-color: transparent;
|
||||
background-image: url("chrome://geckoview/skin/images/dropmarker.svg") !important;
|
||||
background-position: calc(50% + 1px) center !important;
|
||||
background-repeat: no-repeat !important;
|
||||
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
select[size]:focus,
|
||||
select[multiple]:focus,
|
||||
select[size][multiple]:focus,
|
||||
textarea:focus,
|
||||
input[type="file"]:focus > input[type="text"],
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):focus {
|
||||
outline: 0px !important;
|
||||
border-style: solid;
|
||||
border-color: #bfbfbf;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
select:not([size]):not([multiple]):focus,
|
||||
select[size="0"]:focus,
|
||||
select[size="1"]:focus,
|
||||
input[type="color"]:focus,
|
||||
input[type="button"]:focus,
|
||||
input[type="submit"]:focus,
|
||||
input[type="reset"]:focus,
|
||||
button:focus {
|
||||
outline: 0px !important;
|
||||
border-style: solid;
|
||||
border-color: #bfbfbf;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* we need to be specific for selects because the above rules are specific too */
|
||||
textarea:disabled,
|
||||
select[size]:disabled,
|
||||
select[multiple]:disabled,
|
||||
select[size][multiple]:disabled,
|
||||
select:not([size]):not([multiple]):disabled,
|
||||
select[size="0"]:disabled,
|
||||
select[size="1"]:disabled,
|
||||
button:disabled,
|
||||
button:disabled:active,
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):disabled,
|
||||
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])):disabled:active {
|
||||
color: #bebebe;
|
||||
border-color: #bfbfbf;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
select:not([size]):not([multiple]):disabled,
|
||||
select[size="0"]:disabled,
|
||||
select[size="1"]:disabled {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
input[type="button"]:disabled,
|
||||
input[type="button"]:disabled:active,
|
||||
input[type="submit"]:disabled,
|
||||
input[type="submit"]:disabled:active,
|
||||
input[type="reset"]:disabled,
|
||||
input[type="reset"]:disabled:active,
|
||||
input[type="color"]:disabled,
|
||||
input[type="color"]:disabled:active,
|
||||
button:disabled,
|
||||
button:disabled:active {
|
||||
padding-inline-start: 7px;
|
||||
padding-inline-end: 7px;
|
||||
padding-block-start: 0;
|
||||
padding-block-end: 0;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
select:disabled > button {
|
||||
opacity: 0.6;
|
||||
padding-inline-start: 7px;
|
||||
padding-inline-end: 7px;
|
||||
padding-block-start: 1px;
|
||||
padding-block-end: 1px;
|
||||
}
|
||||
|
||||
*:any-link:active,
|
||||
*[role=button]:active,
|
||||
button:not(:disabled):active,
|
||||
input:not(:-moz-any([type="checkbox"], [type="radio"])):not(:focus):not(:disabled):active,
|
||||
select:not(:disabled):active,
|
||||
textarea:not(:focus):not(:disabled):active,
|
||||
option:active,
|
||||
label:active,
|
||||
xul|menulist:active {
|
||||
background-color: rgba(171, 171, 171, 0.5);
|
||||
}
|
||||
|
||||
button:active:hover,
|
||||
input[type="color"]:active:hover,
|
||||
input[type="reset"]:active:hover,
|
||||
input[type="button"]:active:hover,
|
||||
input[type="submit"]:active:hover {
|
||||
padding-inline-end: 7px;
|
||||
padding-inline-start: 7px;
|
||||
}
|
||||
|
||||
input[type=number] > div > div, /* work around bug 946184 */
|
||||
input[type=number]::-moz-number-spin-box {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button:-moz-native-anonymous.datetime-reset-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input[type=range]::-moz-range-track {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
input[type=range][orient=block]::-moz-range-track {
|
||||
inline-size: 0.2em;
|
||||
block-size: 100%;
|
||||
}
|
||||
|
||||
input[type=range][orient=horizontal]::-moz-range-track {
|
||||
width: 100%;
|
||||
height: 0.2em;
|
||||
}
|
||||
|
||||
input[type=range][orient=vertical]::-moz-range-track {
|
||||
width: 0.2em;
|
||||
height: 100%;
|
||||
}
|
|
@ -135,7 +135,6 @@ UNIFIED_SOURCES += [
|
|||
'nsDeviceContextAndroid.cpp',
|
||||
'nsIdleServiceAndroid.cpp',
|
||||
'nsLookAndFeel.cpp',
|
||||
'nsNativeThemeAndroid.cpp',
|
||||
'nsPrintSettingsServiceAndroid.cpp',
|
||||
'nsWidgetFactory.cpp',
|
||||
'nsWindow.cpp',
|
||||
|
|
|
@ -1,310 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsNativeThemeAndroid.h"
|
||||
|
||||
#include "nsIFrame.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "AndroidColors.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "PathHelpers.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPrefs_widget.h"
|
||||
#include "nsNativeBasicTheme.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeAndroid, nsNativeTheme, nsITheme)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
static void ClampRectAndMoveToCenter(nsRect& aRect) {
|
||||
if (aRect.width < aRect.height) {
|
||||
aRect.y += (aRect.height - aRect.width) / 2;
|
||||
aRect.height = aRect.width;
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRect.height < aRect.width) {
|
||||
aRect.x += (aRect.width - aRect.height) / 2;
|
||||
aRect.width = aRect.height;
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintCheckboxControl(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
||||
const nsRect& aRect,
|
||||
const EventStates& aState) {
|
||||
// Checkbox controls aren't something that we can render on Android
|
||||
// natively. We fake native drawing of appearance: checkbox items
|
||||
// out here, and use hardcoded colours from AndroidColors.h to
|
||||
// simulate native theming.
|
||||
RectCornerRadii innerRadii(2, 2, 2, 2);
|
||||
nsRect paddingRect =
|
||||
nsCSSRendering::GetBoxShadowInnerPaddingRect(aFrame, aRect);
|
||||
const nscoord twipsPerPixel = aFrame->PresContext()->DevPixelsToAppUnits(1);
|
||||
Rect shadowGfxRect = NSRectToRect(paddingRect, twipsPerPixel);
|
||||
shadowGfxRect.Round();
|
||||
RefPtr<Path> roundedRect =
|
||||
MakePathForRoundedRect(*aDrawTarget, shadowGfxRect, innerRadii);
|
||||
aDrawTarget->Stroke(
|
||||
roundedRect,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBorderColor)));
|
||||
aDrawTarget->Fill(
|
||||
roundedRect,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBackgroundColor)));
|
||||
|
||||
if (aState.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
aDrawTarget->Fill(
|
||||
roundedRect,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidDisabledColor)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (aState.HasState(NS_EVENT_STATE_ACTIVE)) {
|
||||
aDrawTarget->Fill(
|
||||
roundedRect,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidActiveColor)));
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintCheckMark(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
||||
const nsRect& aRect) {
|
||||
// Points come from the coordinates on a 7X7 unit box centered at 0,0
|
||||
const int32_t checkPolygonX[] = {-3, -1, 3, 3, -1, -3};
|
||||
const int32_t checkPolygonY[] = {-1, 1, -3, -1, 3, 1};
|
||||
const int32_t checkNumPoints = sizeof(checkPolygonX) / sizeof(int32_t);
|
||||
const int32_t checkSize = 9; // 2 units of padding on either side
|
||||
// of the 7x7 unit checkmark
|
||||
|
||||
// Scale the checkmark based on the smallest dimension
|
||||
nscoord paintScale = std::min(aRect.width, aRect.height) / checkSize;
|
||||
nsPoint paintCenter(aRect.x + aRect.width / 2, aRect.y + aRect.height / 2);
|
||||
|
||||
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
|
||||
nsPoint p = paintCenter + nsPoint(checkPolygonX[0] * paintScale,
|
||||
checkPolygonY[0] * paintScale);
|
||||
|
||||
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
builder->MoveTo(NSPointToPoint(p, appUnitsPerDevPixel));
|
||||
for (int32_t polyIndex = 1; polyIndex < checkNumPoints; polyIndex++) {
|
||||
p = paintCenter + nsPoint(checkPolygonX[polyIndex] * paintScale,
|
||||
checkPolygonY[polyIndex] * paintScale);
|
||||
builder->LineTo(NSPointToPoint(p, appUnitsPerDevPixel));
|
||||
}
|
||||
RefPtr<Path> path = builder->Finish();
|
||||
aDrawTarget->Fill(
|
||||
path, ColorPattern(ToDeviceColor(mozilla::widget::sAndroidCheckColor)));
|
||||
}
|
||||
|
||||
static void PaintIndeterminateMark(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
||||
const nsRect& aRect) {
|
||||
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
|
||||
nsRect rect(aRect);
|
||||
rect.y += (rect.height - rect.height / 4) / 2;
|
||||
rect.height /= 4;
|
||||
|
||||
Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *aDrawTarget);
|
||||
|
||||
aDrawTarget->FillRect(
|
||||
devPxRect,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidCheckColor)));
|
||||
}
|
||||
|
||||
static void PaintRadioControl(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
||||
const nsRect& aRect, const EventStates& aState) {
|
||||
// Radio controls aren't something that we can render on Android
|
||||
// natively. We fake native drawing of appearance: radio items
|
||||
// out here, and use hardcoded colours to simulate native
|
||||
// theming.
|
||||
const nscoord twipsPerPixel = aFrame->PresContext()->DevPixelsToAppUnits(1);
|
||||
Rect devPxRect = NSRectToRect(aRect, twipsPerPixel);
|
||||
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
|
||||
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
|
||||
RefPtr<Path> ellipse = builder->Finish();
|
||||
aDrawTarget->Stroke(
|
||||
ellipse,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBorderColor)));
|
||||
aDrawTarget->Fill(
|
||||
ellipse,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBackgroundColor)));
|
||||
|
||||
if (aState.HasState(NS_EVENT_STATE_DISABLED)) {
|
||||
aDrawTarget->Fill(
|
||||
ellipse,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidDisabledColor)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (aState.HasState(NS_EVENT_STATE_ACTIVE)) {
|
||||
aDrawTarget->Fill(
|
||||
ellipse,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidActiveColor)));
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintCheckedRadioButton(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
||||
const nsRect& aRect) {
|
||||
// The dot is an ellipse 2px on all sides smaller than the content-box,
|
||||
// drawn in the foreground color.
|
||||
nsRect rect(aRect);
|
||||
rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
|
||||
nsPresContext::CSSPixelsToAppUnits(2));
|
||||
|
||||
Rect devPxRect = ToRect(nsLayoutUtils::RectToGfxRect(
|
||||
rect, aFrame->PresContext()->AppUnitsPerDevPixel()));
|
||||
|
||||
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
|
||||
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
|
||||
RefPtr<Path> ellipse = builder->Finish();
|
||||
aDrawTarget->Fill(
|
||||
ellipse,
|
||||
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidCheckColor)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeAndroid::DrawWidgetBackground(gfxContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
const nsRect& aRect,
|
||||
const nsRect& aDirtyRect) {
|
||||
EventStates eventState = GetContentState(aFrame, aAppearance);
|
||||
nsRect rect(aRect);
|
||||
ClampRectAndMoveToCenter(rect);
|
||||
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Radio:
|
||||
PaintRadioControl(aFrame, aContext->GetDrawTarget(), rect, eventState);
|
||||
if (IsSelected(aFrame)) {
|
||||
PaintCheckedRadioButton(aFrame, aContext->GetDrawTarget(), rect);
|
||||
}
|
||||
break;
|
||||
case StyleAppearance::Checkbox:
|
||||
PaintCheckboxControl(aFrame, aContext->GetDrawTarget(), rect, eventState);
|
||||
if (IsChecked(aFrame)) {
|
||||
PaintCheckMark(aFrame, aContext->GetDrawTarget(), rect);
|
||||
}
|
||||
if (GetIndeterminate(aFrame)) {
|
||||
PaintIndeterminateMark(aFrame, aContext->GetDrawTarget(), rect);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"Should not get here with a widget type we don't support.");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
LayoutDeviceIntMargin nsNativeThemeAndroid::GetWidgetBorder(
|
||||
nsDeviceContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance) {
|
||||
return LayoutDeviceIntMargin();
|
||||
}
|
||||
|
||||
bool nsNativeThemeAndroid::GetWidgetPadding(nsDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
LayoutDeviceIntMargin* aResult) {
|
||||
switch (aAppearance) {
|
||||
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
|
||||
// and have a meaningful baseline, so they can't have
|
||||
// author-specified padding.
|
||||
case StyleAppearance::Checkbox:
|
||||
case StyleAppearance::Radio:
|
||||
aResult->SizeTo(0, 0, 0, 0);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool nsNativeThemeAndroid::GetWidgetOverflow(nsDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
nsRect* aOverflowRect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeAndroid::GetMinimumWidgetSize(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
LayoutDeviceIntSize* aResult,
|
||||
bool* aIsOverridable) {
|
||||
if (aAppearance == StyleAppearance::Radio ||
|
||||
aAppearance == StyleAppearance::Checkbox) {
|
||||
// 9px + (1px padding + 1px border) * 2
|
||||
aResult->width = aPresContext->CSSPixelsToDevPixels(13);
|
||||
aResult->height = aPresContext->CSSPixelsToDevPixels(13);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeAndroid::WidgetStateChanged(nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
nsAtom* aAttribute,
|
||||
bool* aShouldRepaint,
|
||||
const nsAttrValue* aOldValue) {
|
||||
if (aAppearance == StyleAppearance::Radio ||
|
||||
aAppearance == StyleAppearance::Checkbox) {
|
||||
if (aAttribute == nsGkAtoms::active || aAttribute == nsGkAtoms::disabled ||
|
||||
aAttribute == nsGkAtoms::hover) {
|
||||
*aShouldRepaint = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
*aShouldRepaint = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeAndroid::ThemeChanged() { return NS_OK; }
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsNativeThemeAndroid::ThemeSupportsWidget(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance) {
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Radio:
|
||||
case StyleAppearance::Checkbox:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsNativeThemeAndroid::WidgetIsContainer(StyleAppearance aAppearance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsNativeThemeAndroid::ThemeDrawsFocusForWidget(
|
||||
StyleAppearance aAppearance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsNativeThemeAndroid::ThemeNeedsComboboxDropmarker() { return false; }
|
||||
|
||||
nsITheme::Transparency nsNativeThemeAndroid::GetWidgetTransparency(
|
||||
nsIFrame* aFrame, StyleAppearance aAppearance) {
|
||||
return eUnknownTransparency;
|
||||
}
|
||||
|
||||
already_AddRefed<nsITheme> do_GetNativeThemeDoNotUseDirectly() {
|
||||
static nsCOMPtr<nsITheme> inst;
|
||||
|
||||
if (!inst) {
|
||||
if (StaticPrefs::widget_disable_native_theme_for_content()) {
|
||||
inst = new nsNativeBasicTheme();
|
||||
} else {
|
||||
inst = new nsNativeThemeAndroid();
|
||||
}
|
||||
ClearOnShutdown(&inst);
|
||||
}
|
||||
|
||||
return do_AddRef(inst);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsNativeThemeAndroid_h_
|
||||
#define nsNativeThemeAndroid_h_
|
||||
|
||||
#include "nsITheme.h"
|
||||
#include "nsNativeTheme.h"
|
||||
|
||||
class nsNativeThemeAndroid final : private nsNativeTheme, public nsITheme {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// The nsITheme interface.
|
||||
NS_IMETHOD DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
const nsRect& aRect,
|
||||
const nsRect& aDirtyRect) override;
|
||||
|
||||
[[nodiscard]] LayoutDeviceIntMargin GetWidgetBorder(
|
||||
nsDeviceContext* aContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance) override;
|
||||
|
||||
bool GetWidgetPadding(nsDeviceContext* aContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
LayoutDeviceIntMargin* aResult) override;
|
||||
|
||||
bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
nsRect* aOverflowRect) override;
|
||||
|
||||
NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
mozilla::LayoutDeviceIntSize* aResult,
|
||||
bool* aIsOverridable) override;
|
||||
|
||||
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, StyleAppearance aAppearance,
|
||||
nsAtom* aAttribute, bool* aShouldRepaint,
|
||||
const nsAttrValue* aOldValue) override;
|
||||
|
||||
NS_IMETHOD ThemeChanged() override;
|
||||
|
||||
NS_IMETHOD_(bool)
|
||||
ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance) override;
|
||||
|
||||
NS_IMETHOD_(bool) WidgetIsContainer(StyleAppearance aAppearance) override;
|
||||
|
||||
NS_IMETHOD_(bool)
|
||||
ThemeDrawsFocusForWidget(StyleAppearance aAppearance) override;
|
||||
|
||||
bool ThemeNeedsComboboxDropmarker() override;
|
||||
|
||||
Transparency GetWidgetTransparency(nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance) override;
|
||||
|
||||
nsNativeThemeAndroid() {}
|
||||
|
||||
protected:
|
||||
virtual ~nsNativeThemeAndroid() {}
|
||||
};
|
||||
|
||||
#endif // nsNativeThemeAndroid_h_
|
|
@ -932,3 +932,10 @@ already_AddRefed<nsITheme> do_GetBasicNativeThemeDoNotUseDirectly() {
|
|||
}
|
||||
return do_AddRef(gInstance);
|
||||
}
|
||||
|
||||
// On Android there's no native theme.
|
||||
#ifdef ANDROID
|
||||
already_AddRefed<nsITheme> do_GetNativeThemeDoNotUseDirectly() {
|
||||
return do_GetBasicNativeThemeDoNotUseDirectly();
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче