Rename DeclarationBlock to ApplicableDeclarationBlock

Make it more different from PropertyDeclarationBlock
This commit is contained in:
Simon Sapin 2016-09-06 13:48:12 +08:00
parent 1901a21a2c
commit 3ce64fd269
10 changed files with 49 additions and 49 deletions

View file

@ -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};
@ -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)]
@ -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,

View file

@ -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;
@ -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);
@ -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> {}
}

View file

@ -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;
@ -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,

View file

@ -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;
@ -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 {

View file

@ -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>,
}

View file

@ -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};
@ -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.
@ -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,
}
@ -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,
}
@ -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)
}
@ -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,

View file

@ -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;
@ -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,
@ -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>,

View file

@ -71,7 +71,7 @@ pub struct Stylist {
/// Applicable declarations for a given non-eagerly cascaded pseudo-element.
/// These are eagerly computed once, and then used to resolve the new
/// computed values on the fly on layout.
precomputed_pseudo_element_decls: FnvHashMap<PseudoElement, Vec<DeclarationBlock>>,
precomputed_pseudo_element_decls: FnvHashMap<PseudoElement, Vec<ApplicableDeclarationBlock>>,
rules_source_order: usize,
@ -178,7 +178,7 @@ impl Stylist {
map.$priority.insert(Rule {
selector: selector.complex_selector.clone(),
declarations: DeclarationBlock {
declarations: ApplicableDeclarationBlock {
specificity: selector.specificity,
mixed_declarations: $style_rule.declarations.clone(),
importance: $importance,
@ -350,7 +350,7 @@ impl Stylist {
where E: Element<Impl=TheSelectorImpl> +
fmt::Debug +
PresentationalHintsSynthetizer,
V: Push<DeclarationBlock> + VecLike<DeclarationBlock>
V: Push<ApplicableDeclarationBlock> + VecLike<ApplicableDeclarationBlock>
{
assert!(!self.is_device_dirty);
assert!(style_attribute.is_none() || pseudo_element.is_none(),
@ -407,7 +407,7 @@ impl Stylist {
relations |= AFFECTED_BY_STYLE_ATTRIBUTE;
Push::push(
applicable_declarations,
DeclarationBlock::from_declarations(sa.clone(), Importance::Normal));
ApplicableDeclarationBlock::from_declarations(sa.clone(), Importance::Normal));
}
}
@ -429,7 +429,7 @@ impl Stylist {
relations |= AFFECTED_BY_STYLE_ATTRIBUTE;
Push::push(
applicable_declarations,
DeclarationBlock::from_declarations(sa.clone(), Importance::Important));
ApplicableDeclarationBlock::from_declarations(sa.clone(), Importance::Important));
}
}
@ -665,7 +665,7 @@ impl SelectorMap {
reason: MatchingReason,
importance: Importance)
where E: Element<Impl=TheSelectorImpl>,
V: VecLike<DeclarationBlock>
V: VecLike<ApplicableDeclarationBlock>
{
if self.empty {
return
@ -726,7 +726,7 @@ impl SelectorMap {
/// `self` sorted by specifity and source order.
pub fn get_universal_rules<V>(&self,
matching_rules_list: &mut V)
where V: VecLike<DeclarationBlock>
where V: VecLike<ApplicableDeclarationBlock>
{
if self.empty {
return
@ -757,7 +757,7 @@ impl SelectorMap {
where E: Element<Impl=TheSelectorImpl>,
Str: Borrow<BorrowedStr> + Eq + Hash,
BorrowedStr: Eq + Hash,
Vector: VecLike<DeclarationBlock>
Vector: VecLike<ApplicableDeclarationBlock>
{
if let Some(rules) = hash.get(key) {
SelectorMap::get_matching_rules(element,
@ -779,7 +779,7 @@ impl SelectorMap {
reason: MatchingReason,
importance: Importance)
where E: Element<Impl=TheSelectorImpl>,
V: VecLike<DeclarationBlock>
V: VecLike<ApplicableDeclarationBlock>
{
for rule in rules.iter() {
let block = &rule.declarations.mixed_declarations;
@ -868,28 +868,28 @@ pub struct Rule {
// that it matches. Selector contains an owned vector (through
// ComplexSelector) and we want to avoid the allocation.
pub selector: Arc<ComplexSelector<TheSelectorImpl>>,
pub declarations: DeclarationBlock,
pub declarations: ApplicableDeclarationBlock,
}
/// A property declaration together with its precedence among rules of equal specificity so that
/// we can sort them.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Debug, Clone)]
pub struct DeclarationBlock {
pub struct ApplicableDeclarationBlock {
/// Contains declarations of either importance, but only those of self.importance are relevant.
/// Use DeclarationBlock::iter
/// Use ApplicableDeclarationBlock::iter
pub mixed_declarations: Arc<PropertyDeclarationBlock>,
pub importance: Importance,
pub source_order: usize,
pub specificity: u32,
}
impl DeclarationBlock {
impl ApplicableDeclarationBlock {
#[inline]
pub fn from_declarations(declarations: Arc<PropertyDeclarationBlock>,
importance: Importance)
-> Self {
DeclarationBlock {
ApplicableDeclarationBlock {
mixed_declarations: declarations,
importance: importance,
source_order: 0,
@ -897,20 +897,20 @@ impl DeclarationBlock {
}
}
pub fn iter(&self) -> DeclarationBlockIter {
DeclarationBlockIter {
pub fn iter(&self) -> ApplicableDeclarationBlockIter {
ApplicableDeclarationBlockIter {
iter: self.mixed_declarations.declarations.iter(),
importance: self.importance,
}
}
}
pub struct DeclarationBlockIter<'a> {
pub struct ApplicableDeclarationBlockIter<'a> {
iter: slice::Iter<'a, (PropertyDeclaration, Importance)>,
importance: Importance,
}
impl<'a> Iterator for DeclarationBlockIter<'a> {
impl<'a> Iterator for ApplicableDeclarationBlockIter<'a> {
type Item = &'a PropertyDeclaration;
#[inline]
@ -924,7 +924,7 @@ impl<'a> Iterator for DeclarationBlockIter<'a> {
}
}
impl<'a> DoubleEndedIterator for DeclarationBlockIter<'a> {
impl<'a> DoubleEndedIterator for ApplicableDeclarationBlockIter<'a> {
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
while let Some(&(ref declaration, importance)) = self.iter.next_back() {

View file

@ -51,7 +51,7 @@ use style::properties::PropertyDeclarationBlock;
use style::properties::{ComputedValues, parse_style_attribute};
use style::refcell::{Ref, RefCell, RefMut};
use style::selector_impl::ElementExt;
use style::selector_matching::DeclarationBlock;
use style::selector_matching::ApplicableDeclarationBlock;
use style::sink::Push;
use url::Url;
@ -484,7 +484,7 @@ impl<'le> PartialEq for GeckoElement<'le> {
impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, _hints: &mut V)
where V: Push<DeclarationBlock>
where V: Push<ApplicableDeclarationBlock>
{
// FIXME(bholley) - Need to implement this.
}

View file

@ -7,7 +7,7 @@ use selectors::parser::{LocalName, ParserContext, parse_selector_list};
use std::sync::Arc;
use string_cache::Atom;
use style::properties::{Importance, PropertyDeclarationBlock};
use style::selector_matching::{DeclarationBlock, Rule, SelectorMap};
use style::selector_matching::{ApplicableDeclarationBlock, Rule, SelectorMap};
/// Helper method to get some Rules from selector strings.
/// Each sublist of the result contains the Rules for one StyleRule.
@ -18,7 +18,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
.unwrap().into_iter().map(|s| {
Rule {
selector: s.complex_selector.clone(),
declarations: DeclarationBlock {
declarations: ApplicableDeclarationBlock {
mixed_declarations: Arc::new(PropertyDeclarationBlock {
declarations: Vec::new(),
important_count: 0,