Commit graph

145 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
2b6fce1e57 style: Remove servo/components/{hashglobe,fallible} in favor of try_reserve
Differential Revision: https://phabricator.services.mozilla.com/D134194
2023-06-09 10:22:24 +02:00
Emilio Cobos Álvarez
8bb7d98f0c style: Add support for the revert-layer keyword
This patch looks bigger than it is, but it's mostly because
of plumbing.

To implement revert-layer we need not only the cascade origin of the
declaration, but the whole cascade level, plus also the layer order.

In order to do this, encapsulate these two things inside a 32-bit
`CascadePriority` struct and plumb it through the rule tree and so on.
This allows us to remove the packing and unpacking of CascadeLevel,
though I kept the ShadowCascadeOrder limit for now in case we need to
reintroduce it.

Fix `!important` behavior of layers while at it (implementing it in
`CascadeLevel::cmp`, spec quote included since it was tricky to find)
since some revert-layer tests were depending on it.

The style attribute test is failing now, but follow-up commit fixes
it, see spec issue.

In terms of the actual keyword implementation, it's sort of
straight-forward: We implement revert and revert-layer in a shared
way, by storing the cascade priority that reverted it.

Differential Revision: https://phabricator.services.mozilla.com/D133372
2023-06-09 10:22:22 +02:00
Oriol Brufau
a95a742599 Further changes required by Servo 2023-06-09 10:22:21 +02:00
Emilio Cobos Álvarez
bcd0b74838 style: Honor GTK button layout
This is based off work by smurfd. But this patch doesn't support buttons
both at the left and right, which simplifies a lot the implementation.

Also, clean-up the existing env variables while at it.

Co-authored-by: Nicklas Boman <smurfd@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D132073
2023-06-09 10:22:21 +02:00
Ting-Yu Lin
a0617bff0d style: Run rustfmt on servo/components/style and servo/ports/geckolib
This patch is generated by running `cargo +nightly fmt` under
`servo/components/style/` and `servo/ports/geckolib` against mozilla-central
https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512

My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17)

Manually remove the redundant braces in author_styles.rs to fix a warning.

Differential Revision: https://phabricator.services.mozilla.com/D131556
2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
33ad82c3da style: Make custom properties that are IACVT guaranteed-invalid
This effectively backs out bug 1623396.

See:

  https://github.com/w3c/csswg-drafts/pull/6006
  https://drafts.csswg.org/css-variables/#guaranteed-invalid-value

And related discussion. Matches Chrome stable as per https://groups.google.com/a/chromium.org/g/blink-dev/c/0xrbzYe_vxU/m/7bsL76n9CgAJ

Depends on D116459

Differential Revision: https://phabricator.services.mozilla.com/D116460
2023-06-09 10:22:19 +02:00
Emilio Cobos Álvarez
1b04838278 style: Use GTK menu radius on native context menus and panels
Differential Revision: https://phabricator.services.mozilla.com/D129439
2023-05-31 00:50:33 +02:00
Emilio Cobos Álvarez
07e5ea6966 style: Expose titlebar radius as a chrome-only CSS environment variable
Mostly plumbing.

