Commit graph

884 commits

Author SHA1 Message Date
Oriol Brufau
53cddb1886 Further changes required by Servo 2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
8997888c6f style: Expose line-height resolution to style, and use it from ToResolvedValue
For ToResolvedValue implementation purposes we wouldn't need to split
out the vertical / font / line-height arguments and we could just pass
around the ComputedStyle, but the lh unit would need that distinction,
(because computing lh on font properties should use the parent style).

Differential Revision: https://phabricator.services.mozilla.com/D168705
2023-11-06 09:35:57 +01:00
Jonathan Kew
0bf39dc3d3 style: Resolve <number> to <length> in ToResolvedValue for line-height
This makes the serialization of the 'font' shorthand on computed style return the line-height
as an absolute length rather than a number (font-size multiplier), which is consistent with
what the line-height longhand already returns, and with other browsers.

(See also https://github.com/w3c/csswg-drafts/issues/8385.)

Differential Revision: https://phabricator.services.mozilla.com/D168542
2023-11-06 09:35:57 +01:00
Jonathan Kew
816a0f960b style: Fixes for font-language-override parsing and tests
Differential Revision: https://phabricator.services.mozilla.com/D168555
2023-11-06 09:35:57 +01:00
Jonathan Kew
8a2cfc0b24 style: Use write_char in place of write_str when serializing single-character literals
Generated by running

  find servo/components/style -name "*.rs" -exec perl -p -i -e "s/write_str\(\"(.)\"\)/write_char('\1')/g" {} \;

(and then added `use std::fmt::Write;` in a couple of places to fix build errors that arose).

Differential Revision: https://phabricator.services.mozilla.com/D168217
2023-11-06 09:35:57 +01:00
Jonathan Kew
05fb1b62b7 style: Implement the font-synthesis-{weight,style,small-caps} longhand properties, and make font-synthesis into a shorthand
Differential Revision: https://phabricator.services.mozilla.com/D167480
2023-11-06 09:35:57 +01:00
Oriol Brufau
dbd3eab9cd Further changes required by Servo 2023-11-06 09:35:57 +01:00
Jonathan Kew
449fe2338e style: Create a pref to list icon font families that should be used even when use_document_fonts=0, overriding the browser's font prefs
Some widely-used icon fonts use ligature rules to replace icon names such as "volume_up"
or "down_arrow" with icon glyphs. If the site is designed to use such a font, but the user
disables document fonts and we use our default Latin font instead, the underlying text will
be rendered instead of the intended icon.

To enable such fonts to continue to work, we provide a list of known ligature-icon fonts
and allow them to be used even when the document-fonts setting is disabled.

Differential Revision: https://phabricator.services.mozilla.com/D167923
2023-11-06 09:35:57 +01:00
Boris Chiou
835268aec2 style: Support view-timeline-inset in style system
Support view-timeline-inset: `[ [ auto | <length-percentage> ]{1,2} ]#`.
And its initial value is 0.

Differential Revision: https://phabricator.services.mozilla.com/D166243
2023-11-06 09:35:57 +01:00
Boris Chiou
fffb3c0830 style: Avoid infinite output progress after applying the easing function
The output progress of easing functions could be inf or -inf, per spec,
https://drafts.csswg.org/css-easing-2/#output-progress-value.

But we should avoid using infinity to calculate interpolation or use
the infinite progress in Web Animations API, per the spec issue comments:
https://github.com/w3c/csswg-drafts/issues/8344#issuecomment-1399033481

Differential Revision: https://phabricator.services.mozilla.com/D167342
2023-11-06 09:35:57 +01:00
Tiaan Louw
4559546fbb style: Add lab(), lch(), oklab(), oklch() to specified colors
Use new changes from cssparser and use the new lab/lch/oklab/oklch color
formats.

Introduced a new color type AbsoluteColor.  It represents any kind of
color that has absolute numerical values.  It is also tied to a color
space and therefore can be trivially converted to another color space.

Differential Revision: https://phabricator.services.mozilla.com/D163579
2023-11-06 09:35:57 +01:00
Jonathan Kew
d54d9ec25a style: De-dup items with the same tag in the computed value of font-feature-settings and font-variation-settings
Differential Revision: https://phabricator.services.mozilla.com/D167012
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
fe8cdbe328 style: Use the same computed time representation between Servo and Gecko
Same as above.

Differential Revision: https://phabricator.services.mozilla.com/D167126
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
b96f8f748c style: Share computed animation-iteration-count representation between Servo and Gecko
This removes the special AnimationIterationCount -> f32 conversion from
gecko.mako.rs which will be useful to simplify coordinated properties.

Differential Revision: https://phabricator.services.mozilla.com/D167123
2023-11-06 09:35:57 +01:00
Jonathan Watt
dd372eb5c2 style: Style changes to support the 'page-orientation' property
Differential Revision: https://phabricator.services.mozilla.com/D161800
2023-11-04 08:17:09 +01:00
Jonathan Kew
b7d64ee6a4 style: Animate the 'normal' value of font-style as 'oblique 0deg'
This matches what the spec[1] says for font-style:

> Animation type: by computed value type; normal animates as oblique 0deg

A bunch of WPT tests for font-style animation are landing in https://github.com/web-platform-tests/wpt/pull/37570.
Current Gecko passes 66/129 of the testcases there; with this patch applied it passes all the tests.

[1] https://drafts.csswg.org/css-fonts-4/#font-style-prop

Differential Revision: https://phabricator.services.mozilla.com/D166128
2023-11-04 08:17:09 +01:00
Emilio Cobos Álvarez
18b9e1b615 style: Use used, rather than computed font-size for font-metric dependent units
Differential Revision: https://phabricator.services.mozilla.com/D165737
2023-11-04 08:17:09 +01:00
Ziran Sun
ea04827f05 style: Use root element font size for rem calculation in Container queries
Differential Revision: https://phabricator.services.mozilla.com/D162853
2023-11-04 08:17:09 +01:00
Connor Pearson
2a7055a8ff style: Remove unused std::ops::Rem implementations
Differential Revision: https://phabricator.services.mozilla.com/D161844
2023-11-04 08:17:09 +01:00
Connor Pearson
6a4a97ad7c style: Implement CSS round() function
Co-Authored-By: Emilio Cobos Álvarez <emilio@crisal.io>

Differential Revision: https://phabricator.services.mozilla.com/D156742
2023-11-03 08:59:49 +01:00
Jonathan Watt
2c1799a8df style: Rename page::PageOrientation to page::PageSizeOrientation
The @page rule may contain both 'page-orientation' and 'size' properties. The
'size' property can contain an orientation component which was being
represented as 'PageOrientation' prior to this patch. This patch changes that
to 'PageSizeOrientation' so that 'PageOrientation' can be used for
'page-orientation' in a subsequent patch.

Differential Revision: https://phabricator.services.mozilla.com/D160790
2023-11-03 08:59:49 +01:00
Emilio Cobos Álvarez
efdf518acc style: Remove system font support for various font longhands
We don't use them[1], and these are generally not properties that
authors would be able to set via the font shorthand anyways.

Let's simplify the code. This fixes the font-variant bug and also
unblocks further clean-ups of these properties in the future.

[1]: https://searchfox.org/mozilla-central/rev/59f0bf3c13dd455d9f5415b89178de701ea6b850/widget/LookAndFeelTypes.ipdlh#12-18

Differential Revision: https://phabricator.services.mozilla.com/D160352
2023-11-03 08:59:49 +01:00
David Shin
14eece6f5a style: Container Relative Units: Set flag for USES_VIEWPORT_UNITS only when viewport fallback is actually used
Differential Revision: https://phabricator.services.mozilla.com/D159866
2023-11-03 08:59:49 +01:00
Emilio Cobos Álvarez
bfa293c5c5 style: Split in_media_query and in_container_query bits from computed::Context
No behavior change, but it makes more sense this way :)

Differential Revision: https://phabricator.services.mozilla.com/D159851
2023-11-03 08:59:49 +01:00
David Shin
27958b191a style: Enable lookup and computation of container size queries
Differential Revision: https://phabricator.services.mozilla.com/D158057
2023-11-03 08:59:49 +01:00
David Shin
3acb103324 style: Centralize construction of computed::Context
For controlled construction and access of upcoming, lazily-evaluated container query size.

Differential Revision: https://phabricator.services.mozilla.com/D158055
2023-11-03 08:59:49 +01:00
David Shin
d8785f3a22 style: Implement parsing of container relative lengths
- For now, implementation always returns the fallback value, i.e. small viewport lengths.
- Enabled via existing pref `layout.css.container-queries.enabled`.

Differential Revision: https://phabricator.services.mozilla.com/D158054
2023-11-03 08:59:49 +01:00
Jonathan Kew
6a98b777e0 style: CSS support for the font-palette property
This is just the CSS parsing, not yet connected to the rendering back-end.

Differential Revision: https://phabricator.services.mozilla.com/D157957
2023-11-03 08:59:49 +01:00
Ting-Yu Lin
fea3f9fbc1 style: Move clear property out of gecko.mako.rs
Differential Revision: https://phabricator.services.mozilla.com/D158225
2023-11-03 08:59:49 +01:00
Ting-Yu Lin
3da52edffc style: Run "cargo +nightly fmt" for style components in servo
The directories changed:
* servo/components/selectors/
* servo/components/style/
* servo/components/style_derive/
* servo/ports/geckolib/

Per review request, disable rustfmt in `components_to_transform_3d_matrix()` to
preserve the format for a call to `Transform3D::new`.

My mozilla-central is at
https://hg.mozilla.org/mozilla-central/rev/d1ae84015c22f2034435b47194fdced878072035

My nightly rust is 1.66.0-nightly (8b705839c 2022-09-26).

Differential Revision: https://phabricator.services.mozilla.com/D158234
2023-11-03 08:59:49 +01:00
Emilio Cobos Álvarez
6cfdd989d5 style: Implement <tabpanels> and <deck> without XUL layout
Gijs for front-end bits, layout for the new CSS properties and the
removal of nsDeckFrame / nsStackLayout, Jamie and Morgan for the a11y
changes.

As discussed in the bug, the main tricky part here is handling a11y
correctly. For <deck>, that's trivial (just use `visibility: hidden` to
hide the panels visually, while removing the unselected panels from the
a11y tree).

For <tabpanels> however we need to do something special. We do want to
hide stuff visually, but we want to preserve the contents in the a11y
tree.

For that, the easiest fix is introducing a new privileged CSS property
(-moz-subtree-hidden-only-visually), which takes care of not painting
the frame, but marks stuff offscreen in the accessibility tree. This is
not intended to be a property used widely.

Other than that, the changes are relatively straight-forward, though
some of the accessible/mac changes I could get a sanity-check on.

Differential Revision: https://phabricator.services.mozilla.com/D157875
2023-11-03 08:59:49 +01:00
Emilio Cobos Álvarez
8a63d9e059 style: Simplify our setup for font metric queries from style
While looking at moving the flag around I realized that the only reason
we have FontMetricsProvider and co is because we didn't have access to
the per-document font-prefs cache. That's trivial to fix tho, so do
that and simplify the setup for font queries even more.

Differential Revision: https://phabricator.services.mozilla.com/D157589
2023-11-03 08:59:49 +01:00
Emilio Cobos Álvarez
a44db17432 style: Move line-clamp out of mako and do some adjacent clean-up
No behavior change, but simplifies the following patch.

Differential Revision: https://phabricator.services.mozilla.com/D155180
2023-11-03 08:59:49 +01:00
AW255
12a2c88605 style: 0% values are not skipped when parsing CSS transform
Adds trait ZeroNoPercent to check for values that are 0 (such as 0px) but not 0%

Updated test css/css-transforms/animation/translate-interpolation.html and removed unnecessary formatting changes

