From e4ffd164495cada2f37741c3ce674d990103c34b Mon Sep 17 00:00:00 2001 From: Peijun Ma Date: Sun, 27 Jan 2019 18:05:37 -0500 Subject: Refactor follow_hyperlink and its callers Now they follow the new spec stated at: https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2 It seems like choosing a browsing context is already done in the follow_hyperlink method, so I have removed the TODO in activation_behavior for HTMLAreaElement. The tests in tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/ pass in release builds, but still don't pass in dev build, since the timeout in tests/wpt/web-platform-tests/html/semantics/links/following-hyperlinks/activation-behavior.window.js seems to be too short for dev builds. Navigating to error page on failed URL parsing is still not implemented. There seem to be potential code duplication in activation_behavior methods for both htmlanchorelement.rs and htmlareaelement.rs, in: let referrer_policy = match self.RelList().Contains("noreferrer".into()) { true => Some(ReferrerPolicy::NoReferrer), false => None, }; I didn't pull them out to a separate function since I don't know where I would put that new function. --- components/script/dom/htmlareaelement.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'components/script/dom/htmlareaelement.rs') diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 32a5e8ef89a..a1cf35a7eeb 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -16,7 +16,7 @@ use crate::dom::event::Event; use crate::dom::eventtarget::EventTarget; use crate::dom::htmlanchorelement::follow_hyperlink; use crate::dom::htmlelement::HTMLElement; -use crate::dom::node::{document_from_node, Node}; +use crate::dom::node::Node; use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use euclid::Point2D; @@ -332,18 +332,10 @@ impl Activatable for HTMLAreaElement { } fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { - // Step 1 - let doc = document_from_node(self); - if !doc.is_fully_active() { - return; - } - // Step 2 - // TODO : We should be choosing a browsing context and navigating to it. - // Step 3 let referrer_policy = match self.RelList().Contains("noreferrer".into()) { true => Some(ReferrerPolicy::NoReferrer), false => None, }; - follow_hyperlink(self.upcast::(), None, referrer_policy); + follow_hyperlink(self.as_element(), None, referrer_policy); } } -- cgit v1.2.3