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
This commit is contained in:
Emilio Cobos Álvarez 2023-06-18 14:02:56 +02:00 committed by Martin Robinson
parent ee4e09359f
commit ec6099563e
9 changed files with 161 additions and 16 deletions

View file

@ -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`.