Introduce MaxRect trait

It is implemented for LayoutRect and Rect<Au>.
Replaces the max_rect() function from servo_geometry.
This commit is contained in:
Pyfisch 2018-01-17 23:17:39 +01:00
parent 8c7c5f6e79
commit af52233ae5
9 changed files with 56 additions and 28 deletions

View file

@ -44,7 +44,7 @@ use layout_debug;
use model::{AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
use sequential;
use serde::{Serialize, Serializer};
use servo_geometry::max_rect;
use servo_geometry::MaxRect;
use std::cmp::{max, min};
use std::fmt;
use std::sync::Arc;
@ -1955,7 +1955,7 @@ impl Flow for BlockFlow {
let container_size = Size2D::new(self.base.block_container_inline_size, Au(0));
if self.is_root() {
self.base.clip = max_rect();
self.base.clip = Rect::max_rect();
}
if self.base.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {

View file

@ -46,7 +46,7 @@ use net_traits::image::base::PixelFormat;
use net_traits::image_cache::UsePlaceholder;
use range::Range;
use servo_config::opts;
use servo_geometry::max_rect;
use servo_geometry::MaxRect;
use std::{cmp, f32};
use std::default::Default;
use std::mem;
@ -2381,7 +2381,7 @@ impl SavedStackingContextCollectionState {
.containing_block_clip_stack
.last()
.cloned()
.unwrap_or_else(max_rect);
.unwrap_or_else(MaxRect::max_rect);
state.clip_stack.push(clip);
self.clips_pushed += 1;
}
@ -2447,7 +2447,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let origin = &border_box.origin;
let transform_clip = |clip: &Rect<Au>| {
if *clip == max_rect() {
if *clip == Rect::max_rect() {
return *clip;
}
@ -2458,7 +2458,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
// clip region. Here we don't have enough information to detect when that is
// happening. For the moment we just punt on trying to optimize the display
// list for those cases.
max_rect()
Rect::max_rect()
},
Some(transform) => {
let clip = Rect::new(
@ -2573,7 +2573,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
state.containing_block_clipping_and_scrolling
},
StylePosition::Fixed => {
preserved_state.push_clip(state, &max_rect(), StylePosition::Fixed);
preserved_state.push_clip(state, &Rect::max_rect(), StylePosition::Fixed);
state.current_clipping_and_scrolling
},
_ => state.current_clipping_and_scrolling,
@ -2599,7 +2599,11 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
&stacking_relative_border_box,
);
}
self.base.clip = state.clip_stack.last().cloned().unwrap_or_else(max_rect);
self.base.clip = state
.clip_stack
.last()
.cloned()
.unwrap_or_else(Rect::max_rect);
// We keep track of our position so that any stickily positioned elements can
// properly determine the extent of their movement relative to scrolling containers.
@ -2969,7 +2973,11 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
fn collect_stacking_contexts_for_inline(&mut self, state: &mut StackingContextCollectionState) {
self.base.stacking_context_id = state.current_stacking_context_id;
self.base.clipping_and_scrolling = Some(state.current_clipping_and_scrolling);
self.base.clip = state.clip_stack.last().cloned().unwrap_or_else(max_rect);
self.base.clip = state
.clip_stack
.last()
.cloned()
.unwrap_or_else(Rect::max_rect);
for fragment in self.fragments.fragments.iter_mut() {
let previous_cb_clipping_and_scrolling = state.containing_block_clipping_and_scrolling;

View file

@ -43,7 +43,7 @@ use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use multicol::MulticolFlow;
use parallel::FlowParallelInfo;
use serde::ser::{Serialize, SerializeStruct, Serializer};
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, max_rect};
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
use std::fmt;
use std::iter::Zip;
use std::slice::IterMut;
@ -1062,7 +1062,7 @@ impl BaseFlow {
absolute_cb: ContainingBlockLink::new(),
early_absolute_position_info: EarlyAbsolutePositionInfo::new(writing_mode),
late_absolute_position_info: LateAbsolutePositionInfo::new(),
clip: max_rect(),
clip: MaxRect::max_rect(),
flags: flags,
writing_mode: writing_mode,
thread_id: 0,