Skip to content

style: Move display outside of mako - #19659

Merged
bors-servo merged 1 commit into
servo:masterfrom
CYBAI:display-out-of-mako
Jan 1, 2018
Merged

bors-servo merged 1 commit into
servo:masterfrom
CYBAI:display-out-of-mako

Conversation

@CYBAI

@CYBAI CYBAI commented Dec 30, 2017 •

Copy link
Copy Markdown
Member

This is a sub-PR of #19015
r? emilio



This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/values/specified/box.rs, components/style/properties/longhand/box.mako.rs, components/style/values/computed/box.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs
  • @canaltinova: components/style/values/specified/box.rs, components/style/properties/longhand/box.mako.rs, components/style/values/computed/box.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs
  • @emilio: components/style/values/specified/box.rs, components/style/properties/longhand/box.mako.rs, components/style/values/computed/box.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style 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 Dec 30, 2017

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for doing this one :)

}
}

impl Parse for Display {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should be able to derive this, shouldn't you?

@CYBAI CYBAI Dec 31, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?

@CYBAI CYBAI Dec 31, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just update the PR with derive Parse!
I'd like to know if there's any test error with the patch!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, that will definitely cause tests to fail. I opened #19665 with a solution for that.

@CYBAI CYBAI Jan 1, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

WOW! Great solution! Let me try to fix it!
Thanks a lot!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the information.

use values::specified::length::LengthOrPercentage;

// FIXME(emilio): Why does this reinvent the wheel, again?
#[allow(non_camel_case_types)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, probably just leftover.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And now it uses derive(Parse) the FIXME can go away too :)

@CYBAI
CYBAI force-pushed the display-out-of-mako branch from e36c1ff to aeb83b7 Compare December 31, 2017 06:51
emilio added a commit to emilio/servo that referenced this pull request Dec 31, 2017
This will allow servo#19659 to use derive on display using:

    #[css(aliases = "-webkit-flex")]
    Flex,
    #[css(aliases = "-webkit-inline-flex")]
    InlineFlex,

And such.
emilio added a commit to emilio/servo that referenced this pull request Dec 31, 2017
This will allow servo#19659 to use derive on display using:

    #[css(aliases = "-webkit-flex")]
    Flex,
    #[css(aliases = "-webkit-inline-flex")]
    InlineFlex,

And such.
emilio added a commit to emilio/servo that referenced this pull request Dec 31, 2017
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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using #[allow(missing_docs)] makes this enum more clear :P

%>

</%helpers:longhand>
${helpers.gecko_keyword_conversion(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, I'll double-check the Display enum again and add this FIXME comment here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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:18

bors-servo pushed a commit that referenced this pull request Dec 31, 2017
style_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 -->
@CYBAI
CYBAI force-pushed the display-out-of-mako branch 2 times, most recently from 186174d to b7fbf82 Compare January 1, 2018 13:33

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this works as you think, you still need a cfg per variant, let's put them back one per line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just add them back! I think I have misunderstanding to attributes 😓

Display::Inline => true,
#[cfg(feature = "gecko")]
Display::Contents | Display::Ruby
| Display::RubyBaseContainer => true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@CYBAI CYBAI Jan 1, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That works for me :)

"computed::Display::inline()",
initial_specified_value="specified::Display::inline()",
animation_value_type="discrete",
needs_context=False,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe you can remove this line, too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 error

@CYBAI
CYBAI force-pushed the display-out-of-mako branch from b7fbf82 to a764d90 Compare January 1, 2018 15:51
@bholley

bholley commented Jan 1, 2018

Copy link
Copy Markdown
Contributor

I think we should get @CYBAI L1 commit access to mozilla-central to facilitate try pushes. @emilio, do you mind helping that process along?

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks as always @CYBAI!

@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit a764d90 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 Jan 1, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit a764d90 with merge 2a139ce...

bors-servo pushed a commit that referenced this pull request Jan 1, 2018
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 -->
@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

@CYBAI L1 commit access allows you to push to the try server, do you have an account in https://bugzilla.mozilla.org?

@bors-servo

Copy link
Copy Markdown
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: emilio
Pushing 2a139ce to master...

@bors-servo
bors-servo merged commit a764d90 into servo:master Jan 1, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 1, 2018
@CYBAI
CYBAI deleted the display-out-of-mako branch January 2, 2018 01:42
@CYBAI

CYBAI commented Jan 2, 2018 •

Copy link
Copy Markdown
Member Author

@emilio I don't have an account in bugzilla now. I'll create one later! Thanks.

Update: I just created an bugzilla account!

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.

Move display outside of mako.

5 participants