mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Use Au
in ResolvedMargins
and CollapsedMargin
(#31848)
* change ResolvedMargins to use Au instead of length * made suggested changes removed whitespace changes made suggested changes * Update components/layout_2020/flexbox/layout.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * fixed errors fixed errors fixed formatting fixed errors * modified changes made suggested changes * Update components/layout_2020/fragment_tree/fragment.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> updated components/layout_2020/fragment_tree/fragment.rs * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * updated changes updated changes * unified all the suggested changes here * fixed formatting * reverted unnecessary changes * fixed unnecessary warnings --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
66ad795014
commit
5d518ca8dc
4 changed files with 62 additions and 70 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use app_units::Au;
|
||||
use gfx::font::FontMetrics;
|
||||
use gfx::text::glyph::GlyphStore;
|
||||
use gfx_traits::print_tree::PrintTree;
|
||||
|
@ -61,8 +62,8 @@ pub(crate) struct CollapsedBlockMargins {
|
|||
|
||||
#[derive(Clone, Copy, Debug, Serialize)]
|
||||
pub(crate) struct CollapsedMargin {
|
||||
max_positive: Length,
|
||||
min_negative: Length,
|
||||
max_positive: Au,
|
||||
min_negative: Au,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -259,7 +260,7 @@ impl IFrameFragment {
|
|||
}
|
||||
|
||||
impl CollapsedBlockMargins {
|
||||
pub fn from_margin(margin: &LogicalSides<Length>) -> Self {
|
||||
pub fn from_margin(margin: &LogicalSides<Au>) -> Self {
|
||||
Self {
|
||||
collapsed_through: false,
|
||||
start: CollapsedMargin::new(margin.block_start),
|
||||
|
@ -279,15 +280,15 @@ impl CollapsedBlockMargins {
|
|||
impl CollapsedMargin {
|
||||
pub fn zero() -> Self {
|
||||
Self {
|
||||
max_positive: Length::zero(),
|
||||
min_negative: Length::zero(),
|
||||
max_positive: Au::zero(),
|
||||
min_negative: Au::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(margin: Length) -> Self {
|
||||
pub fn new(margin: Au) -> Self {
|
||||
Self {
|
||||
max_positive: margin.max(Length::zero()),
|
||||
min_negative: margin.min(Length::zero()),
|
||||
max_positive: margin.max(Au::zero()),
|
||||
min_negative: margin.min(Au::zero()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,7 +303,7 @@ impl CollapsedMargin {
|
|||
*self = self.adjoin(other);
|
||||
}
|
||||
|
||||
pub fn solve(&self) -> Length {
|
||||
pub fn solve(&self) -> Au {
|
||||
self.max_positive + self.min_negative
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue