mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Bug 1303229: Get the proper viewport size for stylo. r=heycam
At least until we support scrollbars properly, this size is going to be the correct one. I've left a TODO to grab the proper one once we support it. This allows to trivially test viewport units for now. MozReview-Commit-ID: JdaZ6WlZ2C6 Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
2f8cf6afc3
commit
95ccfa748e
8 changed files with 24 additions and 23 deletions
|
@ -426,7 +426,7 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
|
|||
};
|
||||
|
||||
let computed =
|
||||
properties::apply_declarations(context.viewport_size,
|
||||
properties::apply_declarations(context.viewport_size(),
|
||||
/* is_root = */ false,
|
||||
iter,
|
||||
previous_style,
|
||||
|
|
|
@ -62,9 +62,6 @@ pub enum QuirksMode {
|
|||
/// There's exactly one of these during a given restyle traversal, and it's
|
||||
/// shared among the worker threads.
|
||||
pub struct SharedStyleContext {
|
||||
/// The current viewport size.
|
||||
pub viewport_size: Size2D<Au>,
|
||||
|
||||
/// The CSS selector stylist.
|
||||
pub stylist: Arc<Stylist>,
|
||||
|
||||
|
@ -92,6 +89,13 @@ pub struct SharedStyleContext {
|
|||
pub default_computed_values: Arc<ComputedValues>,
|
||||
}
|
||||
|
||||
impl SharedStyleContext {
|
||||
/// Return a suitable viewport size in order to be used for viewport units.
|
||||
pub fn viewport_size(&self) -> Size2D<Au> {
|
||||
self.stylist.device.au_viewport_size()
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about the current element being processed. We group this together
|
||||
/// into a single struct within ThreadLocalStyleContext so that we can instantiate
|
||||
/// and destroy it easily at the beginning and end of element processing.
|
||||
|
|
|
@ -94,10 +94,10 @@ impl Device {
|
|||
self.viewport_override.as_ref().map(|v| {
|
||||
Size2D::new(Au::from_f32_px(v.size.width),
|
||||
Au::from_f32_px(v.size.height))
|
||||
}).unwrap_or_else(|| {
|
||||
// TODO(emilio): Grab from pres context.
|
||||
Size2D::new(Au::from_f32_px(1024.0),
|
||||
Au::from_f32_px(768.0))
|
||||
}).unwrap_or_else(|| unsafe {
|
||||
// TODO(emilio): Need to take into account scrollbars.
|
||||
Size2D::new(Au((*self.pres_context).mVisibleArea.width),
|
||||
Au((*self.pres_context).mVisibleArea.height))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -540,7 +540,7 @@ trait PrivateMatchMethods: TElement {
|
|||
|
||||
// Invoke the cascade algorithm.
|
||||
let values =
|
||||
Arc::new(cascade(shared_context.viewport_size,
|
||||
Arc::new(cascade(shared_context.viewport_size(),
|
||||
rule_node,
|
||||
inherited_values,
|
||||
layout_parent_style,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue