Commit graph

9046 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
b92440ef7c style: Disable NSCAP_FEATURE_USE_BASE
This is a relatively small code size regression (130k on windows and
macOS, 180k on Linux), for a few high confidence improvements in
speedometer 3. See link in the bug.

If this sticks, we can actually clean up a bunch of code, and eventually
unify RefPtr and nsCOMPtr. But I want this to be on the tree for a while
before doing more aggressive refactorings / actually removing the code.

Differential Revision: https://phabricator.services.mozilla.com/D178267
2023-11-24 08:57:14 +01:00
David Shin
7a2b444a60 style: Implement parsing for baseline-source
Differential Revision: https://phabricator.services.mozilla.com/D173884
2023-11-24 08:57:14 +01:00
Emily McDonough
571136562d style: Remove the layout.css.named-pages.enabled pref
Differential Revision: https://phabricator.services.mozilla.com/D175438
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
920a1c1f08 style: [css-nesting] Update cssparser again
This changes the cssparser setup to:

  * Avoid having to do copies of the ParsingContext all over the place,
    which is useful because I plan to stash more nesting state in there.

  * Use the new RuleBodyParser which allows parsing qualified rules,
    declarations, and so on. Though we still don't use this anywhere.

The next step is to join NestedRuleParser and PropertyDeclarationParser,
so that we can parse declarations in a lot of the nested rules as well.

Differential Revision: https://phabricator.services.mozilla.com/D178053
2023-11-24 08:57:14 +01:00
Oriol Brufau
32f1989a5c Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
ae993e485a style: Move a bit declaration_block and cascade modules
So that they aren't imported via #[path]. This allows cargo to see them
even before building.

Differential Revision: https://phabricator.services.mozilla.com/D178105
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
d1046739fc style: Remove some magic from the bindings
This simplifies a tiny bit our bindings in some places, and complicates
it in others, but over all I think it's better.

It requires a bit more manual code in the rust side to drop and cast the
relevant pointers (which was done implicitly before), but it's a lot
less magic than it used to be, and that's all autogenerated so consumers
don't need to care about it.

The set up is still not ideal. I don't like that we rely on destructors
running in both sides of the FFI boundary, but that's for another day.

This is the last usage of RawOffsetArc, so remove that. We now support
proper Arc<> in structs (GridTemplateAreas uses it), so I don't think
we'll need it any time soon.

Differential Revision: https://phabricator.services.mozilla.com/D177905
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
e9bf977369 style: Finish removing HasArcFFI
Use the actual Locked<T> types around (via a typedef, just for
convenience).

Differential Revision: https://phabricator.services.mozilla.com/D177824
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
3f03650c88 style: Plumb android text scale via nsLookAndFeel
That's how we do it for all other platforms. Do this rather than via a
custom mostly-untested pref, which allows us to simplify text zoom
handling.

Differential Revision: https://phabricator.services.mozilla.com/D177062
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
c2a2113136 style: Container units should prevent us from using the rule cache
Much like with font-relative units, when they're used for a
non-inherited property we need to avoid using the rule cache.

This is because two elements matching the same rules won't get
guaranteed-equal non-inherited style structs.

Depends on D177732

Differential Revision: https://phabricator.services.mozilla.com/D177733
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
af13e670d9 style: Clean up length handling
No behavior change, but using Self is shorter and while I'm touching
this code might as well clean it up a little bit.

Differential Revision: https://phabricator.services.mozilla.com/D177732
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
4b7260d846 style: Remove dead GTK menu styling code
Differential Revision: https://phabricator.services.mozilla.com/D177369
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
9370172552 style: Remove HasArcFFI for AnimationValue
See previous patches for context.

Differential Revision: https://phabricator.services.mozilla.com/D177622
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
779aa9d30e style: Remove HasArcFFI for some types
See blocked bug.

For non-Locked types we can just use the same underlying type at the FFI
boundary. Port StylesheetContents and CssUrlData to this set-up.
CssUrlData is already generated by cbindgen anyways.

Differential Revision: https://phabricator.services.mozilla.com/D177559
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
d9d865e8c9 style: Add an API to parse an absolute length without any other context
This should allow making these work on canvas.

Differential Revision: https://phabricator.services.mozilla.com/D177074
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
a69578993a style: display: inline list-item is also a line participant
So the line break suppression flags should be propagated through it.

Otherwise ruby invariants might break, leading to a nullptr crash in
this case.

On debug builds the assertion was this one:

  https://searchfox.org/mozilla-central/rev/e6cb503ac22402421186e7488d4250cc1c5fecab/layout/generic/nsRubyBaseContainerFrame.cpp#631

Differential Revision: https://phabricator.services.mozilla.com/D177093
2023-11-24 08:57:14 +01:00
Tiaan Louw
18c701e6b5 style: Hardening color checks
Avoid trying to resolve a currentcolor when a foreground color is not
available.

Differential Revision: https://phabricator.services.mozilla.com/D177368
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
e18675401e style: Remove HasFFI as well
After the previous patches we only have one trait which we should also
tweak / rework, so let's put it all on that single trait.

Differential Revision: https://phabricator.services.mozilla.com/D177515
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
42cbb9d3cf style: Remove HasSimpleFFI
It's completely unsused and we don't want to use it any time soon, see
bug 1831539 and related.

Differential Revision: https://phabricator.services.mozilla.com/D177497
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
19e037d921 style: Remove HasBoxFFI
HasBoxFFI and HasArcFFI aren't great, see bug 1831242 as for examples of
why.

HasArcFFI requires a bit more care, but HasBoxFFI doesn't give us much
benefit. Instead use the same type in the FFI boundary.

Differential Revision: https://phabricator.services.mozilla.com/D177252
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
9ac97dd8ad style: when iterating over a selector to find a bucket, choose the rightmost
This restores the pre-regression behavior by choosing the later class in
cases where folks use stuff like `.foo.bar`.

This matches other browsers too.

Differential Revision: https://phabricator.services.mozilla.com/D177398
2023-11-21 15:36:35 +01:00
Boris Chiou
303ea410e2 style: Support self keyword for scroll()
`self` keyword specifies to use the element’s own principal box as the
scroll container. If the principal box is not a scroll container, then the
scroll progress timeline is inactive.

Differential Revision: https://phabricator.services.mozilla.com/D175707
2023-11-21 15:36:35 +01:00
Boris Chiou
f96c75c8d0 style: Update the syntax of scroll() to accept <scroller> and <axis> in any order
The order of <scroller> and <axis> doesn't matter in the parser.
However, we serialize <scroller> first, if it is not the initial value.

Differential Revision: https://phabricator.services.mozilla.com/D173906
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
a27f477c7d style: Rework -x-text-zoom to allow disabling text zoom and min-font-size separately
And use it instead of explicit document checks. This centralizes where
we check for it.

IsChromeDoc is relatively cheap, but this bug wants to also check for
PDF.js which is a bit more expensive.

No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D176940
2023-11-21 15:36:35 +01:00
Tiaan Louw
a6b97563c3 style: Add negate node to use in place of mul_by in sum nodes
Sum nodes would use mul_by to negate nodes to do subtraction, but some
nodes are not distributive.  This patch adds a negate node, so that the
operations inside these negate nodes can be resolved first and then the
"subtraction" can be applied.

Differential Revision: https://phabricator.services.mozilla.com/D172941
2023-11-21 15:36:35 +01:00
Boris Chiou
9fd6f09a41 style: Add animation-timeline: view() in style system
Support view() notation for animation-timeline:
  `<view()> = view( [ <axis> || <'view-timeline-inset'> ]? )`

We move AnimationTimeline and its related types into the generics folder,
and define two new structs for scroll() and view().

