Reindent handle_click_event.

This commit is contained in:
Ms2ger 2015-02-21 18:02:40 +01:00
parent 0be6389158
commit 957c89b101

View file

@ -397,34 +397,42 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
let window = self.window.root();
let window = window.r();
let page = window.page();
match page.hit_test(&point) {
let node = match page.hit_test(&point) {
Some(node_address) => {
debug!("node address is {:?}", node_address.0);
node::from_untrusted_node_address(js_runtime, node_address)
},
None => return,
}.root();
let temp_node =
node::from_untrusted_node_address(
js_runtime, node_address).root();
let maybe_elem: Option<JSRef<Element>> = ElementCast::to_ref(temp_node.r());
let maybe_node = match maybe_elem {
Some(element) => Some(element),
None => temp_node.r().ancestors().filter_map(ElementCast::to_ref).next(),
let el = match ElementCast::to_ref(node.r()) {
Some(el) => el,
None => {
let ancestor = node.r()
.ancestors()
.filter_map(ElementCast::to_ref)
.next();
match ancestor {
Some(ancestor) => ancestor,
None => return,
}
},
};
match maybe_node {
Some(el) => {
let node: JSRef<Node> = NodeCast::from_ref(el);
debug!("clicked on {:?}", node.debug_str());
// 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;
}
match *page.frame() {
Some(ref frame) => {
let window = frame.window.root();
let doc = window.r().Document().root();
doc.r().begin_focus_transaction();
let event =
Event::new(GlobalRef::Window(window.r()),
let event = Event::new(GlobalRef::Window(window.r()),
"click".to_owned(),
EventBubbles::Bubbles,
EventCancelable::Cancelable).root();
@ -439,13 +447,6 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
None => {}
}
}
None => {}
}
}
None => {}
}
}
}
#[derive(PartialEq)]