aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-19 18:13:59 -0500
committerbors-servo <metajack+bors@gmail.com>2015-04-19 18:13:59 -0500
commit8b8daa24b8d25c531ea74a70b4b6e25cb3d7d58c (patch)
tree075bee0237ce4c383c2255de8c64f8967a34b15e /components/script/dom
parent9c7c289acae3ea012338a5b25bc50a10e7f7074d (diff)
parent18d465bcd273f4629998b62ba37937878211e81a (diff)
downloadservo-8b8daa24b8d25c531ea74a70b4b6e25cb3d7d58c.tar.gz
servo-8b8daa24b8d25c531ea74a70b4b6e25cb3d7d58c.zip
Auto merge of #5559 - glennw:iframe-focus, r=jdm
<!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5559) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs19
-rw-r--r--components/script/dom/htmlelement.rs5
2 files changed, 16 insertions, 8 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 3fc82215167..aa360edd3a3 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -64,7 +64,7 @@ use dom::window::{Window, WindowHelpers, ReflowReason};
use layout_interface::{HitTestResponse, MouseOverResponse};
use msg::compositor_msg::ScriptListener;
use msg::constellation_msg::Msg as ConstellationMsg;
-use msg::constellation_msg::{ConstellationChan, Key, KeyState, KeyModifiers, MozBrowserEvent};
+use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent};
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
use net_traits::CookieSource::NonHTTP;
use net_traits::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
@@ -216,7 +216,7 @@ pub trait DocumentHelpers<'a> {
fn is_scripting_enabled(self) -> bool;
fn begin_focus_transaction(self);
fn request_focus(self, elem: JSRef<Element>);
- fn commit_focus_transaction(self);
+ fn commit_focus_transaction(self, focus_type: FocusType);
fn title_changed(self);
fn send_title_to_compositor(self);
fn dirty_all_nodes(self);
@@ -460,7 +460,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
/// Reassign the focus context to the element that last requested focus during this
/// transaction, or none if no elements requested it.
- fn commit_focus_transaction(self) {
+ fn commit_focus_transaction(self, focus_type: FocusType) {
//TODO: dispatch blur, focus, focusout, and focusin events
if let Some(ref elem) = self.focused.get().root() {
@@ -473,9 +473,16 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
if let Some(ref elem) = self.focused.get().root() {
let node: JSRef<Node> = NodeCast::from_ref(elem.r());
node.set_focus_state(true);
+
+ // Update the focus state for all elements in the focus chain.
+ // https://html.spec.whatwg.org/multipage/#focus-chain
+ if focus_type == FocusType::Element {
+ let window = self.window.root();
+ let ConstellationChan(ref chan) = window.r().constellation_chan();
+ let event = ConstellationMsg::FocusMsg(window.r().pipeline());
+ chan.send(event).unwrap();
+ }
}
- // TODO: Update the focus state for all elements in the focus chain.
- // https://html.spec.whatwg.org/multipage/#focus-chain
}
/// Handles any updates when the document's title has changed.
@@ -555,7 +562,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
// https://html.spec.whatwg.org/multipage/#run-authentic-click-activation-steps
el.r().authentic_click_activation(event);
- self.commit_focus_transaction();
+ self.commit_focus_transaction(FocusType::Element);
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::MouseEvent);
}
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 84f1d698cdf..68c097158dc 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -28,6 +28,7 @@ use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_n
use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
+use msg::constellation_msg::FocusType;
use util::str::DOMString;
use string_cache::Atom;
@@ -145,7 +146,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
let document = document.r();
document.begin_focus_transaction();
document.request_focus(element);
- document.commit_focus_transaction();
+ document.commit_focus_transaction(FocusType::Element);
}
// https://html.spec.whatwg.org/multipage/#dom-blur
@@ -159,7 +160,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
let document = document_from_node(self).root();
document.r().begin_focus_transaction();
// If `request_focus` is not called, focus will be set to None.
- document.r().commit_focus_transaction();
+ document.r().commit_focus_transaction(FocusType::Element);
}
}