Auto merge of #14904 - emilio:non-common-attrs, r=bholley

Allow sharing non-common style affecting attribute selectors.

Something I just noticed while re-reading that code is that we prevent sharing among siblings with different non-common attributes, even though we already have the infra to match those selectors:

```rust
    if !match_same_not_common_style_affecting_attributes_rules(element,
                                                               candidate_element,
                                                               shared_context) {
        miss!(NonCommonAttrRules)
    }
```

<!-- 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/14904)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-01-07 15:28:15 -08:00 committed by GitHub
commit 2225ccd464
2 changed files with 10 additions and 15 deletions

View file

@ -30,6 +30,16 @@ use std::slice::IterMut;
use std::sync::Arc;
use stylist::ApplicableDeclarationBlock;
/// Determines the amount of relations where we're going to share style.
#[inline]
fn relations_are_shareable(relations: &StyleRelations) -> bool {
use selectors::matching::*;
!relations.intersects(AFFECTED_BY_ID_SELECTOR |
AFFECTED_BY_PSEUDO_ELEMENTS | AFFECTED_BY_STATE |
AFFECTED_BY_STYLE_ATTRIBUTE |
AFFECTED_BY_PRESENTATIONAL_HINTS)
}
fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &E)
-> CommonStyleAffectingAttributes {
let mut flags = CommonStyleAffectingAttributes::empty();
@ -72,7 +82,6 @@ pub struct MatchResults {
impl MatchResults {
/// Returns true if the primary rule node is shareable with other nodes.
pub fn primary_is_shareable(&self) -> bool {
use traversal::relations_are_shareable;
relations_are_shareable(&self.relations)
}
}
@ -375,8 +384,6 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
element: &E,
style: &Arc<ComputedValues>,
relations: StyleRelations) {
use traversal::relations_are_shareable;
let parent = match element.parent_element() {
Some(element) => element,
None => {

View file

@ -14,7 +14,6 @@ use matching::{MatchMethods, StyleSharingResult};
use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_SELF};
use selector_parser::RestyleDamage;
use selectors::Element;
use selectors::matching::StyleRelations;
use servo_config::opts;
use std::mem;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
@ -276,17 +275,6 @@ pub trait DomTraversal<N: TNode> : Sync {
fn create_thread_local_context(&self) -> Self::ThreadLocalContext;
}
/// Determines the amount of relations where we're going to share style.
#[inline]
pub fn relations_are_shareable(relations: &StyleRelations) -> bool {
use selectors::matching::*;
!relations.intersects(AFFECTED_BY_ID_SELECTOR |
AFFECTED_BY_PSEUDO_ELEMENTS | AFFECTED_BY_STATE |
AFFECTED_BY_NON_COMMON_STYLE_AFFECTING_ATTRIBUTE_SELECTOR |
AFFECTED_BY_STYLE_ATTRIBUTE |
AFFECTED_BY_PRESENTATIONAL_HINTS)
}
/// Helper for the function below.
fn resolve_style_internal<E, F>(context: &StyleContext<E>, element: E, ensure_data: &F)
-> Option<E>