Differential Revision: https://phabricator.services.mozilla.com/D128680
2023-05-31 00:50:31 +02:00
Emilio Cobos Álvarez
e74b41cafe style: Add support for chrome-only environment variables
This bit is taken straight from D73454 (I reviewed it but I guess
another pair of eyes is ok, it's really straight-forward).

Co-authored-by: Nicklas Boman <smurfd@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D128679
2023-05-31 00:50:31 +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
Emilio Cobos Álvarez
832807f15f style: Reserve -- as a custom property name
I think this should be fairly low risk, let's try to get it done sooner
rather than later.

Differential Revision: https://phabricator.services.mozilla.com/D116456
2023-05-24 18:32:31 +02:00
Josh Matthews
01681e79c4 Update nightly rustc. 2021-11-01 08:46:18 -04:00
Emilio Cobos Álvarez
786b08a669 style: Increase custom property size limit a bit.
Differential Revision: https://phabricator.services.mozilla.com/D105978
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
bdbe8fde42 style: Shrink custom property maps before making them immutable.
Differential Revision: https://phabricator.services.mozilla.com/D96132
2021-02-26 16:44:05 +01:00
Emilio Cobos Álvarez
5d388745d8 style: Don't waste string space before making values immutable.
Differential Revision: https://phabricator.services.mozilla.com/D96130
2021-02-26 16:44:05 +01: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
Emilio Cobos Álvarez
f76acc84c6 style: Reformat recent changes. 2020-04-16 17:50:17 +02:00
Emilio Cobos Álvarez
3004286308 style: Custom properties with invalid variable references should be unset, not invalid.
See https://github.com/w3c/csswg-drafts/issues/4075.

There are tests that will get updated and this will make pass in bug 1623347.

Differential Revision: https://phabricator.services.mozilla.com/D67373
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
071ce6f345
style: Rustfmt recent changes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
9817ca386c
style: Remove lazy_static usage from custom_properties.rs.
Differential Revision: https://phabricator.services.mozilla.com/D60039
2020-02-12 02:43:13 +01:00
Makoto Kato
e9c14bb9fc
style: Don't use hardcoded value for safearea.
To implement safe area support on Gecko, we should get safe area from Device.

Differential Revision: https://phabricator.services.mozilla.com/D52504
2020-02-12 02:43:11 +01: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
Emilio Cobos Álvarez
d9aa0571e3
style: Simplify some code now that lifetimes are non-lexical.
Differential Revision: https://phabricator.services.mozilla.com/D54529
2019-11-30 20:45:05 +01: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
Emilio Cobos Álvarez
5aeab7adb1 style: Reformat recent changes. 2019-03-13 15:08:38 +01: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
Shanavas M
b763d6737c Remove OrderedMap in favor of IndexMap 2019-01-10 12:57:09 +05:30
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +01:00
Emilio Cobos Álvarez
dca315e648 style: Prevent exponential blowup of custom properties.
Put a hard cap on the value length instead of counting substitutions, because it
works best, see the comment.

Differential Revision: https://phabricator.services.mozilla.com/D13352
2018-12-02 14:17:22 -05:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Emilio Cobos Álvarez
06fe0a1fc0
style: Fix formatting. 2018-11-17 09:56:05 +01:00
Cameron McCormack
1576dd4c5b
style: Store variable references with a boxed slice rather than a PrecomputedHashSet.
Once we've parsed the variable references, there is no need to keep an entire HashSet
object around, as all we do is iterate over the values.

Differential Revision: https://phabricator.services.mozilla.com/D11735
2018-11-17 09:56:01 +01:00
Emilio Cobos Álvarez
212b3e1311
style: Revert try -> r#try change.
Since we're in an inconsistent state because mako files weren't updated, and
it's really really ugly.
2018-11-10 21:42:17 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Emilio Cobos Álvarez
ac6f921588
style: Fix servo build. 2018-11-05 12:44:54 +01:00
Emilio Cobos Álvarez
99f9d84555
style: Simplify invalid custom property handling.
It's a bit useless to keep a set of invalid properties if we're going
to use them just to reject lookups into another key. This makes it more
consistent with the cascade / no-references code, and should not change
behavior.

Differential Revision: https://phabricator.services.mozilla.com/D9632
2018-11-05 12:33: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
c155efe7a5
style: Remove DeclaredValue::WithVariables.
We never construct it.

Differential Revision: https://phabricator.services.mozilla.com/D5976
2018-09-18 11:39:17 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -07:00
Emilio Cobos Álvarez
39a3d93b4f
style: remove unused AsciiExt imports.
eq_ignore_ascii_case is not in AsciiExt since rustc 1.23.
2018-03-04 15:31:06 +01:00
Emilio Cobos Álvarez
57ebb2c8af
style: Use debug_assert_eq!. 2018-02-05 13:02:54 +01:00
Emilio Cobos Álvarez
7178e9bf69
style: Remove stray space. 2018-02-05 13:02:53 +01:00
Emilio Cobos Álvarez
412f0133ca
style: Remove unneeded impl block. 2018-02-05 13:02:52 +01:00
Emilio Cobos Álvarez
c72a5623b1
style: Avoid double hash lookup when inserting in OrderMap. 2018-02-05 13:02:52 +01:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00