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

Support creating StyleAnimationValue objects from Servo #13553

Merged
merged 4 commits into from Oct 9, 2016

Conversation

@birtles
Copy link
Contributor

birtles commented Oct 3, 2016

These are the servo-side changes for bug 1302949. @Manishearth has already reviewed them there.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix bug 1302949
  • These changes do not require tests because there are existing tests for this in mozilla-central

This change is Reviewable

@highfive
Copy link

highfive commented Oct 3, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @mbrubeck (or someone else) soon.

@highfive
Copy link

highfive commented Oct 3, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/gecko_bindings/bindings.rs, components/style/gecko/wrapper.rs
@highfive
Copy link

highfive commented Oct 3, 2016

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

Manishearth commented Oct 3, 2016

@bors-servo delegate+

feel free to r=me whenever you think it's necessary. Try to get both sides landed at around the same time (if not, no big deal, I can cherry pick when I do the next sync)

@bors-servo
Copy link
Contributor

bors-servo commented Oct 3, 2016

✌️ @birtles can now approve this pull request

@mbrubeck mbrubeck assigned Manishearth and unassigned mbrubeck Oct 3, 2016
@birtles
Copy link
Contributor Author

birtles commented Oct 5, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Oct 5, 2016

Trying commit 7f94994 with merge 28d76a8...

bors-servo added a commit that referenced this pull request Oct 5, 2016
Support creating StyleAnimationValue objects from Servo

These are the servo-side changes for [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59). @Manishearth has already reviewed them there.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59)
- [X] These changes do not require tests because there are existing tests for this in mozilla-central

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

bors-servo commented Oct 5, 2016

💔 Test failed - linux-dev

@Manishearth
Copy link
Member

Manishearth commented Oct 5, 2016

/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75:9: 75:26 error: binary operation `==` cannot be applied to type `core::option::Option<std::sync::Arc<parking_lot::RwLock<properties::PropertyDeclarationBlock>>>` [E0369]
/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75         self.declarations == other.declarations
                                                                                        ^~~~~~~~~~~~~~~~~
/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75:9: 75:26 help: run `rustc --explain E0369` to see a detailed explanation
/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75:9: 75:26 note: an implementation of `std::cmp::PartialEq` might be missing for `core::option::Option<std::sync::Arc<parking_lot::RwLock<properties::PropertyDeclarationBlock>>>`
/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75         self.declarations == other.declarations
                                                                                        ^~~~~~~~~~~~~~~~~
error: aborting due to previous error
@birtles
Copy link
Contributor Author

birtles commented Oct 5, 2016

I'm hitting

/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75:9: 75:26 error: binary operation `==` cannot be applied to type `core::option::Option<std::sync::Arc<parking_lot::RwLock<properties::PropertyDeclarationBlock>>>` [E0369]
/home/servo/buildbot/slave/linux-dev/build/components/style/gecko/wrapper.rs:75         self.declarations == other.declarations
                                                                                        ^~~~~~~~~~~~~~~~~

This used to work. I wonder what changed.

@birtles
Copy link
Contributor Author

birtles commented Oct 5, 2016

Possibly 89a29a7 I guess?

@birtles
Copy link
Contributor Author

birtles commented Oct 5, 2016

@SimonSapin do you have any suggestions how I might fix this build error? Specifically, this line used to work but when I went to land it looks like it has bitrotted because RwLock does do ==:

https://github.com/servo/servo/pull/13553/files#diff-956c49c2a32c332249de4800e44bfcadR74

@birtles
Copy link
Contributor Author

birtles commented Oct 5, 2016

I spoke to @wafflespeanut and @Manishearth on IRC and it looks like I need to use read to get the value and compare it. This is because looking through how this is used in Gecko it looks we do need deep equality. Specifically the operator== where we're using this was added here:

https://hg.mozilla.org/mozilla-central/rev/5db982657c9b2606d9572fced222741cffb136c1

And if that doesn't use deep equality we'll end up doing unnecessary work when we update animations and fail tests that check the number of change notifications we dispatch.

@birtles
Copy link
Contributor Author

birtles commented Oct 6, 2016

I had a look into doing this but quickly remembered I know nothing about rust. I tried doing the following:

impl PartialEq for GeckoDeclarationBlock {
    fn eq(&self, other: &GeckoDeclarationBlock) -> bool {
        let unwrap_declarations = |block: &GeckoDeclarationBlock| {
            match block.declarations {
                None => None,
                Some(ref ptr) => Some(*ptr.read())
            }
        };
        unwrap_declarations(self) == unwrap_declarations(other)
    }
}

But ran into lifetime issues, I think because read() returns a temporary RwLockReadGuard which needs to be kept around long enough for its inner object to be compared. Or something like that. Clearly I'm doing it wrong somehow.

@Manishearth
Copy link
Member

Manishearth commented Oct 6, 2016

Just unroll it

match (*self, *other) {
  (None, None) => true,
  (Some(ref s), Some(ref other)) => s.read() == other.read(),
  _ => false,
}
@birtles
Copy link
Contributor Author

birtles commented Oct 6, 2016

Ooh! That's a lot nicer. It didn't work as-is but I tweaked it as follows:

    fn eq(&self, other: &GeckoDeclarationBlock) -> bool {
        match (self.declarations, other.declarations) {
            (None, None) => true,
            (Some(ref s), Some(ref other)) => *s.read() == *other.read(),
            _ => false,
        }
    }

And I still get:

C:\moz\servo\components\style\gecko\wrapper.rs:75:16: 75:20 error: cannot move out of borrowed content [E0507]
C:\moz\servo\components\style\gecko\wrapper.rs:75         match (self.declarations, other.declarations) {
                                                                 ^~~~
C:\moz\servo\components\style\gecko\wrapper.rs:75:16: 75:20 help: run `rustc --explain E0507` to see a detailed explanation
C:\moz\servo\components\style\gecko\wrapper.rs:75:35: 75:40 error: cannot move out of borrowed content [E0507]
C:\moz\servo\components\style\gecko\wrapper.rs:75         match (self.declarations, other.declarations) {
                                                                                    ^~~~~
C:\moz\servo\components\style\gecko\wrapper.rs:75:35: 75:40 help: run `rustc --explain E0507` to see a detailed explanation
@birtles
Copy link
Contributor Author

birtles commented Oct 6, 2016

Oh, and if I don't dereference the read() I get:

C:\moz\servo\components\style\gecko\wrapper.rs:77:47: 77:55 error: binary operation `==` cannot be applied to type `parking_lot::RwLockReadGuard<'_, properties::PropertyDeclarationBlock>` [E0369]
C:\moz\servo\components\style\gecko\wrapper.rs:77             (Some(ref s), Some(ref other)) => s.read() == other.read(),
@Manishearth
Copy link
Member

Manishearth commented Oct 6, 2016

Try making it (&self.declaration ,...) and (&None, &None), etc in the matches

@birtles
Copy link
Contributor Author

birtles commented Oct 6, 2016

It works! Thank you!
I now hit a different error but I should be able to fix it in the same way--will update the PR tomorrow.
Thanks again.

@birtles
Copy link
Contributor Author

birtles commented Oct 7, 2016

I finally fixed the all the bitrot. Then I re-pulled and I've been bitrotted again. This time by 540ba90.

@birtles
Copy link
Contributor Author

birtles commented Oct 7, 2016

Oh, actually, it's not bitrot. That changeset just broke building on Windows.

@birtles birtles force-pushed the birtles:animvalues branch from 7f94994 to 88a1c2e Oct 7, 2016
@highfive highfive removed the S-tests-failed label Oct 7, 2016
@birtles
Copy link
Contributor Author

birtles commented Oct 7, 2016

@birtles
Copy link
Contributor Author

birtles commented Oct 9, 2016

@bors-servo r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Oct 9, 2016

📌 Commit 7478ac9 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Oct 9, 2016

Testing commit 7478ac9 with merge 7a7cf2d...

bors-servo added a commit that referenced this pull request Oct 9, 2016
Support creating StyleAnimationValue objects from Servo

These are the servo-side changes for [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59). @Manishearth has already reviewed them there.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59)
- [X] These changes do not require tests because there are existing tests for this in mozilla-central

<!-- 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/13553)
<!-- Reviewable:end -->
@birtles
Copy link
Contributor Author

birtles commented Oct 9, 2016

I fixed the merge conflicts but it looks like I've been bitrotted yet again. I don't have a build environment on this computer so this might have to wait a couple more days.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 9, 2016

💔 Test failed - linux-dev

@@ -338,6 +374,54 @@ pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) -> () {
let _ = data.into_box::<PerDocumentStyleData>();
}


#[no_mangle]
pub extern "C" fn Servo_ParseProperty(property_bytes: *const u8,

This comment has been minimized.

@Manishearth

Manishearth Oct 9, 2016

Member

The signature for Servo_ParseProperty doesn't match the generated bindings

This comment has been minimized.

@Manishearth

Manishearth Oct 9, 2016

Member

It seems like the generated bindings were hand-written here, since the signature in ServoBindingList.h is correct. I'll fix this.

This comment has been minimized.

@birtles

birtles Oct 9, 2016

Author Contributor

That's just one of a bunch of things are now broken but used to work. I wish bors-servo had got around to merging it a few days ago when it applied cleanly. I'll look into it on Tuesday.

This comment has been minimized.

@birtles

birtles Oct 9, 2016

Author Contributor

Thanks!

This comment has been minimized.

@Manishearth

Manishearth Oct 9, 2016

Member

Okay, wfm. That was due to a bors bug I need to fix, had a PR open for it iirc.

This comment has been minimized.

@Manishearth

Manishearth Oct 9, 2016

Member

bors bug should be fixed by servo/homu#63

birtles added 4 commits Sep 15, 2016
…aration block; r=Manishearth

The property may be a shorthand property in which case the declaration block
will contain the expanded longhand properties and values.

MozReview-Commit-ID: KxqlYgbIZqL
…n blocks; r=Manishearth

MozReview-Commit-ID: EtX2oLXdGNm
…le value; r=Manishearth

MozReview-Commit-ID: 59CCT0P4CBm
…nishearth

MozReview-Commit-ID: AbX0PCjjEM6
@Manishearth Manishearth force-pushed the birtles:animvalues branch from 7478ac9 to 45e0b90 Oct 9, 2016
@Manishearth
Copy link
Member

Manishearth commented Oct 9, 2016

@bors-servo r+

I think I fixed it

@bors-servo
Copy link
Contributor

bors-servo commented Oct 9, 2016

📌 Commit 45e0b90 has been approved by Manishearth

@birtles
Copy link
Contributor Author

birtles commented Oct 9, 2016

Thanks again!

@bors-servo
Copy link
Contributor

bors-servo commented Oct 9, 2016

Testing commit 45e0b90 with merge 804317c...

bors-servo added a commit that referenced this pull request Oct 9, 2016
Support creating StyleAnimationValue objects from Servo

These are the servo-side changes for [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59). @Manishearth has already reviewed them there.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [bug 1302949](https://bugzilla.mozilla.org/show_bug.cgi?id=1302949#c59)
- [X] These changes do not require tests because there are existing tests for this in mozilla-central

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

bors-servo commented Oct 9, 2016

@bors-servo bors-servo merged commit 45e0b90 into servo:master Oct 9, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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.