mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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:
parent
60331f01d0
commit
ebb57eff22
2 changed files with 10 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue