aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/table_row.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-04-22 16:04:47 -0700
committerSimon Sapin <simon.sapin@exyr.org>2015-04-27 17:12:08 +0200
commit4d46d257cdb2ee42353c915934b338b5f2be4f65 (patch)
tree3d625c97677cd671122cca10b62297dc1ab4c9ff /components/layout/table_row.rs
parent48299a53cbe39d1a8a9bd4547a678d1d1cc345ae (diff)
downloadservo-4d46d257cdb2ee42353c915934b338b5f2be4f65.tar.gz
servo-4d46d257cdb2ee42353c915934b338b5f2be4f65.zip
Address review comments
Diffstat (limited to 'components/layout/table_row.rs')
-rw-r--r--components/layout/table_row.rs61
1 files changed, 28 insertions, 33 deletions
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index 36afbabcd0c..5b6e1909a26 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -30,7 +30,7 @@ use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentageOrAuto;
use util::geometry::Au;
-use util::logical_geometry::{LogicalRect, WritingMode};
+use util::logical_geometry::{LogicalRect, PhysicalSide, WritingMode};
/// A single row of a table.
pub struct TableRowFlow {
@@ -593,58 +593,53 @@ impl CollapsedBorder {
}
}
+ /// Creates a collapsed border style from the given physical side.
+ fn from_side(side: PhysicalSide,
+ css_style: &ComputedValues,
+ provenance: CollapsedBorderProvenance)
+ -> CollapsedBorder {
+ match side {
+ PhysicalSide::Top => CollapsedBorder::top(css_style, provenance),
+ PhysicalSide::Right => CollapsedBorder::right(css_style, provenance),
+ PhysicalSide::Bottom => CollapsedBorder::bottom(css_style, provenance),
+ PhysicalSide::Left => CollapsedBorder::left(css_style, provenance),
+ }
+ }
+
/// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object.
pub fn inline_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
- let writing_mode = css_style.writing_mode;
- match (writing_mode.is_vertical(),
- writing_mode.is_inline_tb(),
- writing_mode.is_bidi_ltr()) {
- (false, _, true) => CollapsedBorder::left(css_style, provenance),
- (false, _, false) => CollapsedBorder::right(css_style, provenance),
- (true, true, _) => CollapsedBorder::top(css_style, provenance),
- (true, false, _) => CollapsedBorder::bottom(css_style, provenance),
- }
+ CollapsedBorder::from_side(css_style.writing_mode.inline_start_physical_side(),
+ css_style,
+ provenance)
}
/// Creates a collapsed border style from the inline-start border described in the given CSS
/// style object.
pub fn inline_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
- let writing_mode = css_style.writing_mode;
- match (writing_mode.is_vertical(),
- writing_mode.is_inline_tb(),
- writing_mode.is_bidi_ltr()) {
- (false, _, true) => CollapsedBorder::right(css_style, provenance),
- (false, _, false) => CollapsedBorder::left(css_style, provenance),
- (true, true, _) => CollapsedBorder::bottom(css_style, provenance),
- (true, false, _) => CollapsedBorder::top(css_style, provenance),
- }
+ CollapsedBorder::from_side(css_style.writing_mode.inline_end_physical_side(),
+ css_style,
+ provenance)
}
/// Creates a collapsed border style from the block-start border described in the given CSS
/// style object.
pub fn block_start(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
- let writing_mode = css_style.writing_mode;
- match (writing_mode.is_vertical(), writing_mode.is_vertical_lr()) {
- (false, _) => CollapsedBorder::top(css_style, provenance),
- (true, true) => CollapsedBorder::left(css_style, provenance),
- (true, false) => CollapsedBorder::right(css_style, provenance),
- }
+ CollapsedBorder::from_side(css_style.writing_mode.block_start_physical_side(),
+ css_style,
+ provenance)
}
/// Creates a collapsed border style from the block-end border described in the given CSS style
/// object.
pub fn block_end(css_style: &ComputedValues, provenance: CollapsedBorderProvenance)
-> CollapsedBorder {
- let writing_mode = css_style.writing_mode;
- match (writing_mode.is_vertical(), writing_mode.is_vertical_lr()) {
- (false, _) => CollapsedBorder::bottom(css_style, provenance),
- (true, true) => CollapsedBorder::right(css_style, provenance),
- (true, false) => CollapsedBorder::left(css_style, provenance),
- }
+ CollapsedBorder::from_side(css_style.writing_mode.block_end_physical_side(),
+ css_style,
+ provenance)
}
/// If `other` has a higher priority per CSS 2.1 § 17.6.2.1, replaces `self` with it.
@@ -659,8 +654,8 @@ impl CollapsedBorder {
// Step 3.
_ if self.width > other.width => {}
_ if self.width < other.width => *self = *other,
- (this_style, other_style) if (this_style as i8) > other_style as i8 => {}
- (this_style, other_style) if (this_style as i8) < other_style as i8 => *self = *other,
+ (this_style, other_style) if this_style > other_style => {}
+ (this_style, other_style) if this_style < other_style => *self = *other,
// Step 4.
_ if (self.provenance as i8) >= other.provenance as i8 => {}
_ => *self = *other,