diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-24 19:53:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-24 19:53:48 -0500 |
commit | 1f323f8848e47b01779de5145dd21d0f74ed16ca (patch) | |
tree | e6255957ec4d4055f033d7f039cf1c6adc3563ad /components/script/layout_wrapper.rs | |
parent | e457d22f81ac0f45c4dc96867162f276de7bd291 (diff) | |
parent | f12af6c8d606f63fbba32e1dc3580f38604da24a (diff) | |
download | servo-1f323f8848e47b01779de5145dd21d0f74ed16ca.tar.gz servo-1f323f8848e47b01779de5145dd21d0f74ed16ca.zip |
Auto merge of #17032 - jryans:stylo-visited, r=emilio
Stylo: visited pseudo-class support
Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1328509
<!-- 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/17032)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r-- | components/script/layout_wrapper.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 5241d01785d..eab6f2fd9c9 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -51,7 +51,7 @@ use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutD use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode}; use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; use selectors::attr::{AttrSelectorOperation, NamespaceConstraint}; -use selectors::matching::{ElementSelectorFlags, MatchingContext}; +use selectors::matching::{ElementSelectorFlags, MatchingContext, RelevantLinkStatus}; use servo_atoms::Atom; use servo_url::ServoUrl; use std::fmt; @@ -680,6 +680,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> { fn match_non_ts_pseudo_class<F>(&self, pseudo_class: &NonTSPseudoClass, _: &mut MatchingContext, + _: &RelevantLinkStatus, _: &mut F) -> bool where F: FnMut(&Self, ElementSelectorFlags), @@ -687,16 +688,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> { match *pseudo_class { // https://github.com/servo/servo/issues/8718 NonTSPseudoClass::Link | - NonTSPseudoClass::AnyLink => unsafe { - match self.as_node().script_type_id() { - // https://html.spec.whatwg.org/multipage/#selector-link - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | - NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => - (*self.element.unsafe_get()).get_attr_val_for_layout(&ns!(), &local_name!("href")).is_some(), - _ => false, - } - }, + NonTSPseudoClass::AnyLink => self.is_link(), NonTSPseudoClass::Visited => false, // FIXME(#15746): This is wrong, we need to instead use extended filtering as per RFC4647 @@ -732,6 +724,20 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> { } #[inline] + fn is_link(&self) -> bool { + unsafe { + match self.as_node().script_type_id() { + // https://html.spec.whatwg.org/multipage/#selector-link + NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | + NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | + NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => + (*self.element.unsafe_get()).get_attr_val_for_layout(&ns!(), &local_name!("href")).is_some(), + _ => false, + } + } + } + + #[inline] fn get_id(&self) -> Option<Atom> { unsafe { (*self.element.id_attribute()).clone() @@ -1187,6 +1193,7 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> { fn match_non_ts_pseudo_class<F>(&self, _: &NonTSPseudoClass, _: &mut MatchingContext, + _: &RelevantLinkStatus, _: &mut F) -> bool where F: FnMut(&Self, ElementSelectorFlags), @@ -1196,6 +1203,11 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> { false } + fn is_link(&self) -> bool { + warn!("ServoThreadSafeLayoutElement::is_link called"); + false + } + fn get_id(&self) -> Option<Atom> { debug!("ServoThreadSafeLayoutElement::get_id called"); None |