Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MouseEvent buttons attribute #23249

Merged
merged 1 commit into from May 16, 2019
Merged

Conversation

@georgeroman
Copy link
Contributor

georgeroman commented Apr 23, 2019


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #22884

This change is Reviewable

@highfive
Copy link

highfive commented Apr 23, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/MouseEvent.webidl, components/constellation/constellation.rs, components/script/dom/mouseevent.rs
  • @cbrewster: components/constellation/constellation.rs
  • @paulrouget: components/constellation/constellation.rs
  • @KiChjang: components/script/dom/webidls/MouseEvent.webidl, components/script_traits/lib.rs, components/script/dom/mouseevent.rs
@highfive
Copy link

highfive commented Apr 23, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@georgeroman
Copy link
Contributor Author

georgeroman commented Apr 23, 2019

I have a question regarding the next steps.
So the MouseEvent needs to have access to the bitmask representing the currently pressed buttons. I could send this information directly in the MouseButtonEvent and MouseMoveEvent but in this case the mouse event triggered by a synthetic click won't have access to it, as it's created on the spot. So the only way to access it is by communicating directly with the constellation. Is this the proper way to it?

@jdm
Copy link
Member

jdm commented Apr 23, 2019

@georgeroman I think synthetic clicks should be treated differently, like whatwg/html#4452 describes. I would expect a synthetic click to produce an event that only claims to have a left mouse button active.

@georgeroman georgeroman changed the title [WIP] Implement MouseEvent buttons attribute Implement MouseEvent buttons attribute Apr 25, 2019
@jdm
Copy link
Member

jdm commented Apr 30, 2019

@highfive highfive assigned Manishearth and unassigned emilio Apr 30, 2019
Copy link
Member

Manishearth left a comment

Looks good! I can't find how right/aux events get triggered, though. Do we just not support those yet?

),
/// The mouse was moved over a point (or was moved out of the recognizable region).
MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>),
MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>, u16),

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 30, 2019

Member

leave an inline comment on the u16 saying it's a button mask of MouseButton values

(or mention this in the doc comment)

@@ -701,7 +702,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let results = self.hit_test_at_point(cursor);
if let Some(item) = results.items.first() {
let node_address = Some(UntrustedNodeAddress(item.tag.0 as *const c_void));
let event = MouseMoveEvent(Some(item.point_in_viewport.to_untyped()), node_address);
let event = MouseMoveEvent(Some(item.point_in_viewport.to_untyped()), node_address, 0);

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 30, 2019

Member

Can you use MouseButton::Left as u16 so it's clear what the zero means?

@@ -658,6 +658,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
result.point_in_viewport.to_untyped(),
Some(UntrustedNodeAddress(result.tag.0 as *const c_void)),
Some(result.point_relative_to_item.to_untyped()),
0,

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 30, 2019

Member

MouseButton::Left as u16

Right,
Right = 2,
/// The middle mouse button.
Middle = 4,

This comment has been minimized.

Copy link
@KwanEsq

KwanEsq Apr 30, 2019

Contributor

Shouldn't this use a new MouseButtonMask enum (or something), rather than mangling this one?

This comment has been minimized.

Copy link
@georgeroman

georgeroman May 2, 2019

Author Contributor

I could add a new enum for this purpose, but it would be exactly the same as this one since MouseButtonEvent (which I use for updating the buttons bitmask) stores the button that triggered the event as a MouseButton.

This comment has been minimized.

Copy link
@KwanEsq

KwanEsq May 2, 2019

Contributor

Then don't alter the values of this enum, just map them ala MouseButton::Left => 1 etc.

@KwanEsq
Copy link
Contributor

KwanEsq commented Apr 30, 2019

Hmm, I guess to make comments on code show up in the conversation I have to "start a review" rather than "add single comment"? (Which I don't feel qualified for)
But I would like to highlight my comment. The existing MouseButton enum seems clearly to be for the button attribute (which has very different button->value mappings to the buttons attribute), so it seems like this PR should add and use a new enum.

Edit: okay, now my comment appears here, it just took a while.

@georgeroman
Copy link
Contributor Author

georgeroman commented May 3, 2019

@Manishearth I also noticed that all mouse events have MouseButton::Left as triggering button, so probably the other buttons are not supported yet.

@KwanEsq
Copy link
Contributor

KwanEsq commented May 3, 2019

Ah yeah, I should have mentioned that as well. Middle-button isn't supported at all, and right-button is incorrectly reported as MouseButton::Left (zero). I was experimenting with implementing them, and the auxclick event. Though given none of the wpt mouse event tests run yet because testdriver isn't yet supported (Support Webdriver based tests project), I wasn't sure about submitting it yet.

@Manishearth
Copy link
Member

Manishearth commented May 9, 2019

@bors-servo
Copy link
Contributor

bors-servo commented May 9, 2019

📌 Commit fd3b4e2 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 10, 2019

Testing commit fd3b4e2 with merge 2872ffb...

bors-servo added a commit that referenced this pull request May 10, 2019
…nishearth

Implement MouseEvent buttons attribute

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22884

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23249)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 10, 2019

💔 Test failed - linux-rel-css

@CYBAI
Copy link
Collaborator

CYBAI commented May 10, 2019

{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "MouseEvent interface: attribute buttons", 
    "test": "/uievents/idlharness.window.html", 
    "line": 257471, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "MouseEvent interface: new MouseEvent(\"event\") must inherit property \"buttons\" with the proper type", 
    "test": "/uievents/idlharness.window.html", 
    "line": 257485, 
    "action": "test_result", 
    "expected": "FAIL"
}
@ferjm
Copy link
Member

ferjm commented May 16, 2019

@bors-servo retry

@CYBAI
Copy link
Collaborator

CYBAI commented May 16, 2019

Due to force-pushed, maybe we need to r+ (or maybe r=Manishearth) again 👀 (sorry I can only help to try 😭)

@ferjm
Copy link
Member

ferjm commented May 16, 2019

@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2019

📌 Commit be3cb00 has been approved by ferjm

@ferjm
Copy link
Member

ferjm commented May 16, 2019

@bors-servo r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2019

💡 This pull request was already approved, no need to approve it again.

  • There's another pull request that is currently being tested, blocking this pull request: #23403
@highfive highfive assigned Manishearth and unassigned ferjm May 16, 2019
@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2019

📌 Commit be3cb00 has been approved by Manishearth

bors-servo added a commit that referenced this pull request May 16, 2019
…nishearth

Implement MouseEvent buttons attribute

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22884

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23249)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2019

Testing commit be3cb00 with merge 3a5ebb1...

@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2019

☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster
Approved by: Manishearth
Pushing 3a5ebb1 to master...

@bors-servo bors-servo merged commit be3cb00 into servo:master May 16, 2019
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

9 participants
You can’t perform that action at this time.