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

Clean up HTMLImageElement::handle_event #17632

Merged
merged 1 commit into from
Jul 7, 2017
Merged

Clean up HTMLImageElement::handle_event #17632

merged 1 commit into from
Jul 7, 2017

Conversation

omakk
Copy link
Contributor

@omakk omakk commented Jul 7, 2017

Reflects desired changes in #15832

Cleans up HTMLImageElement::handle_event located in components/script/dom/htmlimageelement.rs



This change is Reviewable

@highfive
Copy link

highfive commented Jul 7, 2017

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @jdm (or someone else) soon.

@highfive
Copy link

highfive commented Jul 7, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmlareaelement.rs, components/script/dom/htmlimageelement.rs
  • @KiChjang: components/script/dom/htmlareaelement.rs, components/script/dom/htmlimageelement.rs

@highfive
Copy link

highfive commented Jul 7, 2017

warning Warning warning

  • These commits modify 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 Jul 7, 2017
let shape = element.get_shape_from_coords();
let shp = match shape {
Some(x) => x.absolute_coords(bcr_p),
None => return,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to align the => on both lines; the preferred style is None => return, for all of the similar lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make the change now

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jul 7, 2017
@jdm
Copy link
Member

jdm commented Jul 7, 2017

Also, it appears that ./mach test-unit -p script now fails:

   Compiling script_tests v0.0.1 (file:///C:/projects/servo/tests/unit/script)
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:103:28
    |
103 |    assert!(!circ1.hit_test(Point2D::new(10.0, 20.0)));
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 20.0)`
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:105:27
    |
105 |    assert!(circ2.hit_test(Point2D::new(10.0, 12.0)));
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 12.0)`
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:111:28
    |
111 |    assert!(!rect1.hit_test(Point2D::new(10.0, 5.0)));
    |                            ^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 5.0)`
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:113:27
    |
113 |    assert!(rect2.hit_test(Point2D::new(10.0, 12.0)));
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 12.0)`
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:119:28
    |
119 |    assert!(!poly1.hit_test(Point2D::new(10.0, 5.0)));
    |                            ^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 5.0)`
error[E0308]: mismatched types
   --> C:\projects\servo\tests\unit\script\htmlareaelement.rs:121:28
    |
121 |    assert!(!poly2.hit_test(Point2D::new(10.0, 5.0)));
    |                            ^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found struct `euclid::TypedPoint2D`
    |
    = note: expected type `&euclid::TypedPoint2D<f32, euclid::UnknownUnit>`
               found type `euclid::TypedPoint2D<{float}, euclid::UnknownUnit>`
    = help: try with `&Point2D::new(10.0, 5.0)`
error: aborting due to previous error(s)
error: Could not compile `script_tests`.

@omakk
Copy link
Contributor Author

omakk commented Jul 7, 2017

Yea, Area::hit_test now takes a reference making the test fail. Should I get rid of that change?

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Jul 7, 2017
@jdm
Copy link
Member

jdm commented Jul 7, 2017

No, you can update the tests to accommodate it instead.

@omakk
Copy link
Contributor Author

omakk commented Jul 7, 2017

Hopefully that should do it. Thanks for the help @jdm !

@jdm
Copy link
Member

jdm commented Jul 7, 2017

This looks good! Could you squash the commits into one before we merge this?

@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. S-fails-travis labels Jul 7, 2017
Clean up HTMLImageElement::handle_event

Area::hit_test now uses a reference instead of taking ownership

Fix trailing whitespace

Unalign => in match

Fix Area::hit_test tests to reflect updated function signature
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 7, 2017
@omakk
Copy link
Contributor Author

omakk commented Jul 7, 2017

Done!

@jdm
Copy link
Member

jdm commented Jul 7, 2017

@bors-servo: r+
Thanks!

@bors-servo
Copy link
Contributor

📌 Commit 420a787 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jul 7, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 420a787 with merge 6e2e715...

bors-servo pushed a commit that referenced this pull request Jul 7, 2017
Clean up HTMLImageElement::handle_event

Reflects desired changes in #15832

<!-- Please describe your changes on the following line: -->
Cleans up `HTMLImageElement::handle_event` located in `components/script/dom/htmlimageelement.rs`

---
<!-- 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 #15832

- [X] These changes do not require tests because this change maintains the same logic

<!-- 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/17632)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing 6e2e715 to master...

@bors-servo bors-servo merged commit 420a787 into servo:master Jul 7, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up un-idiomatic code in HTMLImageElement::handle_event
4 participants