mirror of
https://github.com/servo/servo.git
synced 2025-06-23 00:24:35 +01:00
layout: If the border style is "none", treat its width as 0.
Closes #1383.
This commit is contained in:
parent
acb3d9f533
commit
511d2b11d4
6 changed files with 97 additions and 23 deletions
|
@ -763,17 +763,17 @@ impl Flow for BlockFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_str(&self) -> ~str {
|
fn debug_str(&self) -> ~str {
|
||||||
if self.is_root {
|
let txt = if self.is_float() {
|
||||||
~"BlockFlow(root)"
|
~"FloatFlow: "
|
||||||
|
} else if self.is_root {
|
||||||
|
~"RootFlow: "
|
||||||
} else {
|
} else {
|
||||||
let txt = if self.is_float() { ~"FloatFlow: " } else { ~"BlockFlow: " };
|
~"BlockFlow: "
|
||||||
|
};
|
||||||
txt.append(match self.box {
|
txt.append(match self.box {
|
||||||
Some(ref rb) => {
|
Some(ref rb) => rb.debug_str(),
|
||||||
rb.debug_str()
|
None => ~"",
|
||||||
}
|
|
||||||
None => { ~"" }
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -281,10 +281,23 @@ impl Box {
|
||||||
///
|
///
|
||||||
/// FIXME(pcwalton): This should not be necessary. Just go to the style.
|
/// FIXME(pcwalton): This should not be necessary. Just go to the style.
|
||||||
pub fn compute_borders(&self, style: &ComputedValues) {
|
pub fn compute_borders(&self, style: &ComputedValues) {
|
||||||
self.border.set(SideOffsets2D::new(style.Border.border_top_width,
|
#[inline]
|
||||||
style.Border.border_right_width,
|
fn width(width: Au, style: border_style::T) -> Au {
|
||||||
style.Border.border_bottom_width,
|
if style == border_style::none {
|
||||||
style.Border.border_left_width))
|
Au(0)
|
||||||
|
} else {
|
||||||
|
width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.border.set(SideOffsets2D::new(width(style.Border.border_top_width,
|
||||||
|
style.Border.border_top_style),
|
||||||
|
width(style.Border.border_right_width,
|
||||||
|
style.Border.border_right_style),
|
||||||
|
width(style.Border.border_bottom_width,
|
||||||
|
style.Border.border_bottom_style),
|
||||||
|
width(style.Border.border_left_width,
|
||||||
|
style.Border.border_left_style)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Populates the box model padding parameters from the given computed style.
|
/// Populates the box model padding parameters from the given computed style.
|
||||||
|
@ -983,12 +996,33 @@ impl Box {
|
||||||
|
|
||||||
/// Returns a debugging string describing this box.
|
/// Returns a debugging string describing this box.
|
||||||
pub fn debug_str(&self) -> ~str {
|
pub fn debug_str(&self) -> ~str {
|
||||||
match self.specific {
|
let class_name = match self.specific {
|
||||||
GenericBox => "(GenericBox)",
|
GenericBox => "GenericBox",
|
||||||
ImageBox(_) => "(ImageBox)",
|
ImageBox(_) => "ImageBox",
|
||||||
ScannedTextBox(_) => "(ScannedTextBox)",
|
ScannedTextBox(_) => "ScannedTextBox",
|
||||||
UnscannedTextBox(_) => "(UnscannedTextBox)",
|
UnscannedTextBox(_) => "UnscannedTextBox",
|
||||||
}.to_str()
|
};
|
||||||
|
|
||||||
|
format!("({}{}{}{})",
|
||||||
|
class_name,
|
||||||
|
self.side_offsets_debug_string("b", self.border.get()),
|
||||||
|
self.side_offsets_debug_string("p", self.padding.get()),
|
||||||
|
self.side_offsets_debug_string("m", self.margin.get()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A helper function to return a debug string describing the side offsets for one of the rect
|
||||||
|
/// box model properties (border, padding, or margin).
|
||||||
|
fn side_offsets_debug_string(&self, name: &str, value: SideOffsets2D<Au>) -> ~str {
|
||||||
|
let zero: SideOffsets2D<Au> = Zero::zero();
|
||||||
|
if value == zero {
|
||||||
|
return "".to_str()
|
||||||
|
}
|
||||||
|
format!(" {}{},{},{},{}",
|
||||||
|
name,
|
||||||
|
*value.top,
|
||||||
|
*value.right,
|
||||||
|
*value.bottom,
|
||||||
|
*value.left)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -448,15 +448,15 @@ impl LayoutTask {
|
||||||
});
|
});
|
||||||
layout_root.traverse_postorder(&mut ComputeDamageTraversal.clone());
|
layout_root.traverse_postorder(&mut ComputeDamageTraversal.clone());
|
||||||
|
|
||||||
debug!("layout: constructed Flow tree");
|
|
||||||
debug!("{:?}", layout_root.dump());
|
|
||||||
|
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
do profile(time::LayoutMainCategory, self.profiler_chan.clone()) {
|
do profile(time::LayoutMainCategory, self.profiler_chan.clone()) {
|
||||||
self.solve_constraints(layout_root, &mut layout_ctx)
|
self.solve_constraints(layout_root, &mut layout_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("layout: constraint solving done:");
|
||||||
|
debug!("{:?}", layout_root.dump());
|
||||||
|
|
||||||
// Build the display list if necessary, and send it to the renderer.
|
// Build the display list if necessary, and send it to the renderer.
|
||||||
if data.goal == ReflowForDisplay {
|
if data.goal == ReflowForDisplay {
|
||||||
do profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone()) {
|
do profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone()) {
|
||||||
|
|
|
@ -15,3 +15,4 @@
|
||||||
== visibility_hidden.html visibility_hidden_ref.html
|
== visibility_hidden.html visibility_hidden_ref.html
|
||||||
== root_height_a.html root_height_b.html
|
== root_height_a.html root_height_b.html
|
||||||
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
|
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
|
||||||
|
== border_style_none_a.html border_style_none_b.html
|
||||||
|
|
20
src/test/ref/border_style_none_a.html
Normal file
20
src/test/ref/border_style_none_a.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: blue;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border-top-width: 3px;
|
||||||
|
border-top-style: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body><img src="png_rgba_colorspace_a.png"></body>
|
||||||
|
</html>
|
||||||
|
|
19
src/test/ref/border_style_none_b.html
Normal file
19
src/test/ref/border_style_none_b.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: blue;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border-top-width: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body><img src="png_rgba_colorspace_a.png"></body>
|
||||||
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue