script: Fix MouseOver handling

Now we only query for the topmost node, and apply the hover state to all
of the parent elements.

This fixes things like #9705, where the hover state was applied only to
the children.

This also makes us more conformant with other browsers in the case of
taking in account margins and paddings.

For example, prior to this PR, when your mouse was over the inner
element, in the bottom part, `hover` styles didn't apply to the parent.

```html
<style>
div {
  padding: 10px;
  margin: 10px;
  height: 15px;
  background: blue;
}

div:hover {
  background: red;
}
</style>

<div>
  <div></div>
</div>
```

Fixes #9705
This commit is contained in:
Emilio Cobos Álvarez 2016-02-20 20:19:13 +01:00
parent 9ceda7de50
commit b1f0581637
3 changed files with 22 additions and 21 deletions

View file

@ -107,11 +107,8 @@ impl LayoutRPC for LayoutRPCImpl {
if mouse_over_list.is_empty() {
Err(())
} else {
let response_list =
mouse_over_list.iter()
.map(|metadata| metadata.node.to_untrusted_node_address())
.collect();
Ok(MouseOverResponse(response_list))
let response = mouse_over_list[0].node.to_untrusted_node_address();
Ok(MouseOverResponse(response))
}
}