Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create empty stacking contexts in display lists #26758

Merged
merged 3 commits into from Jun 9, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

layout2020: Don't create stacking contexts for empty fragments and bo…

…xes.
  • Loading branch information
jdm committed Jun 9, 2020
commit 56ff8f41e0836ef05f33644ddccc9d4e1f00e6ab
@@ -448,6 +448,14 @@ impl Fragment {
return;
}

// If this fragment has a transform applied that makes it take up no spae
// then we don't need to create any stacking contexts for it.
let has_non_invertible_transform =
fragment.has_non_invertible_transform(&containing_block_info.rect.to_untyped());
if has_non_invertible_transform {
return;
}

fragment.build_stacking_context_tree(
fragment_ref,
builder,
@@ -778,6 +786,15 @@ impl BoxFragment {
})
}

/// Returns true if the given style contains a transform that is not invertible.
fn has_non_invertible_transform(&self, containing_block: &Rect<Length>) -> bool {
let list = &self.style.get_box().transform;
match list.to_transform_3d_matrix(Some(containing_block)) {
Ok(t) => !t.0.is_invertible(),
Err(_) => false,
}
}

/// Returns the 4D matrix representing this fragment's transform.
pub fn calculate_transform_matrix(
&self,
@@ -786,6 +803,10 @@ impl BoxFragment {
let list = &self.style.get_box().transform;
let transform =
LayoutTransform::from_untyped(&list.to_transform_3d_matrix(Some(&border_rect)).ok()?.0);
// WebRender will end up dividing by the scale value of this transform, so we
// want to ensure we don't feed it a divisor of 0.
assert_ne!(transform.m11, 0.);
assert_ne!(transform.m22, 0.);

let transform_origin = &self.style.get_box().transform_origin;
let transform_origin_x = transform_origin
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.