mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Parse -moz-alt-content as a whole content value (fixes #15726)
This commit is contained in:
parent
8cd4330b2a
commit
499e81410f
4 changed files with 37 additions and 31 deletions
|
@ -148,7 +148,7 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T {
|
||||||
let style = self.as_element().unwrap().resolved_style();
|
let style = self.as_element().unwrap().resolved_style();
|
||||||
|
|
||||||
return match style.as_ref().get_counters().content {
|
return match style.as_ref().get_counters().content {
|
||||||
content::T::Content(ref value) if !value.is_empty() => {
|
content::T::Items(ref value) if !value.is_empty() => {
|
||||||
TextContent::GeneratedContent((*value).clone())
|
TextContent::GeneratedContent((*value).clone())
|
||||||
}
|
}
|
||||||
_ => TextContent::GeneratedContent(vec![]),
|
_ => TextContent::GeneratedContent(vec![]),
|
||||||
|
|
|
@ -4238,8 +4238,8 @@ clip-path
|
||||||
}
|
}
|
||||||
|
|
||||||
match v {
|
match v {
|
||||||
T::none |
|
T::None |
|
||||||
T::normal => {
|
T::Normal => {
|
||||||
// Ensure destructors run, otherwise we could leak.
|
// Ensure destructors run, otherwise we could leak.
|
||||||
if !self.gecko.mContents.is_empty() {
|
if !self.gecko.mContents.is_empty() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -4247,7 +4247,14 @@ clip-path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
T::Content(items) => {
|
T::MozAltContent => {
|
||||||
|
unsafe {
|
||||||
|
Gecko_ClearAndResizeStyleContents(&mut self.gecko, 1);
|
||||||
|
*self.gecko.mContents[0].mContent.mString.as_mut() = ptr::null_mut();
|
||||||
|
}
|
||||||
|
self.gecko.mContents[0].mType = eStyleContentType_AltContent;
|
||||||
|
},
|
||||||
|
T::Items(items) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_ClearAndResizeStyleContents(&mut self.gecko,
|
Gecko_ClearAndResizeStyleContents(&mut self.gecko,
|
||||||
items.len() as u32);
|
items.len() as u32);
|
||||||
|
@ -4289,8 +4296,6 @@ clip-path
|
||||||
=> self.gecko.mContents[i].mType = eStyleContentType_NoOpenQuote,
|
=> self.gecko.mContents[i].mType = eStyleContentType_NoOpenQuote,
|
||||||
ContentItem::NoCloseQuote
|
ContentItem::NoCloseQuote
|
||||||
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
|
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
|
||||||
ContentItem::MozAltContent
|
|
||||||
=> self.gecko.mContents[i].mType = eStyleContentType_AltContent,
|
|
||||||
ContentItem::Counter(name, style) => {
|
ContentItem::Counter(name, style) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
|
bindings::Gecko_SetContentDataArray(&mut self.gecko.mContents[i],
|
||||||
|
|
|
@ -55,8 +55,6 @@
|
||||||
NoCloseQuote,
|
NoCloseQuote,
|
||||||
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
/// `-moz-alt-content`
|
|
||||||
MozAltContent,
|
|
||||||
/// `attr([namespace? `|`]? ident)`
|
/// `attr([namespace? `|`]? ident)`
|
||||||
Attr(Option<String>, String),
|
Attr(Option<String>, String),
|
||||||
/// `url(url)`
|
/// `url(url)`
|
||||||
|
@ -92,7 +90,6 @@
|
||||||
ContentItem::NoCloseQuote => dest.write_str("no-close-quote"),
|
ContentItem::NoCloseQuote => dest.write_str("no-close-quote"),
|
||||||
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
ContentItem::MozAltContent => dest.write_str("-moz-alt-content"),
|
|
||||||
ContentItem::Attr(ref ns, ref attr) => {
|
ContentItem::Attr(ref ns, ref attr) => {
|
||||||
dest.write_str("attr(")?;
|
dest.write_str("attr(")?;
|
||||||
if let Some(ref ns) = *ns {
|
if let Some(ref ns) = *ns {
|
||||||
|
@ -108,21 +105,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub enum T {
|
pub enum T {
|
||||||
normal,
|
Normal,
|
||||||
none,
|
None,
|
||||||
Content(Vec<ContentItem>),
|
#[cfg(feature = "gecko")]
|
||||||
|
MozAltContent,
|
||||||
|
Items(Vec<ContentItem>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for T {
|
impl ToCss for T {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
match *self {
|
match *self {
|
||||||
T::normal => dest.write_str("normal"),
|
T::Normal => dest.write_str("normal"),
|
||||||
T::none => dest.write_str("none"),
|
T::None => dest.write_str("none"),
|
||||||
T::Content(ref content) => {
|
% if product == "gecko":
|
||||||
|
T::MozAltContent => dest.write_str("-moz-alt-content"),
|
||||||
|
% endif
|
||||||
|
T::Items(ref content) => {
|
||||||
let mut iter = content.iter();
|
let mut iter = content.iter();
|
||||||
try!(iter.next().unwrap().to_css(dest));
|
try!(iter.next().unwrap().to_css(dest));
|
||||||
for c in iter {
|
for c in iter {
|
||||||
|
@ -137,7 +138,7 @@
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
computed_value::T::normal
|
computed_value::T::Normal
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
@ -162,11 +163,17 @@
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser)
|
pub fn parse(context: &ParserContext, input: &mut Parser)
|
||||||
-> Result<SpecifiedValue, ()> {
|
-> Result<SpecifiedValue, ()> {
|
||||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
|
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||||
return Ok(SpecifiedValue::normal)
|
return Ok(SpecifiedValue::Normal)
|
||||||
}
|
}
|
||||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||||
return Ok(SpecifiedValue::none)
|
return Ok(SpecifiedValue::None)
|
||||||
}
|
}
|
||||||
|
% if product == "gecko":
|
||||||
|
if input.try(|input| input.expect_ident_matching("-moz-alt-content")).is_ok() {
|
||||||
|
return Ok(SpecifiedValue::MozAltContent)
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
let mut content = vec![];
|
let mut content = vec![];
|
||||||
loop {
|
loop {
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
|
@ -233,10 +240,6 @@
|
||||||
"no-open-quote" => content.push(ContentItem::NoOpenQuote),
|
"no-open-quote" => content.push(ContentItem::NoOpenQuote),
|
||||||
"no-close-quote" => content.push(ContentItem::NoCloseQuote),
|
"no-close-quote" => content.push(ContentItem::NoCloseQuote),
|
||||||
|
|
||||||
% if product == "gecko":
|
|
||||||
"-moz-alt-content" => content.push(ContentItem::MozAltContent),
|
|
||||||
% endif
|
|
||||||
|
|
||||||
_ => return Err(())
|
_ => return Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,11 +247,10 @@
|
||||||
_ => return Err(())
|
_ => return Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !content.is_empty() {
|
if content.is_empty() {
|
||||||
Ok(SpecifiedValue::Content(content))
|
return Err(());
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
}
|
||||||
|
Ok(SpecifiedValue::Items(content))
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
|
|
@ -1820,9 +1820,8 @@ impl ComputedValues {
|
||||||
pub fn ineffective_content_property(&self) -> bool {
|
pub fn ineffective_content_property(&self) -> bool {
|
||||||
use properties::longhands::content::computed_value::T;
|
use properties::longhands::content::computed_value::T;
|
||||||
match self.get_counters().content {
|
match self.get_counters().content {
|
||||||
T::normal |
|
T::Normal | T::None => true,
|
||||||
T::none => true,
|
T::Items(ref items) => items.is_empty(),
|
||||||
T::Content(ref items) => items.is_empty(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue