diff options
author | David Zbarsky <dzbarsky@gmail.com> | 2015-08-20 12:31:19 -0400 |
---|---|---|
committer | David Zbarsky <dzbarsky@gmail.com> | 2015-11-01 23:16:14 -0800 |
commit | 00980ea595dd54643eee59c1a0e2ddef39286e7f (patch) | |
tree | 75e43edd9ead2fc0e9c484ae57c9bef8bccf2fca /components/layout | |
parent | 35b452660bf0759d222e8f2ac4b8c57f75529443 (diff) | |
download | servo-00980ea595dd54643eee59c1a0e2ddef39286e7f.tar.gz servo-00980ea595dd54643eee59c1a0e2ddef39286e7f.zip |
Implement calc expressions for more value types
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 4 | ||||
-rw-r--r-- | components/layout/inline.rs | 7 | ||||
-rw-r--r-- | components/layout/model.rs | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index adb48e3248f..399b3e5a9f4 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -340,6 +340,10 @@ impl CandidateBSizeIterator { (LengthOrPercentageOrNone::Percentage(percent), Some(block_container_block_size)) => { Some(block_container_block_size.scale_by(percent)) } + (LengthOrPercentageOrNone::Calc(calc), Some(block_container_block_size)) => { + Some(block_container_block_size.scale_by(calc.percentage()) + calc.length()) + } + (LengthOrPercentageOrNone::Calc(_), _) | (LengthOrPercentageOrNone::Percentage(_), None) | (LengthOrPercentageOrNone::None, _) => None, (LengthOrPercentageOrNone::Length(length), _) => Some(length), diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 5bd622871e1..8711881ffaf 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -27,6 +27,7 @@ use std::{fmt, isize, mem}; use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::{text_overflow, vertical_align, white_space}; use style::properties::ComputedValues; +use style::values::computed::LengthOrPercentage; use text; use unicode_bidi; use util; @@ -953,15 +954,15 @@ impl InlineFlow { offset_from_baseline = offset_from_baseline - *depth_below_baseline } }, - vertical_align::T::Length(length) => { + vertical_align::T::LengthOrPercentage(LengthOrPercentage::Length(length)) => { offset_from_baseline = offset_from_baseline - length } - vertical_align::T::Percentage(p) => { + vertical_align::T::LengthOrPercentage(LengthOrPercentage::Percentage(p)) => { let line_height = fragment.calculate_line_height(layout_context); let percent_offset = line_height.scale_by(p); offset_from_baseline = offset_from_baseline - percent_offset } - vertical_align::T::Calc(calc) => { + vertical_align::T::LengthOrPercentage(LengthOrPercentage::Calc(calc)) => { let line_height = fragment.calculate_line_height(layout_context); let percent_offset = line_height.scale_by(calc.percentage()); offset_from_baseline = offset_from_baseline - percent_offset - calc.length() diff --git a/components/layout/model.rs b/components/layout/model.rs index 8ee98a39678..f49ac51ad21 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -411,6 +411,8 @@ pub fn specified_or_none(length: LengthOrPercentageOrNone, containing_length: Au match length { LengthOrPercentageOrNone::None => None, LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent)), + LengthOrPercentageOrNone::Calc(calc) => + Some(containing_length.scale_by(calc.percentage()) + calc.length()), LengthOrPercentageOrNone::Length(length) => Some(length), } } |