Skip to content

script: Fix MouseOver handling - #9715

Merged
bors-servo merged 5 commits into
servo:masterfrom
emilio:mousemove
Mar 3, 2016
Merged

bors-servo merged 5 commits into
servo:masterfrom
emilio:mousemove

Conversation

@emilio

@emilio emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member

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.

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

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

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

Fixes #9705

Review on Reviewable

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify layout and script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 20, 2016
@emilio emilio changed the title layout: Fix MouseOver handling script: Fix MouseOver handling Feb 20, 2016
@emilio

emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member Author

r? @nox or @SimonSapin

@emilio

emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member Author

This implements https://html.spec.whatwg.org/#selector-hover except for the <label> stuff (for which I don't think we have a decent API right now).

I'm going to do a try run just in case this changes some test expectations, but I don't think we do :hover reftests or similar.

@bors-servo: try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 07694bb with merge b28b4dd...

bors-servo pushed a commit that referenced this pull request Feb 20, 2016
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

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9715)
<!-- Reviewable:end -->
@emilio

emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member Author

Also, our mouseover/mouseout semantics aren't the same as gecko's (both with and without this PR).

Check the console output aftermoving the mouse around with a test like this:

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

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

<div id="outer">
  <div id="inner"></div>
</div>

<script>
  [].slice.call(document.querySelectorAll('div')).forEach(function(div) {
    div.addEventListener('mouseover', function(e) {
      console.log('over: ' + this.id + ' ' + e.target.id);
    });

    div.addEventListener('mouseout', function(e) {
      console.log('out: ' + this.id + ' ' + e.target.id);
    });
  })
</script>

I'll try to fix it as a followup.

@emilio

emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member Author

Meh, was easier than what it seemed. Now we're almost consistent with Gecko, at least in that case.

Will try to look at more complex situations, but it seems to me that the logic is right.

@emilio
emilio force-pushed the mousemove branch 2 times, most recently from 57cbaec to 2092704 Compare February 20, 2016 21:04
@emilio

emilio commented Feb 20, 2016

Copy link
Copy Markdown
Member Author

Ok, fixed the last bits of incompatibility with other engines (see https://github.com/servo/servo/pull/9715/files#diff-30a18e04d7e0b66aafdf192e416cad44R836), but still don't know if we have any testing infrastructure for this...

@Ms2ger

Ms2ger commented Feb 21, 2016

Copy link
Copy Markdown
Contributor

You can submit some manual tests to wpt, then we can at least easily compare to other browsers.

@emilio
emilio force-pushed the mousemove branch 3 times, most recently from 4a166fc to afc40f4 Compare February 21, 2016 23:38
@emilio

emilio commented Feb 21, 2016

Copy link
Copy Markdown
Member Author

@Ms2ger Updated, added the test to uievents/order-of-events/mouse-events, let me know if there's a better place :)

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #9738) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 24, 2016
@emilio

emilio commented Feb 24, 2016

Copy link
Copy Markdown
Member Author

Rebased and refactored it to be drastically more performant and legible.

@KiChjang KiChjang removed the S-needs-rebase There are merge conflict errors. label Feb 24, 2016
@emilio

emilio commented Feb 24, 2016

Copy link
Copy Markdown
Member Author

@bors-servo: try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 0f7d806 with merge d9e2dcc...

bors-servo pushed a commit that referenced this pull request Feb 24, 2016
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

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9715)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #9661) made this pull request unmergeable. Please resolve the merge conflicts.

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #9756) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Mar 2, 2016
emilio added 5 commits March 2, 2016 20:01
Now we only query for the topmost node, and apply the hover state to all
of the parent elements.

This fixes things like servo#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 servo#9705
This increases mouseover/out performance drastically on my machine.
@emilio

emilio commented Mar 2, 2016

Copy link
Copy Markdown
Member Author

Rebased it after the flat DL landing.

@emilio emilio removed the S-needs-rebase There are merge conflict errors. label Mar 2, 2016
@mbrubeck

mbrubeck commented Mar 3, 2016

Copy link
Copy Markdown
Contributor

@bors-servo r+

Nice!


Reviewed 1 of 2 files at r3, 2 of 6 files at r6, 4 of 4 files at r7.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 3662491 has been approved by mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 3662491 with merge 056a7cf...

@highfive highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Mar 3, 2016
bors-servo pushed a commit that referenced this pull request Mar 3, 2016
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

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9715)
<!-- Reviewable:end -->
@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 3, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 3662491 into servo:master Mar 3, 2016
@emilio
emilio deleted the mousemove branch March 3, 2016 18:29
bors-servo pushed a commit that referenced this pull request Mar 16, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Mar 17, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Mar 19, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Mar 19, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Mar 19, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Apr 3, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Apr 4, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Apr 4, 2016
Implement Document#elementsFromPoint

Fixes #9859.

I'm trying to implement Document#elementsFromPoint, which I need to reuse the `get_nodes_under_mouse` and `mouse_over` function which have been removed a days ago in #9715. So I added it back while I'm not sure if my implementation is correct. Any advice will be greatly appreciated.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10034)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a:hover doesn't catch hovers of <label> element inside <a>

8 participants