mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Issue 8719: Add basic support for :active selector
This commit is contained in:
parent
80cb0cf821
commit
421c354d44
5 changed files with 63 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue