Commit graph

187 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
4f8856c545 Bug 1730503 - Make RDM force Android-style scrollbars better. r=mstange,devtools-backward-compat-reviewers,nchevobbe
There are a few bits that still don't work with this patch but will with the
following patches.

Differential Revision: https://phabricator.services.mozilla.com/D128083
2021-10-12 09:21:17 +00:00
Emilio Cobos Álvarez
2095f9d26f Bug 1735077 - Don't change indeterminate radio rendering, as that's apparently a thing.
MANUAL PUSH: Trivial reftest fix CLOSED TREE.
2021-10-11 15:52:27 +02:00
Emilio Cobos Álvarez
745866d09d Bug 1735077 - Fix rendering of <input type=checkbox/radio disabled checked>. r=jwatt
The simplification in bug 1734115 missed this case.

Differential Revision: https://phabricator.services.mozilla.com/D128054
2021-10-11 12:45:01 +00:00
Emilio Cobos Alvarez
f03b517ce2 Bug 1734723 - Don't use transparent borders for checkbox/radio when focused. r=mstange
As those don't draw the outline on top.

Differential Revision: https://phabricator.services.mozilla.com/D127890
2021-10-08 10:59:02 +00:00
Emilio Cobos Álvarez
e50c80851e Bug 1734115 - Add basic support for dark form controls to nsNativeBasicTheme. r=mstange
For that:

 * Tweak the standin system colors to match the non-native theme.

 * Use those system colors for button and field backgrounds.

 * Rename the "should use system colors" bit to "is high contrast",
   which is what it really is (specially now that we use system colors
   also in non-high-contrast).

Border colors and other colors like the <input type=range> and such
might need some extra tweaking perhaps, but this is a decent start and
looks good in https://crisal.io/tmp/form-controls.html afaict (dark mode
toggle needs the color-scheme pref enabled of course).

Differential Revision: https://phabricator.services.mozilla.com/D127533
2021-10-05 14:40:52 +00:00
Emilio Cobos Álvarez
e2d6174424 Bug 1734010 - Remove unneeded special-case for datetime reset button in nsNativeBasicTheme. r=jwatt
The button specifies background-color: transparent in an author
stylesheet and thus is unthemed:

  https://searchfox.org/mozilla-central/rev/25002b534963ad95ff0c1a3dd0f906ba023ddc8e/toolkit/content/widgets/datetimebox.css#53

While at it, simplify similar code / remove unneeded includes.

Differential Revision: https://phabricator.services.mozilla.com/D127486
2021-10-05 13:55:41 +00:00
Emilio Cobos Álvarez
faacceefe2 Bug 1734009 - Pass color-related arguments down to the non-native theme in a more convenient way. r=dholbert
This avoids adding yet another parameter for the light/dark
color-scheme.

This shouldn't have any behavior change, but is a prerequisite to
implement dark form controls on the non-native theme.

Differential Revision: https://phabricator.services.mozilla.com/D127482
2021-10-05 09:40:00 +00:00
Daniel Holbert
70f76180d5 Bug 1733465 part 3: Make nsPresContext::GetRootWidget() return an already_AddRefed pointer instead of a raw pointer. r=tnikkel
Also, make the same change to nsPresContext::GetTextInputHandlingWidget and
TextComposition::GetWidget, which are essentially aliases/wrappers for this
function.

This patch shouldn't change behavior at all, aside from:
* optimizing away some redundant reference counting and widget-lookups
* delaying some nsIWidget::Release() calls, which will now happen after we're
  actually done using the object, instead of happening when the getter
  completes. (It's unlikely this impacts behavior, because there are other
  objects that are keeping the nsIWidget instance alive.)

Motivation / "wins" from this patch:
* nsPresContext::GetRootWidget already works with a refcounted pointer
  internally. Before this patch, it drops the reference before returning the
  pointer.  This is a bit suspect and would cause security issues, in the
  unlikely event that this were the last strong reference to the object.  It
  can just as easily/efficiently transfer the strong reference to the caller,
  and let the caller determine when to release it.
* Many of the callers were already storing the return value in nsCOMPtr, which
  meant that they were incurring an additional AddRef/Release when
  populating/destructing that smart pointer. Now they can just take ownership
  of the already_AddRefed return value and avoid redundnat refcount-churn.
* For the callers that weren't storing the return value in nsCOMPtr, some of
  them were calling this getter twice in a row (once to test for truthiness and
  once to use the known-truthy value).  This was wasteful, both from the
  repeated lookup-work (since the function isn't a trivial getter), and from
  repeated refcount-churn.  This patch collapses these repeat-calls to a single
  call, avoiding those inefficiencies.

Differential Revision: https://phabricator.services.mozilla.com/D127180
2021-10-01 20:38:10 +00:00
Sandor Molnar
325902a5b7 Backed out 5 changesets (bug 1733465) for causing android build bustages in android/SessionAccessibility.cpp. CLOSED TREE
Backed out changeset 4c5b28b66740 (bug 1733465)
Backed out changeset 3db0452b185c (bug 1733465)
Backed out changeset d7460c9c6acb (bug 1733465)
Backed out changeset 3cee3f595e45 (bug 1733465)
Backed out changeset 267d5fc92f12 (bug 1733465)
2021-10-01 19:13:59 +03:00
Daniel Holbert
54c1df0de9 Bug 1733465 part 3: Make nsPresContext::GetRootWidget() return an already_AddRefed pointer instead of a raw pointer. r=tnikkel
Also, make the same change to nsPresContext::GetTextInputHandlingWidget and
TextComposition::GetWidget, which are essentially aliases/wrappers for this
function.

This patch shouldn't change behavior at all, aside from:
* optimizing away some redundant reference counting and widget-lookups
* delaying some nsIWidget::Release() calls, which will now happen after we're
  actually done using the object, instead of happening when the getter
  completes. (It's unlikely this impacts behavior, because there are other
  objects that are keeping the nsIWidget instance alive.)

Motivation / "wins" from this patch:
* nsPresContext::GetRootWidget already works with a refcounted pointer
  internally. Before this patch, it drops the reference before returning the
  pointer.  This is a bit suspect and would cause security issues, in the
  unlikely event that this were the last strong reference to the object.  It
  can just as easily/efficiently transfer the strong reference to the caller,
  and let the caller determine when to release it.
* Many of the callers were already storing the return value in nsCOMPtr, which
  meant that they were incurring an additional AddRef/Release when
  populating/destructing that smart pointer. Now they can just take ownership
  of the already_AddRefed return value and avoid redundnat refcount-churn.
* For the callers that weren't storing the return value in nsCOMPtr, some of
  them were calling this getter twice in a row (once to test for truthiness and
  once to use the known-truthy value).  This was wasteful, both from the
  repeated lookup-work (since the function isn't a trivial getter), and from
  repeated refcount-churn.  This patch collapses these repeat-calls to a single
  call, avoiding those inefficiencies.

Differential Revision: https://phabricator.services.mozilla.com/D127180
2021-10-01 14:37:06 +00:00
Emilio Cobos Álvarez
c18dd9edcd Bug 1731052 - Consider whether the color is CSS accessible to decide whether to use standins in nsNativeBasicTheme. r=mstange
We need to use standins for CSS-accesible colors in high contrast mode
(when appropriate) so that the CSS color matches the one in forms.css.

But this is not needed for e.g. scrollbar colors, which are not
CSS-accessible. So shuffle around the checks so that we account for
that as we should.

Differential Revision: https://phabricator.services.mozilla.com/D125830
2021-09-16 19:06:09 +00:00
Emilio Cobos Álvarez
8f9d065216 Bug 1730752 - Use SelectedItem rather than Highlight on nsNativeBasicTheme. r=morgan
Highlight is about selection colors since bug 1693222. SelectedItem is the
right color pair to use here. These are the same on Windows.

Differential Revision: https://phabricator.services.mozilla.com/D125594
2021-09-15 08:19:28 +00:00
Emilio Cobos Álvarez
f39a1503ae Bug 1730603 - Use standins if forced to in nsNativeBasicTheme.
MANUAL PUSH: hcm test fix CLOSED TREE
2021-09-14 02:55:51 +02:00
Emilio Cobos Álvarez
d41c93a17a Bug 1687682 - Make autofill use a semi-transparent background-image rather than filter. r=mstange,tgiles
With the non-native theme we don't need filter for this to affect
"native" inputs, we can just implement the logic in nsNativeBasicTheme
instead.

A bit unfortunate that we need that special-case, but it seems better
than using filter, which can break websites due to it creating an
stacking context.

I _think_ there are tests that I need to adjust for this change, but if
not I'll write some.

Keep the current behavior behind a pref just in case.

Differential Revision: https://phabricator.services.mozilla.com/D125232
2021-09-12 11:16:07 +00:00
Iulian Moraru
1121a4ab66 Backed out changeset 282b96702ce9 (bug 1687682) for causing multiple mochitest failures. 2021-09-11 04:07:28 +03:00
Emilio Cobos Álvarez
269520d9e9 Bug 1687682 - Make autofill use a semi-transparent background-image rather than filter. r=mstange,tgiles
With the non-native theme we don't need filter for this to affect
"native" inputs, we can just implement the logic in nsNativeBasicTheme
instead.

A bit unfortunate that we need that special-case, but it seems better
than using filter, which can break websites due to it creating an
stacking context.

I _think_ there are tests that I need to adjust for this change, but if
not I'll write some.

Keep the current behavior behind a pref just in case.

Differential Revision: https://phabricator.services.mozilla.com/D125232
2021-09-10 22:44:44 +00:00
Cosmin Sabou
c859adbb63 Bug 1727289 - null-check root pres context to avoid crashes on automation in some cases.
​
MANUAL PUSH: Trivial orange fix CLOSED TREE
​
2021-08-30 22:54:39 +03:00
Emilio Cobos Alvarez
d1f5731c04 Bug 1727289 - Prefer widget scale for scrollbar parts. r=mstange
Print preview documents might use a different DPI depending on the print
target.

Differential Revision: https://phabricator.services.mozilla.com/D123939
2021-08-30 18:01:44 +00:00
Emilio Cobos Álvarez
cd1744924f Bug 1722397 - Add a way to use the native accent color for selection and form controls on Android. r=agi
I tied it to the use-theme-accent bit in non-native-theme just for
convenience (so that form controls just react to this).

This works nicely, but I didn't turn this on by default because the
accessiblecaret images are hardcoded-blue pngs, and they look ugly
without being the same color as the native accent.

Differential Revision: https://phabricator.services.mozilla.com/D120898
2021-07-27 17:12:15 +00:00
Emilio Cobos Álvarez
9f65d4a846 Bug 1722031 - Tweak accent-color foreground computation and let it ride the trains. r=mstange
The accent-color computation right now chooses between black and white,
which is not ideal.

I tried to make it so that authors could choose the foreground colors in
the linked CSSWG issue from the comment, but that didn't go anywhere.

I think choosing a contrasting color that is in-line and contrasting
enough with the accent-color chosen by the page when darkening is better
than just black or white.

If we want the black-or-white behavior we can just change
layout.css.accent-color.target-contrast-ratio to something large enough.

https://accent-color.glitch.me/ is a nice playground to see this patch
in action.

Differential Revision: https://phabricator.services.mozilla.com/D120723
2021-07-24 13:30:25 +00:00
Emilio Cobos Alvarez
ec3cfdc989 Bug 1717245 - Don't use system colors in the non-native theme if we're not painting backgrounds. r=mstange
(Like for printing with backgrounds disabled).

Otherwise layout darkens our foreground colors etc, and that causes contrast to
be poor.

Since the point of not painting backgrounds is saving ink, using the
regular colors seems fine.

Differential Revision: https://phabricator.services.mozilla.com/D118276
2021-06-22 10:43:17 +00:00
Nicolas Silva
2be01aafa4 Bug 1711648 - Move LayoutRect to the Box2D representation. r=jrmuizel.
Differential Revision: https://phabricator.services.mozilla.com/D117293
2021-06-11 13:33:10 +00:00
Alexandru Michis
b9be72a526 Backed out 6 changesets (bug 1711648) for causing crashes in FrameBuilder.
CLOSED TREE

Backed out changeset 0384828b36cc (bug 1711648)
Backed out changeset 15d8e0d681ef (bug 1711648)
Backed out changeset b27d8421ebc5 (bug 1711648)
Backed out changeset 12da58f4ac4f (bug 1711648)
Backed out changeset 1d4c0b685f0e (bug 1711648)
Backed out changeset 367235e897e3 (bug 1711648)
2021-06-10 18:28:27 +03:00
Nicolas Silva
69c80ddaa7 Bug 1711648 - Move LayoutRect to the Box2D representation. r=jrmuizel.
Differential Revision: https://phabricator.services.mozilla.com/D117293
2021-06-10 13:07:34 +00:00
Marian-Vasile Laza
5dc1a42e67 Backed out 6 changesets (bug 1711648) for causing build bustages.
CLOSED TREE

Backed out changeset a803c960b909 (bug 1711648)
Backed out changeset d07c38d536c5 (bug 1711648)
Backed out changeset 823b75fc8c3c (bug 1711648)
Backed out changeset 602a2bcc5e29 (bug 1711648)
Backed out changeset 99ce7c7e458d (bug 1711648)
Backed out changeset bdbc65799b8a (bug 1711648)
2021-06-10 12:25:48 +03:00
Nicolas Silva
6cdbec834a Bug 1711648 - Move LayoutRect to the Box2D representation. r=jrmuizel.
Differential Revision: https://phabricator.services.mozilla.com/D117293
2021-06-10 08:08:07 +00:00
Emilio Cobos Álvarez
c413e19eec Bug 1714524 - Don't draw native theme focus outlines if the author specifies a non-auto outline. r=mstange
While this doesn't match traditional Gecko behavior, the non-native
theme has much more opinionated focus outlines so I think this makes
sense.

It also matches Safari and Chrome, afaict.

Differential Revision: https://phabricator.services.mozilla.com/D116831
2021-06-08 12:16:08 +00:00
Alexandru Michis
1d2f036537 Backed out changeset c97ffb4d1b95 (bug 1714524) for causing mochitest failures in test_focusrings.xhtml
CLOSED TREE
2021-06-08 04:34:29 +03:00
Emilio Cobos Álvarez
83e940c1fd Bug 1714524 - Don't draw native theme focus outlines if the author specifies a non-auto outline. r=mstange
While this doesn't match traditional Gecko behavior, the non-native
theme has much more opinionated focus outlines so I think this makes
sense.

It also matches Safari and Chrome, afaict.

Differential Revision: https://phabricator.services.mozilla.com/D116831
2021-06-07 23:54:21 +00:00
Emilio Cobos Álvarez
f2a6ce01df Bug 1690954 - Draw the menulist arrow button using currentColor rather than a fixed color. r=jfkthame
As its background might not be themed.

Differential Revision: https://phabricator.services.mozilla.com/D115194
2021-05-17 12:11:15 +00:00
Emilio Cobos Álvarez
2ecfa192c1 Bug 1710324 - Use non-native scrollbar drawing in nsNativeThemeGTK. r=stransky
Right now we paint scrollbars using gtk in nsNativeThemeGTK, and that
makes them look a bit inconsistent if the non-native implementation ends
up drawing them differently. I think scrollbars should look the same
regardless of where they're drawn.

This simplifies the code, and also brings proper scrollbar-{width,color}
support to the native theme, which is nice because Thunderbird uses it
if you use a theme there.

I opted for removing the code, but let me know if you'd rather keep it
behind the widget.non-native-theme.enabled pref or such.

Differential Revision: https://phabricator.services.mozilla.com/D114699
2021-05-11 13:57:18 +00:00
Emilio Cobos Álvarez
e746e3a732 Bug 1709647 - Don't use theme active scrollbar thumb color for dark scrollbars if it's greyish. r=stransky
As in that case it probably doesn't have enough contrast. This is drive-by
since, while I was looking at that GTK theme, the scrollbars are monochrome.

Differential Revision: https://phabricator.services.mozilla.com/D114394
2021-05-11 09:32:20 +00:00
Emilio Cobos Álvarez
34a9a0f457 Bug 1705605 - Implement accent-color in nsNativeBasicTheme. r=mstange
This is a new addition for CSS UI Level 4:

  https://drafts.csswg.org/css-ui-4/#widget-accent

I want to provide feedback on some spec issues, and thought it was a
kinda neat thing to prototype (it also makes testing contrast and such
with random GTK themes easier).

For now enable for Nightly only.

Differential Revision: https://phabricator.services.mozilla.com/D112312
2021-04-27 10:41:00 +00:00
Emilio Cobos Álvarez
c0ba36dc12 Bug 1703774 - Fix radii computation in WebRender codepath for auto-style outline. r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D111235
2021-04-08 14:23:25 +00:00
Emilio Cobos Alvarez
9ac846cb5c Bug 1703604 - When using a transparent scrollbar button / track color, use the thumb color to paint the scrollbar arrow. r=spohl
This improves the rendering of youtube.com on Windows, and I think should be uncontroversial.

scrollbar-color: transparent transparent will still get you the fully transparent scrollbar.

Differential Revision: https://phabricator.services.mozilla.com/D111137
2021-04-08 09:48:01 +00:00
Butkovits Atila
933498728f Backed out changeset 47b38a36e71a (bug 1703604) for causing bustages at nsNativeBasicThemeGTK.cpp. CLOSED TREE 2021-04-08 02:55:47 +03:00
Emilio Cobos Alvarez
25c7684295 Bug 1703604 - When using a transparent scrollbar button / track color, use the thumb color to paint the scrollbar arrow. r=spohl
This improves the rendering of youtube.com on Windows, and I think should be uncontroversial.

scrollbar-color: transparent transparent will still get you the fully transparent scrollbar.

Differential Revision: https://phabricator.services.mozilla.com/D111137
2021-04-07 19:41:17 +00:00
Stephen A Pohl
b35b953353 Bug 1702755: Correct corner radii of progress bar, range and meter form controls in non-native theme. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D110668
2021-04-02 14:39:17 +00:00
Emilio Cobos Álvarez
390c6943fe Bug 1702676 - Change public LookAndFeel API to accept a color scheme. r=mstange
This shouldn't change behavior, but is the biggest cross-platform part
of the change so I'd like to get it landed sooner rather than later.

The two calls like:

  GetColor(ColorID::TextSelectBackground, color);
  if (color == 0x000000) {
    mColorTextSelectForeground = NS_RGB(0xff, 0xff, 0xff);
  } else {
    mColorTextSelectForeground = NS_DONT_CHANGE_COLOR;
  }

that I'm removing are just broken. They were calling the version of
GetColor the function that took a default value when the color wasn't
available, not the version of the color with the outparam.

To prevent such mistakes, add two signatures, GetColor(), returning a
Maybe<nscolor> and Color(), returning a color with a fallback.

Differential Revision: https://phabricator.services.mozilla.com/D110651
2021-04-02 12:22:14 +00:00
Narcis Beleuzu
e9fb777466 Backed out changeset 597b9606c3ca (bug 1702676) for reftest failures on mq_prefers_reduced_motion_reduce.html CLOSED TREE 2021-04-02 09:34:53 +03:00
Emilio Cobos Álvarez
f7f84a3c53 Bug 1702676 - Change public LookAndFeel API to accept a color scheme. r=mstange
This shouldn't change behavior, but is the biggest cross-platform part
of the change so I'd like to get it landed sooner rather than later.

The two calls like:

  GetColor(ColorID::TextSelectBackground, color);
  if (color == 0x000000) {
    mColorTextSelectForeground = NS_RGB(0xff, 0xff, 0xff);
  } else {
    mColorTextSelectForeground = NS_DONT_CHANGE_COLOR;
  }

that I'm removing are just broken. They were calling the version of
GetColor the function that took a default value when the color wasn't
available, not the version of the color with the outparam.

To prevent such mistakes, add two signatures, GetColor(), returning a
Maybe<nscolor> and Color(), returning a color with a fallback.

Differential Revision: https://phabricator.services.mozilla.com/D110651
2021-04-02 00:21:37 +00:00
Emilio Cobos Álvarez
92686b6ec6 Bug 1702282 - Minor cleanup to ComputeCheckboxColors. r=mstange
No behavior change.

Depends on D110449

Differential Revision: https://phabricator.services.mozilla.com/D110450
2021-04-01 19:02:19 +00:00
Emilio Cobos Álvarez
f7e9b9f2f8 Bug 1702282 - Improve contrast of disabled checkmarks and radio buttons. r=mstange
Use a more opaque checkmark color.

Depends on D110448

Differential Revision: https://phabricator.services.mozilla.com/D110449
2021-04-01 19:02:19 +00:00
Emilio Cobos Álvarez
01639dfc2d Bug 1702282 - Remove useless !isDisabled checks in nsNativeBasicTheme. r=mstange
We always check whether something is disabled first so they're just
noise.

No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D110448
2021-04-01 19:02:18 +00:00
Emilio Cobos Álvarez
0c995f22b1 Bug 1701825 - Minor scrollbar tweaks. r=stransky
This is a follow-up that I thought was worth doing, but let me know if
you disagree or what not. I think this produces the best results:

 * For light pages, we still get light scrollbars for the track, but the
   active thumb still uses the dark theme highlight color.

 * For dark pages, we again still use the themed highlight color for the
   thumb, and we use dark scrollbar colors elsewhere like we do now.

Again, let me know if you think this is not worth it, or is too much, or
what not. I've tested this on a decent range of popular GTK themes and
it looks like a clear progression to me.

Differential Revision: https://phabricator.services.mozilla.com/D110203
2021-03-30 17:31:33 +00:00
Emilio Cobos Álvarez
03f14a4edc Bug 1701846 - Make setting overlay scrollbars on GTK do something sane-ish. r=mstange
So that they work sorta similar to the native ones. This is intended
mostly for testing, but hey, if someone is motivated enough...

I haven't tracked the native gtk overlay scrollbar durations down,
someone motivated enough could do that if they wanted to. But this seems
close enough.

Differential Revision: https://phabricator.services.mozilla.com/D110192
2021-03-30 03:31:21 +00:00
Emilio Cobos Álvarez
ab1118bc65 Bug 1700802 - Add a small radius to the auto style outline. r=mstange
(When not following the frame's border radius of course)

This makes stuff like:

  data:text/html,<input style="border-color: lightgrey">

More aesthetically pleasing when focused, and we still keep the square
inside the outline (this is what Safari does).

Differential Revision: https://phabricator.services.mozilla.com/D109680
2021-03-25 11:28:08 +00:00
Emilio Cobos Álvarez
75e5766b67 Bug 1699930 - Don't let GTK text scale affect non-native scrollbar sizes. r=mstange
This matches the native theme. We plumb it via LookAndFeel to avoid
having to load GTK settings in child processes.

Differential Revision: https://phabricator.services.mozilla.com/D109275
2021-03-22 16:11:33 +00:00
Emilio Cobos Álvarez
c0053473fd Bug 1699931 - Fix checked checkbox radius in the non-native theme. r=mstange
This is caused by a minor issue with WebRender disabled where the radii
was slightly off because it wasn't accounting for the deflation of the
rect.

Differential Revision: https://phabricator.services.mozilla.com/D109206
2021-03-22 08:12:22 +00:00
Emilio Cobos Álvarez
5cbba9b317 Bug 1699937 - Don't draw focus outlines for box-shadow in the non-native theme. r=mstange
This is a relatively easy way to improve the rendering with the
non-native theme while not regressing anything.

In the future, once non-native-theme is shipped and default everywhere,
I think we could provide something like:

  bool nsITheme::GetShadowRect(nsIFrame*, StyleAppearance, LayoutDeviceRect&, RectCornerRadii&)

or such, where we can provide a precise rect + radii, and we would avoid
painting the shadow if the function returned false. That would allow us
to remove the native theme box shadow code path, and avoid WR fallback,
all at once.

Differential Revision: https://phabricator.services.mozilla.com/D109209
2021-03-20 23:08:11 +00:00