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 -moz-binding in geckolib #11287

Merged
merged 7 commits into from May 24, 2016
Merged

Support -moz-binding in geckolib #11287

merged 7 commits into from May 24, 2016

Conversation

@heycam
Copy link
Member

heycam commented May 20, 2016

Thank you for contributing to Servo! Please replace each [ ] by [X] when the step is complete, and replace __ with appropriate data:

  • ./mach build -d does not report any errors
  • ./mach test-tidy --faster does not report any errors
  • These changes fix #__ (github issue number if applicable).

Either:

  • There are tests for these changes OR
  • These changes do not require tests because changes target stylo

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


This change is Reviewable

@highfive
Copy link

highfive commented May 20, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/selector_matching.rs, components/style/properties/properties.mako.rs, components/style/Cargo.toml, components/style/parser.rs, components/style/lib.rs, components/style/properties/longhand/box.mako.rs, components/style/stylesheets.rs, components/style/properties/helpers.mako.rs
  • @KiChjang: components/script/dom/htmllinkelement.rs, components/script/dom/cssstyledeclaration.rs, components/script/dom/element.rs, components/script/dom/htmlstyleelement.rs
@highfive
Copy link

highfive commented May 20, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style and script code, but no tests are modified. Please consider adding a test!
@heycam
Copy link
Member Author

heycam commented May 20, 2016

@highfive highfive assigned bholley and unassigned jdm May 20, 2016
@heycam heycam changed the title Moz binding Support -moz-binding in geckolib May 20, 2016
@heycam heycam force-pushed the heycam:moz-binding branch from eb3d10d to e07dffd May 20, 2016
@highfive
Copy link

highfive commented May 20, 2016

New code was committed to pull request.

@bors-servo
Copy link
Contributor

bors-servo commented May 20, 2016

The latest upstream changes (presumably #11277) made this pull request unmergeable. Please resolve the merge conflicts.

@heycam heycam force-pushed the heycam:moz-binding branch from e07dffd to 7af125a May 20, 2016
#[cfg(feature = "gecko")]
pub fn dummy_extra_data() -> ParserContextExtraData {
ParserContextExtraData { }
}

This comment has been minimized.

@bholley

bholley May 23, 2016

Contributor

Instead of exposing this everywhere, I think we should have a ParserContext::new and ParserContext::new_with_extra_data, where the former delegates to the latter and passes in a sensible default. Then we can make ::default() a static factory method on ParserContextExtraData.

This comment has been minimized.

@heycam

heycam May 24, 2016

Author Member

I cant add a static method to ParserContextExtraData when it's a typedef for () in the non-geckolib config. I could make it an enum with no constructors. (And all the non-geckolib places where I pass in () for the extra_data parameter I'll replace with ParserContextExtraData::default()).

use std::fmt::{self, Debug};

