mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Add style_traits::ToCss for AtomIdent
Differential Revision: https://phabricator.services.mozilla.com/D136290
This commit is contained in:
parent
f39ab4ffc1
commit
199f54342c
6 changed files with 20 additions and 20 deletions
|
@ -69,7 +69,7 @@ impl ToCss for NonTSPseudoClass {
|
||||||
$(NonTSPseudoClass::$name => concat!(":", $css),)*
|
$(NonTSPseudoClass::$name => concat!(":", $css),)*
|
||||||
NonTSPseudoClass::Lang(ref s) => {
|
NonTSPseudoClass::Lang(ref s) => {
|
||||||
dest.write_str(":lang(")?;
|
dest.write_str(":lang(")?;
|
||||||
s.to_css(dest)?;
|
cssparser::ToCss::to_css(s, dest)?;
|
||||||
return dest.write_char(')');
|
return dest.write_char(')');
|
||||||
},
|
},
|
||||||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::values::AtomIdent;
|
||||||
|
|
||||||
use super::CssRules;
|
use super::CssRules;
|
||||||
|
|
||||||
use cssparser::{Parser, SourceLocation, ToCss as CssParserToCss, Token};
|
use cssparser::{Parser, SourceLocation, Token};
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
||||||
use crate::str::CssStringWriter;
|
use crate::str::CssStringWriter;
|
||||||
use crate::{Namespace, Prefix};
|
use crate::{Namespace, Prefix};
|
||||||
use cssparser::{self, SourceLocation};
|
use cssparser::SourceLocation;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
|
|
||||||
|
@ -25,15 +25,15 @@ pub struct NamespaceRule {
|
||||||
|
|
||||||
impl ToCssWithGuard for NamespaceRule {
|
impl ToCssWithGuard for NamespaceRule {
|
||||||
// https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSNamespaceRule
|
// https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSNamespaceRule
|
||||||
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest_str: &mut CssStringWriter) -> fmt::Result {
|
||||||
|
let mut dest = CssWriter::new(dest_str);
|
||||||
dest.write_str("@namespace ")?;
|
dest.write_str("@namespace ")?;
|
||||||
if let Some(ref prefix) = self.prefix {
|
if let Some(ref prefix) = self.prefix {
|
||||||
let prefix = prefix.to_string();
|
prefix.to_css(&mut dest)?;
|
||||||
cssparser::serialize_identifier(&prefix, dest)?;
|
dest.write_char(' ')?;
|
||||||
dest.write_str(" ")?;
|
|
||||||
}
|
}
|
||||||
dest.write_str("url(")?;
|
dest.write_str("url(")?;
|
||||||
self.url.to_string().to_css(&mut CssWriter::new(dest))?;
|
self.url.to_string().to_css(&mut dest)?;
|
||||||
dest.write_str(");")
|
dest.write_str(");")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||||
use crate::str::CssStringWriter;
|
use crate::str::CssStringWriter;
|
||||||
use crate::values::{AtomIdent, CustomIdent};
|
use crate::values::{AtomIdent, CustomIdent};
|
||||||
use style_traits::{CssWriter, ParseError, ToCss};
|
use style_traits::{CssWriter, ParseError, ToCss};
|
||||||
use cssparser::{ToCss as CssParserToCss, Parser, SourceLocation};
|
use cssparser::{Parser, SourceLocation};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
@ -23,7 +23,7 @@ use std::fmt::{self, Write};
|
||||||
///
|
///
|
||||||
/// We do not support pseudo selectors yet.
|
/// We do not support pseudo selectors yet.
|
||||||
/// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors
|
/// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToShmem)]
|
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
||||||
pub struct PageSelector(pub AtomIdent);
|
pub struct PageSelector(pub AtomIdent);
|
||||||
|
|
||||||
impl PageSelector {
|
impl PageSelector {
|
||||||
|
@ -46,15 +46,6 @@ impl Parse for PageSelector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for PageSelector {
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write
|
|
||||||
{
|
|
||||||
(&self.0).to_css(dest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A list of [`@page`][page selectors]
|
/// A list of [`@page`][page selectors]
|
||||||
///
|
///
|
||||||
/// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors
|
/// [page-selectors]: https://drafts.csswg.org/css2/page.html#page-selectors
|
||||||
|
|
|
@ -324,7 +324,6 @@ impl ToCss for ScrollTimelineSelector {
|
||||||
where
|
where
|
||||||
W: Write,
|
W: Write,
|
||||||
{
|
{
|
||||||
use crate::cssparser::ToCss as CssparserToCss;
|
|
||||||
dest.write_str("selector(")?;
|
dest.write_str("selector(")?;
|
||||||
dest.write_char('#')?;
|
dest.write_char('#')?;
|
||||||
self.0.to_css(dest)?;
|
self.0.to_css(dest)?;
|
||||||
|
|
|
@ -293,6 +293,16 @@ impl cssparser::ToCss for AtomIdent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
impl style_traits::ToCss for AtomIdent {
|
||||||
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
|
where
|
||||||
|
W: Write,
|
||||||
|
{
|
||||||
|
cssparser::ToCss::to_css(self, dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl PrecomputedHash for AtomIdent {
|
impl PrecomputedHash for AtomIdent {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue