mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +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
|
@ -24,7 +24,7 @@ use std::fmt::{self, Write};
|
|||
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering};
|
||||
use str::starts_with_ignore_ascii_case;
|
||||
use string_cache::Atom;
|
||||
use style_traits::{CSSPixel, DevicePixel};
|
||||
use style_traits::{CSSPixel, CssWriter, DevicePixel};
|
||||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylesheets::Origin;
|
||||
|
@ -236,7 +236,7 @@ pub struct Expression {
|
|||
}
|
||||
|
||||
impl ToCss for Expression {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
dest.write_str("(")?;
|
||||
|
@ -408,7 +408,7 @@ impl MediaExpressionValue {
|
|||
}
|
||||
|
||||
impl MediaExpressionValue {
|
||||
fn to_css<W>(&self, dest: &mut W, for_expr: &Expression) -> fmt::Result
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>, for_expr: &Expression) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
|
|
|
@ -16,7 +16,7 @@ use selectors::parser::{self as selector_parser, Selector, Visit, SelectorParseE
|
|||
use selectors::visitor::SelectorVisitor;
|
||||
use std::fmt;
|
||||
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss as ToCss_};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_};
|
||||
|
||||
pub use gecko::pseudo_element::{PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT};
|
||||
pub use gecko::snapshot::SnapshotMap;
|
||||
|
@ -86,12 +86,12 @@ impl ToCss for NonTSPseudoClass {
|
|||
}, )*
|
||||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||
dest.write_str(":-moz-locale-dir(")?;
|
||||
dir.to_css(dest)?;
|
||||
dir.to_css(&mut CssWriter::new(dest))?;
|
||||
return dest.write_char(')')
|
||||
},
|
||||
NonTSPseudoClass::Dir(ref dir) => {
|
||||
dest.write_str(":dir(")?;
|
||||
dir.to_css(dest)?;
|
||||
dir.to_css(&mut CssWriter::new(dest))?;
|
||||
return dest.write_char(')')
|
||||
},
|
||||
NonTSPseudoClass::MozAny(ref selectors) => {
|
||||
|
|
|
@ -12,9 +12,9 @@ use gecko_bindings::sugar::refptr::RefPtr;
|
|||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use parser::ParserContext;
|
||||
use servo_arc::{Arc, RawOffsetArc};
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Write};
|
||||
use std::mem;
|
||||
use style_traits::{ToCss, ParseError};
|
||||
use style_traits::{CssWriter, ToCss, ParseError};
|
||||
|
||||
/// A specified url() value for gecko. Gecko does not eagerly resolve SpecifiedUrls.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -136,7 +136,10 @@ impl SpecifiedUrl {
|
|||
}
|
||||
|
||||
impl ToCss for SpecifiedUrl {
|
||||
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,
|
||||
{
|
||||
dest.write_str("url(")?;
|
||||
self.serialization.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue