Attachment #8822399: part 12. Compile some bits that call ComputedValues::initial_values only for servo, not stylo for bug #1298588

View | Details | Raw Unified | Return to bug 1298588
Collapse All | Expand All

(-)a/servo/components/style/stylist.rs (-1 / +5 lines)
Line     Link Here 
 Lines 5-21    Link Here 
5
//! Selector matching.
5
//! Selector matching.
6
6
7
use {Atom, LocalName};
7
use {Atom, LocalName};
8
use data::ComputedStyle;
8
use data::ComputedStyle;
9
use dom::PresentationalHintsSynthetizer;
9
use dom::PresentationalHintsSynthetizer;
10
use element_state::*;
10
use element_state::*;
11
use error_reporting::StdoutErrorReporter;
11
use error_reporting::StdoutErrorReporter;
12
use keyframes::KeyframesAnimation;
12
use keyframes::KeyframesAnimation;
13
use media_queries::{Device, MediaType};
13
use media_queries::Device;
14
#[cfg(feature = "servo")]
15
use media_queries::MediaType;
14
use parking_lot::RwLock;
16
use parking_lot::RwLock;
15
use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
17
use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
16
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
18
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
17
use quickersort::sort_by;
19
use quickersort::sort_by;
18
use restyle_hints::{RestyleHint, DependencySet};
20
use restyle_hints::{RestyleHint, DependencySet};
19
use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
21
use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
20
use selector_parser::{ElementExt, SelectorImpl, PseudoElement, Snapshot};
22
use selector_parser::{ElementExt, SelectorImpl, PseudoElement, Snapshot};
21
use selectors::Element;
23
use selectors::Element;
 Lines 29-44   use std::borrow::Borrow; Link Here 
29
use std::collections::HashMap;
31
use std::collections::HashMap;
30
use std::fmt;
32
use std::fmt;
31
use std::hash::BuildHasherDefault;
33
use std::hash::BuildHasherDefault;
32
use std::hash::Hash;
34
use std::hash::Hash;
33
use std::slice;
35
use std::slice;
34
use std::sync::Arc;
36
use std::sync::Arc;
35
use style_traits::viewport::ViewportConstraints;
37
use style_traits::viewport::ViewportConstraints;
36
use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
38
use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
39
#[cfg(feature = "servo")]
37
use viewport::{self, MaybeNew, ViewportRule};
40
use viewport::{self, MaybeNew, ViewportRule};
38
41
39
pub type FnvHashMap<K, V> = HashMap<K, V, BuildHasherDefault<::fnv::FnvHasher>>;
42
pub type FnvHashMap<K, V> = HashMap<K, V, BuildHasherDefault<::fnv::FnvHasher>>;
40
43
41
/// This structure holds all the selectors and device characteristics
44
/// This structure holds all the selectors and device characteristics
42
/// for a given document. The selectors are converted into `Rule`s
45
/// for a given document. The selectors are converted into `Rule`s
43
/// (defined in rust-selectors), and introduced in a `SelectorMap`
46
/// (defined in rust-selectors), and introduced in a `SelectorMap`
44
/// depending on the pseudo-element (see `PerPseudoElementSelectorMap`),
47
/// depending on the pseudo-element (see `PerPseudoElementSelectorMap`),
 Lines 376-391   impl Stylist { Link Here 
376
                                default,
379
                                default,
377
                                None,
380
                                None,
378
                                Box::new(StdoutErrorReporter),
381
                                Box::new(StdoutErrorReporter),
379
                                CascadeFlags::empty());
382
                                CascadeFlags::empty());
380
383
381
        Some(ComputedStyle::new(rule_node, Arc::new(computed)))
384
        Some(ComputedStyle::new(rule_node, Arc::new(computed)))
382
    }
385
    }
383
386
387
    #[cfg(feature = "servo")]
384
    pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) {
388
    pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) {
385
        let cascaded_rule = ViewportRule {
389
        let cascaded_rule = ViewportRule {
386
            declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(),
390
            declarations: viewport::Cascade::from_stylesheets(stylesheets, &device).finish(),
387
        };
391
        };
388
392
389
        self.viewport_constraints = ViewportConstraints::maybe_new(device.viewport_size, &cascaded_rule);
393
        self.viewport_constraints = ViewportConstraints::maybe_new(device.viewport_size, &cascaded_rule);
390
        if let Some(ref constraints) = self.viewport_constraints {
394
        if let Some(ref constraints) = self.viewport_constraints {
391
            device = Device::new(MediaType::Screen, constraints.size);
395
            device = Device::new(MediaType::Screen, constraints.size);
(-)a/servo/components/style/viewport.rs (-1 / +8 lines)
Line     Link Here 
 Lines 2-33    Link Here 
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
//! The [`@viewport`][at] at-rule and [`meta`][meta] element.
5
//! The [`@viewport`][at] at-rule and [`meta`][meta] element.
6
//!
6
//!
7
//! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule
7
//! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule
8
//! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta
8
//! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta
9
9
10
#[cfg(feature = "servo")]
10
use app_units::Au;
11
use app_units::Au;
11
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
12
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
12
use cssparser::ToCss as ParserToCss;
13
use cssparser::ToCss as ParserToCss;
14
#[cfg(feature = "servo")]
13
use euclid::scale_factor::ScaleFactor;
15
use euclid::scale_factor::ScaleFactor;
14
use euclid::size::{Size2D, TypedSize2D};
16
use euclid::size::TypedSize2D;
17
#[cfg(feature = "servo")]
18
use euclid::size::Size2D;
15
use media_queries::Device;
19
use media_queries::Device;
16
use parser::{ParserContext, log_css_error};
20
use parser::{ParserContext, log_css_error};
21
#[cfg(feature = "servo")]
17
use properties::ComputedValues;
22
use properties::ComputedValues;
18
use std::ascii::AsciiExt;
23
use std::ascii::AsciiExt;
19
use std::borrow::Cow;
24
use std::borrow::Cow;
20
use std::fmt;
25
use std::fmt;
21
use std::iter::Enumerate;
26
use std::iter::Enumerate;
22
use std::str::Chars;
27
use std::str::Chars;
23
use style_traits::{ToCss, ViewportPx};
28
use style_traits::{ToCss, ViewportPx};
24
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
29
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
25
use stylesheets::{Stylesheet, Origin};
30
use stylesheets::{Stylesheet, Origin};
31
#[cfg(feature = "servo")]
26
use values::computed::{Context, ToComputedValue};
32
use values::computed::{Context, ToComputedValue};
27
use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength};
33
use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength};
28
34
29
macro_rules! declare_viewport_descriptor {
35
macro_rules! declare_viewport_descriptor {
30
    ( $( $variant_name: expr => $variant: ident($data: ident), )+ ) => {
36
    ( $( $variant_name: expr => $variant: ident($data: ident), )+ ) => {
31
         declare_viewport_descriptor_inner!([] [ $( $variant_name => $variant($data), )+ ] 0);
37
         declare_viewport_descriptor_inner!([] [ $( $variant_name => $variant($data), )+ ] 0);
32
    };
38
    };
33
}
39
}
 Lines 582-597   impl Cascade { Link Here 
582
}
588
}
583
589
584
pub trait MaybeNew {
590
pub trait MaybeNew {
585
    fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
591
    fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
586
                     rule: &ViewportRule)
592
                     rule: &ViewportRule)
587
                     -> Option<ViewportConstraints>;
593
                     -> Option<ViewportConstraints>;
588
}
594
}
589
595
596
#[cfg(feature = "servo")]
590
impl MaybeNew for ViewportConstraints {
597
impl MaybeNew for ViewportConstraints {
591
    fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
598
    fn maybe_new(initial_viewport: TypedSize2D<f32, ViewportPx>,
592
                 rule: &ViewportRule)
599
                 rule: &ViewportRule)
593
                 -> Option<ViewportConstraints>
600
                 -> Option<ViewportConstraints>
594
    {
601
    {
595
        use std::cmp;
602
        use std::cmp;
596
603
597
        if rule.declarations.is_empty() {
604
        if rule.declarations.is_empty() {

Return to bug 1298588