mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
Don't match native anonymous content to user/author rules.
This commit is contained in:
parent
210b1be1d0
commit
22b62e0913
5 changed files with 83 additions and 60 deletions
|
@ -28,6 +28,7 @@ use gecko_bindings::bindings::Gecko_StoreStyleDifference;
|
|||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
||||
use gecko_bindings::structs::{nsIAtom, nsIContent, nsStyleContext};
|
||||
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
|
||||
use parking_lot::RwLock;
|
||||
use parser::ParserContextExtraData;
|
||||
use properties::{ComputedValues, parse_style_attribute};
|
||||
|
@ -624,4 +625,9 @@ impl<'le> ElementExt for GeckoElement<'le> {
|
|||
fn is_link(&self) -> bool {
|
||||
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn matches_user_and_author_rules(&self) -> bool {
|
||||
self.flags() & (NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE as u32) == 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ pub enum CacheMiss {
|
|||
LocalName,
|
||||
Namespace,
|
||||
Link,
|
||||
UserAndAuthorRules,
|
||||
State,
|
||||
IdAttr,
|
||||
StyleAttr,
|
||||
|
@ -143,6 +144,10 @@ fn element_matches_candidate<E: TElement>(element: &E,
|
|||
miss!(Link)
|
||||
}
|
||||
|
||||
if element.matches_user_and_author_rules() != candidate_element.matches_user_and_author_rules() {
|
||||
miss!(UserAndAuthorRules)
|
||||
}
|
||||
|
||||
if element.get_state() != candidate_element.get_state() {
|
||||
miss!(State)
|
||||
}
|
||||
|
|
|
@ -101,6 +101,8 @@ impl PseudoElementCascadeType {
|
|||
|
||||
pub trait ElementExt: Element<Impl=SelectorImpl> {
|
||||
fn is_link(&self) -> bool;
|
||||
|
||||
fn matches_user_and_author_rules(&self) -> bool;
|
||||
}
|
||||
|
||||
impl SelectorImpl {
|
||||
|
|
|
@ -398,4 +398,9 @@ impl<E: Element<Impl=SelectorImpl>> ElementExt for E {
|
|||
fn is_link(&self) -> bool {
|
||||
self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn matches_user_and_author_rules(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ impl Stylist {
|
|||
pseudo: &PseudoElement,
|
||||
parent: &Arc<ComputedValues>)
|
||||
-> Option<(Arc<ComputedValues>, StrongRuleNode)>
|
||||
where E: Element<Impl=SelectorImpl> +
|
||||
where E: ElementExt +
|
||||
fmt::Debug +
|
||||
PresentationalHintsSynthetizer
|
||||
{
|
||||
|
@ -418,7 +418,7 @@ impl Stylist {
|
|||
pseudo_element: Option<&PseudoElement>,
|
||||
applicable_declarations: &mut V,
|
||||
reason: MatchingReason) -> StyleRelations
|
||||
where E: Element<Impl=SelectorImpl> +
|
||||
where E: ElementExt +
|
||||
fmt::Debug +
|
||||
PresentationalHintsSynthetizer,
|
||||
V: Push<ApplicableDeclarationBlock> + VecLike<ApplicableDeclarationBlock>
|
||||
|
@ -456,6 +456,7 @@ impl Stylist {
|
|||
}
|
||||
debug!("preshints: {:?}", relations);
|
||||
|
||||
if element.matches_user_and_author_rules() {
|
||||
// Step 3: User and author normal rules.
|
||||
map.user.get_all_matching_rules(element,
|
||||
parent_bf,
|
||||
|
@ -506,7 +507,7 @@ impl Stylist {
|
|||
|
||||
debug!("style attr important: {:?}", relations);
|
||||
|
||||
// Step 7: User and UA `!important` rules.
|
||||
// Step 7: User `!important` rules.
|
||||
map.user.get_all_matching_rules(element,
|
||||
parent_bf,
|
||||
applicable_declarations,
|
||||
|
@ -515,7 +516,11 @@ impl Stylist {
|
|||
Importance::Important);
|
||||
|
||||
debug!("user important: {:?}", relations);
|
||||
} else {
|
||||
debug!("skipping non-agent rules");
|
||||
}
|
||||
|
||||
// Step 8: UA `!important` rules.
|
||||
map.user_agent.get_all_matching_rules(element,
|
||||
parent_bf,
|
||||
applicable_declarations,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue