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
This commit is contained in:
Emilio Cobos Álvarez 2018-11-15 08:25:13 +00:00
parent 60331f01d0
commit ebb57eff22
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 10 additions and 1 deletions

View file

@ -309,7 +309,9 @@ impl PropertyDeclarationBlock {
.find(|(declaration, _)| declaration.id() == property)
}
fn shorthand_to_css(
/// Tries to serialize a given shorthand from the declarations in this
/// block.
pub fn shorthand_to_css(
&self,
shorthand: ShorthandId,
dest: &mut CssStringWriter,

View file

@ -1354,6 +1354,13 @@ impl ShorthandId {
NonCustomPropertyId::from(self).to_nscsspropertyid()
}
/// Converts from a nsCSSPropertyID to a ShorthandId.
#[cfg(feature = "gecko")]
#[inline]
pub fn from_nscsspropertyid(prop: nsCSSPropertyID) -> Result<Self, ()> {
PropertyId::from_nscsspropertyid(prop)?.as_shorthand().map_err(|_| ())
}
/// Get the longhand ids that form this shorthand.
pub fn longhands(&self) -> NonCustomPropertyIterator<LonghandId> {
% for property in data.shorthands: