Commit graph

204 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
85b7a60a69 style: Reduce code size of shorthand serialization
Differential Revision: https://phabricator.services.mozilla.com/D118835
2023-05-24 18:32:37 +02:00
Emilio Cobos Álvarez
58e9ee4d1e style: Make get_shorthand_appendable_value less generic
This will allow to save some codesize from longhands_to_css.

Differential Revision: https://phabricator.services.mozilla.com/D118834
2023-05-24 18:32:37 +02:00
Emilio Cobos Álvarez
b4546993b4 style: Fix whitespace handling inside CSS variables
As per w3c/csswg-drafts#881 and w3c/csswg-drafts#774.

Differential Revision: https://phabricator.services.mozilla.com/D116459
2023-05-24 18:32:31 +02:00
Lewin Probst
976f5b76bc Updated cssparser dependency to 0.29.
Signed-off-by: Lewin Probst <info@emirror.de>
2021-11-18 16:16:46 +01:00
Emilio Cobos Álvarez
490db1e2bd style: Reduce the amount of code generated by UnparsedValues::substitute_variables.
This reduces the amount of assembly instructions generated by this
function from 18k+ to ~800.

This should make reasoning about its stack space usage sane, and should
fix the ASAN stack overflows, but also we should take this regardless,
because it's saner and makes reading it simpler.

I also think that the writing_mode shenanigans is fixing a bug (I think
before this, we'd pick the first physical value which mapped to any of
the properties, which is wrong), but I haven't bothered looking for a
test-case that fails before my patch. The relevant WPTs
(css/css-logical/animation*) still pass.

Differential Revision: https://phabricator.services.mozilla.com/D105342
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
b0d05d1a5d style: Cache substituted values from shorthand properties during the cascade.
This brings the time down to 1.6ms from 4.8ms on the test-case in the
bug. This should be improvable too, but I think this is a nice
improvement for regular styling as well.

Differential Revision: https://phabricator.services.mozilla.com/D105187
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
f58301ecbc style: Avoid UTF-8 -> UTF-16 conversion during CSSOM serialization.
This lifts a bunch of string conversions higher up the stack, but allows
us to make the servo code use utf-8 unconditionally, and seemed faster
in my benchmarking (see comment 0).

It should also make a bunch of attribute setters faster too (like
setting .cssText), now that we use UTF8String for them (we couldn't
because we couldn't specify different string types for the getter and
setters).

Differential Revision: https://phabricator.services.mozilla.com/D99590
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
e1bf1648c7 style: Fix declaration block serialization and logical properties.
As per https://github.com/w3c/csswg-drafts/issues/3030.

Also remove a system font special-case. It's generally handled in
shorthands/font.mako.rs, and when it's not, it's really the same issue
as https://github.com/w3c/csswg-drafts/issues/2515.

Browsers are all over the place for the system font case, so I think
it's fine.

Differential Revision: https://phabricator.services.mozilla.com/D96045
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
5b42605b79 style: Remove unused DeclarationBlock::get_at_importance.
Differential Revision: https://phabricator.services.mozilla.com/D94693
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
436632f378 style: Introduce InspectorUtils.supports().
Which allows to run CSS.supports in chrome/user-agent context. We should
probably add a couple more tweaks for stuff like quirks or what not (the
`ParsingMode` enum), but that seem lower priority.

I only added the one-value version of CSS.supports because it should be enough
and supporting the two value version required a bit of awkward code due to when
we parse the CSS property name right now.

Differential Revision: https://phabricator.services.mozilla.com/D92585
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
60d89cfbc0 style: CSSOM should respect rule-level property restrictions.
Differential Revision: https://phabricator.services.mozilla.com/D90729
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
97f29c893f
style: Fix gecko build. 2020-06-18 23:51:18 +02:00
Cameron McCormack
9b980e2f49
style: Add telemetry for -moz-appearance usage.
Differential Revision: https://phabricator.services.mozilla.com/D77637
2020-06-18 23:51:15 +02:00
Emilio Cobos Álvarez
3884328ce3
style: Clear last_parsed_property_id right after successfully parsing the value.
Rather than waiting until parsing another id (successfully or
unsuccessfully).

If we error before we even get to PropertyId::parse, we'd incorrectly
associate the error with the wrong property, incorrectly omitting it
sometimes.

Differential Revision: https://phabricator.services.mozilla.com/D78260
2020-06-18 23:51:14 +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
Martin Robinson
36701e0223 Combine AnimationAndTransitionDeclarations and AnimationRules
These two structs are very similar, so we can combine them.
2020-06-16 19:25:52 +02:00
Martin Robinson
b875f14e86 Better computation of animation keyframes
This begins to address #26625 by properly applying CSS variables during
keyframe computation and no longer using `apply_declarations`. Instead,
walk the declarations, combining them into IntermediateComputedKeyframe,
maintaining declarations that modify CSS custom properties. Then compute
a set of AnimationValues for each keyframe and use those to produce
interpolated animation values.
2020-06-05 13:40:29 +02:00
Emilio Cobos Álvarez
ec6ecf7d21 style: Clean up cascade rule iteration. r=nordzilla
The current API was pretty awkward as a result of two things:

 * Not being able to create empty iterators for smallbitvec.
 * We used to call the `F` function multiple times, but turns out that
   collecting the declarations in a SmallVec was a perf win.

So clean this up so that it looks more similar to other APIs, taking an
iterator directly.

This is a bit more code, but hopefully easier to understand (and also hopefully
easier to optimize).

The motivation for this work is that I plan to investigate rebasing / landing
https://github.com/servo/servo/pull/20151, and I don't want more instantiations
of apply_declarations and such.

Differential Revision: https://phabricator.services.mozilla.com/D74369
2020-06-04 01:50:36 +02:00
Makoto Kato
80a1b64384
style: Part 2. Use Device for parameter instead of CssEnvironment.
CssEnvironment always is in Device, so use Device as parameter instead of CssEnvironment.

Differential Revision: https://phabricator.services.mozilla.com/D52507
2020-02-12 02:43:11 +01:00
Makoto Kato
c5bd98354d
style: Always use CssEnvironment from media query's device.
Although CssEnvironment is in Device of media query implementation, some code
creates CssEnvironment instance without Device. So I would like always to use it from Device of media query.

Differential Revision: https://phabricator.services.mozilla.com/D52506
2020-02-12 02:43:11 +01:00
Emilio Cobos Álvarez
ad61cae6b0 style: Update smallvec to 1.0.
Differential Revision: https://phabricator.services.mozilla.com/D56044
2019-12-16 14:23:56 +01:00
Emilio Cobos Álvarez
b0f3a68a6c style: Rustfmt declaration_block.rs.
Differential Revision: https://phabricator.services.mozilla.com/D43400
2019-09-12 22:34:16 +02:00
Simon Sapin
1d38bc0419 Fix some new warnings 2019-06-22 14:59:09 +02:00
violet
af8e8e6a34 style: Do not report error for unknown property if its known moz prefixed version is specified.
Suppose that `prop` is a property that we haven't supported yet, while its `-moz-prop`
version is already supported.

If an author specifies in a declaration block this property in its standard form
as well as multiple verdor specific forms, as long as `-moz-prop` is specified, we
shouldn't report error for unknown property `prop`. Because that's just noise.

Differential Revision: https://phabricator.services.mozilla.com/D31998
2019-05-29 16:14:23 +02:00
Emilio Cobos Álvarez
4b761848a0 style: Remove unnecessary mut usage. 2019-05-10 12:43:01 +02:00
Emilio Cobos Álvarez
dd6252e34f style: Don't report errors for properties for which we've parsed another value in the same declaration block.
I thought a bit about how to test it and it's not particularly great.
test_css_parse_error_smoketest.html is great to assert that something _gets_
reported, but not that it doesn't :)

