mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Inline Document::load_anchor_href into its only caller.
This commit is contained in:
parent
40b5c4586e
commit
da88e9ad9f
2 changed files with 10 additions and 12 deletions
|
@ -86,7 +86,7 @@ use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
|||
use ipc_channel::ipc;
|
||||
use layout_interface::{LayoutChan, Msg};
|
||||
use string_cache::{Atom, QualName};
|
||||
use url::{Url, UrlParser};
|
||||
use url::Url;
|
||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||
|
||||
use num::ToPrimitive;
|
||||
|
@ -242,7 +242,6 @@ pub trait DocumentHelpers<'a> {
|
|||
fn disarm_reflow_timeout(self);
|
||||
fn unregister_named_element(self, to_unregister: &Element, id: Atom);
|
||||
fn register_named_element(self, element: &Element, id: Atom);
|
||||
fn load_anchor_href(self, href: DOMString);
|
||||
fn find_fragment_node(self, fragid: DOMString) -> Option<Root<Element>>;
|
||||
fn hit_test(self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress>;
|
||||
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress>;
|
||||
|
@ -464,15 +463,6 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
}
|
||||
|
||||
fn load_anchor_href(self, href: DOMString) {
|
||||
let window = self.window.root();
|
||||
let base_url = window.get_url();
|
||||
let url = UrlParser::new().base_url(&base_url).parse(&href);
|
||||
// FIXME: handle URL parse errors more gracefully.
|
||||
let url = url.unwrap();
|
||||
window.load_url(url);
|
||||
}
|
||||
|
||||
/// Attempt to find a named element in this page's document.
|
||||
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
|
||||
fn find_fragment_node(self, fragid: DOMString) -> Option<Root<Element>> {
|
||||
|
|
|
@ -29,6 +29,8 @@ use std::default::Default;
|
|||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
||||
use url::UrlParser;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLAnchorElement {
|
||||
htmlelement: HTMLElement,
|
||||
|
@ -155,7 +157,13 @@ impl<'a> Activatable for &'a HTMLAnchorElement {
|
|||
value.push_str(&suffix);
|
||||
}
|
||||
debug!("clicked on link to {}", value);
|
||||
doc.r().load_anchor_href(value);
|
||||
|
||||
let window = doc.window();
|
||||
let base_url = window.get_url();
|
||||
let url = UrlParser::new().base_url(&base_url).parse(&value);
|
||||
// FIXME: handle URL parse errors more gracefully.
|
||||
let url = url.unwrap();
|
||||
window.load_url(url);
|
||||
}
|
||||
|
||||
//TODO:https://html.spec.whatwg.org/multipage/#the-a-element
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue