diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-08-03 09:24:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-03 09:24:31 -0500 |
commit | 15947f8f73bc8145916e1213f559eede815d8529 (patch) | |
tree | 57924c858576655760621ac9e0d9e4e2a8cad445 /components/layout/fragment.rs | |
parent | e2d4ff5b62aff7fc6f40460270af44e1ab5283d4 (diff) | |
parent | 60e2f44a1950559398fa25aa9aa36cd2a7fa39ad (diff) | |
download | servo-15947f8f73bc8145916e1213f559eede815d8529.tar.gz servo-15947f8f73bc8145916e1213f559eede815d8529.zip |
Auto merge of #12330 - stshine:flexitem, r=pcwalton
Implement flexible box layout for row container
<!-- Please describe your changes on the following line: -->
This pull requests implements basic flexible box layout for row container.
It has implemented most basic flexbox features, including grow, shrink, multi-line, *reverse properties, and alignment under `justify-content`, `align-items`, `align-self`, `align-content`.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
r? @pcwalton
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12330)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r-- | components/layout/fragment.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 0fb5c6579c1..0ddb083c1c0 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -23,7 +23,7 @@ use inline::{InlineMetrics, LAST_FRAGMENT_OF_ELEMENT}; use ipc_channel::ipc::IpcSender; #[cfg(debug_assertions)] use layout_debug; -use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, specified}; +use model::{self, Direction, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, specified}; use msg::constellation_msg::PipelineId; use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder}; @@ -39,7 +39,7 @@ use std::fmt; use std::sync::{Arc, Mutex}; use style::arc_ptr_eq; use style::computed_values::content::ContentItem; -use style::computed_values::{border_collapse, clear, color, display, mix_blend_mode}; +use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode}; use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration}; use style::computed_values::{transform_style, vertical_align, white_space, word_break, z_index}; use style::dom::TRestyleDamage; @@ -1109,6 +1109,20 @@ impl Fragment { } } + /// Returns the border width in given direction if this fragment has property + /// 'box-sizing: border-box'. The `border_padding` field should have been initialized. + pub fn box_sizing_boundary(&self, direction: Direction) -> Au { + match (self.style().get_position().box_sizing, direction) { + (box_sizing::T::border_box, Direction::Inline) => { + self.border_padding.inline_start_end() + } + (box_sizing::T::border_box, Direction::Block) => { + self.border_padding.block_start_end() + } + _ => Au(0) + } + } + /// Computes the margins in the inline direction from the containing block inline-size and the /// style. After this call, the inline direction of the `margin` field will be correct. /// |