Commit graph

1142 commits

Author SHA1 Message Date
Simon Sapin
4a4199c1d6 Don’t parse unspported values of content 2020-07-24 09:31:24 +02:00
Simon Sapin
82e274aec9 Make a bool for display: list-item available to flow box construction 2020-07-23 16:43:57 +02:00
Emilio Cobos Álvarez
a7d740331d
style: Fix a warning in layout-2020 2020-06-18 23:51:19 +02:00
Emilio Cobos Álvarez
bb8c3ee8ba
style: fix formatting. 2020-06-18 23:51:18 +02:00
Emilio Cobos Álvarez
97f29c893f
style: Fix gecko build. 2020-06-18 23:51:18 +02:00
Emilio Cobos Álvarez
7a696cbffe
style: build / rebase fixes. 2020-06-18 23:51:17 +02:00
Colomban Wendling
af2e157c88
style: Fix tree column header color to follow theme.
The background color for the tree column headers is drawn using the
system APIs, but the foreground uses custom colors, which didn't follow
theme.  This can lead to unreadable text with specific colors, e.g.
leading to black on black.

Fix this by using system colors for the foreground as well.  It also
adds on-hover styling to match possible background change on hover.

Differential Revision: https://phabricator.services.mozilla.com/D78073
2020-06-18 23:51:15 +02:00
Emilio Cobos Álvarez
c578a82adc
style: Fix some manual occurrences of try().
Depends on D80099

Differential Revision: https://phabricator.services.mozilla.com/D80100
2020-06-18 23:51:15 +02:00
Emilio Cobos Álvarez
685e749cfc
style: Switch all callsites of try() to try_parse() in the style crate.
Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
2020-06-18 23:51:14 +02:00
Philipp Zech
5af0d7ca7c
style: Remove StyleFontSize enum from nsStyleConsts.h.
Differential Revision: https://phabricator.services.mozilla.com/D77511
2020-06-18 23:51:14 +02:00
Utsav Oza
8372cf1bd8 Derive Serialize and Deserialize traits for font styles for #[cfg_attr(feature = "servo")] 2020-06-12 18:43:09 +05:30
Utsav Oza
c21fde3751 Implement CanvasRenderingContext2D.font property 2020-06-10 22:11:24 +05:30
Simon Sapin
64124f7a5e Layout 2020 skeleton for display: flex, behind a pref 2020-06-04 13:09:57 +02:00
Emilio Cobos Álvarez
762abbaf9f
style: Rustfmt recent changes. 2020-06-04 02:02:50 +02:00
Boris Chiou
eff8f0fca0 style: Update aspect-ratio syntax for HTML IMG mapped ratio.
Differential Revision: https://phabricator.services.mozilla.com/D76942
2020-06-04 01:50:36 +02:00
Emilio Cobos Álvarez
224550f818 style: Derive parse for ShapeRadius.
Depends on D76331

Differential Revision: https://phabricator.services.mozilla.com/D76332
2020-06-04 01:50:36 +02:00
Emilio Cobos Álvarez
e259c53c62 style: Derive parse for TextOverflowSide.
Depends on D76330

Differential Revision: https://phabricator.services.mozilla.com/D76331
2020-06-04 01:50:36 +02:00
Boris Chiou
35546aea54 style: Use style::One for Integer to avoid implementing Mul.
Differential Revision: https://phabricator.services.mozilla.com/D76207
2020-06-04 01:50:36 +02:00
Boris Chiou
7022f451e1 style: Replace AspectRatio with computed::position::Ratio in media-queries.
Also, we drop the pref, layout.css.aspect-ratio-number.enabled, becacuse
the spec of css-sizing-4 uses Number now.

Differential Revision: https://phabricator.services.mozilla.com/D75233
2020-06-04 01:50:36 +02:00
Boris Chiou
fc9321bb23 style: Let aspect-ratio (css-sizing-4) support 'auto | <ratio>'.
In order to test its parsing and serialization, we expose it but protect
it behind a pref.

Besides, I would like to drop layout.css.aspect-ratio-number.enabled in
the next patch because the spec has been updated. It seems we don't have
to keep this pref and we should always use Number.

Differential Revision: https://phabricator.services.mozilla.com/D74955
2020-06-04 01:50:36 +02:00
Mats Palmgren
6f58c66589 style: Implement style system support for Masonry layout.
This implements support for this CSS Masonry layout proposal:
https://github.com/w3c/csswg-drafts/issues/4650