Differential Revision: https://phabricator.services.mozilla.com/D30201
2019-05-10 12:42:57 +02:00
Emilio Cobos Álvarez
02210264e7 style: Centralize a bit invalid value error reporting.
Also, buffer the errors, since we're going to want to look at the whole
declaration block to skip reporting them.

This shouldn't change behavior, just moves some work to the caller, and defers a
bit the work so that it happens only when error reporting is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D30200
2019-05-10 12:42:56 +02:00
Emilio Cobos Álvarez
49842f5031 style: Fix servo build, and appease tidy / fmt. 2019-04-12 12:20:15 +02:00
Cameron McCormack
40248ae5fd style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-04-12 12:19:52 +02:00
Julian Descottes
5a55978478 style: Augment CSS errors with the CSS selector.
Differential Revision: https://phabricator.services.mozilla.com/D24894
2019-04-12 12:19:35 +02:00
Emilio Cobos Álvarez
6fd17ccb35 style: Implement CSS revert keyword.
The only fishy bit is the animation stuff. In particular, there are two places
where we just mint the revert behavior:

 * When serializing web-animations keyframes (the custom properties stuff in
   declaration_block.rs). That codepath is already not sound and I wanted to
   get rid of it in bug 1501530, but what do I know.

 * When getting an animation value from a property declaration. At that point
   we no longer have the CSS rules that apply to the element to compute the
   right revert value handy. It'd also use the wrong style anyway, I think,
   given the way StyleBuilder::for_animation works.

   We _could_ probably get them out of somewhere, but it seems like a whole lot
   of code reinventing the wheel which is probably not useful, and that Blink
   and WebKit just cannot implement either since they don't have a rule tree,
   so it just doesn't seem worth the churn.

The custom properties code looks a bit different in order to minimize hash
lookups in the common case. FWIW, `revert` for custom properties doesn't seem
very useful either, but oh well.

Differential Revision: https://phabricator.services.mozilla.com/D21877
2019-03-13 15:08:35 +01:00
Emilio Cobos Álvarez
a427e4f763 style: Introduce the concept of legacy shorthands.
We need this because there's a weird mapping between these properties' values
('always' maps to 'page').

See https://drafts.csswg.org/css-cascade-4/#legacy-shorthand.

Differential Revision: https://phabricator.services.mozilla.com/D12213
2018-12-02 14:17:25 -05:00
Emilio Cobos Álvarez
8bed8ae122 style: Remove the display: -moz-box overrides display: -webkit-box hack.
display: -moz-box is no longer exposed to content so this is not necessary.

See bug 1407701 for context.

Differential Revision: https://phabricator.services.mozilla.com/D12961
2018-12-02 14:17:21 -05:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
ebb57eff22
style: Add a mechanism to serialize shorthands for getComputedStyle().
This implements the mechanism reusing the animation machinery for now, so it
asserts in a few cases that this wouldn't handle correctly.

For shorthands that have colors and other bits we'd need a more sophisticated
mechanism with a bit more code (that resolves colors and such), but it'd look
something like this regardless, and we should have this in any case.

Differential Revision: https://phabricator.services.mozilla.com/D11944
2018-11-17 09:56:05 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Emilio Cobos Álvarez
b7da1bac88
style: Implement the env() function with hardcoded zeros for safe-area-inset.
Intent to Implement and Ship: https://groups.google.com/d/msg/mozilla.dev.platform/EVKyR1B87T0/_l-_qK8SAAAJ

Differential Revision: https://phabricator.services.mozilla.com/D9609
2018-11-05 12:33:16 +01:00
Emilio Cobos Álvarez
5cafac5d10
style: Remove DeclaredValue.
I think it used to be the case that all PropertyDeclaration variants had a
DeclaredValueOwned<T> inside. But that's no longer the case, so this abstraction
seems less useful now.

Differential Revision: https://phabricator.services.mozilla.com/D5978
2018-09-18 11:39:31 +02:00
Emilio Cobos Álvarez
89b8f30737
style: Hook the use counters into StyleSheet parsing.
Still not hooked into telemetry, I talked with :janerik and :gfritzsche about
that, but test incoming!

This intentionally doesn't handle CSSOM and such for now, will file followups
for those, though should be trivial.

I want to unify / clean up how we do the use counters and the error reporting
stuff for CSSOM, since the current function call still shows up in profiles,
but that should be a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D3828
2018-09-03 12:31:33 +02:00
Cameron McCormack
249b865eb8
style: Simplify PropertyDeclarationBlock::get a little.
Depends On D3747

Differential Revision: https://phabricator.services.mozilla.com/D3748
2018-09-03 12:30:12 +02:00
Cameron McCormack
b20bbea033
style: Replace NormalDeclarationIterator return type with impl Trait.
Differential Revision: https://phabricator.services.mozilla.com/D3747
2018-09-03 12:30:01 +02:00
Xidorn Quan
1a91beaf57
style: Remove DeclarationPushMode.
Bug: 1473180
Reviewed-by: emilio
MozReview-Commit-ID: LFgYeKE1SNk
2018-07-24 03:29:59 +02:00
Xidorn Quan
a0edeb1a92
style: Remove DeclarationPushMode::Update and related code.
Bug: 1473180
Reviewed-by: emilio
MozReview-Commit-ID: 1fI5YRa54lQ
2018-07-24 03:29:42 +02:00
Xidorn Quan
b14b2beaad
style: Add new algorithm for setting property to be used in later commit.
Bug: 1473180
Reviewed-by: emilio
MozReview-Commit-ID: CdM8hDB6rFj
2018-07-24 03:29:28 +02:00
Emilio Cobos Álvarez
5504cbdfd7
style: Animate logical properties.
The setup is that AnimationValue only contains physical properties, and
we physicalize when building keyframes and transitions.

Bug: 1309752
Reviewed-by: birtles
MozReview-Commit-ID: 9dI20N0LFrk
2018-07-24 03:28:10 +02:00
Xidorn Quan
d4ea70fd34
style: Have the CSSOM appending behavior behind a pref and only enable it on Nightly.
Bug: 1461285
Reviewed-by: emilio
MozReview-Commit-ID: 6BzPTNjXjyA
2018-07-16 19:42:53 +02:00
Xidorn Quan
2be1375745
style: Add a declaration iterator to AllShorthand for simplify code.
Bug: 1461285
Reviewed-by: emilio
MozReview-Commit-ID: 9w2B3SpdkQo
2018-07-16 19:42:42 +02:00
Xidorn Quan
36038869aa
style: Rename DeclarationSource to DeclarationPushMode.
Bug: 1461285
Reviewed-by: emilio
MozReview-Commit-ID: Iyv9JrXrpzl
2018-07-16 19:42:27 +02:00
Emilio Cobos Álvarez
750c223021
style: Fix tidy. 2018-06-23 20:34:10 +02:00
Emilio Cobos Álvarez
3a0c3224b9
style: Move the error reporter into ParserContext.
Summary:
This should make it easier to report errors, and also reduce codesize.

The reason this was so generic is that error reporting was unconditionally
enabled and was super-hot, but now that's no longer the case after bug 1452143,
so we can afford the virtual call in the "error reporting enabled" case.

This opens the possibility of simplifying a lot the error setup as well, though
this patch doesn't do it.

Test Plan: No behavior change, so no new tests.

Reviewers: xidorn

Bug #: 1469957

Differential Revision: https://phabricator.services.mozilla.com/D1734

MozReview-Commit-ID: F3wTdhX9MB5
2018-06-23 20:36:23 +02:00