mirror of
https://github.com/servo/servo.git
synced 2025-06-28 11:03:39 +01:00
Auto merge of #14136 - stshine:orthogonal-symmetry, r=SimonSapin
style: Add a "start_end()" method to LogicalMargin <!-- Please describe your changes on the following line: --> Add a `LogicalMargin::start_end()` method that receives a `Direction' parameter. This is useful for some layout that is symmetric in inline and block directions, like flexbox. Part of #14123. --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @SimonSapin <!-- 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/14136) <!-- Reviewable:end -->
This commit is contained in:
commit
d16f312464
5 changed files with 22 additions and 12 deletions
|
@ -213,6 +213,13 @@ impl Debug for DebugWritingMode {
|
|||
}
|
||||
|
||||
|
||||
// Used to specify the logical direction.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Direction {
|
||||
Inline,
|
||||
Block
|
||||
}
|
||||
|
||||
/// A 2D size in flow-relative dimensions
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(Serialize))]
|
||||
|
@ -763,6 +770,16 @@ impl<T: Copy + Add<T, Output=T>> LogicalMargin<T> {
|
|||
self.block_start + self.block_end
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn start_end(&self, direction: Direction) -> T {
|
||||
match direction {
|
||||
Direction::Inline =>
|
||||
self.inline_start + self.inline_end,
|
||||
Direction::Block =>
|
||||
self.block_start + self.block_end
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn top_bottom(&self, mode: WritingMode) -> T {
|
||||
self.debug_writing_mode.check(mode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue