mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Support multiple backgrounds in servo layout
This commit is contained in:
parent
66cdf9ae4f
commit
69ada0d7a3
5 changed files with 125 additions and 95 deletions
|
@ -69,10 +69,10 @@
|
|||
${caller.body()}
|
||||
}
|
||||
pub mod computed_value {
|
||||
use super::single_value;
|
||||
pub use super::single_value::computed_value as single_value;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T(pub Vec<single_value::computed_value::T>);
|
||||
pub struct T(pub Vec<single_value::T>);
|
||||
}
|
||||
|
||||
impl ToCss for computed_value::T {
|
||||
|
|
|
@ -10,7 +10,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
"::cssparser::Color::RGBA(::cssparser::RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */",
|
||||
animatable=True)}
|
||||
|
||||
<%helpers:vector_longhand gecko_only="True" name="background-image" animatable="False">
|
||||
<%helpers:vector_longhand name="background-image" animatable="False">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::specified::Image;
|
||||
|
@ -79,7 +79,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
}
|
||||
</%helpers:vector_longhand>
|
||||
|
||||
<%helpers:vector_longhand name="background-position" gecko_only="True" animatable="True">
|
||||
<%helpers:vector_longhand name="background-position" animatable="True">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
|
@ -121,25 +121,21 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
${helpers.single_keyword("background-repeat",
|
||||
"repeat repeat-x repeat-y no-repeat",
|
||||
vector=True,
|
||||
gecko_only=True,
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("background-attachment",
|
||||
"scroll fixed" + (" local" if product == "gecko" else ""),
|
||||
vector=True,
|
||||
gecko_only=True,
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("background-clip",
|
||||
"border-box padding-box content-box",
|
||||
vector=True,
|
||||
gecko_only=True,
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("background-origin",
|
||||
"padding-box border-box content-box",
|
||||
vector=True,
|
||||
gecko_only=True,
|
||||
animatable=False)}
|
||||
|
||||
<%helpers:vector_longhand name="background-size" animatable="True">
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
% endfor
|
||||
|
||||
loop {
|
||||
if background_color.is_none() {
|
||||
if let Ok(value) = input.try(|input| background_color::parse(context, input)) {
|
||||
if let Ok(value) = input.try(|input| background_color::parse(context, input)) {
|
||||
if background_color.is_none() {
|
||||
background_color = Some(value);
|
||||
continue
|
||||
} else {
|
||||
// color can only be the last element
|
||||
return Err(())
|
||||
}
|
||||
} else {
|
||||
// color can only be the last element
|
||||
return Err(())
|
||||
}
|
||||
if position.is_none() {
|
||||
if let Ok(value) = input.try(|input| background_position::single_value::parse(context, input)) {
|
||||
|
@ -118,6 +118,11 @@
|
|||
.unwrap_or(0));
|
||||
% endfor
|
||||
|
||||
// There should be at least one declared value
|
||||
if len == 0 {
|
||||
return Err(())
|
||||
}
|
||||
|
||||
let iter = repeat(None).take(len - 1).chain(once(Some(self.background_color)))
|
||||
% for name in "image position repeat size attachment origin clip".split():
|
||||
.zip(extract_value(self.background_${name}).into_iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue