mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Clean up BoxFragment display list builder in layout_2020
This makes things a big easier to read and will make it easier to add support for position:fixed.
This commit is contained in:
parent
c67b3d71e2
commit
20b8edc625
1 changed files with 52 additions and 43 deletions
|
@ -244,20 +244,27 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
}
|
||||
|
||||
fn build(&mut self, builder: &mut DisplayListBuilder) {
|
||||
let hit_info = hit_info(&self.fragment.style, self.fragment.tag, Cursor::Default);
|
||||
if hit_info.is_some() {
|
||||
let mut common = builder.common_properties(self.border_rect);
|
||||
common.hit_info = hit_info;
|
||||
if let Some(clip_id) = self.border_edge_clip(builder) {
|
||||
common.clip_id = clip_id
|
||||
}
|
||||
builder.wr.push_hit_test(&common)
|
||||
}
|
||||
|
||||
builder.clipping_and_scrolling_scope(|builder| {
|
||||
self.build_hit_test(builder);
|
||||
self.build_background(builder);
|
||||
self.build_border(builder);
|
||||
|
||||
builder.clipping_and_scrolling_scope(|builder| {
|
||||
// We want to build the scroll frame after the background and border, because
|
||||
// they shouldn't scroll with the rest of the box content.
|
||||
self.build_scroll_frame_if_necessary(builder);
|
||||
|
||||
let content_rect = self
|
||||
.fragment
|
||||
.content_rect
|
||||
.to_physical(self.fragment.style.writing_mode, self.containing_block)
|
||||
.translate(self.containing_block.origin.to_vector());
|
||||
for child in &self.fragment.children {
|
||||
child.build_display_list(builder, &content_rect)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn build_scroll_frame_if_necessary(&self, builder: &mut DisplayListBuilder) {
|
||||
let overflow_x = self.fragment.style.get_box().overflow_x;
|
||||
let overflow_y = self.fragment.style.get_box().overflow_y;
|
||||
let original_scroll_and_clip_info = builder.current_space_and_clip;
|
||||
|
@ -289,16 +296,18 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
wr::units::LayoutVector2D::zero(),
|
||||
);
|
||||
}
|
||||
|
||||
let content_rect = self
|
||||
.fragment
|
||||
.content_rect
|
||||
.to_physical(self.fragment.style.writing_mode, self.containing_block)
|
||||
.translate(self.containing_block.origin.to_vector());
|
||||
for child in &self.fragment.children {
|
||||
child.build_display_list(builder, &content_rect)
|
||||
}
|
||||
});
|
||||
|
||||
fn build_hit_test(&self, builder: &mut DisplayListBuilder) {
|
||||
let hit_info = hit_info(&self.fragment.style, self.fragment.tag, Cursor::Default);
|
||||
if hit_info.is_some() {
|
||||
let mut common = builder.common_properties(self.border_rect);
|
||||
common.hit_info = hit_info;
|
||||
if let Some(clip_id) = self.border_edge_clip(builder) {
|
||||
common.clip_id = clip_id
|
||||
}
|
||||
builder.wr.push_hit_test(&common)
|
||||
}
|
||||
}
|
||||
|
||||
fn build_background(&mut self, builder: &mut DisplayListBuilder) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue