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

Prefer auto-generation for some keyword props #13902

Merged
merged 4 commits into from Oct 26, 2016

Conversation

wafflespeanut
Copy link
Contributor

@wafflespeanut wafflespeanut commented Oct 24, 2016


  • ./mach build-geckolib does not report any errors
  • These changes do not require tests because it's a refactor

r? @Manishearth or @emilio


This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/properties/longhand/font.mako.rs, components/style/properties/longhand/inherited_box.mako.rs, components/style/properties/data.py
  • @emilio: components/style/properties/gecko.mako.rs, components/style/properties/longhand/font.mako.rs, components/style/properties/longhand/inherited_box.mako.rs, components/style/properties/data.py

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 24, 2016
@highfive
Copy link

warning Warning warning

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

// And, firefox doesn't support 'pixelated' (https://bugzilla.mozilla.org/show_bug.cgi?id=856337)
${helpers.single_keyword("image-rendering",
"auto crispedges",
extra_gecko_values="optimizequality optimizespeed",
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be manual, since the serialization is custom, and there's some aliasing going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, yeah, the problem lies in crisp-edges. I'll better add an option for that in python.

@Manishearth
Copy link
Member

r? @emilio

@highfive highfive assigned emilio and unassigned Manishearth Oct 24, 2016
@wafflespeanut wafflespeanut 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 Oct 24, 2016
@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 Oct 25, 2016
@wafflespeanut
Copy link
Contributor Author

wafflespeanut commented Oct 25, 2016

@emilio The parsing/serialization code for image-rendering is there only for the sake of a gecko constant. It's CRISPEDGES in gecko, whereas we expect it to be CRISP_EDGES. So, I've added a tiny patch to ignore hyphens for such cases.

# This is a workaround for gecko constants with unexpected names i.e., a constant
# corresponding to a keyword 'foo-bar' declared as FOOBAR instead of FOO_BAR
if self.keyword is not None:
self.keyword.ignore_hyphens = ignore_hyphens
Copy link
Member

Choose a reason for hiding this comment

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

I think this feels a lot like a hack. If we want to both work-around it and auto-generate it, I think instead of this we should be passing a "keyword to constant" map instead, and then look it up in gecko_constant or replace otherwise.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

IMO workarounds like ignore_hyphens that get used just once probably shouldn't exist 😄 I'd prefer if we manually did image-rendering. Though I'm good with the map solution too.

@wafflespeanut
Copy link
Contributor Author

@emilio @Manishearth So, I've gone for predicting constants based on their edit distance (python has a built-in object for that). It works quite well for all the constants we generate now. You think this would be useful? If it is, then I'll go ahead and fix the tests. If it's not, then I'll revert the changes to image-rendering stuff and we'll land this.

@wafflespeanut
Copy link
Contributor Author

Well, I've fallen back to @emilio's idea of having a constants map. It'll also be useful in the future (#13668 for instance)

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

r=me with those addressed, thanks for doing this! :)

@@ -312,6 +312,7 @@
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
'gecko_constant_prefix', 'gecko_enum_prefix',
'extra_gecko_values', 'extra_servo_values',
'custom_consts',
Copy link
Member

Choose a reason for hiding this comment

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

There's another instance of this same list below (line 359)

pub mod computed_value {
use cssparser::ToCss;
use std::fmt;
<% consts_map = { "crisp-edges": "CRISPEDGES" } %>
Copy link
Member

Choose a reason for hiding this comment

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

rename to image_rendering_custom_consts?

@wafflespeanut
Copy link
Contributor Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit ff27e4f has been approved by emilio

@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. labels Oct 26, 2016
@bors-servo
Copy link
Contributor

⌛ Testing commit ff27e4f with merge bd94b5e...

bors-servo pushed a commit that referenced this pull request Oct 26, 2016
Prefer auto-generation for some keyword props

<!-- 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-geckolib` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because it's a refactor

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

r? @Manishearth or @emilio

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

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 26, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Oct 26, 2016
@wafflespeanut
Copy link
Contributor Author

@bors-servo r=emilio

Oops. Forgot to change the enum variants in other crates :)

@bors-servo
Copy link
Contributor

📌 Commit e7cbd10 has been approved by emilio

@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. labels Oct 26, 2016
@bors-servo
Copy link
Contributor

⌛ Testing commit e7cbd10 with merge 3c16dde...

bors-servo pushed a commit that referenced this pull request Oct 26, 2016
Prefer auto-generation for some keyword props

<!-- 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-geckolib` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because it's a refactor

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

r? @Manishearth or @emilio

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

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 26, 2016
@wafflespeanut
Copy link
Contributor Author

@bors-servo retry #13776

@bors-servo
Copy link
Contributor

⚡ Previous build results for mac-dev-unit, windows-dev are reusable. Rebuilding only arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2...

@bors-servo
Copy link
Contributor

@bors-servo bors-servo merged commit e7cbd10 into servo:master Oct 26, 2016
@wafflespeanut wafflespeanut deleted the keyword branch November 29, 2016 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-tests-failed The changes caused existing tests to fail.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants