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
Merged

Conversation

@wafflespeanut
Copy link
Member

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

highfive commented Oct 24, 2016

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
Copy link

highfive commented Oct 24, 2016

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",

This comment has been minimized.

@Manishearth

Manishearth Oct 24, 2016

Member

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

This comment has been minimized.

@wafflespeanut

wafflespeanut Oct 24, 2016

Author Member

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

@Manishearth
Copy link
Member

Manishearth commented Oct 24, 2016

r? @emilio

@wafflespeanut
Copy link
Member 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

This comment has been minimized.

@emilio

emilio Oct 25, 2016

Member

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?

This comment has been minimized.

@Manishearth

Manishearth Oct 25, 2016

Member

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 wafflespeanut force-pushed the wafflespeanut:keyword branch from 58f93c8 to 31fb345 Oct 25, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 25, 2016

@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 wafflespeanut force-pushed the wafflespeanut:keyword branch from 31fb345 to 1e7d854 Oct 25, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 26, 2016

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)

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keyword branch from dabef3f to 74265fd Oct 26, 2016
@emilio
emilio approved these changes Oct 26, 2016
Copy link
Member

emilio left a comment

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',

This comment has been minimized.

@emilio

emilio Oct 26, 2016

Member

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" } %>

This comment has been minimized.

@emilio

emilio Oct 26, 2016

Member

rename to image_rendering_custom_consts?

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keyword branch 2 times, most recently from fb6a195 to ff27e4f Oct 26, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 26, 2016

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

📌 Commit ff27e4f has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

Testing commit ff27e4f with merge bd94b5e...

bors-servo added 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

bors-servo commented Oct 26, 2016

💔 Test failed - linux-rel-wpt

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keyword branch from ff27e4f to e7cbd10 Oct 26, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 26, 2016

@bors-servo r=emilio

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

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

📌 Commit e7cbd10 has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

Testing commit e7cbd10 with merge 3c16dde...

bors-servo added 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

bors-servo commented Oct 26, 2016

💔 Test failed - linux-rel-wpt

@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 26, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

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 commented Oct 26, 2016

@bors-servo bors-servo merged commit e7cbd10 into servo:master Oct 26, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@wafflespeanut wafflespeanut deleted the wafflespeanut:keyword branch Nov 29, 2016
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.

None yet

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