Commit graph

8451 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
4522e7f94a style: Add experimental support for "e", "pi", and various trigonometric functions in calc()
I'll add some tests before enabling. Also, WebKit folks (who have
implemented cos() / tan() / sin()) said they will upstream their tests
to WPT, so I'll extend those with the inverse functions before landing
as well.

Differential Revision: https://phabricator.services.mozilla.com/D124990
2023-05-30 23:26:01 +02:00
Oriol Brufau
4f193fbf49 Further changes required by Servo 2023-05-30 23:26:00 +02:00
Emilio Cobos Álvarez
1e5806610b style: Don't consider system-ui valid for user font prioritization
Since the user can't configure it, at least from the UI (we could add UI
for it but it's unclear it'd be worth it).

Differential Revision: https://phabricator.services.mozilla.com/D125182
2023-05-30 23:26:00 +02:00
Emilio Cobos Álvarez
7108be870d style: Add a simple CSSLayerRule implementation
The specifics of how this is going to work are still getting spec'd /
discussed in https://github.com/w3c/csswg-drafts/issues/6576, but this
allows DevTools to work fine and the feature to be complete enough for
Nightly experimentation (with the other in-flight patches).

Otherwise devtools crashes when trying to inspect pages that use them.

Differential Revision: https://phabricator.services.mozilla.com/D124656
2023-05-30 23:26:00 +02:00
Emilio Cobos Álvarez
0cc049946e style: Fix layer statement with nested layer names
When we had:

  @layer A.B;

We were registering "A" and "B", not "A" and "A.B", which was the intention.

Fix is trivial.

Depends on D124620

Differential Revision: https://phabricator.services.mozilla.com/D124621
2023-05-30 23:26:00 +02:00
Emilio Cobos Álvarez
92092bf0aa style: Fix out of order child layer registration, and enable the tests
This makes layer order use a fixed set of bits per nesting level, to "reserve"
bits for children before they are registered.

See the comment in LayerOrder for the implementation limits it imposes, and
potential alternatives if these limits are not enough (but I think they should
be).

Enable the tests, as they mostly pass now (commit incoming to fix the remaining
ones).

Differential Revision: https://phabricator.services.mozilla.com/D124620
2023-05-30 23:09:44 +02:00
Oriol Brufau
f351d955ad Further changes required by Servo 2023-05-30 23:09:44 +02:00
Jonathan Kew
d299040d55 style: Fix the serialization order for the text-decoration shorthand to match the canonical order in the spec
Differential Revision: https://phabricator.services.mozilla.com/D124536
2023-05-30 23:09:44 +02:00
Oriol Brufau
f063308e33 Further changes required by Servo 2023-05-30 23:09:43 +02:00
Emilio Cobos Álvarez
6bc198b757 style: Implement @import layer|layer(<name>)
This works modulo the existing nested layer order bug. Will be covered
by WPT /css/css-cascade/layer-import.html once the feature is enabled (I
can probably enable it right away for those tests, but I'd rather fix
the obvious bugs first).

Differential Revision: https://phabricator.services.mozilla.com/D124538
2023-05-30 23:09:43 +02:00
Emilio Cobos Álvarez
3dc3fb9412 style: Plumb layer order through ApplicableDeclarationBlock, and make it have an effect
Same, I want to land this separately to see if it affects
micro-benchmarks. If so, we might want to pack the layer order
_somewhere_ (though in this case I'm not sure where, tbh).

With this, layer rules should have an effect on the page. There are
a few things missing before being able to enable them:

 * Fix nested layer order in some cases (when parent layers are declared
   out of order, see the previous commit mentioning this).
 * Some kind of OM representation, perhaps.
 * Tests of course, which are coming in bug 1728722 and bug 1727276.

But this should be enough to allow playing with them.

Depends on D124337

Differential Revision: https://phabricator.services.mozilla.com/D124338
2023-05-30 23:09:43 +02:00
Emilio Cobos Álvarez
874737d877 style: Add layer_order to rules
I want to land this separately because we might want to get smarter with
the size of the Rule struct (maybe restricting layer order to a u8 per
scope and packing it with the source order, since 255 layers seem
plenty), but I'd rather do the obvious thing for now.

Depends on D124336

Differential Revision: https://phabricator.services.mozilla.com/D124337
2023-05-27 06:25:55 +02:00
Emilio Cobos Álvarez
1f62a7144d style: Tweak recursion in add_rule to only cause a function call per recursion level
This code is really hot, and we've had perf regressions in the past for
introducing function calls in the hot path.

After the previous patch, add_rule is recursive and thus it can't be
inlined, causing a function call for each CSS rule.

This reduces the overhead by making the function take a rule list
instead, causing a function call per rule _list_, which should be
unnoticeable in practice.

Depends on D124335

Differential Revision: https://phabricator.services.mozilla.com/D124336
2023-05-27 06:25:55 +02:00
Emilio Cobos Álvarez
8705e3f39f style: Compute layer order during CascadeData rebuild
For that, deal with children in add_rule recursively, to keep the
current layer name up-to-date in block layer rules.

This is not the final version of this code, as right now something like
this:

  @layer A {
    ...
  }

  @layer B {
    ...
  }

  @layer A.A {
    ...
  }

Would give A.A more priority over B, which is not correct. There are
tests for this incoming in wpt sync and such, but that can be tweaked
later.

Differential Revision: https://phabricator.services.mozilla.com/D124335
2023-05-27 06:25:46 +02:00
Emilio Cobos Álvarez
9976f9a589 style: Factor out adding a rule in CascadeData::add_rule
This shouldn't have any behavior change, but is necessary because for
cascade layers we are going to need to handle the child rules / sheets
ourselves, in order to handle nested layers properly.

Differential Revision: https://phabricator.services.mozilla.com/D124334
2023-05-27 06:01:30 +02:00
Oriol Brufau
9822db5d3c Further changes required by Servo 2023-05-27 05:59:01 +02:00
Emilio Cobos Álvarez
017036dba8 style: Add attributes to the rule hash
See the discussion here: https://twitter.com/Rich_Harris/status/1433153204678799365

This should make attribute selectors roughly as fast as class selectors.

I think it's worth trying and see if perf bots complain on
micro-benchmarks and stylebench and such.

I made attributes more specific than local names, but less specific than
classes, which I think makes sense. When doing something like
foo[data-bar], filtering by data-bar seems likely to yield less elements
than filtering by foo.

While at it, remove the bloom filter pref since we shipped it in
bug 1704551 for 87 and we haven't heard complaints.

Differential Revision: https://phabricator.services.mozilla.com/D124383
2023-05-26 21:49:57 +02:00
Emilio Cobos Álvarez
44e71dee2e style: Remove cascade layers pref
These have been enabled by default for quite a while.

Differential Revision: https://phabricator.services.mozilla.com/D175513
2023-05-26 21:43:29 +02:00
Emilio Cobos Álvarez
dbb51abc62 style: Hook up basic @layer rule parsing
Disabled, and of course doing nothing for now still, but this is another
piece that is useful to get reviewed separately.

Don't allow layers to be interleaved with @import / @namespace rules as
per https://github.com/w3c/csswg-drafts/issues/6522.

Differential Revision: https://phabricator.services.mozilla.com/D124229
2023-05-26 15:23:26 +02:00
Emilio Cobos Álvarez
623c8d8d45 style: Tweak at-rule parsing APIs to support cascade layers
This needs https://github.com/servo/rust-cssparser/pull/287 and a
cssparser update.

Differential Revision: https://phabricator.services.mozilla.com/D124216
2023-05-26 15:23:26 +02:00
Emilio Cobos Álvarez
74787a9c46 style: Restore an #[allow] that will otherwise cause warnings. 2023-05-26 15:23:25 +02:00
Emilio Cobos Álvarez
5fad3b4cde style: Add some scaffolding for @layer rules
Not hooked anywhere yet, so this doesn't change behavior, but adds the
basic data model etc.

Adding parsing support requires some changes to cssparser to allow the
same at rule to be block and statement-like at the same time, so better
done separately.

Differential Revision: https://phabricator.services.mozilla.com/D124079
2023-05-26 15:23:25 +02:00
Oriol Brufau
8eb5fa21fd Further changes required by Servo 2023-05-26 15:23:25 +02:00
Emilio Cobos Álvarez
693806b853 style: Implement image-rendering: smooth and image-rendering: pixelated
Also, more directly go from StyleImageRendering to wr::ImageRendering.

 * image-rendering: smooth the non-deprecated version of
   OptimizeQuality, which maps to SamplingFilter::LINEAR /
   wr::ImageRendering::Auto (which uses gl::LINEAR).

 * image-rendering: pixelated maps to wr::ImageRendering::Pixelated /
   SamplingFilter::POINT which is the same crisp-edges does.

Note that this uncovers that we were mapping image-rendering:
crisp-edges to wr::ImageRendering::Pixelated.

I'm going to preserve behavior on this patch but we should consider
switching that to map to wr::ImageRendering::CrispEdges on a
follow-up (filed bug 1728831 for this).

Differential Revision: https://phabricator.services.mozilla.com/D124378
2023-05-26 15:23:25 +02:00
Oriol Brufau
212733900e Further changes required by Servo 2023-05-26 15:23:25 +02:00
Emilio Cobos Álvarez
036056d2a9 style: Move image-rendering out of mako
It's easier to touch in the future that way, even though the derive list is
massive.

Differential Revision: https://phabricator.services.mozilla.com/D124377
2023-05-26 15:23:24 +02:00
Emilio Cobos Álvarez
5f5ea8603d style: Fix selecteditem color on macOS
This is an oversight. I made selecteditem be -moz-html-cellhighlight,
but that's for inactive cells.

Use the inactive cell color everywhere (though android doesn't
differentiate). This matches other browsers and what was reviewed on
this bug.

MANUAL PUSH: The semi-transparent text-selection-disabled color caused
one test failure CLOSED TREE.
2023-05-26 15:23:24 +02:00
Emilio Cobos Álvarez
e47f35aa50 style: Implement SelectedItem and SelectedItemText system colors
Since Highlight / HighlightText are now equivalent to the text selection
ones, remove those too.

Differential Revision: https://phabricator.services.mozilla.com/D123964
2023-05-26 15:23:24 +02:00
Emilio Cobos Álvarez
55d0636fe5 style: Remove layout.css.is-and-where-better-error-recovery.enabled
We shipped this in 84

Differential Revision: https://phabricator.services.mozilla.com/D123623
2023-05-24 18:32:43 +02:00
Emilio Cobos Álvarez
fa840e1666 style: Implement transform: perspective(none)
Differential Revision: https://phabricator.services.mozilla.com/D123350
2023-05-24 18:32:43 +02:00
Nicolas Silva
ce45f68d9c style: Update euclid in stylo
Differential Revision: https://phabricator.services.mozilla.com/D85762
2023-05-24 18:32:43 +02:00
Emilio Cobos Álvarez
db1ada85dc style: Workaround GCC-calling-into-LLVM ABI issue by making GenericFontFamily larger
This enum being a bit larger doesn't cause many common data structures
to grow, so this should be fine.

Differential Revision: https://phabricator.services.mozilla.com/D123146
2023-05-24 18:32:43 +02:00
Matt Woodrow
79893116e7 style: Return an infinite perspective in TransformOperation::Perspective::to_animated_zero
Differential Revision: https://phabricator.services.mozilla.com/D122919
2023-05-24 18:32:42 +02:00
Emilio Cobos Álvarez
26c5db6a6e style: Respect transparent and system color border colors in forced-colors mode
Differential Revision: https://phabricator.services.mozilla.com/D123111
2023-05-24 18:32:42 +02:00
Emilio Cobos Álvarez
f31f541125 style: Add a use counter for content-visibility
Differential Revision: https://phabricator.services.mozilla.com/D122873
2023-05-24 18:32:42 +02:00
Oriol Brufau
6ea5fdc40e Further changes required by Servo 2023-05-24 18:32:42 +02:00
Mats Palmgren
0cb64672f4 style: [css-fonts] Implement 'font-synthesis: small-caps'
Differential Revision: https://phabricator.services.mozilla.com/D114313
2023-05-24 18:32:42 +02:00
Oriol Brufau
fd3d12e214 Further changes required by Servo 2023-05-24 18:32:41 +02:00
Barret Rennie
c241182d09 style: Support color-mix() in non-sRGB color spaces
Out of gamut colours are currently clipped into sRGB.

Differential Revision: https://phabricator.services.mozilla.com/D120561
2023-05-24 18:32:41 +02:00
Oriol Brufau
d564f200aa Further changes required by Servo 2023-05-24 18:32:41 +02:00
Emilio Cobos Álvarez
5530f7e90c style: Support break-inside: avoid-{page,column}
break-before/after: page|column seem harder because you need to deal
with nested breaks, I think, but this should be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D121206
2023-05-24 18:32:41 +02:00
Emilio Cobos Álvarez
cf44eb3e77 style: Don't alias -apple-system to system-ui for now, to keep /css/css-fonts/animations/system-fonts.html happy
We probably want to do this when they do something different, but for
now behavior should be the same and it causes some subtests to fail
because `getComputedStyle(..).fontFamily` for system fonts seems to
return -apple-system, but `.style.fontFamily = "-apple-system"` returns
`system-ui`.

MANUAL PUSH: Orange fix on a CLOSED TREE
2023-05-24 18:32:41 +02:00
Nazım Can Altınova
d9719a3946 style: Remove the unused "gecko_profiler" feature from servo
This was being used when we had special code for gecko profiler in the servo
codebase but we just removed the last one. This is safe to remove now. The
"enabled" feature in the gecko-profiler crate is being controlled by
gkrust-shared directly now.

Differential Revision: https://phabricator.services.mozilla.com/D120796
2023-05-24 18:32:41 +02:00
Oriol Brufau
2376747273 Further changes required by Servo 2023-05-24 18:32:40 +02:00
Nazım Can Altınova
5a9fae3fb5 style: Remove the old profiler label frames code in the servo codebase and replace it with the new API
Differential Revision: https://phabricator.services.mozilla.com/D120795
2023-05-24 18:32:40 +02:00
Mike Hommey
9e33a154fd style: Setup bindgen flags for servo similarly to cranelift and neqo
While the use of toml allows the flags to be separated, the split is
done via some shell shenanigans anyways, and servo's build.rs can
handle the same just fine.

Differential Revision: https://phabricator.services.mozilla.com/D121042
2023-05-24 18:32:40 +02:00
Morgan Reschenberg
9b070745c9 style: Add MozNativevisitedhyperlinktext color, use it to style visited links
Differential Revision: https://phabricator.services.mozilla.com/D120657
2023-05-24 18:32:40 +02:00
Oriol Brufau
e617ece91e Further changes required by Servo 2023-05-24 18:32:40 +02:00
Emilio Cobos Álvarez
028f2f95d2 style: Initial support for the color-scheme CSS property
Add initial support for the color-scheme CSS property, allowing pages to
choose between light and dark system colors per-element, and such.

Things that are left to do so that this can be enabled by default:

 * Dark system colors on Windows / Android / Standins.
 * Dark Canvas/CanvasText/Link visited colors (which right now are set
   via PreferenceSheet).
 * Dark form controls in nsNativeBasicTheme.
 * Processing the color-scheme meta tag to fill-in
   Document::mColorSchemeBits.

But this seems like enough progress to be landable on its own.

Differential Revision: https://phabricator.services.mozilla.com/D120843
2023-05-24 18:32:40 +02:00
Oriol Brufau
fd41056ca5 Further changes required by Servo 2023-05-24 18:32:39 +02:00