Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfx: Implement most of `box-shadow` per CSS-BACKGROUNDS. #3940

Closed
wants to merge 6 commits into from

gfx: Address most of the review comments for `box-shadow`

  • Loading branch information
pcwalton committed Dec 8, 2014
commit 23560826ce77e543ccd82589ab08b957ed1427b6
@@ -46,7 +46,11 @@ pub struct PaintContext<'a> {
/// rect used by the last display item. We cache the last value so that we avoid pushing and
/// popping clip rects unnecessarily.
pub transient_clip_rect: Option<Rect<Au>>,
/// The scale factor.
/// The factor by which this tile is zoomed in. Typically pinch zooming is the reason why this
/// will have a value other than 1.0.
///
/// Unlike much of the rest of the graphics code, typed units aren't useful for this value
/// because it's only used in conjunction with the Azure API, which doesn't use typed units.
pub scale: AzFloat,
}

@@ -1241,7 +1241,7 @@ pub mod longhands {
}
</%self:single_component_value>

<%self:raw_longhand name="box-shadow">
<%self:longhand name="box-shadow">
use cssparser;
pub type SpecifiedValue = Vec<SpecifiedBoxShadow>;
@@ -1253,7 +1253,6 @@ pub mod longhands {
pub blur_radius: specified::Length,
pub spread_radius: specified::Length,
pub color: Option<specified::CSSColor>,
pub inset: bool,
}
pub mod computed_value {
@@ -1269,7 +1268,6 @@ pub mod longhands {
pub blur_radius: Au,
pub spread_radius: Au,
pub color: computed::CSSColor,
pub inset: bool,
}
}
@@ -1278,20 +1276,14 @@ pub mod longhands {
Vec::new()
}
pub fn parse_specified(input: &[ComponentValue], _: &Url)
-> Result<DeclaredValue<SpecifiedValue>,()> {
if input.len() == 1 {
match input[0] {
Ident(ref value) if value.as_slice().eq_ignore_ascii_case("none") => {
return Ok(SpecifiedValue(Vec::new()))
}
_ => {}
pub fn parse(input: &[ComponentValue], _: &Url) -> Result<SpecifiedValue,()> {
match one_component_value(input) {
Ok(&Ident(ref value)) if value.as_slice().eq_ignore_ascii_case("none") => {
return Ok(Vec::new())
}
_ => {}
}
match parse_slice_comma_separated(input, parse_one_box_shadow) {
Ok(result) => Ok(SpecifiedValue(result)),
Err(()) => Err(()),
}
parse_slice_comma_separated(input, parse_one_box_shadow)
}
pub fn to_computed_value(value: SpecifiedValue, context: &computed::Context)
@@ -1302,27 +1294,12 @@ pub mod longhands {
offset_y: computed::compute_Au(value.offset_y, context),
blur_radius: computed::compute_Au(value.blur_radius, context),
spread_radius: computed::compute_Au(value.spread_radius, context),
color: match value.color {
Some(color) => color,
None => cssparser::RGBAColor(context.color),
},
inset: value.inset,
color: value.color.unwrap_or(cssparser::CurrentColor),
}
}).collect()
}
fn parse_one_box_shadow(iter: ParserIter) -> Result<SpecifiedBoxShadow,()> {
let inset = match iter.next() {
Some(&Ident(ref value)) if value.as_slice().eq_ignore_ascii_case("inset") => {
true
}
Some(other) => {
iter.push_back(other);
false
}
None => return Err(()),
};
let mut lengths = [specified::Au_(Au(0)), ..4];
for (i, length) in lengths.iter_mut().enumerate() {
match iter.next() {
@@ -1368,11 +1345,9 @@ pub mod longhands {
blur_radius: lengths[2],
spread_radius: lengths[3],
color: color,
inset: inset,
})
}
</%self:raw_longhand>
>>>>>>> gfx: Implement most of `box-shadow` per CSS-BACKGROUNDS.
</%self:longhand>
}


@@ -9,7 +9,7 @@
left: 100px;
border-left: solid green 10px;
border-right: solid green 10px;
box-shadow: 10px 10px;
box-shadow: 20px 10px;
}
</style>
</head>
@@ -8,7 +8,7 @@
width: 120px;
height: 100px;
top: 110px;
left: 110px;
left: 120px;
background: black;
}
#b {
@@ -1,5 +1,5 @@
<head>
<!-- Tests that box-shadow blur does something. -->
<!-- Tests that the box-shadow color is correct if unspecified. -->
<style>
section {
position: absolute;
@@ -9,7 +9,7 @@
left: 100px;
border: solid black 1px;
color: blue;
box-shadow: 10px 10px;
box-shadow: 30px 10px;
}
</style>
</head>
@@ -1,5 +1,5 @@
<head>
<!-- Tests that box-shadow blur does something. -->
<!-- Tests that the box-shadow color is correct if unspecified. -->
<style>
section {
position: absolute;
@@ -8,7 +8,7 @@
top: 100px;
left: 100px;
border: solid black 1px;
box-shadow: 10px 10px blue;
box-shadow: 30px 10px blue;
}
</style>
</head>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.