Differential Revision: https://phabricator.services.mozilla.com/D154930
2023-11-03 08:59:49 +01:00
Ennui Langeweile
f7c340f881
Implement support for the drop-shadow filter (#30439)
* Implement support for `drop-shadow`

* Clean up remnant from early attempts

* Fix misleading comments on GenericSimpleShadow
If Servo-specific `style` changes will need to be upstreamed anyway, I might as well fix a thing that had thrown me off!

* Revert "Fix misleading comments on GenericSimpleShadow"

This reverts commit cdc810b826ac082041adc212c24649ee3b86ca0a.

* Clean up an import

* Update test expectations

* Fix missing expectation on Layout 2013
2023-10-04 11:32:45 +00:00
David Shin
af058e6332 style: C++ ComputedTimingFunction uses Rust's timing function calculation
This was made economical by having Rust's computed `easing::TimingFunction` use
a fully resolved function for `linear(...)` easing, as per draft resolution from
https://github.com/w3c/csswg-drafts/issues/7415

Differential Revision: https://phabricator.services.mozilla.com/D151295
2023-10-02 14:37:19 +00:00
David Shin
bb0f857dfa style: Port bezier edge cases handling from C++ to Rust
Differential Revision: https://phabricator.services.mozilla.com/D150569
2023-10-02 14:37:19 +00:00
David Shin
168c868330 style: Update rust's step function basd on C++ ComputedTimingFunction
Differential Revision: https://phabricator.services.mozilla.com/D150566
2023-10-02 14:37:19 +00:00
David Shin
a585d41910 style: Move Rust animation to ComputedTimingFunction
Differential Revision: https://phabricator.services.mozilla.com/D150565
2023-10-02 14:37:19 +00:00
Ziran Sun
6fec9d6f8c style: Add support for parsing the contain-intrinsic-size property from the CSS-sizing specification
Differential Revision: https://phabricator.services.mozilla.com/D151001
2023-10-02 14:37:19 +00:00
David Shin
c49a49d7a5 style: linear(...) easing: Simplify piecewise linear implementation given parsing simplification
Differential Revision: https://phabricator.services.mozilla.com/D150163
2023-10-02 14:37:19 +00:00
David Shin
e3e2ee64de style: linear(...) easing: Parsing should split a linear stop value into two for entries with both linear-stop-length set
This brings the behaviour inline with `linear-gradient(...)`

Differential Revision: https://phabricator.services.mozilla.com/D149926
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
a19674a5a7 style: Use style interpolation code for gradients
This ensures they're clamped on Animated -> sRGB conversion, and in the
future we'll have to implement different color spaces so we'll need to
use it anyways.

Differential Revision: https://phabricator.services.mozilla.com/D149792
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
5de65d9f2c style: Make viewport-relative units zoomable via "zoom text only"
They're not font relative, so it we probably want them to be zoomed.

Differential Revision: https://phabricator.services.mozilla.com/D148796
2023-10-02 14:37:19 +00:00
Boris Chiou
0c709f714b style: Support scroll-timeline-axis longhand in style system
Implement "scroll-timeline-axis: block | inline | vertical | horizontal".

Differential Revision: https://phabricator.services.mozilla.com/D146019
2023-10-02 14:37:19 +00:00
Boris Chiou
8d8594ef86 style: Support scroll-timeline-name longhand in style system
Implement "scroll-timeline-name: none | <custom-ident>".

Differential Revision: https://phabricator.services.mozilla.com/D146018
2023-10-02 14:37:19 +00:00
Oriol Brufau
105050d46d Further changes required by Servo 2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
dcafbde256 style: Move fixed-point font types to Rust
Now that cbindgen and rust support const generics, it seems more simple.

This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.

Differential Revision: https://phabricator.services.mozilla.com/D148847
2023-10-02 14:37:19 +00:00
David Shin
b31be826c4 style: Hook up linear easing calculation for servo and expose it to C++
Differential Revision: https://phabricator.services.mozilla.com/D146838
2023-10-02 14:37:19 +00:00
David Shin
6326a384a8 style: Rust side plumbing work for linear easing function
Add LinearFunction to TimingFunction. Because the linear function is a
variable list of linear stops, the enum is no longer Copyable.

Differential Revision: https://phabricator.services.mozilla.com/D146837
2023-10-02 14:37:19 +00:00