mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something is written to it. This allows removing plenty of useless monomorphisations caused by the former W/SequenceWriter<W> pair of types.
This commit is contained in:
parent
3672856efa
commit
cd8f96cc9e
89 changed files with 873 additions and 533 deletions
|
@ -15,7 +15,7 @@ use servo_arc::Arc;
|
|||
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use std::fmt::{self, Write};
|
||||
use str::CssStringWriter;
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use stylesheets::CssRules;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
|
@ -43,7 +43,7 @@ impl DocumentRule {
|
|||
impl ToCssWithGuard for DocumentRule {
|
||||
fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
||||
dest.write_str("@-moz-document ")?;
|
||||
self.condition.to_css(dest)?;
|
||||
self.condition.to_css(&mut CssWriter::new(dest))?;
|
||||
dest.write_str(" {")?;
|
||||
for rule in self.rules.read_with(guard).0.iter() {
|
||||
dest.write_str(" ")?;
|
||||
|
@ -167,8 +167,10 @@ impl UrlMatchingFunction {
|
|||
}
|
||||
|
||||
impl ToCss for UrlMatchingFunction {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
UrlMatchingFunction::Url(ref url) => {
|
||||
url.to_css(dest)
|
||||
|
@ -219,8 +221,10 @@ impl DocumentCondition {
|
|||
}
|
||||
|
||||
impl ToCss for DocumentCondition {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
let mut iter = self.0.iter();
|
||||
let first = iter.next()
|
||||
.expect("Empty DocumentCondition, should contain at least one URL matching function");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue