mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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.
This commit is contained in:
parent
62ff032130
commit
e4ffd16449
2 changed files with 16 additions and 24 deletions
|
@ -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::<Element>(), None, referrer_policy);
|
||||
follow_hyperlink(self.as_element(), None, referrer_policy);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue