aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-04 18:21:48 -0600
committerbors-servo <metajack+bors@gmail.com>2015-04-04 18:21:48 -0600
commitb63fb0c0a7e9cd9208d66319c910750aaaac844c (patch)
tree730bee60cc0d1a43e248f5a60d2c8616e22fdf48 /components/script/dom/node.rs
parent8758d7d11abd3a0e84e2af5c41911b767723513e (diff)
parent791fa3757dd11b53c9ef7ef112f460675eddea17 (diff)
downloadservo-b63fb0c0a7e9cd9208d66319c910750aaaac844c.tar.gz
servo-b63fb0c0a7e9cd9208d66319c910750aaaac844c.zip
auto merge of #5461 : mbrubeck/servo/focus, r=jdm
Fixes #5460. This supports for simple focusable elements that are their own DOM anchors, like text `input` fields. Requires servo/rust-selectors#20. r? @SimonSapin
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index a302308d33a..f9b81cad136 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -152,6 +152,8 @@ bitflags! {
#[doc = "Specifies whether or not there is an authentic click in progress on \
this element."]
const CLICK_IN_PROGRESS = 0x100,
+ #[doc = "Specifies whether this node has the focus."]
+ const IN_FOCUS_STATE = 0x200,
}
}
@@ -440,6 +442,9 @@ pub trait NodeHelpers<'a> {
fn get_hover_state(self) -> bool;
fn set_hover_state(self, state: bool);
+ fn get_focus_state(self) -> bool;
+ fn set_focus_state(self, state: bool);
+
fn get_disabled_state(self) -> bool;
fn set_disabled_state(self, state: bool);
@@ -618,6 +623,14 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
self.set_flag(IN_HOVER_STATE, state)
}
+ fn get_focus_state(self) -> bool {
+ self.get_flag(IN_FOCUS_STATE)
+ }
+
+ fn set_focus_state(self, state: bool) {
+ self.set_flag(IN_FOCUS_STATE, state)
+ }
+
fn get_disabled_state(self) -> bool {
self.get_flag(IN_DISABLED_STATE)
}
@@ -1036,6 +1049,8 @@ pub trait RawLayoutNodeHelpers {
#[allow(unsafe_code)]
unsafe fn get_hover_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
+ unsafe fn get_focus_state_for_layout(&self) -> bool;
+ #[allow(unsafe_code)]
unsafe fn get_disabled_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_enabled_state_for_layout(&self) -> bool;
@@ -1050,6 +1065,11 @@ impl RawLayoutNodeHelpers for Node {
}
#[inline]
#[allow(unsafe_code)]
+ unsafe fn get_focus_state_for_layout(&self) -> bool {
+ self.flags.get().contains(IN_FOCUS_STATE)
+ }
+ #[inline]
+ #[allow(unsafe_code)]
unsafe fn get_disabled_state_for_layout(&self) -> bool {
self.flags.get().contains(IN_DISABLED_STATE)
}