From 62961370ecdf7c412760452fcc1a894c686ace0c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 4 Jan 2017 13:54:03 -0500 Subject: [PATCH] Bug 1298588 part 12. Compile some bits that call ComputedValues::initial_values only for servo, not stylo. r=bholley Stylist::set_device seems to only be used in servo code, and is the only consumer of ViewportConstraints::maybe_new. --- components/style/stylist.rs | 9 ++++++++- components/style/viewport.rs | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/components/style/stylist.rs b/components/style/stylist.rs index e0c6bf3f68d1..5952e242cf10 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -11,7 +11,9 @@ use data::ComputedStyle; use dom::{PresentationalHintsSynthetizer, TElement}; use error_reporting::StdoutErrorReporter; use keyframes::KeyframesAnimation; -use media_queries::{Device, MediaType}; +use media_queries::Device; +#[cfg(feature = "servo")] +use media_queries::MediaType; use parking_lot::RwLock; use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance}; use properties::{PropertyDeclaration, PropertyDeclarationBlock}; @@ -34,6 +36,7 @@ use std::slice; use std::sync::Arc; use style_traits::viewport::ViewportConstraints; use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets}; +#[cfg(feature = "servo")] use viewport::{self, MaybeNew, ViewportRule}; pub use ::fnv::FnvHashMap; @@ -385,6 +388,10 @@ impl Stylist { /// /// This means that we may need to rebuild style data even if the /// stylesheets haven't changed. + /// + /// Viewport_Constraints::maybe_new is servo-only (see the comment above it + /// explaining why), so we need to be servo-only too, since we call it. + #[cfg(feature = "servo")] pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc]) { let cascaded_rule = ViewportRule { declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(), diff --git a/components/style/viewport.rs b/components/style/viewport.rs index d8d45016b25c..38ff5a6942d7 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -9,13 +9,18 @@ #![deny(missing_docs)] +#[cfg(feature = "servo")] use app_units::Au; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important}; use cssparser::ToCss as ParserToCss; +#[cfg(feature = "servo")] use euclid::scale_factor::ScaleFactor; -use euclid::size::{Size2D, TypedSize2D}; +#[cfg(feature = "servo")] +use euclid::size::Size2D; +use euclid::size::TypedSize2D; use media_queries::Device; use parser::{ParserContext, log_css_error}; +#[cfg(feature = "servo")] use properties::ComputedValues; use std::ascii::AsciiExt; use std::borrow::Cow; @@ -25,6 +30,7 @@ use std::str::Chars; use style_traits::{ToCss, ViewportPx}; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; use stylesheets::{Stylesheet, Origin}; +#[cfg(feature = "servo")] use values::computed::{Context, ToComputedValue}; use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength}; @@ -605,6 +611,11 @@ pub trait MaybeNew { -> Option; } +/// MaybeNew for ViewportConstraints uses ComputedValues::initial_values which +/// is servo-only (not present in gecko). Once it has been changed to properly +/// use per-document initial computed values, or not use the initial computed +/// values at all, it can go back to being compiled unconditionally. +#[cfg(feature = "servo")] impl MaybeNew for ViewportConstraints { fn maybe_new(initial_viewport: TypedSize2D, rule: &ViewportRule)