aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_wrapper.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-24 19:53:48 -0500
committerGitHub <noreply@github.com>2017-05-24 19:53:48 -0500
commit1f323f8848e47b01779de5145dd21d0f74ed16ca (patch)
treee6255957ec4d4055f033d7f039cf1c6adc3563ad /components/script/layout_wrapper.rs
parente457d22f81ac0f45c4dc96867162f276de7bd291 (diff)
parentf12af6c8d606f63fbba32e1dc3580f38604da24a (diff)
downloadservo-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.rs34
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