Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport -moz-binding in geckolib #11287
Conversation
highfive
commented
May 20, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 20, 2016
highfive
commented
May 20, 2016
|
New code was committed to pull request. |
|
|
| #[cfg(feature = "gecko")] | ||
| pub fn dummy_extra_data() -> ParserContextExtraData { | ||
| ParserContextExtraData { } | ||
| } |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
| use heapsize::HeapSizeOf; | ||
| use std::fmt::{self, Debug}; | ||
|
|
||
| macro_rules! define_holder_gecko_arc { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
| } | ||
|
|
||
| fn clone_from(&mut self, source: &$x) { | ||
| unsafe { |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
emilio
May 24, 2016
Member
nit: Also, this can use early return to dedent the rest of the function a bit.
highfive
commented
May 24, 2016
|
New code was committed to pull request. |
1 similar comment
highfive
commented
May 24, 2016
|
New code was committed to pull request. |
|
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+ |
|
|
|
|
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 -->
|
|
highfive
commented
May 24, 2016
|
|
@bors-servo retry |
|
|
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 -->
|
|
heycam commentedMay 20, 2016
•
edited by larsbergstrom
Thank you for contributing to Servo! Please replace each
[ ]by[X]when the step is complete, and replace__with appropriate data:./mach build -ddoes not report any errors./mach test-tidy --fasterdoes not report any errorsEither:
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