mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Serialize media rule and supports rule like Gecko.
This commit is contained in:
parent
d7b4471c80
commit
ae3989ebf0
3 changed files with 20 additions and 13 deletions
|
@ -46,12 +46,7 @@ impl ToCssWithGuard for MediaRule {
|
|||
where W: fmt::Write {
|
||||
dest.write_str("@media ")?;
|
||||
self.media_queries.read_with(guard).to_css(dest)?;
|
||||
dest.write_str(" {")?;
|
||||
for rule in self.rules.read_with(guard).0.iter() {
|
||||
dest.write_str(" ")?;
|
||||
rule.to_css(guard, dest)?;
|
||||
}
|
||||
dest.write_str(" }")
|
||||
self.rules.read_with(guard).to_css_block(guard, dest)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#[cfg(feature = "gecko")]
|
||||
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
|
||||
use servo_arc::{Arc, RawOffsetArc};
|
||||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard};
|
||||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use std::fmt;
|
||||
use stylesheets::{CssRule, RulesMutateError};
|
||||
use stylesheets::loader::StylesheetLoader;
|
||||
use stylesheets::rule_parser::State;
|
||||
|
@ -88,6 +90,21 @@ impl CssRules {
|
|||
self.0.remove(index);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Serializes this CSSRules to CSS text as a block of rules.
|
||||
///
|
||||
/// This should be speced into CSSOM spec at some point. See
|
||||
/// <https://github.com/w3c/csswg-drafts/issues/1985>
|
||||
pub fn to_css_block<W>(&self, guard: &SharedRwLockReadGuard, dest: &mut W)
|
||||
-> fmt::Result where W: fmt::Write
|
||||
{
|
||||
dest.write_str(" {")?;
|
||||
for rule in self.0.iter() {
|
||||
dest.write_str("\n ")?;
|
||||
rule.to_css(guard, dest)?;
|
||||
}
|
||||
dest.write_str("\n}")
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait to implement helpers for `Arc<Locked<CssRules>>`.
|
||||
|
|
|
@ -47,12 +47,7 @@ impl ToCssWithGuard for SupportsRule {
|
|||
where W: fmt::Write {
|
||||
dest.write_str("@supports ")?;
|
||||
self.condition.to_css(dest)?;
|
||||
dest.write_str(" {")?;
|
||||
for rule in self.rules.read_with(guard).0.iter() {
|
||||
dest.write_str(" ")?;
|
||||
rule.to_css(guard, dest)?;
|
||||
}
|
||||
dest.write_str(" }")
|
||||
self.rules.read_with(guard).to_css_block(guard, dest)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue