mirror of
https://github.com/servo/servo.git
synced 2025-08-18 03:45:33 +01:00
layout: Make Fragment
hold ArcRefCell
inside (#34923)
Push the interior mutability into enum variants of `Fragment`, so that they can be cloned. This saves memory in the `Fragment` tree as the `Fragment` enum is now a relatively wee 16 bytes and the interior parts can be a variety of sizes. Before, every `Fragment` was the size of the biggest kind (`BoxFragment` - 248 bytes). This a step on the way toward incremental layout. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
c936dd6c4e
commit
de780dcde4
18 changed files with 257 additions and 233 deletions
|
@ -246,6 +246,7 @@ impl Fragment {
|
|||
) {
|
||||
match self {
|
||||
Fragment::Box(box_fragment) | Fragment::Float(box_fragment) => {
|
||||
let box_fragment = &*box_fragment.borrow();
|
||||
match box_fragment.style.get_inherited_box().visibility {
|
||||
Visibility::Visible => BuilderForBoxFragment::new(
|
||||
box_fragment,
|
||||
|
@ -259,6 +260,7 @@ impl Fragment {
|
|||
},
|
||||
Fragment::AbsoluteOrFixedPositioned(_) => {},
|
||||
Fragment::Positioning(positioning_fragment) => {
|
||||
let positioning_fragment = positioning_fragment.borrow();
|
||||
if let Some(style) = positioning_fragment.style.as_ref() {
|
||||
let rect = positioning_fragment
|
||||
.rect
|
||||
|
@ -272,65 +274,74 @@ impl Fragment {
|
|||
);
|
||||
}
|
||||
},
|
||||
Fragment::Image(image) => match image.style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
builder.is_contentful = true;
|
||||
Fragment::Image(image) => {
|
||||
let image = image.borrow();
|
||||
match image.style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
builder.is_contentful = true;
|
||||
|
||||
let image_rendering = image
|
||||
.style
|
||||
.get_inherited_box()
|
||||
.image_rendering
|
||||
.to_webrender();
|
||||
let rect = image
|
||||
.rect
|
||||
.translate(containing_block.origin.to_vector())
|
||||
.to_webrender();
|
||||
let clip = image
|
||||
.clip
|
||||
.translate(containing_block.origin.to_vector())
|
||||
.to_webrender();
|
||||
let common = builder.common_properties(clip, &image.style);
|
||||
let image_rendering = image
|
||||
.style
|
||||
.get_inherited_box()
|
||||
.image_rendering
|
||||
.to_webrender();
|
||||
let rect = image
|
||||
.rect
|
||||
.translate(containing_block.origin.to_vector())
|
||||
.to_webrender();
|
||||
let clip = image
|
||||
.clip
|
||||
.translate(containing_block.origin.to_vector())
|
||||
.to_webrender();
|
||||
let common = builder.common_properties(clip, &image.style);
|
||||
|
||||
if let Some(image_key) = image.image_key {
|
||||
builder.wr().push_image(
|
||||
&common,
|
||||
rect,
|
||||
image_rendering,
|
||||
wr::AlphaType::PremultipliedAlpha,
|
||||
image_key,
|
||||
wr::ColorF::WHITE,
|
||||
if let Some(image_key) = image.image_key {
|
||||
builder.wr().push_image(
|
||||
&common,
|
||||
rect,
|
||||
image_rendering,
|
||||
wr::AlphaType::PremultipliedAlpha,
|
||||
image_key,
|
||||
wr::ColorF::WHITE,
|
||||
);
|
||||
}
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
}
|
||||
},
|
||||
Fragment::IFrame(iframe) => {
|
||||
let iframe = iframe.borrow();
|
||||
match iframe.style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
builder.is_contentful = true;
|
||||
let rect = iframe.rect.translate(containing_block.origin.to_vector());
|
||||
|
||||
let common = builder.common_properties(rect.to_webrender(), &iframe.style);
|
||||
builder.wr().push_iframe(
|
||||
rect.to_webrender(),
|
||||
common.clip_rect,
|
||||
&wr::SpaceAndClipInfo {
|
||||
spatial_id: common.spatial_id,
|
||||
clip_chain_id: common.clip_chain_id,
|
||||
},
|
||||
iframe.pipeline_id.into(),
|
||||
true,
|
||||
);
|
||||
}
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
}
|
||||
},
|
||||
Fragment::IFrame(iframe) => match iframe.style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
builder.is_contentful = true;
|
||||
let rect = iframe.rect.translate(containing_block.origin.to_vector());
|
||||
|
||||
let common = builder.common_properties(rect.to_webrender(), &iframe.style);
|
||||
builder.wr().push_iframe(
|
||||
rect.to_webrender(),
|
||||
common.clip_rect,
|
||||
&wr::SpaceAndClipInfo {
|
||||
spatial_id: common.spatial_id,
|
||||
clip_chain_id: common.clip_chain_id,
|
||||
},
|
||||
iframe.pipeline_id.into(),
|
||||
true,
|
||||
);
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
},
|
||||
Fragment::Text(t) => match t.parent_style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
self.build_display_list_for_text_fragment(t, builder, containing_block)
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
Fragment::Text(text) => {
|
||||
let text = &*text.borrow();
|
||||
match text.parent_style.get_inherited_box().visibility {
|
||||
Visibility::Visible => {
|
||||
self.build_display_list_for_text_fragment(text, builder, containing_block)
|
||||
},
|
||||
Visibility::Hidden => (),
|
||||
Visibility::Collapse => (),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue