diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs
index af019fb88c5..a5e9fb10947 100644
--- a/components/script/dom/htmlanchorelement.rs
+++ b/components/script/dom/htmlanchorelement.rs
@@ -6,7 +6,7 @@ use std::cell::Cell;
use std::default::Default;
use dom_struct::dom_struct;
-use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
+use html5ever::{local_name, LocalName, Prefix};
use js::rust::HandleObject;
use num_traits::ToPrimitive;
use servo_atoms::Atom;
@@ -28,10 +28,10 @@ use crate::dom::element::{reflect_referrer_policy_attribute, AttributeMutation,
use crate::dom::event::Event;
use crate::dom::eventtarget::EventTarget;
use crate::dom::htmlelement::HTMLElement;
+use crate::dom::htmlhyperlinkelementutils::{HyperlinkElement, HyperlinkElementTraits};
use crate::dom::htmlimageelement::HTMLImageElement;
use crate::dom::mouseevent::MouseEvent;
-use crate::dom::node::{BindContext, Node, NodeTraits};
-use crate::dom::urlhelper::UrlHelper;
+use crate::dom::node::{BindContext, Node};
use crate::dom::virtualmethods::VirtualMethods;
use crate::links::{follow_hyperlink, LinkRelations};
use crate::script_runtime::CanGc;
@@ -40,7 +40,6 @@ use crate::script_runtime::CanGc;
pub(crate) struct HTMLAnchorElement {
htmlelement: HTMLElement,
rel_list: MutNullableDom,
-
#[no_trace]
relations: Cell,
#[no_trace]
@@ -78,48 +77,11 @@ impl HTMLAnchorElement {
can_gc,
)
}
+}
- ///
- fn set_url(&self) {
- // Step 1. Set this element's url to null.
- *self.url.borrow_mut() = None;
-
- // Step 2. If this element's href content attribute is absent, then return.
- let attribute = self
- .upcast::()
- .get_attribute(&ns!(), &local_name!("href"));
-
- let Some(attribute) = attribute else {
- return;
- };
-
- // Step 3. Let url be the result of encoding-parsing a URL given this element's
- // href content attribute's value, relative to this element's node document.
- let document = self.owner_document();
- let url = document.encoding_parse_a_url(&attribute.value());
-
- // Step 4. If url is not failure, then set this element's url to url.
- if let Ok(url) = url {
- *self.url.borrow_mut() = Some(url);
- }
- }
-
- // https://html.spec.whatwg.org/multipage/#reinitialise-url
- fn reinitialize_url(&self) {
- // Step 1.
- match *self.url.borrow() {
- Some(ref url) if url.scheme() == "blob" && url.cannot_be_a_base() => return,
- _ => (),
- }
-
- // Step 2.
- self.set_url();
- }
-
- // https://html.spec.whatwg.org/multipage/#update-href
- fn update_href(&self, url: DOMString, can_gc: CanGc) {
- self.upcast::()
- .set_string_attribute(&local_name!("href"), url, can_gc);
+impl HyperlinkElement for HTMLAnchorElement {
+ fn get_url(&self) -> &DomRefCell