Commit graph

193 commits

Author SHA1 Message Date
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
Emilio Cobos Álvarez
e6f9ad0edb
style: Don't call the before change closure with the locked declaration block.
Test Plan: No behavior change.

Reviewers: xidorn

Bug #: 1468665

Differential Revision: https://phabricator.services.mozilla.com/D1681
2018-06-23 20:34:14 +02:00
Emilio Cobos Álvarez
00b42fc6ef
style: Remove some cfgs. 2018-06-23 20:34:10 +02:00
Emilio Cobos Álvarez
cdbc409759
style: Trivially simplify a condition.
Bug: 1466963
Reviewed-by: xidorn
MozReview-Commit-ID: L9LzpPt4js4
2018-06-12 12:15:15 -07:00
Emilio Cobos Álvarez
3c7fb2a217
style: Add a before-change callback to remove_property.
Bug: 1466963
Reviewed-by: xidorn
MozReview-Commit-ID: 4vyN9iLT7e3
2018-06-12 12:15:14 -07:00
Emilio Cobos Álvarez
6ca324f8b5
style: Remove unused PropertyDeclarationBlock::set_importance.
Bug: 1466963
Reviewed-by: xidorn
MozReview-Commit-ID: 1YrlOvktag9
2018-06-12 12:15:14 -07:00
Emilio Cobos Álvarez
e052666153
style: Fix a typo.
Nobody looks at the result from parsing, but this is the right thing to return.

Bug: 1466963
Reviewed-by: xidorn
MozReview-Commit-ID: 9P5VARiPIAk
2018-06-12 12:15:13 -07:00
Emilio Cobos Álvarez
915c8725ae
style: Remove PropertyId::name.
It's only used for the error path in property parsing, so most of the time is
not useful.

Use the just-introduced NonCustomPropertyId::name to preserve the alias name,
which we were doing by passing the name around.

Bug: 1466645
Reviewed-by: xidorn
MozReview-Commit-ID: 46xxZKCoeBB
2018-06-12 12:15:12 -07:00
Emilio Cobos Álvarez
600f19540e
style: Make PropertyId::parse less of a footgun.
Bug: 1466095
Reviewed-by: xidorn
MozReview-Commit-ID: 2BmtSDPmHj9
2018-06-02 12:08:40 +02:00
Matt Brubeck
e3f79d9130 Update to smallbitvec 2.1 2018-04-17 17:24:54 -07:00
Xidorn Quan
3274e84278 Have CSSOM append rather than replace slot in declaration block.
The early return for identical setting in importance matching as well
as the comment before `index_to_remove` are removed because the order
is web-exposing regardless of whether it's from CSSOM or parsing. e.g.
`top: 1px; left: 2px; top: 1px;` is effectively `left: 2px; top: 1px;`,
not `top: 1px; left: 2px;`.
2018-04-07 19:58:27 +10:00
Emilio Cobos Álvarez
8c4b401dd3
style: Only expose longhands to rust via iterators.
The key here is that we only filter longhands if the shorthand is accessible to
content and vice-versa. This prevents the bug that prevented me to land this
patch before, which was us not expanding properly chrome-only shorthands.

Again, this is incomplete, and I need to teach LonghandsToSerialize to get a
potentially incomplete list of properties, and all that.
2018-02-28 00:19:31 +01:00