зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #14136 - style: Add a "start_end()" method to LogicalMargin (from stshine:orthogonal-symmetry); r=SimonSapin
<!-- 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 Source-Repo: https://github.com/servo/servo Source-Revision: d16f3124640be647b4ed67cc4a68cebd55cdb7cc
This commit is contained in:
Родитель
c1e5c03fc6
Коммит
96276fe1da
|
@ -34,7 +34,6 @@ use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow};
|
|||
use inline::{InlineFragmentNodeInfo, LAST_FRAGMENT_OF_ELEMENT};
|
||||
use linked_list::prepend_from;
|
||||
use list_item::{ListItemFlow, ListStyleTypeContent};
|
||||
use model::Direction;
|
||||
use multicol::{MulticolColumnFlow, MulticolFlow};
|
||||
use parallel;
|
||||
use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
|
||||
|
@ -49,6 +48,7 @@ use style::computed_values::{caption_side, display, empty_cells, float, list_sty
|
|||
use style::computed_values::content::ContentItem;
|
||||
use style::computed_values::position;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::logical_geometry::Direction;
|
||||
use style::properties::{self, ServoComputedValues};
|
||||
use style::selector_impl::{PseudoElement, RestyleDamage};
|
||||
use style::selector_matching::Stylist;
|
||||
|
|
|
@ -19,7 +19,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
|||
use gfx::display_list::StackingContext;
|
||||
use gfx_traits::ScrollRootId;
|
||||
use layout_debug;
|
||||
use model::{Direction, IntrinsicISizes, MaybeAuto, MinMaxConstraint};
|
||||
use model::{IntrinsicISizes, MaybeAuto, MinMaxConstraint};
|
||||
use model::{specified, specified_or_none};
|
||||
use std::cmp::{max, min};
|
||||
use std::ops::Range;
|
||||
|
@ -27,7 +27,7 @@ use std::sync::Arc;
|
|||
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
|
||||
use style::computed_values::border_collapse;
|
||||
use style::context::{SharedStyleContext, StyleContext};
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::logical_geometry::{Direction, LogicalSize};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
|
|
|
@ -23,7 +23,7 @@ use inline::{InlineMetrics, LAST_FRAGMENT_OF_ELEMENT, LineMetrics};
|
|||
use ipc_channel::ipc::IpcSender;
|
||||
#[cfg(debug_assertions)]
|
||||
use layout_debug;
|
||||
use model::{self, Direction, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
|
||||
use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::{Image, ImageMetadata};
|
||||
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||
|
@ -44,7 +44,7 @@ use style::computed_values::{transform_style, vertical_align, white_space, word_
|
|||
use style::computed_values::content::ContentItem;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::dom::TRestyleDamage;
|
||||
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::selector_impl::RestyleDamage;
|
||||
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
|
||||
|
|
|
@ -504,13 +504,6 @@ impl ToGfxMatrix for ComputedMatrix {
|
|||
}
|
||||
}
|
||||
|
||||
// Used to specify the logical direction.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Direction {
|
||||
Inline,
|
||||
Block
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css2/visudet.html#min-max-widths
|
||||
// https://drafts.csswg.org/css2/visudet.html#min-max-heights
|
||||
/// A min or max constraint
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче