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 upAdd support for gecko-only array values; use for stylo #11851
Conversation
highfive
commented
Jun 24, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 24, 2016
6e9eaeb
to
871bb57
| self.gecko.mImage.mImageCount = cmp::max(self.gecko.mImage.mLayers.len() as u32, | ||
| self.gecko.mImage.mImageCount); | ||
|
|
||
| // TODO: pre-grow the nsTArray to the right capacity |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // TODO: pre-grow the nsTArray to the right capacity | ||
| // otherwise the below code won't work | ||
| for (image, geckoimage) in images.0.into_iter().zip(self.gecko.mImage.mLayers.iter_mut()) { |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 24, 2016
Author
Member
Github doesn't show this diff well, but the below code is simply indented one level with a change to the Gecko_SetGradientImageValue line
| "<thing> [ , <thing> ]*", but only support a single value | ||
| in servo | ||
| </%doc> | ||
| <%def name="gecko_autoarray_longhand(name, **kwargs)"> |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 24, 2016
Author
Member
once servo starts supporting <thing> [ , <thing> ]* properties we can refactor this to work in general and have a thin conditional-compile wrapper around it.
|
Nice! In terms of reallocating, I think we should just do an FFI call, otherwise there's lots of stuff we need to worry about. Didn't look too closely here, @emilio should probably review since he did the initial array stuff. But it's great to see a clean and easy abstraction on this stuff! :-) |
|
Yeah, reallocating is basically why I didn't made a more vec-like interface for nsTArray. I can't probably take a deeper look today (I'm packing things), but yeah, I'd go with the FFI call to reallocate. Probably we could share allocators (I already had a patch for it, though I need to double-check it does the correct thing evrrywhere), but for now I think we should try to avoid duplicating all the logic there. If a template function with a pointer to the nsTArray doesn't work (I don't think it'd work, since the functions won't ever be instantiated), probably passing the size of the element would be sufficient, though it'd require to do a bit more math. Probably receiving a size and a pointer to I can prioritize the allocator patch though, if you'd prefer to try to write that logic in rust. |
|
nsTArray<uint8_t>, I meant |
|
Ugh, github mobile strips my less than signs, I meant an nsTArray of uint8_t |
|
|
||
| impl ToCss for computed_value::T { | ||
| fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { | ||
| if self.0.len() >= 1 { |
This comment has been minimized.
This comment has been minimized.
emilio
Jun 24, 2016
Member
This is probably a bit more tricky. In some props we might need to write none in the empty case, eg, animation-name.
This comment has been minimized.
This comment has been minimized.
| single_value::parse(context, parser) | ||
| }).map(|ok| SpecifiedValue(ok)) | ||
| } | ||
| impl ToComputedValue for SpecifiedValue { |
This comment has been minimized.
This comment has been minimized.
emilio
Jun 24, 2016
Member
Some (most?) of these properties are computed-value as specified, which would just involve a generic clone which would be cheaper.
I'm not opposed to land this as is, but I'd want a note about that here.
|
I think you can force-instantiate a generic function in C++. Something like http://stackoverflow.com/a/2155790/3670407 in the cpp file. |
|
Oh I guess the issue here is that we don't necessarily know the type we want it for in C++? I guess in that case just passing a size might be better. |
|
Is the allocator patch necessary? I was hoping we could call whatever grow function gecko uses through FFI; I just don't yet know which function that is (havent really looked), and what button to press to get bindings for it. That way we can use whatever reallcoation logic that gecko uses. And we are not dependent on shared allocators. |
|
Oh, monomorphization. Ugh. |
|
Oh, sure you can force-instantiate it, and we can probably know most if not all of the types we'd need. I don't want to know what MSVC would think about that though :P So yea, I'd go for an ffi fn like:
|
|
If there are only a couple of types, it might be nicer to just have explicit separate FFI calls for each T to avoid too much scary munging. Is it more like 3 or more like 15? |
|
I think there were about 6 different types in the layers structure, and a few more at least. |
|
So, https://dxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTArray.h#380 exists and is really all we need here. It is not parametrized on the type, just on the ActualAlloc (not sure what actualalloc we use, or what exactly that is). So it will always be monomorphized. How do I get bindings to this? |
|
@Manishearth So our That doesn't change the way we can generate bindings to it though, and it'd be creating a gecko function with the signature as above, and just calling that other function from gecko instead of doing it manually. |
|
I'm having tons of trouble building bindgen. First, I tried using llvm38, getting the following error: "_clang_Cursor_isFunctionInlined", referenced from:
bindgen::clang::Cursor::is_inlined_function::hbf3ecb6d1f288ea8 in libbindgen.rlib(bindgen.0.o)I have a local clone of LLVM that is close to trunk (cloned a month ago), which I installed. This made the bindgen build work. (I later ran Then when running bindgen I get
The bindings files are just emptied out. I'm pretty sure I've done something wrong at this point Could someone with a working bindgen setup explain how theirs was set up? Preferably on a mac. |
|
Yeah, you need to brew install llvm38. We don't actually need the tip stuff for stylo, so @emilio is going to make that dep optional. For the headers, you need to make sure your standard library is installed to /usr/local. On mac, I think xcode-select --install should do it. |
|
I did run xcode-select --install, it seemed to already exist. Mine are in /usr/include though. They work when used on an external C++ file; just seems like bindgen can't find them. So currently we need to use llvm tip to get things working, right? llvm38 is just a future goal? |
f0dd478
to
c0c4b34
|
|
c0c4b34
to
209255b
|
@bors-servo: r+ Awesome! :) |
|
|
|
@bors-servo: p=1
|
Add support for gecko-only array values; use for stylo Doesn't yet work, because I can't grow nsTArrays from Rust. If anyone knows how to add bindings for that, let me know! Thoughts on the design so far? Once this PR lands, all of the array-accepting background- properties can just use gecko_autoarray_longhand and some iterators in the geckolib implementation without changing much other code to work with arrays. cc @emilio @bholley <!-- 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/11851) <!-- Reviewable:end -->
|
|
This doesn't actually work in this case, because the values aren't the same. One is |
Cleanups in autoarray helper Addresses @emilio's comments from #11851 - Replace gecko_autoarray_longhand with vector_longhand, make it configurable - Allow for empty vectors, use empty vector longhand in box-shadow <!-- 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/12458) <!-- Reviewable:end -->
Cleanups in autoarray helper Addresses @emilio's comments from #11851 - Replace gecko_autoarray_longhand with vector_longhand, make it configurable - Allow for empty vectors, use empty vector longhand in box-shadow <!-- 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/12458) <!-- Reviewable:end -->
Cleanups in autoarray helper Addresses @emilio's comments from #11851 - Replace gecko_autoarray_longhand with vector_longhand, make it configurable - Allow for empty vectors, use empty vector longhand in box-shadow <!-- 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/12458) <!-- Reviewable:end -->
Manishearth commentedJun 24, 2016
•
edited by larsbergstrom
Doesn't yet work, because I can't grow nsTArrays from Rust. If anyone knows how to add bindings for that, let me know!
Thoughts on the design so far? Once this PR lands, all of the array-accepting background- properties can just use gecko_autoarray_longhand and some iterators in the geckolib implementation without changing much other code to work with arrays.
cc @emilio @bholley
This change is