Avoid Window::GetComputedStyle when checking for display: none

This commit is contained in:
Alex Fong 2018-02-12 20:36:23 +08:00
parent 1d8e78720b
commit 8d09398230
5 changed files with 10 additions and 19 deletions

View file

@ -350,14 +350,14 @@ impl Element {
/// style will be `None` for elements in a `display: none` subtree. otherwise, the element has a
/// layout box iff it doesn't have `display: none`.
fn style(&self) -> Option<Arc<ComputedValues>> {
pub fn style(&self) -> Option<Arc<ComputedValues>> {
window_from_node(self).style_query(
self.upcast::<Node>().to_trusted_node_address()
)
}
// https://drafts.csswg.org/cssom-view/#css-layout-box
fn has_css_layout_box(&self) -> bool {
pub fn has_css_layout_box(&self) -> bool {
self.style()
.map_or(false, |s| !s.get_box().clone_display().is_none())
}