Repository navigation
style: Move display outside of mako - #19659
Conversation
|
Heads up! This PR modifies the following files:
|
| } | ||
| } | ||
|
|
||
| impl Parse for Display { |
There was a problem hiding this comment.
You should be able to derive this, shouldn't you?
There was a problem hiding this comment.
Oh, yeah, I think I should try to use derive for it.
However, I have only one concern to make it use derive.
For Display::Flex and Display::InlineFlex, they are originally matches with -webkit- prefix.
If we try to derive Parse, I think it will be matched without the prefix?
There was a problem hiding this comment.
Just update the PR with derive Parse!
I'd like to know if there's any test error with the patch!
There was a problem hiding this comment.
Oh, that will definitely cause tests to fail. I opened #19665 with a solution for that.
There was a problem hiding this comment.
WOW! Great solution! Let me try to fix it!
Thanks a lot!
There was a problem hiding this comment.
By the way, the CI build in the patch without #[parse(alias = "-webkit-flex")] still succeeded.
I guess it didn't be tested. Shall we have another PR to add test for it?
There was a problem hiding this comment.
Sure, the CI build succeeds, but that's only a portion of the tests we run. To run all the tests you should push to Mozilla's try server (https://wiki.mozilla.org/ReleaseEngineering/TryServer), which I think you don't have commit access to because it's a Gecko thingie.
For PRs that just move code around I don't use to push them if I'm confident the changes are correct (we run the tests when the patch lands anyway), but for bigger changes I push and get a link like: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9f764414e0f2341c4494164b8341ab9d901e7524
There was a problem hiding this comment.
Thanks for the information.
| use values::specified::length::LengthOrPercentage; | ||
|
|
||
| // FIXME(emilio): Why does this reinvent the wheel, again? | ||
| #[allow(non_camel_case_types)] |
There was a problem hiding this comment.
I think after moving this enum into specified module, we don't need this anymore.
Besides, I think even in the old way, maybe we don't need it either?
There was a problem hiding this comment.
And now it uses derive(Parse) the FIXME can go away too :)
e36c1ff to
aeb83b7
Compare
This will allow servo#19659 to use derive on display using: #[css(aliases = "-webkit-flex")] Flex, #[css(aliases = "-webkit-inline-flex")] InlineFlex, And such.
This will allow servo#19659 to use derive on display using: #[css(aliases = "-webkit-flex")] Flex, #[css(aliases = "-webkit-inline-flex")] InlineFlex, And such.
This will allow servo#19659 to use derive on display using: #[parse(aliases = "-webkit-flex")] Flex, #[parse(aliases = "-webkit-inline-flex")] InlineFlex, And such.
| WebkitInlineBox, | ||
| #[cfg(feature = "gecko")] | ||
| /// `box` variant for `moz` | ||
| MozBox, |
There was a problem hiding this comment.
I'd just #[allow(missing_docs)], for the variants, and remove the comments, they are more noise than good I think, and for keywords that's just fine. In particular, these for example are wrong (-moz-box is a XUL display type, as lots of the ones below starting with -moz).
There was a problem hiding this comment.
Using #[allow(missing_docs)] makes this enum more clear :P
| %> | ||
|
|
||
| </%helpers:longhand> | ||
| ${helpers.gecko_keyword_conversion( |
There was a problem hiding this comment.
It's very unfortunate that we still need to list all the values here... Can you double-check that adding a new value to the Display enum at least causes a compile error here?
And can you leave a FIXME above like:
# FIXME(emilio): Listing all the display values here is very unfortunate, we should teach C++ to use the
# Rust enum directly, or generate the conversions to `StyleDisplay`.There was a problem hiding this comment.
Sure, I'll double-check the Display enum again and add this FIXME comment here.
There was a problem hiding this comment.
Yeah, I tried to add a display-test into display_values and it caused compilation error with
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index 641d72afae..b32248b513 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -32,7 +32,7 @@ ${helpers.predefined_type(
display_values = """inline block inline-block
table inline-table table-row-group table-header-group table-footer-group
table-row table-column-group table-column table-cell table-caption
- list-item none
+ list-item none display-test
""".split()
webkit_prefixed_display_values = "flex inline-flex".split()
display_values += webkit_prefixed_display_values Compiling style v0.0.1 (file:///Users/cybai/codespace/servo/components/style)
error[E0599]: no associated item named `DisplayTest` found for type `gecko_bindings::structs::root::mozilla::StyleDisplay` in the current scope
--> servo/target/geckolib/debug/build/style-55046d2555925070/out/properties.rs:7989:23
|
7989 | = structs::StyleDisplay::DisplayTest as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: Could not compile `style`.
To learn more, run the command again with --verbose.
GeckoLib build completed in 0:00:18style_derive: Support parse-time aliases. This will allow #19659 to use derive on display using: #[parse(aliases = "-webkit-flex")] Flex, #[parse(aliases = "-webkit-inline-flex")] InlineFlex, And such. <!-- 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/19665) <!-- Reviewable:end -->
186174d to
b7fbf82
Compare
emilio
left a comment
There was a problem hiding this comment.
Few more changes needed, but looks much nicer!
| display_values = """inline block inline-block | ||
| table inline-table table-row-group table-header-group table-footer-group | ||
| table-row table-column-group table-column table-cell table-caption | ||
| list-item none |
There was a problem hiding this comment.
This is Gecko-only code now, so no need to ad the if product == "gecko":, nor special-casing webkit_prefixed_display_values, just put them on the same list.
There was a problem hiding this comment.
Yeah! You're right!!
I'll put the string of display_values as the second argument of Keyword and remove this variable.
| Flex, | ||
| #[parse(aliases = "-webkit-inline-flex")] | ||
| InlineFlex, | ||
| #[cfg(feature = "gecko")] |
There was a problem hiding this comment.
I don't think this works as you think, you still need a cfg per variant, let's put them back one per line.
There was a problem hiding this comment.
Just add them back! I think I have misunderstanding to attributes 😓
| Display::Inline => true, | ||
| #[cfg(feature = "gecko")] | ||
| Display::Contents | Display::Ruby | ||
| | Display::RubyBaseContainer => true, |
There was a problem hiding this comment.
nit: indentation here looks somewhat weird, what about:
pub fn is_line_participant(&self) -> bool {
match *self {
Display::Inline => true,
#[cfg(feature = "gecko")]
Display::Contents |
Display::Ruby |
Display::RubyBaseContainer => true,Not particularly sold on it, so if you think it's cleaner as-is that's fine for me too.
There was a problem hiding this comment.
I was thinking about
match *self {
Display::Inline => true,
#[cfg(feature = "gecko")]
Display::Contents
| Display::Ruby
| Display::RubyBaseContainer => true,but waiting for your comments :P
Thus, I'll follow the indentation you provided above, thanks!
| "computed::Display::inline()", | ||
| initial_specified_value="specified::Display::inline()", | ||
| animation_value_type="discrete", | ||
| needs_context=False, |
There was a problem hiding this comment.
I believe you can remove this line, too.
There was a problem hiding this comment.
It seems we still need this line.
If I remove it, I'll get the error like following:
error[E0061]: this function takes 1 parameter but 2 parameters were supplied
--> servo/target/geckolib/debug/build/style-55046d2555925070/out/properties.rs:7874:39
|
7874 | specified::Display::parse(context, input)
| ^^^^^^^^^^^^^^ expected 1 parameter
|
::: components/style/values/specified/box.rs
|
24 | #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
| ----- defined here
error: aborting due to previous errorb7fbf82 to
a764d90
Compare
|
@bors-servo r+ |
|
📌 Commit a764d90 has been approved by |
style: Move display outside of mako This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19658 - [x] These changes do not require tests <!-- 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/19659) <!-- Reviewable:end -->
|
@CYBAI L1 commit access allows you to push to the try server, do you have an account in https://bugzilla.mozilla.org? |
|
☀️ 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 |
|
@emilio I don't have an account in bugzilla now. I'll create one later! Thanks. Update: I just created an bugzilla account! |
This is a sub-PR of #19015
r? emilio
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is