mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Look for relevant links while matching
Adjust the matching process to look for a "relevant link" while matching. A "relevant link" is the element being matched if it is a link or the nearest ancestor link. Matching for links now depends on the `VisitedHandlingMode`, which determines whether all links match as if they are unvisited (the default) or if the relevant link matches as visited (and all others remain unvisited). If a relevant link is ever found for any selector, track this as part of the `MatchingContext` object. This is used in the next patch to determine if an additional match and cascade should be performed to compute the styles when visited. MozReview-Commit-ID: 3xUbRo7vpuD
This commit is contained in:
parent
8ae546f7ea
commit
e3a256803d
8 changed files with 197 additions and 55 deletions
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Traits that nodes must implement. Breaks the otherwise-cyclic dependency between layout and
|
||||
//! style.
|
||||
//! Traits that nodes must implement. Breaks the otherwise-cyclic dependency
|
||||
//! between layout and style.
|
||||
|
||||
use attr::{AttrSelectorOperation, NamespaceConstraint};
|
||||
use matching::{ElementSelectorFlags, MatchingContext};
|
||||
use matching::{ElementSelectorFlags, MatchingContext, RelevantLinkStatus};
|
||||
use parser::SelectorImpl;
|
||||
|
||||
pub trait Element: Sized {
|
||||
|
@ -50,6 +50,7 @@ pub trait Element: Sized {
|
|||
fn match_non_ts_pseudo_class<F>(&self,
|
||||
pc: &<Self::Impl as SelectorImpl>::NonTSPseudoClass,
|
||||
context: &mut MatchingContext,
|
||||
relevant_link: &RelevantLinkStatus,
|
||||
flags_setter: &mut F) -> bool
|
||||
where F: FnMut(&Self, ElementSelectorFlags);
|
||||
|
||||
|
@ -58,6 +59,9 @@ pub trait Element: Sized {
|
|||
context: &mut MatchingContext)
|
||||
-> bool;
|
||||
|
||||
/// Whether this element is a `link`.
|
||||
fn is_link(&self) -> bool;
|
||||
|
||||
fn get_id(&self) -> Option<<Self::Impl as SelectorImpl>::Identifier>;
|
||||
|
||||
fn has_class(&self, name: &<Self::Impl as SelectorImpl>::ClassName) -> bool;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue