aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorCYBAI <cyb.ai.815@gmail.com>2018-01-28 23:47:39 +0800
committerCYBAI <cyb.ai.815@gmail.com>2018-01-28 23:47:39 +0800
commit37802dfd197cfddfee72c00abe59582b0ea4c1af (patch)
tree8e058a2ed207081c5038a8ac3aaebda05373dba4 /components/script
parent2a46067587d63aec176621ab3b6112ef5200a248 (diff)
downloadservo-37802dfd197cfddfee72c00abe59582b0ea4c1af.tar.gz
servo-37802dfd197cfddfee72c00abe59582b0ea4c1af.zip
script: Move `style` as Element method
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/element.rs26
-rw-r--r--components/script/dom/node.rs5
2 files changed, 14 insertions, 17 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a1bcaa0437e..16a84737c47 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -107,7 +107,8 @@ use style::context::QuirksMode;
use style::dom_apis;
use style::element_state::ElementState;
use style::invalidation::element::restyle_hints::RestyleHint;
-use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
+use style::properties::{ComputedValues, Importance, PropertyDeclaration};
+use style::properties::{PropertyDeclarationBlock, parse_style_attribute};
use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size};
use style::properties::longhands::{overflow_x, overflow_y};
use style::rule_tree::CascadeLevel;
@@ -347,13 +348,18 @@ 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>> {
+ 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 {
- let style = self.upcast::<Node>().style();
-
- // 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.
- style.map_or(false, |s| !s.get_box().clone_display().is_none())
+ self.style()
+ .map_or(false, |s| !s.get_box().clone_display().is_none())
}
// https://drafts.csswg.org/cssom-view/#potentially-scrollable
@@ -380,9 +386,7 @@ impl Element {
/// Computed value of overflow-x or overflow-y is "visible"
fn has_any_visible_overflow(&self) -> bool {
- let style = self.upcast::<Node>().style();
-
- style.map_or(false, |s| {
+ self.style().map_or(false, |s| {
let box_ = s.get_box();
box_.clone_overflow_x() == overflow_x::computed_value::T::Visible ||
@@ -392,9 +396,7 @@ impl Element {
/// Computed value of overflow-x or overflow-y is "hidden"
fn has_any_hidden_overflow(&self) -> bool {
- let style = self.upcast::<Node>().style();
-
- style.map_or(false, |s| {
+ self.style().map_or(false, |s| {
let box_ = s.get_box();
box_.clone_overflow_x() == overflow_x::computed_value::T::Hidden ||
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 28e10cf798c..68e6f63e168 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -82,7 +82,6 @@ use std::mem;
use std::ops::Range;
use style::context::QuirksMode;
use style::dom::OpaqueNode;
-use style::properties::ComputedValues;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::Stylesheet;
use style::thread_state;
@@ -620,10 +619,6 @@ impl Node {
window_from_node(self).client_rect_query(self.to_trusted_node_address())
}
- pub fn style(&self) -> Option<Arc<ComputedValues>> {
- window_from_node(self).style_query(self.to_trusted_node_address())
- }
-
// https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth
// https://drafts.csswg.org/cssom-view/#dom-element-scrollheight
// https://drafts.csswg.org/cssom-view/#dom-element-scrolltop