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

Implement support for (most of) border-image. #895

Merged
merged 3 commits into from Feb 22, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update wrench and sample to run with new interface changes.

  • Loading branch information
gw3583 committed Feb 20, 2017
commit 1ad927acabe547cfa0e9f9420d02c1d19d05984e
@@ -146,17 +146,26 @@ fn main() {
sub_clip,
ColorF::new(0.0, 1.0, 0.0, 1.0));
let border_side = webrender_traits::BorderSide {
width: 10.0,
color: ColorF::new(0.0, 0.0, 1.0, 1.0),
style: webrender_traits::BorderStyle::Groove,
};
let border_widths = webrender_traits::BorderWidths {
top: 10.0,
left: 10.0,
bottom: 10.0,
right: 10.0,
};
let border_details = webrender_traits::BorderDetails::Normal(webrender_traits::NormalBorder {
top: border_side,
right: border_side,
bottom: border_side,
left: border_side,
radius: webrender_traits::BorderRadius::uniform(20.0),
});
builder.push_border(LayoutRect::new(LayoutPoint::new(100.0, 100.0), LayoutSize::new(100.0, 100.0)),
sub_clip,
border_side,
border_side,
border_side,
border_side,
webrender_traits::BorderRadius::uniform(20.0));
border_widths,
border_details);


if false { // draw text?
@@ -270,13 +270,23 @@ impl YamlFrameReader {
let colors = broadcast(&colors, 4);
let styles = broadcast(&styles, 4);

let top = BorderSide { width: widths[0], color: colors[0], style: styles[0] };
let left = BorderSide { width: widths[1], color: colors[1], style: styles[1] };
let bottom = BorderSide { width: widths[2], color: colors[2], style: styles[2] };
let right = BorderSide { width: widths[3], color: colors[3], style: styles[3] };

let widths = BorderWidths { top: widths[0], left: widths[1], bottom: widths[2], right: widths[3] };
let top = BorderSide { color: colors[0], style: styles[0] };
let left = BorderSide { color: colors[1], style: styles[1] };
let bottom = BorderSide { color: colors[2], style: styles[2] };
let right = BorderSide { color: colors[3], style: styles[3] };
let details = BorderDetails::Normal(NormalBorder {
top: top,
left: left,
bottom: bottom,
right: right,
radius: radius,
});
let clip = self.to_clip_region(&item["clip"], &bounds, wrench).unwrap_or(*clip_region);
self.builder().push_border(bounds, clip, left, top, right, bottom, radius);
self.builder().push_border(bounds,
clip,
widths,
details);
}

fn handle_box_shadow(&mut self, wrench: &mut Wrench, clip_region: &ClipRegion, item: &Yaml) {
@@ -559,28 +559,35 @@ impl YamlFrameWriter {
},
Border(item) => {
str_node(&mut v, "type", "border");
let trbl = vec![&item.top, &item.right, &item.bottom, &item.left];
let widths: Vec<f32> = trbl.iter().map(|x| x.width).collect();
let colors: Vec<String> = trbl.iter().map(|x| color_to_string(x.color)).collect();
let styles: Vec<String> = trbl.iter().map(|x| {
match x.style {
BorderStyle::None => "none",
BorderStyle::Solid => "solid",
BorderStyle::Double => "double",
BorderStyle::Dotted => "dotted",
BorderStyle::Dashed => "dashed",
BorderStyle::Hidden => "hidden",
BorderStyle::Ridge => "ridge",
BorderStyle::Inset => "inset",
BorderStyle::Outset => "outset",
BorderStyle::Groove => "groove",
}.to_owned()
}).collect();
yaml_node(&mut v, "width", f32_vec_yaml(&widths, true));
yaml_node(&mut v, "color", string_vec_yaml(&colors, true));
yaml_node(&mut v, "style", string_vec_yaml(&styles, true));
if let Some(radius_node) = maybe_radius_yaml(&item.radius) {
yaml_node(&mut v, "radius", radius_node);
match item.details {
BorderDetails::Normal(ref details) => {
let trbl = vec![&details.top, &details.right, &details.bottom, &details.left];
let widths: Vec<f32> = vec![item.widths.top, item.widths.right, item.widths.bottom, item.widths.left];
let colors: Vec<String> = trbl.iter().map(|x| color_to_string(x.color)).collect();
let styles: Vec<String> = trbl.iter().map(|x| {
match x.style {
BorderStyle::None => "none",
BorderStyle::Solid => "solid",
BorderStyle::Double => "double",
BorderStyle::Dotted => "dotted",
BorderStyle::Dashed => "dashed",
BorderStyle::Hidden => "hidden",
BorderStyle::Ridge => "ridge",
BorderStyle::Inset => "inset",
BorderStyle::Outset => "outset",
BorderStyle::Groove => "groove",
}.to_owned()
}).collect();
yaml_node(&mut v, "width", f32_vec_yaml(&widths, true));
yaml_node(&mut v, "color", string_vec_yaml(&colors, true));
yaml_node(&mut v, "style", string_vec_yaml(&styles, true));
if let Some(radius_node) = maybe_radius_yaml(&details.radius) {
yaml_node(&mut v, "radius", radius_node);
}
}
BorderDetails::Image(..) => {
println!("TODO: image border");
}
}
},
BoxShadow(item) => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.