mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
Auto merge of #15913 - emilio:viewport-size, r=heycam,hiro
Use the proper viewport size for stylo Reviewed upstream at [bug 1303229](https://bugzil.la/1303229). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15913) <!-- Reviewable:end -->
This commit is contained in:
commit
06f99c13f2
12 changed files with 32 additions and 40 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,
|
||||
|
|
|
@ -63,9 +63,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>,
|
||||
|
||||
|
@ -93,6 +90,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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1373,8 +1373,7 @@ extern "C" {
|
|||
style: ServoComputedValuesBorrowed,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed,
|
||||
set: RawServoStyleSetBorrowed,
|
||||
result:
|
||||
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
||||
}
|
||||
|
|
|
@ -539,7 +539,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