mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make list-style-image use UrlOrNone.
MozReview-Commit-ID: 6E82Tq5nrfC
This commit is contained in:
parent
75e97c02dc
commit
47b4648e62
2 changed files with 7 additions and 81 deletions
|
@ -43,7 +43,7 @@ use std::marker::PhantomData;
|
|||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use style::computed_values::{caption_side, display, empty_cells, float, list_style_position};
|
||||
use style::computed_values::{caption_side, display, empty_cells, float, list_style_image, list_style_position};
|
||||
use style::computed_values::content::ContentItem;
|
||||
use style::computed_values::position;
|
||||
use style::context::SharedStyleContext;
|
||||
|
@ -1264,14 +1264,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
fn build_flow_for_list_item(&mut self, node: &ConcreteThreadSafeLayoutNode, flotation: float::T)
|
||||
-> ConstructionResult {
|
||||
let flotation = FloatKind::from_property(flotation);
|
||||
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image.0 {
|
||||
Some(ref url) => {
|
||||
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
|
||||
list_style_image::T::Url(ref url, ref _extra_data) => {
|
||||
let image_info = box ImageFragmentInfo::new(node,
|
||||
Some((*url).clone()),
|
||||
&self.layout_context.shared);
|
||||
vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)]
|
||||
}
|
||||
None => {
|
||||
list_style_image::T::None => {
|
||||
match ListStyleTypeContent::from_list_style_type(node.style(self.style_context())
|
||||
.get_list()
|
||||
.list_style_type) {
|
||||
|
|
|
@ -26,83 +26,9 @@ ${helpers.single_keyword("list-style-type", """
|
|||
gecko_constant_prefix="NS_STYLE_LIST_STYLE",
|
||||
animatable=False)}
|
||||
|
||||
<%helpers:longhand name="list-style-image" animatable="False">
|
||||
use cssparser::{ToCss, Token};
|
||||
use std::fmt;
|
||||
use url::Url;
|
||||
use values::LocalToCss;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum SpecifiedValue {
|
||||
None,
|
||||
Url(Url),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::None => dest.write_str("none"),
|
||||
SpecifiedValue::Url(ref url) => url.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::{ToCss, Token};
|
||||
use std::fmt;
|
||||
use url::Url;
|
||||
use values::LocalToCss;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T(pub Option<Url>);
|
||||
|
||||
impl ToCss for T {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match self.0 {
|
||||
None => dest.write_str("none"),
|
||||
Some(ref url) => url.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, _context: &Context) -> computed_value::T {
|
||||
match *self {
|
||||
SpecifiedValue::None => computed_value::T(None),
|
||||
SpecifiedValue::Url(ref url) => computed_value::T(Some(url.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
||||
match *computed {
|
||||
computed_value::T(None) => SpecifiedValue::None,
|
||||
computed_value::T(Some(ref url)) => SpecifiedValue::Url(url.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
Ok(SpecifiedValue::None)
|
||||
} else {
|
||||
Ok(SpecifiedValue::Url(context.parse_url(&*try!(input.expect_url()))))
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T(None)
|
||||
}
|
||||
</%helpers:longhand>
|
||||
${helpers.predefined_type("list-style-image", "UrlOrNone", "computed_value::T::None",
|
||||
needs_context=True,
|
||||
animatable="False")}
|
||||
|
||||
<%helpers:longhand name="quotes" animatable="False">
|
||||
use std::borrow::Cow;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue