aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-03-01 22:18:49 -0700
committerbors-servo <metajack+bors@gmail.com>2015-03-01 22:18:49 -0700
commitfed878710c5697b49ccf5185ebe08a58be27073f (patch)
tree09274f1134407a6a5d2b0ef4c8bcaa98bed5a5da /components/script/dom
parent154427ce51cf06b54940f84895d8f42aca79e2c2 (diff)
parent83f56ed0610bd1fc3494b4f9e78866ef583be6dc (diff)
downloadservo-fed878710c5697b49ccf5185ebe08a58be27073f.tar.gz
servo-fed878710c5697b49ccf5185ebe08a58be27073f.zip
auto merge of #5111 : KiChjang/servo/step-1-anchor, r=Manishearth
Fixes #4871
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs16
-rw-r--r--components/script/dom/htmlanchorelement.rs7
2 files changed, 21 insertions, 2 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index d33e223bde5..6e5413ebdc8 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -189,6 +189,7 @@ pub trait DocumentHelpers<'a> {
fn window(self) -> Temporary<Window>;
fn encoding_name(self) -> Ref<'a, DOMString>;
fn is_html_document(self) -> bool;
+ fn is_fully_active(self) -> bool;
fn url(self) -> Url;
fn quirks_mode(self) -> QuirksMode;
fn set_quirks_mode(self, mode: QuirksMode);
@@ -232,6 +233,21 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
self.is_html_document
}
+ // https://html.spec.whatwg.org/multipage/browsers.html#fully-active
+ fn is_fully_active(self) -> bool {
+ let window = self.window.root();
+ let window = window.r();
+ let browser_context = window.browser_context();
+ let browser_context = browser_context.as_ref().unwrap();
+ let active_document = browser_context.active_document().root();
+
+ if self.clone() != active_document.r() {
+ return false;
+ }
+ // FIXME: It should also check whether the browser context is top-level or not
+ true
+ }
+
// http://dom.spec.whatwg.org/#dom-document-url
fn url(self) -> Url {
self.url.clone()
diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs
index 8d427528aba..0856aae3c80 100644
--- a/components/script/dom/htmlanchorelement.rs
+++ b/components/script/dom/htmlanchorelement.rs
@@ -113,7 +113,11 @@ impl<'a> Activatable for JSRef<'a, HTMLAnchorElement> {
//https://html.spec.whatwg.org/multipage/semantics.html#the-a-element:activation-behaviour
fn activation_behavior(&self) {
- //TODO: Step 1. If the node document is not fully active, abort.
+ //Step 1. If the node document is not fully active, abort.
+ let doc = document_from_node(*self).root();
+ if !doc.r().is_fully_active() {
+ return;
+ }
//TODO: Step 2. Check if browsing context is specified and act accordingly.
//TODO: Step 3. Handle <img ismap/>.
//TODO: Step 4. Download the link is `download` attribute is set.
@@ -123,7 +127,6 @@ impl<'a> Activatable for JSRef<'a, HTMLAnchorElement> {
Some(ref href) => {
let value = href.r().Value();
debug!("clicked on link to {}", value);
- let doc = document_from_node(*self).root();
doc.r().load_anchor_href(value);
}
None => ()