Commit graph

8732 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
a9baf5fe3d style: Use first generic rather than only generic to determine fallback font family
This seems like more sensible behavior. We have another use of
only_generic(), but that affects font sizing and other browsers agree
with us there:

  <div style="font-family: monospace">Should be 13px</div>
  <div style="font-family: something, monospace">Should be 16px</div>

So not touching that one.

Differential Revision: https://phabricator.services.mozilla.com/D130732
2023-06-09 10:22:20 +02:00
Emilio Cobos Álvarez
88b82f569b style: Top layer elements that are display:contents should be display: block
As per https://fullscreen.spec.whatwg.org/#new-stacking-layer:

    If its specified display property is contents, it computes to block.

Differential Revision: https://phabricator.services.mozilla.com/D131585
2023-06-09 10:22:20 +02:00
Ting-Yu Lin
2dbc89d1f5 style: Support scrollbar-gutter in the style system
This patch adds `scrollbar-gutter` property in CSS Overflow level 3 [1] to the
style system.

`devtools/shared/css/generated/properties-db.js` is generated by
`./mach devtools-css-db`.

[1] https://drafts.csswg.org/css-overflow-3/#scrollbar-gutter-property

Differential Revision: https://phabricator.services.mozilla.com/D131460
2023-06-09 10:22:19 +02:00
Ting-Yu Lin
a0617bff0d style: Run rustfmt on servo/components/style and servo/ports/geckolib
This patch is generated by running `cargo +nightly fmt` under
`servo/components/style/` and `servo/ports/geckolib` against mozilla-central
https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512

My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17)

Manually remove the redundant braces in author_styles.rs to fix a warning.

Differential Revision: https://phabricator.services.mozilla.com/D131556
2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
33ad82c3da style: Make custom properties that are IACVT guaranteed-invalid
This effectively backs out bug 1623396.

See:

  https://github.com/w3c/csswg-drafts/pull/6006
  https://drafts.csswg.org/css-variables/#guaranteed-invalid-value

And related discussion. Matches Chrome stable as per https://groups.google.com/a/chromium.org/g/blink-dev/c/0xrbzYe_vxU/m/7bsL76n9CgAJ

Depends on D116459

Differential Revision: https://phabricator.services.mozilla.com/D116460
2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
71ec52f140 style: Partially back out bug 1105364
Apparently using transparent borders and outlines is a common
accessibility technique to make those visible in HCM.

Bug 1740924 comment 9 seemed to indicate we were the only browser
rendering those browsers, but I just confirmed that Edge at least does
show them.

Keep respecting system colors as that's per spec.

Differential Revision: https://phabricator.services.mozilla.com/D131412
2023-06-09 10:22:19 +02:00
Oriol Brufau
7797a19c70 Further changes required by Servo 2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
c232cd49b4 style: Use preferred color scheme when forcing colors with system colors (except windows HCM)
This causes (among other things) pages to be dark when using regular
windows system colors and forcing colors to "always", which is nice.

Differential Revision: https://phabricator.services.mozilla.com/D131165
2023-06-09 10:22:19 +02:00
Mats Palmgren
71c04d1d3c style: [css-lists] Remove the internal '-moz-list-reversed' CSS property that is no longer needed
Differential Revision: https://phabricator.services.mozilla.com/D129957
2023-06-09 10:22:19 +02:00
Mats Palmgren
82c0673881 style: [css-lists] Style system changes to support 'reversed(<counter-name>)'
Differential Revision: https://phabricator.services.mozilla.com/D129955
2023-06-09 10:22:18 +02:00
Emilio Cobos Álvarez
53b657e97b style: Add a foreground color to attention selection
In some platforms (like macOS, windows dark mode, android, and some gtk
themes) the foreground selection color might be `currentcolor`, and that
doesn't generally guarantee enough contrast with the attention
background.

Remove HeadlessLookAndFeelGTK's handling of this color since it's
useless (always overridden by prefs in all.js)

Differential Revision: https://phabricator.services.mozilla.com/D130617
2023-06-09 10:22:18 +02:00
Emilio Cobos Álvarez
063d736837 style: Remove some prefs for pseudo-classes that we have shipped/unshipped successfully
And remove code for :-moz-submit-invalid completely.

Differential Revision: https://phabricator.services.mozilla.com/D130737
2023-06-09 10:22:18 +02:00
Emilio Cobos Álvarez
6d887b96bc style: Unexpose :-moz-locale-dir and :-moz-lwtheme* from content
Behind a pref for now. Given these selectors do nothing on non-chrome
documents (they just don't match) it seems worth trying.

A cursory search seems to indicate they're not used for UA detection or
something like that (or at least I haven't found such an usage).

Differential Revision: https://phabricator.services.mozilla.com/D130736
2023-06-09 10:22:18 +02:00
Emilio Cobos Álvarez
04282ff04c style: Allow matches() / querySelector() / etc on chrome docs to access chrome-only selectors. r=boris
Without this some tests fail with the previous patch because code like:

  https://searchfox.org/mozilla-central/rev/267682a8f45221bf0bfe999d4a0239706a43bc56/browser/base/content/browser-gestureSupport.js#651

starts throwing. Unfortunately I had missed that on my try run, because
the error message didn't include that exception (it seemed like an
intermittent browser-chrome failure instead).

We could expose a ChromeOnly API for this, but this seems better. This
fixes it trivially, and also removes the "no url data" situation from
the selector parser, which is nice.

Differential Revision: https://phabricator.services.mozilla.com/D130818
2023-06-09 10:22:18 +02:00
Emilio Cobos Álvarez
a0e29d7032 style: Refactor :-moz-lwtheme pseudo-classes to get invalidated correctly
Use the same document state mechanism we have for :moz-locale-dir. Also,
simplify the setup of the later to be the same as :dir(), allowing the
matching code to be less repetitive.

This should fix some flakiness in chrome mochitests, but we have no existing
tests for these pseudo-classes more generally and since they're just
chrome-only I'm not super-excited about adding more.

Differential Revision: https://phabricator.services.mozilla.com/D130735
2023-06-09 10:22:17 +02:00
Emilio Cobos Álvarez
5b68241958 style: Simplify :dir() implementation
This I noticed while working on the following patches. Shouldn't have
any behavior change: the behavior does in fact match the element state
flag semantics correctly if we do this. We did split the dir flags into
two element bits a while ago.

:not(:dir()) still behaves correctly of course, and we have tests for that.

Differential Revision: https://phabricator.services.mozilla.com/D130734
2023-06-09 10:22:17 +02:00
Patrick Walton
cdec48328e Place floats in layout 2020, but don't flow text around the floats yet.
This commit puts floats behind the `layout.floats.enabled` pref, because of the
following issues and unimplemented features:

* Inline formatting contexts don't take floats into account, so text doesn't
  flow around the floats yet.

* Non-floated block formatting contexts don't take floats into account, so BFCs
  can overlap floats.

* Block formatting contexts that contain floats don't expand vertically to
  contain all the floats. That is, floats can stick out the bottom of BFCs,
  contra spec.
2023-06-03 06:09:21 +02:00
bors-servo
7399a3a686
Auto merge of #29816 - Loirooriol:sync, r=mrobinson
Backport several style changes from Gecko (3)

<!-- Please describe your changes on the following line: -->
This continues https://github.com/servo/servo/pull/29772.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-05-31 20:44:42 +02:00
Pu Xingyu
fb91a5c0f5 style: Enable 'column-span' for layout 2020 2023-05-31 19:25:01 +08:00
Oriol Brufau
7cfbaf37f7 Further changes required by Servo 2023-05-31 00:50:36 +02:00
Emilio Cobos Álvarez
fdbb4d01e6 style: Merge branches in some ComputedValues functions
This should mitigate the code size impact. Also make get_resolved_value
non-generic to avoid monomorphizing it multiple times.

Differential Revision: https://phabricator.services.mozilla.com/D130354
2023-05-31 00:50:36 +02:00
Emilio Cobos Álvarez
b9d2ae624b style: Remove other Widget* colors
These are only used for frameset painting and the non-e10s <select>
dropdown focus codepath. We have other more appropriate standard
colors for this.

Differential Revision: https://phabricator.services.mozilla.com/D129992
2023-05-31 00:50:36 +02:00
Emilio Cobos Álvarez
4ed53833ea style: Remove TextForeground/Background system colors
Same thing, there's nor reason these should be different from other
CSS-exposed colors.

Differential Revision: https://phabricator.services.mozilla.com/D129991
2023-05-31 00:50:36 +02:00
Emilio Cobos Álvarez
2fd66ea588 style: Remove WindowBackground/Foreground system colors
There's no reason for these to be different to the CSS-exposed
Window/WindowText.

Differential Revision: https://phabricator.services.mozilla.com/D129990
2023-05-31 00:50:36 +02:00
Emilio Cobos Álvarez
b1ef020aa2 style: Serialize text-decoration using Servo
The code introduced in the preceding patch deals with currentColor correctly,
so we should be able to do this now.

This uncovers a bug in the existing serialization code when a non-auto
text-decoration-thickness was used, caught by
css/css-text-decor/parsing/text-decoration-computed.html.

Differential Revision: https://phabricator.services.mozilla.com/D130018
2023-05-31 00:50:35 +02:00
Oriol Brufau
b3e40479f8 Further changes required by Servo 2023-05-31 00:50:35 +02:00
Emilio Cobos Álvarez
b702426c99 style: Generalize resolved style code to deal with all shorthands
This removes the various assumptions that the animation code does.

Code size might be a concern, we can optimize if it is a problem,
but let's do the obvious thing for now.

Differential Revision: https://phabricator.services.mozilla.com/D130017
2023-05-31 00:50:35 +02:00
Emilio Cobos Álvarez
04776cd116 style: Treat empty root margin as zero as per spec
Differential Revision: https://phabricator.services.mozilla.com/D130131
2023-05-31 00:50:35 +02:00
Emilio Cobos Álvarez
285c645b78 style: Make autofill background configurable via system color prefs
And remove the autofill.background pref for 95 (or 96, depending on
when this lands) assuming nothing terrible causes us to turn it off on
94.

Differential Revision: https://phabricator.services.mozilla.com/D129988
2023-05-31 00:50:35 +02:00
Oriol Brufau
5f46c027ea Further changes required by Servo 2023-05-31 00:50:35 +02:00
Emilio Cobos Álvarez
f70b0e7108 style: Make Canvas/CanvasText and Link colors color-scheme-aware
For that, add `.dark` version of the browser.display* prefs that control
the light version of these colors.

The default for background/foreground colors are taken from the
GenericDarkColors used in LookAndFeel.

The defaults for links are based on this discussion:

  https://github.com/whatwg/html/issues/5426#issuecomment-904021675

(So they effectively match Chrome).

Whether the dark colors should be exposed in about:preferences (like the
light colors are) is TBD.

With this patch, we pass all the tests in:

  /html/semantics/document-metadata/the-meta-element/color-scheme/

Use the colors to paint the default canvas background and the default
colors.

There are three "regressions", though they are really progressions: we
now render the reference as the test expects (before we rendered a light
canvas background even for the reference).

Apart of these iframe tests (which we should look into, I filed
https://bugzilla.mozilla.org/show_bug.cgi?id=1738380), there are three
remaining test failures.

Two of them are due to `color: initial` not changing based on the
color-scheme. Safari also fails these tests, and the thing they're
really testing is whether system colors are preserved at computed-value
time:

  https://github.com/w3c/csswg-drafts/issues/3847

Regarding that change, I'm not so sure the trade-offs there are worth
it, as that not only complicates interpolation (we wouldn't be able to
use system colors in color-mix among others, see
https://github.com/w3c/csswg-drafts/issues/5780) plus it changes
inheritance behavior in sorta unexpected ways, see:

  https://github.com/w3c/csswg-drafts/issues/6773

Which I just filed because apparently no browser implements this
correctly. So for now will punt on those (keep matching Safari).

There's an svg-as-image test:

  https://searchfox.org/mozilla-central/rev/f8576fec48d866c5f988baaf1fa8d2f8cce2a82f/testing/web-platform/tests/css/css-color-adjust/rendering/dark-color-scheme/svg-as-image.html

Which isn't using the feature at all and I'm not sure why is it supposed
to pass (why prefers-color-scheme: dark is supposed to match that SVG
image). This test fails in all browsers apparently:

  https://wpt.fyi/results/css/css-color-adjust/rendering/dark-color-scheme/svg-as-image.html?label=master&label=experimental&aligned

I sent https://github.com/web-platform-tests/wpt/pull/31407 to remove
it and hopefully get it reviewed by some Chromium folks.

Differential Revision: https://phabricator.services.mozilla.com/D129746
2023-05-31 00:50:34 +02:00
Emilio Cobos Álvarez
c3322938f2 style: Move Canvas/Link color computation to C++-land
This doesn't change behavior but will allow us to deduplicate some
logic given we compute the effective color-scheme in C++.

Differential Revision: https://phabricator.services.mozilla.com/D129744
2023-05-31 00:50:34 +02:00
Emilio Cobos Álvarez
6c16c019fc style: Implement <meta name=color-scheme>
There are still tests failing because
https://bugzilla.mozilla.org/show_bug.cgi?id=1736034 hasn't been synced
yet.

Once that lands, they will still fail because we don't change
Canvas/CanvasText based on color-scheme, but that I'm attaching
patches for after this one.

Differential Revision: https://phabricator.services.mozilla.com/D129743
2023-05-31 00:50:34 +02:00
Oriol Brufau
3a23598080 Further changes required by Servo 2023-05-31 00:50:34 +02:00
Mats Palmgren
9c6bf6d23b style: Fix broken 'list-style' serialization
Differential Revision: https://phabricator.services.mozilla.com/D129847
2023-05-31 00:50:34 +02:00
Oriol Brufau
40b7d87bbb Further changes required by Servo 2023-05-31 00:50:34 +02:00
Emilio Cobos Álvarez
1b04838278 style: Use GTK menu radius on native context menus and panels
Differential Revision: https://phabricator.services.mozilla.com/D129439
2023-05-31 00:50:33 +02:00
Emilio Cobos Álvarez
9868cd52ba style: Allow parsing layer statements inside nested rules
This fixes https://wpt.live/css/css-cascade/layer-media-query.html once
it syncs.

Differential Revision: https://phabricator.services.mozilla.com/D129424
2023-05-31 00:50:33 +02:00
Emilio Cobos Álvarez
1b2ef21c8c style: Update layer ordering to follow the spec
The bitfield approach worked when the layer order was in pre-order, but
the spec was changed to make it work like post-order and I don't think
there's a way to keep it working like that, so keep the layer order in a
separate data structure that we look up when going from Rule to
ApplicableDeclarationBlock.

This is just a vector index operation so hopefully shouldn't be too bad.

This patch intentionally regresses @keyframe handling to some extent,
since we need a bit more complicated approach and it seemed worth
implementing in a separate patch.

Depends on D129380

Differential Revision: https://phabricator.services.mozilla.com/D129381
2023-05-31 00:50:33 +02:00
Emilio Cobos Álvarez
5f2a29659f style: Store a LayerOrder in ApplicableDeclarationBlock
This shouldn't change behavior jut yet.

Differential Revision: https://phabricator.services.mozilla.com/D129380
2023-05-31 00:50:33 +02:00
Emilio Cobos Álvarez
77078dd660 style: Make browser.tabs.drawInTitlebar a tri-state
To more properly support Linux having a different default at runtime.

Expose the resolved value in appinfo for convenience, and use it in the
front-end as needed.

Differential Revision: https://phabricator.services.mozilla.com/D129004
2023-05-31 00:50:33 +02:00
stransky
578ecdba79 style: [Linux] Export titlebar radius as int from LookAndFeel
Titlebar radius is exported as integer from Gtk so there's no need to use floats here.

Differential Revision: https://phabricator.services.mozilla.com/D128993
2023-05-31 00:50:32 +02:00
Emilio Cobos Álvarez
c3c3dacb97 style: Don't use nsContentUtils::sNamespaceManager in servo
Differential Revision: https://phabricator.services.mozilla.com/D129030
2023-05-31 00:50:32 +02:00
Mike Hommey
00d2cec626 style: Remove unused import_rule::PendingSheet
Differential Revision: https://phabricator.services.mozilla.com/D128823
2023-05-31 00:50:32 +02:00
Emilio Cobos Álvarez
efb5a8cfe5 style: Fix rebase mistake
MANUAL PUSH: Bustage fix CLOSED TREE
2023-05-31 00:50:32 +02:00
Emilio Cobos Álvarez
0be968fb4c style: Remove -moz-gtk-csd-transparent-background
We always use alpha visual for WebRender, and appearance: none is
unnecessary (root element has no intrinsic appearance).

Differential Revision: https://phabricator.services.mozilla.com/D128682
2023-05-31 00:50:32 +02:00
Oriol Brufau
c204f3a96d Further changes required by Servo 2023-05-31 00:50:31 +02:00
Emilio Cobos Álvarez
07e5ea6966 style: Expose titlebar radius as a chrome-only CSS environment variable
Mostly plumbing.

Differential Revision: https://phabricator.services.mozilla.com/D128680
2023-05-31 00:50:31 +02:00
Oriol Brufau
5c861b90c5 Further changes required by Servo 2023-05-31 00:50:31 +02:00
Emilio Cobos Álvarez
e74b41cafe style: Add support for chrome-only environment variables
This bit is taken straight from D73454 (I reviewed it but I guess
another pair of eyes is ok, it's really straight-forward).

Co-authored-by: Nicklas Boman <smurfd@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D128679
2023-05-31 00:50:31 +02:00