mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Move box fragment hit testing to a dedicated display item
This commit is contained in:
parent
53fc6143dc
commit
c495b5adb2
1 changed files with 17 additions and 12 deletions
|
@ -38,7 +38,11 @@ impl DisplayListBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn common_properties(
|
fn common_properties(&self, clip_rect: units::LayoutRect) -> wr::CommonItemProperties {
|
||||||
|
self.common_properties_with_hit_info(clip_rect, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn common_properties_with_hit_info(
|
||||||
&self,
|
&self,
|
||||||
clip_rect: units::LayoutRect,
|
clip_rect: units::LayoutRect,
|
||||||
hit_info: HitInfo,
|
hit_info: HitInfo,
|
||||||
|
@ -91,7 +95,7 @@ impl Fragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let hit_info = hit_info(&t.parent_style, t.tag, Cursor::Text);
|
let hit_info = hit_info(&t.parent_style, t.tag, Cursor::Text);
|
||||||
let common = builder.common_properties(rect.clone().into(), hit_info);
|
let common = builder.common_properties_with_hit_info(rect.clone().into(), hit_info);
|
||||||
let color = t.parent_style.clone_color();
|
let color = t.parent_style.clone_color();
|
||||||
builder
|
builder
|
||||||
.wr
|
.wr
|
||||||
|
@ -104,8 +108,7 @@ impl Fragment {
|
||||||
.rect
|
.rect
|
||||||
.to_physical(i.style.writing_mode, containing_block)
|
.to_physical(i.style.writing_mode, containing_block)
|
||||||
.translate(&containing_block.top_left);
|
.translate(&containing_block.top_left);
|
||||||
let hit_info = None;
|
let common = builder.common_properties(rect.clone().into());
|
||||||
let common = builder.common_properties(rect.clone().into(), hit_info);
|
|
||||||
builder.wr.push_image(
|
builder.wr.push_image(
|
||||||
&common,
|
&common,
|
||||||
rect.into(),
|
rect.into(),
|
||||||
|
@ -134,11 +137,15 @@ impl BoxFragment {
|
||||||
.to_physical(self.style.writing_mode, containing_block)
|
.to_physical(self.style.writing_mode, containing_block)
|
||||||
.translate(&containing_block.top_left)
|
.translate(&containing_block.top_left)
|
||||||
.into();
|
.into();
|
||||||
let hit_info = hit_info(&self.style, self.tag, Cursor::Default);
|
|
||||||
let border_radius = self.border_radius(&border_rect);
|
let border_radius = self.border_radius(&border_rect);
|
||||||
|
let hit_info = hit_info(&self.style, self.tag, Cursor::Default);
|
||||||
|
if hit_info.is_some() {
|
||||||
|
let common = builder.common_properties_with_hit_info(border_rect, hit_info);
|
||||||
|
builder.wr.push_hit_test(&common)
|
||||||
|
}
|
||||||
|
|
||||||
self.background_display_items(builder, hit_info, border_rect, &border_radius);
|
self.background_display_items(builder, border_rect, &border_radius);
|
||||||
self.border_display_items(builder, hit_info, border_rect, border_radius);
|
self.border_display_items(builder, border_rect, border_radius);
|
||||||
let content_rect = self
|
let content_rect = self
|
||||||
.content_rect
|
.content_rect
|
||||||
.to_physical(self.style.writing_mode, containing_block)
|
.to_physical(self.style.writing_mode, containing_block)
|
||||||
|
@ -170,14 +177,13 @@ impl BoxFragment {
|
||||||
fn background_display_items(
|
fn background_display_items(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut DisplayListBuilder,
|
builder: &mut DisplayListBuilder,
|
||||||
hit_info: HitInfo,
|
|
||||||
border_rect: units::LayoutRect,
|
border_rect: units::LayoutRect,
|
||||||
border_radius: &wr::BorderRadius,
|
border_radius: &wr::BorderRadius,
|
||||||
) {
|
) {
|
||||||
let background_color = self
|
let background_color = self
|
||||||
.style
|
.style
|
||||||
.resolve_color(self.style.clone_background_color());
|
.resolve_color(self.style.clone_background_color());
|
||||||
if background_color.alpha > 0 || hit_info.is_some() {
|
if background_color.alpha > 0 {
|
||||||
builder.clipping_and_scrolling_scope(|builder| {
|
builder.clipping_and_scrolling_scope(|builder| {
|
||||||
if !border_radius.is_zero() {
|
if !border_radius.is_zero() {
|
||||||
builder.current_space_and_clip.clip_id = builder.wr.define_clip(
|
builder.current_space_and_clip.clip_id = builder.wr.define_clip(
|
||||||
|
@ -191,7 +197,7 @@ impl BoxFragment {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let common = builder.common_properties(border_rect, hit_info);
|
let common = builder.common_properties(border_rect);
|
||||||
builder.wr.push_rect(&common, rgba(background_color))
|
builder.wr.push_rect(&common, rgba(background_color))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -200,7 +206,6 @@ impl BoxFragment {
|
||||||
fn border_display_items(
|
fn border_display_items(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut DisplayListBuilder,
|
builder: &mut DisplayListBuilder,
|
||||||
hit_info: HitInfo,
|
|
||||||
border_rect: units::LayoutRect,
|
border_rect: units::LayoutRect,
|
||||||
radius: wr::BorderRadius,
|
radius: wr::BorderRadius,
|
||||||
) {
|
) {
|
||||||
|
@ -229,7 +234,7 @@ impl BoxFragment {
|
||||||
BorderStyle::Outset => wr::BorderStyle::Outset,
|
BorderStyle::Outset => wr::BorderStyle::Outset,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let common = builder.common_properties(border_rect, hit_info);
|
let common = builder.common_properties(border_rect);
|
||||||
let details = wr::BorderDetails::Normal(wr::NormalBorder {
|
let details = wr::BorderDetails::Normal(wr::NormalBorder {
|
||||||
top: side(b.border_top_style, b.border_top_color),
|
top: side(b.border_top_style, b.border_top_color),
|
||||||
right: side(b.border_right_style, b.border_right_color),
|
right: side(b.border_right_style, b.border_right_color),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue