mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #19222 - upsuper:serialize-group-rule, r=emilio
Serialize media rule and supports rule like Gecko This should fix [bug 1417207](https://bugzilla.mozilla.org/show_bug.cgi?id=1417207). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19222) <!-- Reviewable:end -->
This commit is contained in:
commit
b2c19b1544
3 changed files with 20 additions and 13 deletions
|
@ -46,12 +46,7 @@ impl ToCssWithGuard for MediaRule {
|
||||||
where W: fmt::Write {
|
where W: fmt::Write {
|
||||||
dest.write_str("@media ")?;
|
dest.write_str("@media ")?;
|
||||||
self.media_queries.read_with(guard).to_css(dest)?;
|
self.media_queries.read_with(guard).to_css(dest)?;
|
||||||
dest.write_str(" {")?;
|
self.rules.read_with(guard).to_css_block(guard, dest)
|
||||||
for rule in self.rules.read_with(guard).0.iter() {
|
|
||||||
dest.write_str(" ")?;
|
|
||||||
rule.to_css(guard, dest)?;
|
|
||||||
}
|
|
||||||
dest.write_str(" }")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
|
||||||
use servo_arc::{Arc, RawOffsetArc};
|
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::{CssRule, RulesMutateError};
|
||||||
use stylesheets::loader::StylesheetLoader;
|
use stylesheets::loader::StylesheetLoader;
|
||||||
use stylesheets::rule_parser::State;
|
use stylesheets::rule_parser::State;
|
||||||
|
@ -88,6 +90,21 @@ impl CssRules {
|
||||||
self.0.remove(index);
|
self.0.remove(index);
|
||||||
Ok(())
|
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>>`.
|
/// A trait to implement helpers for `Arc<Locked<CssRules>>`.
|
||||||
|
|
|
@ -47,12 +47,7 @@ impl ToCssWithGuard for SupportsRule {
|
||||||
where W: fmt::Write {
|
where W: fmt::Write {
|
||||||
dest.write_str("@supports ")?;
|
dest.write_str("@supports ")?;
|
||||||
self.condition.to_css(dest)?;
|
self.condition.to_css(dest)?;
|
||||||
dest.write_str(" {")?;
|
self.rules.read_with(guard).to_css_block(guard, dest)
|
||||||
for rule in self.rules.read_with(guard).0.iter() {
|
|
||||||
dest.write_str(" ")?;
|
|
||||||
rule.to_css(guard, dest)?;
|
|
||||||
}
|
|
||||||
dest.write_str(" }")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue