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

Implement parsing/serialization and glue for will-change property #15813

Merged
merged 3 commits into from
Mar 22, 2017

Conversation

canova
Copy link
Contributor

@canova canova commented Mar 3, 2017

Implement parsing/serialization and glue for will-change property


  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Mar 3, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/properties/data.py, components/style/properties/longhand/effects.mako.rs, components/style/properties/longhand/position.mako.rs, components/style/properties/longhand/svg.mako.rs, components/style/properties/longhand/box.mako.rs, components/style/properties/properties.mako.rs
  • @emilio: components/style/properties/gecko.mako.rs, components/style/properties/data.py, components/style/properties/longhand/effects.mako.rs, components/style/properties/longhand/position.mako.rs, components/style/properties/longhand/svg.mako.rs, components/style/properties/longhand/box.mako.rs, components/style/properties/properties.mako.rs

@highfive
Copy link

highfive commented Mar 3, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • 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 Mar 3, 2017
@canova
Copy link
Contributor Author

canova commented Mar 3, 2017

Parsing/serialization of the will-change property is completed but the current glue is crashing in a stylo build. I'm doing something wrong when assigning values to mWillChange(root::nsTArray<::nsstring::nsStringRepr>) but still investigating the problem.
Do you have suggestions for me at constructing nsTArray?
r? @Manishearth @emilio

@highfive highfive assigned Manishearth and unassigned mbrubeck Mar 3, 2017
@canova canova force-pushed the will-change branch 2 times, most recently from 2d94066 to f84a825 Compare March 3, 2017 23:08
@Manishearth
Copy link
Member

r? @upsuper ? I'm not quite familiar with the will-change stuff.

@canaltinova there are methods on nsTarray defined in gecko_bindings/sugar/ns_t_array.rs. You can use those to set its length, and then mutate elements. Be careful, the Rust code doesn't know how to run C++ side constructors, so setting the length will give you an array full of garbage data, into which you have to move the strings.

@highfive highfive assigned upsuper and unassigned Manishearth Mar 3, 2017
@upsuper
Copy link
Contributor

upsuper commented Mar 4, 2017

Reviewed 3 of 3 files at r1, 6 of 6 files at r2.
Review status: 7 of 9 files reviewed at latest revision, 6 unresolved discussions.


components/style/properties/properties.mako.rs, line 455 at r2 (raw file):

    /// Returns true if property requires a stacking context.
    #[cfg(feature = "gecko")]
    pub fn creates_stacking_context(&self) -> bool {

Having three individual functions for things which are mostly used together seems to be bad both for code size and for performance. Could you merge these functions together and make it a bitflag? I guess this can become a general mechanism for having flags on properties.


components/style/properties/longhand/box.mako.rs, line 1972 at r1 (raw file):

                    let mut iter = features.iter();
                    // handle head element
                    try!(iter.next().unwrap().to_css(dest));

You can use the ? syntax.


components/style/properties/longhand/box.mako.rs, line 1988 at r1 (raw file):

    pub enum AnimateableFeature {
        ScrollPosition,
        Contents,

Actually I'm not sure whether it's worth distinguishing these two values from other identifiers. Effectively they are just another two identifiers. Doing so makes the code look more similiar to what the spec describes, but it takes a bit runtime cost. I guess I can live either way, though.


components/style/properties/longhand/box.mako.rs, line 1989 at r1 (raw file):

        ScrollPosition,
        Contents,
        CustomIdent(String),

Probably better using Atom so that we can avoid copying the string all the time from specified value to computed value, and that would


components/style/properties/longhand/box.mako.rs, line 1994 at r1 (raw file):

    impl Parse for AnimateableFeature {
        fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
            if input.try(|input| input.expect_ident_matching("scroll-position")).is_ok() {

I don't think you need to add separate if-blocks for these two values. They can be merged into the match_ignore_ascii_case! block, right?


components/style/properties/longhand/box.mako.rs, line 2002 at r1 (raw file):

            match_ignore_ascii_case! { &input.expect_ident()?,
                "will-change" | "none" | "all" | "auto" => Err(()),

This may need to exclude CSS-wide keywords as well... or probably expect_ident should not accept those keywords as identifier at all. Not sure whether the parser is implemented that way. cc @SimonSapin


Comments from Reviewable

@upsuper upsuper 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 Mar 4, 2017
@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 Mar 4, 2017
@canova
Copy link
Contributor Author

canova commented Mar 4, 2017

Review status: 0 of 9 files reviewed at latest revision, 6 unresolved discussions.


components/style/properties/longhand/box.mako.rs, line 1972 at r1 (raw file):

Previously, upsuper (Xidorn Quan) wrote…

You can use the ? syntax.

Done.


components/style/properties/longhand/box.mako.rs, line 1988 at r1 (raw file):

Previously, upsuper (Xidorn Quan) wrote…

Actually I'm not sure whether it's worth distinguishing these two values from other identifiers. Effectively they are just another two identifiers. Doing so makes the code look more similiar to what the spec describes, but it takes a bit runtime cost. I guess I can live either way, though.

Yes, you're right. I thought the same while I was implementing this and decided to make that way. But it seems like performance is a bigger factor. Also simplifies the code. Changed it.


components/style/properties/longhand/box.mako.rs, line 1989 at r1 (raw file):

Previously, upsuper (Xidorn Quan) wrote…

Probably better using Atom so that we can avoid copying the string all the time from specified value to computed value, and that would

Used Atom but contains and scroll-position keywords needs to be added to html5ever-atoms crate. Opened a PR: servo/html5ever#256


components/style/properties/longhand/box.mako.rs, line 1994 at r1 (raw file):

Previously, upsuper (Xidorn Quan) wrote…

I don't think you need to add separate if-blocks for these two values. They can be merged into the match_ignore_ascii_case! block, right?

Done.


components/style/properties/longhand/box.mako.rs, line 2002 at r1 (raw file):

Previously, upsuper (Xidorn Quan) wrote…

This may need to exclude CSS-wide keywords as well... or probably expect_ident should not accept those keywords as identifier at all. Not sure whether the parser is implemented that way. cc @SimonSapin

Yes, tested it and CSS-wide keywords were passing. Excluded them. Thanks.


Comments from Reviewable

@canova
Copy link
Contributor Author

canova commented Mar 4, 2017

@upsuper The flags are being held in mako right now. We need to check in some function and transfer it to rust. Are you suggesting to hold them somewhere else and check them with bitflags? If you are not, probably mako will increase the complexity of the function with bitflags. Could you elaborate?

@canova
Copy link
Contributor Author

canova commented Mar 4, 2017

@upsuper Oh, it looks like stylo atoms are in this auto generated file:
https://dxr.mozilla.org/servo/source/components/style/gecko_string_cache/atom_macro.rs
Do we need to add scroll-position to http://searchfox.org/mozilla-central/source/dom/base/nsGkAtomList.h and regenerate it in servo?

bors-servo pushed a commit to servo/html5ever that referenced this pull request Mar 4, 2017
Add "contents" and "scroll-position" keywords to local names

They are needed for servo/servo#15813

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/html5ever/256)
<!-- Reviewable:end -->
@upsuper
Copy link
Contributor

upsuper commented Mar 6, 2017

Reviewed 1 of 2 files at r3.
Review status: 0 of 9 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/style/properties/longhand/box.mako.rs, line 2002 at r1 (raw file):

Previously, canaltinova (Nazım Can Altınova) wrote…

Yes, tested it and CSS-wide keywords were passing. Excluded them. Thanks.

Hmmm, I really think this should be done in cssparser rather than each separate property, so probably there is nothing you should change here.


Comments from Reviewable

@upsuper
Copy link
Contributor

upsuper commented Mar 7, 2017

The flags are being held in mako right now. We need to check in some function and transfer it to rust. Are you suggesting to hold them somewhere else and check them with bitflags? If you are not, probably mako will increase the complexity of the function with bitflags. Could you elaborate?

My idea is that we can do something like

bitflags! {
    pub flags PropertyFlags: u8 {
        const CREATES_STACKING_CONTEXT = 0x01,
        const FIXPOS_CB = 0x02,
        const ABSPOS_CB = 0x04,
    }
}

pub fn flags(&self) -> PropertyFlags {
    match *self {
        % for property in data.longhands:
            LonghandId::${property.camel_case} =>
            %if property.creates_stacking_context:
                CREATES_STACKING_CONTEXT |
            %endif
            %if property.fixpos_cb:
                FIXPOS_CB |
            %endif
            %if property.abspos_cb:
                ABSPOS_CB |
            %endif
            PropertyFlags::empty(),
        % endfor
    }
}

@upsuper
Copy link
Contributor

upsuper commented Mar 7, 2017

Do we need to add scroll-position to http://searchfox.org/mozilla-central/source/dom/base/nsGkAtomList.h and regenerate it in servo?

I can do that.

@upsuper
Copy link
Contributor

upsuper commented Mar 7, 2017

Reviewed 9 of 9 files at r4, 6 of 6 files at r5, 2 of 2 files at r6.
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


Comments from Reviewable

@upsuper
Copy link
Contributor

upsuper commented Mar 7, 2017

Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/style/properties/longhand/box.mako.rs, line 1989 at r1 (raw file):

Previously, canaltinova (Nazım Can Altınova) wrote…

Used Atom but contains and scroll-position keywords needs to be added to html5ever-atoms crate. Opened a PR: servo/html5ever#256

It doesn't seem to me we need contents, though...


Comments from Reviewable

@upsuper
Copy link
Contributor

upsuper commented Mar 7, 2017

#15846 for updating the atom list from gecko.

@bors-servo
Copy link
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-msvc-dev
State: approved= try=False

The flags are creates_stacking_context, fixpos_cb and abspos_cb. These will be needed in will-change glue.
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Mar 21, 2017
@canova
Copy link
Contributor Author

canova commented Mar 21, 2017

Thanks for the reviews!
@bors-servo r=upsuper,emilio

@bors-servo
Copy link
Contributor

📌 Commit ea1e405 has been approved by upsuper,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 Mar 21, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit ea1e405 with merge aa3237a...

bors-servo pushed a commit that referenced this pull request Mar 21, 2017
Implement parsing/serialization and glue for will-change property

Implement parsing/serialization  and glue for will-change property

---
<!-- 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 #15706 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes

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

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

💔 Test failed - mac-rel-wpt1

@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 Mar 21, 2017
@bors-servo
Copy link
Contributor

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

1 similar comment
@bors-servo
Copy link
Contributor

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

@Manishearth
Copy link
Member

@bors-servo clean retry r- r=upsuper,emilio

@bors-servo
Copy link
Contributor

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors-servo
Copy link
Contributor

📌 Commit ea1e405 has been approved by upsuper,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-tests-failed The changes caused existing tests to fail. labels Mar 22, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit ea1e405 with merge cb1438e...

bors-servo pushed a commit that referenced this pull request Mar 22, 2017
Implement parsing/serialization and glue for will-change property

Implement parsing/serialization  and glue for will-change property

---
<!-- 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 #15706 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes

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

<!-- 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/15813)
<!-- 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-css, mac-rel-wpt1, mac-rel-wpt2, windows-msvc-dev
Approved by: upsuper,emilio
Pushing cb1438e to master...

@bors-servo bors-servo merged commit ea1e405 into servo:master Mar 22, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 22, 2017
@canova canova deleted the will-change branch April 5, 2017 16:23
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.

Stylo needs will-change support
7 participants