Note:
1. The syntax of scroll() doesn't match the current version of the spec.
    I will update it in Bug 1814444.
2. We will handle the creation/usage of the Anonymous View Progress Timelines
    in the next patch.

Differential Revision: https://phabricator.services.mozilla.com/D173904
2023-11-21 15:36:35 +01:00
Oriol Brufau
115a45f8eb Further changes required by Servo 2023-11-21 15:36:35 +01:00
Boris Chiou
b1bcb22650 style: Move animation-related values from box.rs/ui.rs to animation.rs
Although we store animation and transition style values in StyleUIReset and
define their properties in longhands/ui.mako.rs, but we may move them in
the future if this style struct becomes too large. So let's move the
definition of their values to an independent module, animation, so we
don't have to worry about this again.

This patch doesn't change any other things. Only move code.

Differential Revision: https://phabricator.services.mozilla.com/D173903
2023-11-21 15:36:35 +01:00
CanadaHonk
a5b85ec834 style: Refactor ImportLayer into enum
Refactored ImportLayer into an enum instead of a struct and using
Option everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D176793
2023-11-21 15:36:35 +01:00
CanadaHonk
2e713d4366 style: Serialize NaN and infinity percentages correctly
NaN and infinity percentages are now serialized as expected.

Also added some new WPT tests as percentages were previously untested
and added some spec comments to previous NaN/inf serialization code.

Differential Revision: https://phabricator.services.mozilla.com/D176726
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
6f090b8a85 style: [css-nesting] Update cssparser to allow parsing qualified rules along with declaration
No implementation just yet (the default QualifiedRuleParser
implementation just rejects stuff), but this is plumbing that I'd rather
get reviewed separately.

Differential Revision: https://phabricator.services.mozilla.com/D176686
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
93e0711194 style: [css-nesting] Process nested rules at cascade data rebuild
More nesting plumbing. Still does nothing because we don't parse the
nested rules.

Should be trivial to prove this patch doesn't change any behavior so
far, but I want to land it on its own because it can have performance
implications.

This follows the pattern of what we do with other rules like layers and
container conditions, that is, keep the ancestor selectors in a stack,
and poke at the last one in order to replace the ancestor.

This changes the behavior of replace_parent_selector as with the newer
version of the spec, stuff like:

  div {
    .foo {
      stuff
    }
  }

Should work as `div .foo`. A test is added for this case.

Differential Revision: https://phabricator.services.mozilla.com/D176560
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
d4e12b9db6 style: [css-nesting] Add storage for nested rules
Allow to have a CssRules list inside a StyleRule.

This only introduces the storage and serialization code for them, but we
still don't parse it.

Differential Revision: https://phabricator.services.mozilla.com/D176550
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
1182296c4b style: Enable all math functions on chrome code
They should be stable.

Not sure this is worth writing a test for since the idea is that this
code goes away eventually.

Differential Revision: https://phabricator.services.mozilla.com/D176680
2023-11-21 15:36:35 +01:00
Oriol Brufau
a523fffc9e Further changes required by Servo 2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
e91a0d8b96 style: Share code to parse @import layer + supports()
The duplication was slightly annoying me :)

Differential Revision: https://phabricator.services.mozilla.com/D176564
2023-11-21 15:36:35 +01:00
CanadaHonk
5671b9f025 style: Fix @import supports() parsing position
Fixed @import supports() being parsed in the incorrect position as per spec.

Also added more WPT tests for layer and supports in one @import.

Differential Revision: https://phabricator.services.mozilla.com/D176193
2023-11-21 15:36:35 +01:00
CanadaHonk
0c246b0b7c style: Fix @import serialization order
Fixed @import serialization being out of (spec) order.

Also added some more WPT tests.

Differential Revision: https://phabricator.services.mozilla.com/D176182
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
5d59674c8a style: Use more non-native rendering of menus
This makes our menus closer to GTK4, and depends less on the native menu
rendering etc. Thunderbird already does this to some extent.