macro_rules! define_holder_gecko_arc {
($x:ident, $y:ident, $z:ident) => (

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

More descriptive names please. :-)

use heapsize::HeapSizeOf;
use std::fmt::{self, Debug};

macro_rules! define_holder_gecko_arc {

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

This could use some comments.

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

I'd also call this define_gecko_holder_arc or just define_holder_arc since we're in geckolib.


impl $x {
pub fn new(data: *mut $z) -> $x {
assert!(!data.is_null());

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

debug_assert

}

fn clone_from(&mut self, source: &$x) {
unsafe {

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

I think we can just take the default impl and not override this here - we don't save any work unless I'm missing something.

@@ -102,8 +102,10 @@ export RUST_BACKTRACE=1
-match "pair" \
-match "SheetParsingMode.h" \
-match "StaticPtr.h" \
-match "nsProxyRelease.h" \

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

Do we really need to do this? Why not just use opaque types?

This comment has been minimized.

@heycam

heycam May 24, 2016

Author Member

Opaque types would work, but we'd need those opaque types to look like:

pub enum nsMainThreadHolder<T> {}
pub enum nsMainThreadHandle<T> {}

but currently using -opaque-type I get:

pub enum nsMainThreadHolder {}
pub enum nsMainThreadHandle {}

which doesn't work with the types in bindings.rs we generate:

pub type ThreadSafePrincipalHolder = nsMainThreadPtrHolder<nsIPrincipal>;
pub type ThreadSafeURIHolder = nsMainThreadPtrHolder<nsIURI>;
SpecifiedValue::Url(ref url, _) => {
try!(dest.write_str("url(\""));
try!(write!(&mut CssStringWriter::new(dest), "{}", url));
try!(dest.write_str("\")"));

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

Can we implement ToCss for Url somewhere, and then just delegate to that here (and in the other places where we need to do this)? Followup patch is fine.

referrer: referrer.clone(),
principal: principal.clone(),
};
Ok(SpecifiedValue::Url(context.parse_url(&*try!(input.expect_url())), extra_data))

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

It seems a bit clearer to me to hoist the parse_url piece to an assignment to a temporary right above the |match| expression. That also avoids doing all the refcounting in error cases.

fn set__moz_binding(&mut self, v: longhands::_moz_binding::computed_value::T) {
use style::properties::longhands::_moz_binding::SpecifiedValue as BindingValue;
match v {
BindingValue::None => assert!(self.gecko.mBinding.mRawPtr.is_null()),

This comment has been minimized.

@bholley

bholley May 24, 2016

Contributor

debug_assert - please remember to do this, since I might not catch them all.


pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
Ok(SpecifiedValue::None)

This comment has been minimized.

@emilio

emilio May 24, 2016

Member

nit: Also, this can use early return to dedent the rest of the function a bit.

@heycam heycam force-pushed the heycam:moz-binding branch from 7af125a to e75b1c3 May 24, 2016
@highfive
Copy link

highfive commented May 24, 2016

New code was committed to pull request.

1 similar comment
@highfive
Copy link

highfive commented May 24, 2016

New code was committed to pull request.

@bholley
Copy link
Contributor

bholley commented May 24, 2016

I was hoping that we could avoid all the DOM changes by the new_with_extra_data thing, but I guess there are other callers.

I think now that the ideal refactoring would be to rename ParserContextExtraData to ParserContextOptions, and hoist the error reporter and the base URL into that, along with any additional optional Gecko fields.

We can clean that up later though, and I'd rather get this landed.

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2016

📌 Commit f2b1ef4 has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2016

Testing commit f2b1ef4 with merge 6bd05f8...

bors-servo added a commit that referenced this pull request May 24, 2016
Support -moz-binding in geckolib

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 --faster` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Either:
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because changes target stylo

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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11287)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented May 24, 2016

  ▶ Unexpected subtest result in /css-transitions-1_dev/html/detached-container-001.htm:
  │ FAIL [expected PASS] transition within detached container / values
  │   → assert_equals: no intermediate values expected 2 but got 1
  │ 
  │ .cases.values.done@http://web-platform.test:8000/css-transitions-1_dev/html/detached-container-001.htm:69:29
  │ runLoop/&lt;/&lt;/&lt;/&lt;@http://web-platform.test:8000/css-transitions-1_dev/html/support/runParallelAsyncHarness.js:121:26
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1226:20
  │ runLoop/&lt;/&lt;/&lt;@http://web-platform.test:8000/css-transitions-1_dev/html/support/runParallelAsyncHarness.js:120:21
  │ runLoop/&lt;/&lt;@http://web-platform.test:8000/css-transitions-1_dev/html/support/runParallelAsyncHarness.js:119:17
  └ runLoop/&lt;@http://web-platform.test:8000/css-transitions-1_dev/html/support/runParallelAsyncHarness.js:117:13
@mbrubeck
Copy link
Contributor

mbrubeck commented May 24, 2016

@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2016

Testing commit f2b1ef4 with merge 2a2b88f...

bors-servo added a commit that referenced this pull request May 24, 2016
Support -moz-binding in geckolib

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 --faster` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Either:
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because changes target stylo

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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11287)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2016

@bors-servo bors-servo merged commit f2b1ef4 into servo:master May 24, 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
@heycam heycam deleted the heycam:moz-binding branch May 25, 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

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