aboutsummaryrefslogtreecommitdiffstats
path: root/components/style_traits/values.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2023-06-18 14:02:56 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-08-16 17:46:41 +0200
commitec6099563ed0eefe71606d1fef4caf2b2bd6ac3c (patch)
tree49e67e385ff6ee4d9575ddb12bb0deb107e9f0ff /components/style_traits/values.rs
parentee4e09359f91c612011560a57b3ea99c01aae3c2 (diff)
downloadservo-ec6099563ed0eefe71606d1fef4caf2b2bd6ac3c.tar.gz
servo-ec6099563ed0eefe71606d1fef4caf2b2bd6ac3c.zip
style: Implement parsing / serialization for container{,-type,-name} CSS properties
Two noteworthy details that may seem random otherwise: * Moving values around in nsStyleDisplay is needed so that the struct remains under the size limit that we have to avoid jumping allocator buckets. * All the test expectation churn is because tests depend on `container-type: size` parsing to run, and now they run. Tests for the relevant bits I implemented are passing, with the only exception of some `container-name-computed.html` failures which are https://github.com/w3c/csswg-drafts/issues/7181. Safari agrees with us there. Other notes when looking at the spec and seeing how it matches the implementation: * `container` syntax doesn't match spec, but matches tests and sanity: https://github.com/w3c/csswg-drafts/issues/7180 * `container-type` syntax doesn't _quite_ match spec, but matches tests and I think it's a spec bug since the definition for the missing keyword is gone: https://github.com/w3c/csswg-drafts/issues/7179 Differential Revision: https://phabricator.services.mozilla.com/D142419
Diffstat (limited to 'components/style_traits/values.rs')
-rw-r--r--components/style_traits/values.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/components/style_traits/values.rs b/components/style_traits/values.rs
index 1677629d1a9..d04485790f8 100644
--- a/components/style_traits/values.rs
+++ b/components/style_traits/values.rs
@@ -44,9 +44,9 @@ use std::fmt::{self, Write};
/// * `#[css(represents_keyword)]` can be used on bool fields in order to
/// serialize the field name if the field is true, or nothing otherwise. It
/// also collects those keywords for `SpecifiedValueInfo`.
-/// * `#[css(bitflags(single="", mixed="", validate="")]` can be used to derive
-/// parse / serialize / etc on bitflags. The rules for parsing bitflags are
-/// the following:
+/// * `#[css(bitflags(single="", mixed="", validate="", overlapping_bits)]` can
+/// be used to derive parse / serialize / etc on bitflags. The rules for parsing
+/// bitflags are the following:
///
/// * `single` flags can only appear on their own. It's common that bitflags
/// properties at least have one such value like `none` or `auto`.
@@ -66,6 +66,13 @@ use std::fmt::{self, Write};
///
/// But `bar baz` will be valid, as they don't share bits, and so would
/// `foo` with any other flag, or `bazz` on its own.
+/// * `overlapping_bits` enables some tracking during serialization of mixed
+/// flags to avoid serializing variants that can subsume other variants.
+/// In the example above, you could do:
+/// mixed="foo,bazz,bar,baz", overlapping_bits
+/// to ensure that if bazz is serialized, bar and baz aren't, even though
+/// their bits are set. Note that the serialization order is canonical,
+/// and thus depends on the order you specify the flags in.
///
/// * finally, one can put `#[css(derive_debug)]` on the whole type, to
/// implement `Debug` by a single call to `ToCss::to_css`.