I've intentionally left out a shorthand (place-tracks?) for now until
we have a draft CSS spec for this.

Differential Revision: https://phabricator.services.mozilla.com/D67061
2020-06-04 01:50:36 +02:00
Simon Sapin
09dbf91e7b display: contents computes to block on the root element 2020-05-15 13:25:35 +02:00
Martin Robinson
9c7b1ae715 layout_2020: Add initial support for getComputedStyle
This implementation is more-or-less on par with the one from layout_2013
and in some cases better. There are still some cases where we don't
return the correct "resolved value," but this is enough to test
animations and transitions.
2020-05-11 20:14:01 +02:00
Emilio Cobos Álvarez
848a6203de Some servo build fixes. 2020-04-16 18:29:30 +02:00
Emilio Cobos Álvarez
f76acc84c6 style: Reformat recent changes. 2020-04-16 17:50:17 +02:00
Tim Nguyen
d17b3cc202 style: Omit center positions in conic/radial gradient serialization.
Differential Revision: https://phabricator.services.mozilla.com/D67461
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
414edb5a4a style: Simplify the implementation of HasAuthorSpecifiedRules.
This patch computes the author-specified properties during the CSS cascade, and
removes the complex rule-tree-based implementation that tries to do the cascade
again.

This changes behavior in two ways, one of them which is not observable to
content, I believe:

 * revert now re-enables the native styling. This was brought up in
   https://github.com/w3c/csswg-drafts/issues/4777 and I think it is a bug-fix.

   This is observable to content, and I'm adding a test for it.

 * We don't look at inherited styles from our ancestors when `inherit` is
   specified in a non-author stylesheet. This was introduced for bug 452969 but
   we don't seem to inherit background anymore for file controls or such. It
   seems back then file controls used to have a text-field.

   I audited forms.css and ua.css and we don't explicitly inherit
   padding / border / background-color into any nested form control.

We keep the distinction between border/background and padding, because the later
has some callers. I think we should try to align with Chromium in the long run
and remove the padding bit.

We need to give an appearance to the range-thumb and such so that we can assert
that we don't call HasAuthorSpecifiedRules on non-themed stuff. I used a new
internal value for that.

Differential Revision: https://phabricator.services.mozilla.com/D67722
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
7d438cd816 style: Ensure that derived types are right for optimized-away implementations.
We have this optimization where, for non-generic structs, we generate just a
clone / move as the ToComputedValue / ToResolvedValue implementation.

This moves the optimization a bit further down, and refines it so that we still
generate all the relevant where clauses that make it sound, that is, that all
the ToComputedValue implementations of the fields return the same type.

Otherwise this wouldn't be sound and the type would need to become generic.

We add an escape hatch (no_field_bound) for fields that need to be cloned but
which don't implement the trait. This is right now only for the RefPtr<> in the
shared font-family list, and a piece of code in PaintWorklet which looks kinda
fishy, and probably should be fixed (but we don't ship it in Firefox and there's
a pre-existing FIXME for servo, so I punted on it for now).

The other thing this patch does is adding a bunch of ToComputedValue /
ToResolvedValue implementations that are trivial and were missing.

Differential Revision: https://phabricator.services.mozilla.com/D67913
2020-04-16 16:35:07 +02:00
Emily McDonough
e0b4619fa5 style: Enable multiple grid repeat values in Servo.
Differential Revision: https://phabricator.services.mozilla.com/D60931
2020-04-16 16:35:07 +02:00
Sam Mauldin
ccc41dd89d style: Unprefix existing CSS4 system colors.
Expect forced-colors-mode-backplate tests to fail because they were passing for the wrong reason,
and the backplate is now properly applied, causing them to fail.

Remove tests for field and fieldtext from color-valid.html because they are tested again
in system-color-valid.html.

Differential Revision: https://phabricator.services.mozilla.com/D66879
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
4a19074664 style: Rename -moz-menulist-button to -moz-menulist-arrow-button.
This should be less confusing. This is not supported outside of chrome:// or
user-agent stylesheets so we can name this however we want.

Differential Revision: https://phabricator.services.mozilla.com/D65605
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
7af9a087aa style: Use enums for text-align / text-align-last.
This also fixes some backwards logic in nsBlockFrame::ReflowDirtyLines, and adds
some static assertions to nsGenericHTMLElement that almost cause a very subtle
bug.

Depends on D63792

Differential Revision: https://phabricator.services.mozilla.com/D63793
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
76e9cb44f0 style: Use cbindgen for SVG lengths.
Depends on D63777

Differential Revision: https://phabricator.services.mozilla.com/D63778
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
18570bf077 style: Use cbindgen for cursors.
Pretty straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D63777
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
787ac98d18 style: Properly reject numbers as part of <length-percentage>.
We never fast-reject numbers (because they could be part of a product). Without
this refactoring we'd accept stuff like calc(10) and crash during the evaluation
for obvious reasons.

Differential Revision: https://phabricator.services.mozilla.com/D63401
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
c0f2a4e785 style: Simplify math function resolution.
So as to avoid allocating an intermediate tree in Rust to resolve
`<length-percentage>` values.

Differential Revision: https://phabricator.services.mozilla.com/D63399
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
280402b2a1 style: Fix C++ side of <length-percentage> values.
Differential Revision: https://phabricator.services.mozilla.com/D63398
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
7e8dbd0896 style: Make CalcNode the specified representation of <length> and <length-percentage> values.
This is the meat of the patch. There are a couple improvements done in a couple
later patches which should hopefully be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D63397
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
426edbd991 style: Move the guts of calc nodes into a generic enum.
We'll have different leaf nodes as we progress in the value computation stage.

Differential Revision: https://phabricator.services.mozilla.com/D63396
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
869553357d style: Implement ToCss for CalcNode.
We'll use `CalcNode` as the specified value representation for <length> and
<length-percentage> values, so they'll have to implement ToCss.

There's one minor issue (two calls to to_css() instead of to_css_impl() which
are addressed later in the series).

Differential Revision: https://phabricator.services.mozilla.com/D63395
2020-04-16 16:35:07 +02:00
Jonathan Kew
471e491a89 style: Add support for the 'all' value of text-decoration-skip-ink.
Differential Revision: https://phabricator.services.mozilla.com/D61184
2020-04-16 16:35:07 +02:00
Tim Nguyen
61712d1a03 style: Implement parsing for CSS conic-gradient syntax.
Differential Revision: https://phabricator.services.mozilla.com/D62148
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
f25e0b77e9 style: Minor gradient parsing cleanup.
I suggested the compat_mode bit in D62923 but it was somehow only applied to one
of the branches.

Also rustfmt the code for consistency, and add a local alias.

Differential Revision: https://phabricator.services.mozilla.com/D63015
2020-04-16 16:35:07 +02:00
Tim Nguyen
25b265a10f style: Refactor GenericGradient for conic-gradient support.
Differential Revision: https://phabricator.services.mozilla.com/D62923
2020-04-16 16:35:07 +02:00
Tim Nguyen
fc88e908d5 style: Re-introduce display: -moz-stack; as <legacy-stack>.
Differential Revision: https://phabricator.services.mozilla.com/D62758
2020-04-16 16:35:07 +02:00
Martin McNickle
28d8565f38 style: Use the cbindgen output for GridAutoFlow directly in gecko.
Depends on D62787

Differential Revision: https://phabricator.services.mozilla.com/D62910
2020-04-16 16:35:07 +02:00
Martin McNickle
cf20c627b5 style: Replace existing GridAutoFlow struct with a bitflags! backed one.
Differential Revision: https://phabricator.services.mozilla.com/D62787
2020-04-16 16:35:07 +02:00
Tim Nguyen
0e3c122890 style: Make GradientItem and ColorStop support angular color stops.
Differential Revision: https://phabricator.services.mozilla.com/D62544
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
239302b1ed style: Split clip-path and shape-outside values.
We don't actually share _that_ much code across them. This makes callers clearer
and code less confusing, IMHO.

This also has the benefit of not autocompleting path from devtools for
shape-outside.

Differential Revision: https://phabricator.services.mozilla.com/D62373
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
4dadcf71a5 style: Some preparation to start using cbindgen for shape-outside and clip-path.
Tweak the ShapeSourceRepresentation so that it doesn't store Option<>s.

Some renames so that GeometryBox doesn't conflict with the Gecko type, and some
other usual bits / re-exports to deal with cbindgen and generics.

Also, drive-by derive parsing of GeometryBox as it's trivial.

Doing this unfortunately is not possible without removing nsStyleImage first, so
let's do that before.

This makes us serialize in the shortest form for shape-outside, but that's what
we should do anyway.

(aside: the shapes code is a bit too generic, maybe we should unify
ClippingShape and FloatAreaShape...)

Differential Revision: https://phabricator.services.mozilla.com/D62163
2020-04-16 16:35:07 +02:00