aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_interface.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-02-20 20:19:13 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-03-02 20:01:41 +0100
commitb1f05816373f5e68ce242e0b1a45a50851f868bb (patch)
tree2eb8c7ddedefb7cb5c1767883836e386a9270795 /components/script/layout_interface.rs
parent9ceda7de509d3dff01a766077011207f94ffadfd (diff)
downloadservo-b1f05816373f5e68ce242e0b1a45a50851f868bb.tar.gz
servo-b1f05816373f5e68ce242e0b1a45a50851f868bb.zip
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
Diffstat (limited to 'components/script/layout_interface.rs')
-rw-r--r--components/script/layout_interface.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs
index 17f553d43e8..4ad7c241f14 100644
--- a/components/script/layout_interface.rs
+++ b/components/script/layout_interface.rs
@@ -106,6 +106,7 @@ pub trait LayoutRPC {
fn node_geometry(&self) -> NodeGeometryResponse;
/// Requests the node containing the point of interest
fn hit_test(&self, point: Point2D<f32>) -> Result<HitTestResponse, ()>;
+ /// Query layout for the topmost node under the mouse.
fn mouse_over(&self, point: Point2D<f32>) -> Result<MouseOverResponse, ()>;
/// Query layout for the resolved value of a given CSS property
fn resolved_style(&self) -> ResolvedStyleResponse;
@@ -139,7 +140,7 @@ pub struct NodeGeometryResponse {
pub client_rect: Rect<i32>,
}
pub struct HitTestResponse(pub UntrustedNodeAddress);
-pub struct MouseOverResponse(pub Vec<UntrustedNodeAddress>);
+pub struct MouseOverResponse(pub UntrustedNodeAddress);
pub struct ResolvedStyleResponse(pub Option<String>);
#[derive(Clone)]