Leave the old code behind a pref for now (just in case). Also fix some
code in nsNativeTheme::GetContentState (fixes rendering of radio menu
items).

Differential Revision: https://phabricator.services.mozilla.com/D175664
2023-11-21 15:36:35 +01:00
Jonathan Kew
9dfa7fb136 style: Implement CSS and rendering (but not copy/paste) support for the (non-standard) -webkit-text-security property
Differential Revision: https://phabricator.services.mozilla.com/D174951
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
bedf574092 style: Avoid linear search to check for custom property presence
The test-case in the next patch from 10s to a couple hundred
milliseconds on my machine. No behavior change other than that.

Differential Revision: https://phabricator.services.mozilla.com/D175612
2023-11-21 15:36:35 +01:00
Mirko Brodesser
9a97080dbb style: Replace popover's ':open' and ':closed' pseudo-classes with ':popover-open'
See https://github.com/whatwg/html/pull/9077.

Differential Revision: https://phabricator.services.mozilla.com/D175223
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
bc82d005ae style: Remove cascade layers pref
These have been enabled by default for quite a while.

Differential Revision: https://phabricator.services.mozilla.com/D175513
2023-11-21 15:36:35 +01:00
Oriol Brufau
9ce567d7fe Further changes required by Servo 2023-11-21 15:36:35 +01:00
CanadaHonk
1ac62a4ce8 style: Implement supports() syntax for @import rules
Implemented supports conditions using supports() in @import rules as per
CSS Cascading and Inheritance Level 4.

Locked behind new pref, layout.css.import-supports.enabled,
only enabled in nightlies in this patch.

Also added new WPT tests for @import supports() generally.

Spec: https://drafts.csswg.org/css-cascade-4/#conditional-import
WPT tests: https://wpt.fyi/results/css/css-cascade/import-conditions.html

Differential Revision: https://phabricator.services.mozilla.com/D172622
2023-11-21 15:36:35 +01:00
Oriol Brufau
b844a4e992 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
0709e13446 style: Allow to use ThinVec/nsTArray in the style crate
This allows to clean-up the previous patches by using a single ThinVec
(which stores length / capacity along with the allocation).

Differential Revision: https://phabricator.services.mozilla.com/D175029
2023-11-21 15:36:35 +01:00
Jonathan Kew
a2df8f7ea5 style: Accept a comma-separated list of language codes in the :lang() pseudo
This is the other extension to the :lang() pseudo-class in  Selectors-4.
(Also supported in Safari.)

Depends on D174999

Differential Revision: https://phabricator.services.mozilla.com/D175000
2023-11-21 15:36:35 +01:00
CanadaHonk
13e2d10474 style: Implement inverted-colors media feature
Implemented the inverted-colors media feature from Media Queries Level 5
for all platforms.
Spec: https://drafts.csswg.org/mediaqueries-5/#inverted

Platform specific implementations:
- Windows: Checks system color filter setting, and if it is inverted
  (note: Windows does not live update due to having to read a reg key)
- Mac: Checks dedicated inverted accessibility system setting
- Android: Checks dedicated inverted system setting
- Linux: No GTK API exposes anything like it so always none

Locked behind new pref `layout.css.inverted-colors.enabled`,
always off by default for now.

Also added new WPT tests (none previously).

Other browsers:
- WebKit: shipped since Safari 9.1 (Jan 2017)
- Blink: no signal

Test page: https://goose.icu/inverted-colors

Differential Revision: https://phabricator.services.mozilla.com/D173201
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
5dd35ac6cd style: Simplify NAC setup
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

  * The style system, since we still want to match content rules from
    stylesheets in the UA widget. We also match user rules, which is a
    bit sketchy, but that was the previous behavior, will file a
    follow-up for that.

  * The reflector code, since we want the scope for UA widgets to not
    include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
    got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-11-21 15:36:35 +01:00