mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Simplify some code in handle_click_event.
This commit is contained in:
parent
c4b93d30e4
commit
a1d21d4c5e
1 changed files with 5 additions and 6 deletions
|
@ -1107,14 +1107,14 @@ impl ScriptTask {
|
||||||
node::from_untrusted_node_address(
|
node::from_untrusted_node_address(
|
||||||
self.js_runtime.ptr, node_address).root();
|
self.js_runtime.ptr, node_address).root();
|
||||||
|
|
||||||
let maybe_node = if !temp_node.is_element() {
|
let maybe_node = match ElementCast::to_ref(*temp_node) {
|
||||||
temp_node.ancestors().find(|node| node.is_element())
|
Some(element) => Some(element),
|
||||||
} else {
|
None => temp_node.ancestors().filter_map(ElementCast::to_ref).next(),
|
||||||
Some(*temp_node)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match maybe_node {
|
match maybe_node {
|
||||||
Some(node) => {
|
Some(el) => {
|
||||||
|
let node = NodeCast::from_ref(el);
|
||||||
debug!("clicked on {:s}", node.debug_str());
|
debug!("clicked on {:s}", node.debug_str());
|
||||||
// Prevent click event if form control element is disabled.
|
// Prevent click event if form control element is disabled.
|
||||||
if node.click_event_filter_by_disabled_state() { return; }
|
if node.click_event_filter_by_disabled_state() { return; }
|
||||||
|
@ -1132,7 +1132,6 @@ impl ScriptTask {
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events
|
||||||
event.set_trusted(true);
|
event.set_trusted(true);
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
||||||
let el = ElementCast::to_ref(node).unwrap(); // is_element() check already exists above
|
|
||||||
el.authentic_click_activation(*event);
|
el.authentic_click_activation(*event);
|
||||||
|
|
||||||
doc.commit_focus_transaction();
|
doc.commit_focus_transaction();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue