diff options
author | Steve Melia <steve.j.melia@gmail.com> | 2016-06-17 22:59:05 +0100 |
---|---|---|
committer | Steve Melia <steve.j.melia@gmail.com> | 2016-07-04 22:24:13 +0100 |
commit | 421c354d44f93ff8f52affde1b595f4e14b9ed27 (patch) | |
tree | 2a6410c9ea876fdbaece5dcb80de83f1add62592 /components/script/dom/activation.rs | |
parent | 80cb0cf8214fd52d2884724614c40cb278ee7575 (diff) | |
download | servo-421c354d44f93ff8f52affde1b595f4e14b9ed27.tar.gz servo-421c354d44f93ff8f52affde1b595f4e14b9ed27.zip |
Issue 8719: Add basic support for :active selector
Diffstat (limited to 'components/script/dom/activation.rs')
-rw-r--r-- | components/script/dom/activation.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs index ff8d59aac96..5c59393f766 100644 --- a/components/script/dom/activation.rs +++ b/components/script/dom/activation.rs @@ -10,6 +10,9 @@ use dom::event::{Event, EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; use dom::mouseevent::MouseEvent; use dom::node::window_from_node; +use dom::window::ReflowReason; +use script_layout_interface::message::ReflowQueryType; +use style::context::ReflowGoal; /// Trait for elements with defined activation behavior pub trait Activatable { @@ -29,6 +32,25 @@ pub trait Activatable { // https://html.spec.whatwg.org/multipage/#implicit-submission fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool); + + // https://html.spec.whatwg.org/multipage/#concept-selector-active + fn enter_formal_activation_state(&self) { + self.as_element().set_active_state(true); + + let win = window_from_node(self.as_element()); + win.reflow(ReflowGoal::ForDisplay, + ReflowQueryType::NoQuery, + ReflowReason::ElementStateChanged); + } + + fn exit_formal_activation_state(&self) { + self.as_element().set_active_state(false); + + let win = window_from_node(self.as_element()); + win.reflow(ReflowGoal::ForDisplay, + ReflowQueryType::NoQuery, + ReflowReason::ElementStateChanged); + } } /// Whether an activation was initiated via the click() method |