aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/document.rs1
-rw-r--r--components/script/dom/element.rs6
-rw-r--r--components/script/dom/htmlstyleelement.rs1
-rw-r--r--components/script/dom/nodelist.rs23
-rw-r--r--components/script/dom/window.rs40
-rw-r--r--components/selectors/bloom.rs2
-rw-r--r--components/style/gecko/global_style_data.rs28
-rw-r--r--components/style/properties/helpers.mako.rs12
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs2
-rw-r--r--components/style/properties/longhand/box.mako.rs45
-rw-r--r--components/style/properties/longhand/inherited_svg.mako.rs23
-rw-r--r--components/style/properties/properties.mako.rs16
12 files changed, 99 insertions, 100 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index d603d898f5c..c97d352872c 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -703,6 +703,7 @@ impl Document {
// Step 3
let global_scope = self.window.upcast::<GlobalScope>();
let webrender_pipeline_id = global_scope.pipeline_id().to_webrender();
+ self.window.update_viewport_for_scroll(x, y);
self.window.perform_a_scroll(x,
y,
ClipId::root_scroll_node(webrender_pipeline_id),
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a431d0c9dbb..2c7372ebddf 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -1356,7 +1356,7 @@ impl Element {
// Step 10 (TODO)
// Step 11
- win.scroll_node(node.to_trusted_node_address(), x, y, behavior);
+ win.scroll_node(node, x, y, behavior);
}
// https://w3c.github.io/DOM-Parsing/#parsing
@@ -1798,7 +1798,7 @@ impl ElementMethods for Element {
// Step 10 (TODO)
// Step 11
- win.scroll_node(node.to_trusted_node_address(), self.ScrollLeft(), y, behavior);
+ win.scroll_node(node, self.ScrollLeft(), y, behavior);
}
// https://drafts.csswg.org/cssom-view/#dom-element-scrolltop
@@ -1891,7 +1891,7 @@ impl ElementMethods for Element {
// Step 10 (TODO)
// Step 11
- win.scroll_node(node.to_trusted_node_address(), x, self.ScrollTop(), behavior);
+ win.scroll_node(node, x, self.ScrollTop(), behavior);
}
// https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index bf4266e1875..bbce33f3d52 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -111,6 +111,7 @@ impl HTMLStyleElement {
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*self.stylesheet.borrow_mut() = Some(sheet);
+ self.cssom_stylesheet.set(None);
doc.invalidate_stylesheets();
}
diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs
index 39b4cc1c41e..31e4dfb40c8 100644
--- a/components/script/dom/nodelist.rs
+++ b/components/script/dom/nodelist.rs
@@ -103,11 +103,9 @@ impl NodeList {
}
}
- pub fn iter(&self) -> NodeListIterator {
- NodeListIterator {
- nodes: self,
- offset: 0,
- }
+ pub fn iter<'a>(&'a self) -> impl Iterator<Item=Root<Node>> + 'a {
+ let len = self.Length();
+ (0..len).flat_map(move |i| self.Item(i))
}
}
@@ -289,18 +287,3 @@ impl ChildrenList {
self.last_index.set(0u32);
}
}
-
-pub struct NodeListIterator<'a> {
- nodes: &'a NodeList,
- offset: u32,
-}
-
-impl<'a> Iterator for NodeListIterator<'a> {
- type Item = Root<Node>;
-
- fn next(&mut self) -> Option<Root<Node>> {
- let result = self.nodes.Item(self.offset);
- self.offset = self.offset + 1;
- result
- }
-}
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index d560c71b3ad..58f0e7b4a1a 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -13,7 +13,6 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::EventHandlerBinding::OnBeforeUnloadEventHandlerNonNull;
use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull;
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
-use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
use dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
@@ -1126,8 +1125,11 @@ impl Window {
//let document = self.Document();
// Step 12
let global_scope = self.upcast::<GlobalScope>();
- self.perform_a_scroll(x.to_f32().unwrap_or(0.0f32),
- y.to_f32().unwrap_or(0.0f32),
+ let x = x.to_f32().unwrap_or(0.0f32);
+ let y = y.to_f32().unwrap_or(0.0f32);
+ self.update_viewport_for_scroll(x, y);
+ self.perform_a_scroll(x,
+ y,
global_scope.pipeline_id().root_scroll_node(),
behavior,
None);
@@ -1158,9 +1160,6 @@ impl Window {
scroll_offset: Vector2D::new(-x, -y),
})).unwrap();
- // TODO (farodin91): Raise an event to stop the current_viewport
- self.update_viewport_for_scroll(x, y);
-
let global_scope = self.upcast::<GlobalScope>();
let message = ConstellationMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
global_scope.constellation_chan().send(message).unwrap();
@@ -1450,33 +1449,32 @@ impl Window {
}
pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32> {
- let mut node = Root::from_ref(node);
- loop {
- if let Some(scroll_offset) = self.scroll_offsets
- .borrow()
- .get(&node.to_untrusted_node_address()) {
- return *scroll_offset
- }
- node = match node.GetParentNode() {
- Some(node) => node,
- None => break,
- }
+ if let Some(scroll_offset) = self.scroll_offsets
+ .borrow()
+ .get(&node.to_untrusted_node_address()) {
+ return *scroll_offset
}
- let vp_origin = self.current_viewport.get().origin;
- Vector2D::new(vp_origin.x.to_f32_px(), vp_origin.y.to_f32_px())
+ Vector2D::new(0.0, 0.0)
}
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
pub fn scroll_node(&self,
- node: TrustedNodeAddress,
+ node: &Node,
x_: f64,
y_: f64,
behavior: ScrollBehavior) {
if !self.reflow(ReflowGoal::ForScriptQuery,
- ReflowQueryType::NodeScrollRootIdQuery(node),
+ ReflowQueryType::NodeScrollRootIdQuery(node.to_trusted_node_address()),
ReflowReason::Query) {
return;
}
+
+ // The scroll offsets are immediatly updated since later calls
+ // to topScroll and others may access the properties before
+ // webrender has a chance to update the offsets.
+ self.scroll_offsets.borrow_mut().insert(node.to_untrusted_node_address(),
+ Vector2D::new(x_ as f32, y_ as f32));
+
let NodeScrollRootIdResponse(scroll_root_id) = self.layout_rpc.node_scroll_root_id();
// Step 12
diff --git a/components/selectors/bloom.rs b/components/selectors/bloom.rs
index 8caab9935cb..0e8290fc8c9 100644
--- a/components/selectors/bloom.rs
+++ b/components/selectors/bloom.rs
@@ -7,7 +7,7 @@
use fnv::FnvHasher;
use std::hash::{Hash, Hasher};
-// The top 12 bits of the 32-bit hash value are not used by the bloom filter.
+// The top 8 bits of the 32-bit hash value are not used by the bloom filter.
// Consumers may rely on this to pack hashes more efficiently.
pub const BLOOM_HASH_MASK: u32 = 0x00ffffff;
const KEY_SIZE: usize = 12;
diff --git a/components/style/gecko/global_style_data.rs b/components/style/gecko/global_style_data.rs
index 0f80a18816e..f396a4ee451 100644
--- a/components/style/gecko/global_style_data.rs
+++ b/components/style/gecko/global_style_data.rs
@@ -16,12 +16,6 @@ use std::ffi::CString;
/// Global style data
pub struct GlobalStyleData {
- /// How many threads parallel styling can use.
- pub num_threads: usize,
-
- /// The parallel styling thread pool.
- pub style_thread_pool: Option<rayon::ThreadPool>,
-
/// Shared RWLock for CSSOM objects
pub shared_lock: SharedRwLock,
@@ -29,6 +23,15 @@ pub struct GlobalStyleData {
pub options: StyleSystemOptions,
}
+/// Global thread pool
+pub struct StyleThreadPool {
+ /// How many threads parallel styling can use.
+ pub num_threads: usize,
+
+ /// The parallel styling thread pool.
+ pub style_thread_pool: Option<rayon::ThreadPool>,
+}
+
fn thread_name(index: usize) -> String {
format!("StyleThread#{}", index)
}
@@ -53,8 +56,8 @@ fn thread_shutdown(_: usize) {
}
lazy_static! {
- /// Global style data
- pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = {
+ /// Global thread pool
+ pub static ref STYLE_THREAD_POOL: StyleThreadPool = {
let stylo_threads = env::var("STYLO_THREADS")
.map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS value"));
let mut num_threads = match stylo_threads {
@@ -93,11 +96,14 @@ lazy_static! {
pool
};
- GlobalStyleData {
+ StyleThreadPool {
num_threads: num_threads,
style_thread_pool: pool,
- shared_lock: SharedRwLock::new(),
- options: StyleSystemOptions::default(),
}
};
+ /// Global style data
+ pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = GlobalStyleData {
+ shared_lock: SharedRwLock::new(),
+ options: StyleSystemOptions::default(),
+ };
}
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index 54b5c313e36..8c6701497e4 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -9,7 +9,7 @@
<%def name="predefined_type(name, type, initial_value, parse_method='parse',
needs_context=True, vector=False, computed_type=None, initial_specified_value=None,
- allow_quirks=False, **kwargs)">
+ allow_quirks=False, allow_empty=False, **kwargs)">
<%def name="predefined_type_inner(name, type, initial_value, parse_method)">
#[allow(unused_imports)]
use app_units::Au;
@@ -27,7 +27,9 @@
pub use values::computed::${type} as T;
% endif
}
+ % if initial_value:
#[inline] pub fn get_initial_value() -> computed_value::T { ${initial_value} }
+ % endif
% if initial_specified_value:
#[inline] pub fn get_initial_specified_value() -> SpecifiedValue { ${initial_specified_value} }
% endif
@@ -46,7 +48,9 @@
}
</%def>
% if vector:
- <%call expr="vector_longhand(name, predefined_type=type, **kwargs)">
+ <%call
+ expr="vector_longhand(name, predefined_type=type, allow_empty=allow_empty or not initial_value, **kwargs)"
+ >
${predefined_type_inner(name, type, initial_value, parse_method)}
% if caller:
${caller.body()}
@@ -202,7 +206,7 @@
}
pub fn get_initial_value() -> computed_value::T {
- % if allow_empty:
+ % if allow_empty and allow_empty != "NotInitial":
computed_value::T(SmallVec::new())
% else:
let mut v = SmallVec::new();
@@ -333,7 +337,7 @@
let quirks_mode = context.quirks_mode;
::properties::substitute_variables_${property.ident}(
&declared_value, &custom_props,
- |value| {
+ &mut |value| {
if let Some(ref mut cascade_info) = *cascade_info {
cascade_info.on_cascade_property(&declaration,
&value);
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index 3874f972a25..99b2cc377f6 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -582,7 +582,7 @@ impl AnimationValue {
&variables.url_data,
variables.from_shorthand,
&custom_props,
- |v| {
+ &mut |v| {
let declaration = match *v {
DeclaredValue::Value(value) => {
PropertyDeclaration::${prop.camel_case}(value.clone())
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index 4f0449ad0bf..871eb37513d 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -429,17 +429,19 @@ ${helpers.predefined_type("transition-timing-function",
extra_prefixes="moz webkit",
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-timing-function")}
-${helpers.predefined_type("transition-property",
- "TransitionProperty",
- "computed::TransitionProperty::All",
- initial_specified_value="specified::TransitionProperty::All",
- vector=True,
- allow_empty=True,
- need_index=True,
- needs_context=False,
- animation_value_type="none",
- extra_prefixes="moz webkit",
- spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property")}
+${helpers.predefined_type(
+ "transition-property",
+ "TransitionProperty",
+ "computed::TransitionProperty::All",
+ initial_specified_value="specified::TransitionProperty::All",
+ vector=True,
+ allow_empty="NotInitial",
+ need_index=True,
+ needs_context=False,
+ animation_value_type="none",
+ extra_prefixes="moz webkit",
+ spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property",
+)}
${helpers.predefined_type("transition-delay",
"Time",
@@ -668,16 +670,17 @@ ${helpers.predefined_type("scroll-snap-destination",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="ComputedValue")}
-${helpers.predefined_type("scroll-snap-coordinate",
- "Position",
- "computed::Position::zero()",
- vector=True,
- products="gecko",
- spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
- animation_value_type="ComputedValue",
- allow_empty=True,
- delegate_animate=True)}
-
+${helpers.predefined_type(
+ "scroll-snap-coordinate",
+ "Position",
+ "computed::Position::zero()",
+ vector=True,
+ products="gecko",
+ spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
+ animation_value_type="ComputedValue",
+ allow_empty="NotInitial",
+ delegate_animate=True,
+)}
<%helpers:longhand name="transform" extra_prefixes="webkit"
animation_value_type="ComputedValue"
diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs
index 3799c89d3ad..1d7fd7a985a 100644
--- a/components/style/properties/longhand/inherited_svg.mako.rs
+++ b/components/style/properties/longhand/inherited_svg.mako.rs
@@ -88,17 +88,18 @@ ${helpers.predefined_type("stroke-opacity", "Opacity", "1.0",
products="gecko", animation_value_type="ComputedValue",
spec="https://www.w3.org/TR/SVG11/painting.html#StrokeOpacityProperty")}
-${helpers.predefined_type("stroke-dasharray",
- "LengthOrPercentageOrNumber",
- "Either::First(0.0)",
- "parse_non_negative",
- vector="True",
- delegate_animate="True",
- allow_empty="True",
- products="gecko",
- animation_value_type="ComputedValue",
- space_separated_allowed="True",
- spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
+${helpers.predefined_type(
+ "stroke-dasharray",
+ "LengthOrPercentageOrNumber",
+ None,
+ "parse_non_negative",
+ vector=True,
+ delegate_animate=True,
+ products="gecko",
+ animation_value_type="ComputedValue",
+ space_separated_allowed="True",
+ spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing",
+)}
${helpers.predefined_type(
"stroke-dashoffset", "LengthOrPercentageOrNumber",
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 390ad3d3c27..4507ea5119a 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -373,13 +373,13 @@ impl PropertyDeclarationIdSet {
value: &DeclaredValue<longhands::${property.ident}::SpecifiedValue>,
% endif
custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>,
- f: F,
+ f: &mut F,
error_reporter: &ParseErrorReporter,
quirks_mode: QuirksMode)
% if property.boxed:
- where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
+ where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
% else:
- where F: FnOnce(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>)
+ where F: FnMut(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>)
% endif
{
if let DeclaredValue::WithVariables(ref with_variables) = *value {
@@ -404,13 +404,13 @@ impl PropertyDeclarationIdSet {
url_data: &UrlExtraData,
from_shorthand: Option<ShorthandId>,
custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>,
- f: F,
+ f: &mut F,
error_reporter: &ParseErrorReporter,
quirks_mode: QuirksMode)
% if property.boxed:
- where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
+ where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
% else:
- where F: FnOnce(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>)
+ where F: FnMut(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>)
% endif
{
f(&
@@ -1765,7 +1765,9 @@ pub mod style_structs {
/// Returns whether there are any transitions specified.
#[cfg(feature = "servo")]
pub fn specifies_transitions(&self) -> bool {
- self.transition_property_count() > 0
+ self.transition_duration_iter()
+ .take(self.transition_property_count())
+ .any(|t| t.seconds() > 0.)
}
% endif
}