Skip to content

Commit

Permalink
Auto merge of #13179 - servo:flatter-stylist, r=emilio
Browse files Browse the repository at this point in the history
Remove one level of nesting in `Stylist`

<!-- Please describe your changes on the following line: -->

Since #13134, the "normal" and "important" parts of `Stylist` are identical, so we don’t need to store them twice.

r? @emilio

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/13179)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Sep 6, 2016
2 parents 1901a21 + 74eaf2a commit 89126b4
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 161 deletions.
10 changes: 5 additions & 5 deletions components/script/dom/element.rs
Expand Up @@ -91,7 +91,7 @@ use style::properties::{DeclaredValue, Importance};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::refcell::Ref;
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
use style::selector_matching::DeclarationBlock;
use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push;
use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage};
Expand Down Expand Up @@ -291,7 +291,7 @@ pub trait LayoutElementHelpers {

#[allow(unsafe_code)]
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, &mut V)
where V: Push<DeclarationBlock>;
where V: Push<ApplicableDeclarationBlock>;
#[allow(unsafe_code)]
unsafe fn get_colspan(self) -> u32;
#[allow(unsafe_code)]
Expand Down Expand Up @@ -324,11 +324,11 @@ impl LayoutElementHelpers for LayoutJS<Element> {

#[allow(unsafe_code)]
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: Push<DeclarationBlock>
where V: Push<ApplicableDeclarationBlock>
{
#[inline]
fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock {
DeclarationBlock::from_declarations(
fn from_declaration(rule: PropertyDeclaration) -> ApplicableDeclarationBlock {
ApplicableDeclarationBlock::from_declarations(
Arc::new(PropertyDeclarationBlock {
declarations: vec![(rule, Importance::Normal)],
important_count: 0,
Expand Down
6 changes: 3 additions & 3 deletions components/script/layout_wrapper.rs
Expand Up @@ -63,7 +63,7 @@ use style::element_state::*;
use style::properties::{ComputedValues, PropertyDeclarationBlock};
use style::refcell::{Ref, RefCell, RefMut};
use style::selector_impl::{ElementSnapshot, NonTSPseudoClass, PseudoElement, ServoSelectorImpl};
use style::selector_matching::DeclarationBlock;
use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push;
use style::str::is_whitespace;
use url::Url;
Expand Down Expand Up @@ -442,7 +442,7 @@ impl<'le> fmt::Debug for ServoLayoutElement<'le> {

impl<'le> PresentationalHintsSynthetizer for ServoLayoutElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: Push<DeclarationBlock>
where V: Push<ApplicableDeclarationBlock>
{
unsafe {
self.element.synthesize_presentational_hints_for_legacy_attributes(hints);
Expand Down Expand Up @@ -1094,5 +1094,5 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {

impl<'le> PresentationalHintsSynthetizer for ServoThreadSafeLayoutElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, _hints: &mut V)
where V: Push<DeclarationBlock> {}
where V: Push<ApplicableDeclarationBlock> {}
}
4 changes: 2 additions & 2 deletions components/style/animation.rs
Expand Up @@ -16,7 +16,7 @@ use properties::longhands::animation_play_state::computed_value::AnimationPlaySt
use properties::longhands::transition_timing_function::computed_value::StartEnd;
use properties::longhands::transition_timing_function::computed_value::TransitionTimingFunction;
use properties::{self, ComputedValues, Importance};
use selector_matching::DeclarationBlock;
use selector_matching::ApplicableDeclarationBlock;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use string_cache::Atom;
Expand Down Expand Up @@ -384,7 +384,7 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
// an Arc in the below (more common case).
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
KeyframesStepValue::Declarations(ref declarations) => {
let declaration_block = DeclarationBlock {
let declaration_block = ApplicableDeclarationBlock {
mixed_declarations: declarations.clone(),
importance: Importance::Normal,
source_order: 0,
Expand Down
4 changes: 2 additions & 2 deletions components/style/dom.rs
Expand Up @@ -13,7 +13,7 @@ use properties::{ComputedValues, PropertyDeclarationBlock};
use refcell::{Ref, RefMut};
use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint};
use selector_impl::{ElementExt, PseudoElement};
use selector_matching::DeclarationBlock;
use selector_matching::ApplicableDeclarationBlock;
use sink::Push;
use std::fmt::Debug;
use std::ops::BitOr;
Expand Down Expand Up @@ -186,7 +186,7 @@ pub trait TDocument : Sized + Copy + Clone {

pub trait PresentationalHintsSynthetizer {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: Push<DeclarationBlock>;
where V: Push<ApplicableDeclarationBlock>;
}

pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
Expand Down
2 changes: 1 addition & 1 deletion components/style/keyframes.rs
Expand Up @@ -75,7 +75,7 @@ pub struct Keyframe {

/// `!important` is not allowed in keyframe declarations,
/// so the second value of these tuples is always `Importance::Normal`.
/// But including them enables `compute_style_for_animation_step` to create a `DeclarationBlock`
/// But including them enables `compute_style_for_animation_step` to create a `ApplicableDeclarationBlock`
/// by cloning an `Arc<_>` (incrementing a reference count) rather than re-creating a `Vec<_>`.
pub block: Arc<PropertyDeclarationBlock>,
}
Expand Down
20 changes: 10 additions & 10 deletions components/style/matching.rs
Expand Up @@ -16,7 +16,7 @@ use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
use properties::longhands::display::computed_value as display;
use properties::{ComputedValues, cascade, PropertyDeclarationBlock};
use selector_impl::{TheSelectorImpl, PseudoElement};
use selector_matching::{DeclarationBlock, Stylist};
use selector_matching::{ApplicableDeclarationBlock, Stylist};
use selectors::bloom::BloomFilter;
use selectors::matching::{MatchingReason, StyleRelations, AFFECTED_BY_PSEUDO_ELEMENTS};
use selectors::{Element, MatchAttr};
Expand Down Expand Up @@ -51,9 +51,9 @@ fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &
}

pub struct ApplicableDeclarations {
pub normal: SmallVec<[DeclarationBlock; 16]>,
pub normal: SmallVec<[ApplicableDeclarationBlock; 16]>,
pub per_pseudo: HashMap<PseudoElement,
Vec<DeclarationBlock>,
Vec<ApplicableDeclarationBlock>,
BuildHasherDefault<::fnv::FnvHasher>>,

/// Whether the `normal` declarations are shareable with other nodes.
Expand All @@ -78,11 +78,11 @@ impl ApplicableDeclarations {

#[derive(Clone)]
pub struct ApplicableDeclarationsCacheEntry {
pub declarations: Vec<DeclarationBlock>,
pub declarations: Vec<ApplicableDeclarationBlock>,
}

impl ApplicableDeclarationsCacheEntry {
fn new(declarations: Vec<DeclarationBlock>) -> ApplicableDeclarationsCacheEntry {
fn new(declarations: Vec<ApplicableDeclarationBlock>) -> ApplicableDeclarationsCacheEntry {
ApplicableDeclarationsCacheEntry {
declarations: declarations,
}
Expand All @@ -105,11 +105,11 @@ impl Hash for ApplicableDeclarationsCacheEntry {
}

struct ApplicableDeclarationsCacheQuery<'a> {
declarations: &'a [DeclarationBlock],
declarations: &'a [ApplicableDeclarationBlock],
}

impl<'a> ApplicableDeclarationsCacheQuery<'a> {
fn new(declarations: &'a [DeclarationBlock]) -> ApplicableDeclarationsCacheQuery<'a> {
fn new(declarations: &'a [ApplicableDeclarationBlock]) -> ApplicableDeclarationsCacheQuery<'a> {
ApplicableDeclarationsCacheQuery {
declarations: declarations,
}
Expand Down Expand Up @@ -159,14 +159,14 @@ impl ApplicableDeclarationsCache {
}
}

pub fn find(&self, declarations: &[DeclarationBlock]) -> Option<Arc<ComputedValues>> {
pub fn find(&self, declarations: &[ApplicableDeclarationBlock]) -> Option<Arc<ComputedValues>> {
match self.cache.find(&ApplicableDeclarationsCacheQuery::new(declarations)) {
None => None,
Some(ref values) => Some((*values).clone()),
}
}

pub fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
pub fn insert(&mut self, declarations: Vec<ApplicableDeclarationBlock>, style: Arc<ComputedValues>) {
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
}

Expand Down Expand Up @@ -493,7 +493,7 @@ trait PrivateMatchMethods: TNode {
fn cascade_node_pseudo_element<'a, Ctx>(&self,
context: &Ctx,
parent_style: Option<&Arc<ComputedValues>>,
applicable_declarations: &[DeclarationBlock],
applicable_declarations: &[ApplicableDeclarationBlock],
mut old_style: Option<&mut Arc<ComputedValues>>,
applicable_declarations_cache:
&mut ApplicableDeclarationsCache,
Expand Down
6 changes: 3 additions & 3 deletions components/style/properties/properties.mako.rs
Expand Up @@ -29,7 +29,7 @@ use computed_values;
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
use logical_geometry::WritingMode;
use parser::{ParserContext, ParserContextExtraData, log_css_error};
use selector_matching::DeclarationBlock;
use selector_matching::ApplicableDeclarationBlock;
use stylesheets::Origin;
use values::LocalToCss;
use values::HasViewportPercentage;
Expand Down Expand Up @@ -1718,7 +1718,7 @@ mod lazy_static_module {
#[allow(unused_mut, unused_imports)]
fn cascade_with_cached_declarations(
viewport_size: Size2D<Au>,
applicable_declarations: &[DeclarationBlock],
applicable_declarations: &[ApplicableDeclarationBlock],
shareable: bool,
parent_style: &ComputedValues,
cached_style: &ComputedValues,
Expand Down Expand Up @@ -1863,7 +1863,7 @@ static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
///
/// Returns the computed values and a boolean indicating whether the result is cacheable.
pub fn cascade(viewport_size: Size2D<Au>,
applicable_declarations: &[DeclarationBlock],
applicable_declarations: &[ApplicableDeclarationBlock],
shareable: bool,
parent_style: Option<<&ComputedValues>,
cached_style: Option<<&ComputedValues>,
Expand Down

0 comments on commit 89126b4

Please sign in to comment.