Commit Graph

1486 Commits

Author SHA1 Message Date
bors-servo 0d5cc0faee Auto merge of #229 - waywardmonkeys:remove-2-transmutes, r=jrmuizel
core-foundation: Remove 2 transmutes in macros.

These transmutes were going from one type of pointer to another,
and so can be done as casts instead.

Doing so also means that one unsafe block can be removed.

This was found via clippy.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/229)
<!-- Reviewable:end -->
2018-07-20 11:43:33 -04:00
bors-servo 13399fa3f8 Auto merge of #232 - servo:jrmuizel-patch-1, r=jdm
Use stable rust instead of nightly

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/232)
<!-- Reviewable:end -->
2018-07-20 11:40:04 -04:00
Jeff Muizelaar 0ab07de566 Use stable rust instead of nightly 2018-07-20 11:34:00 -04:00
bors-servo 8ff175b50a Auto merge of #231 - servo:scrollhide, r=jrmuizel
Hide a 10.13+ API behind a cargo feature.

Fixes #230.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/231)
<!-- Reviewable:end -->
2018-07-20 11:29:44 -04:00
Josh Matthews a5935351b5 Hide a 10.13+ API behind a cargo feature. 2018-07-20 11:15:53 -04:00
Bruce Mitchener 2c7ecae7a1 core-foundation: Remove 2 transmutes in macros.
These transmutes were going from one type of pointer to another,
and so can be done as casts instead.

Doing so also means that one unsafe block can be removed.

This was found via clippy.
2018-07-19 22:18:06 +07:00
bors-servo 2bea7c75b9 Auto merge of #226 - grovesNL:class-macro, r=jdm
Use new objc class macro

This PR removes the `class` function in favor of the [new `class` macro exposed by objc](https://github.com/SSheldon/rust-objc/issues/65) which caches access by class name. Note that this macro should eventually (through procedural macros) be able to link directly to the class.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/226)
<!-- Reviewable:end -->
2018-07-17 15:40:33 -04:00
Joshua Groves 82978bf6fe Use class macro 2018-07-16 19:52:42 -06:00
bors-servo 87878545f7 Auto merge of #227 - servo:gleam, r=jdm
Update gleam to 0.6

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/227)
<!-- Reviewable:end -->
2018-07-16 11:27:13 -04:00
Anthony Ramine bec66aa8f8 Update gleam to 0.6 2018-07-16 17:13:10 +02:00
bors-servo a5930ad107 Auto merge of #225 - jrmuizel:minor-ver, r=jdm
Bump minor version of core-foundation for past changes.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/225)
<!-- Reviewable:end -->
2018-07-12 10:47:08 -04:00
Jeff Muizelaar 4fe550a8fc Bump minor version of core-foundation for past changes. 2018-07-12 10:14:25 -04:00
bors-servo 6074cded51 Auto merge of #223 - mehcode:feature/attributed-string, r=jrmuizel
Add CF(Mutable)AttributedString and a couple helpers

Just declared stuff that I'm using. Copied the basic template from CFString.

----

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/223)
<!-- Reviewable:end -->
2018-07-06 16:47:27 -04:00
Ryan Leckey 1d369075c3 Add CF(Mutable)AttributedString and a couple helpers 2018-07-06 12:25:18 -07:00
bors-servo 2aac8fb85b Auto merge of #220 - TimNN:cfstring-refactor, r=jdm
CFString refactor / cleanup

This pull request:
- removes two unnecessary casts (from `CFIndex` to `usize` and back again)
- extracts the to rust string conversion: instead of doing it on-the-fly in the `Display` implementation (and thus only supporting the indirect `ToString` way to get a rust string from a `CFString`, which _always_ allocates) this implements `From<&CFString> for Cow<str>` allowing everyone the possibility of avoiding an allocation if the `CFString` is already formatted in UTF-8.

Rebase of #76 (note to self: next time, re-open first, then push).

cc @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/220)
<!-- Reviewable:end -->
2018-05-29 15:34:10 -04:00
Tim Neumann dd3a4b5af0 CFString: remove unnecessary casts 2018-05-29 21:29:28 +02:00
Tim Neumann 5faf448418 CFString: extract to Cow conversion 2018-05-29 21:27:58 +02:00
bors-servo 410c1e8a15 Auto merge of #219 - snapview:cg-extensions, r=jdm
Additional functions for `CGImage` and `CGDataProvider`

1. Adds a possibility to construct a CGImage from a given provider. I don't know if it's the most optimal way to implement it and if it is safe, but it would be nice to wrap this function somehow, that was the first attempt to do it.
2. Adds some rendring intent constants.
3. Adds a function which allows to create a data provider from a slice. This is highly unsafe, that's why I marked it with unsafe. And I'm not sure if it is the best way to do this. Perhaps the one can store something like `Option<slice>` in the data provider, but in this case the provider will get some lifetime parameter (and we have to update the foreign type definition). I'm not sure that having slice parameter and a lifetime would make it 100% safe though, because when we're passing a data provider ref to some FFI, they could theoretically retain a data provider (or the image which uses the data provider), expecting that the data inside the data provider lives long enough. Probably the only "really safe" way to manage the data provider data is the one which is currently available (via `Arc<Vec<u8>>`), but this limitation of having `Arc<Vec<u8>>` may be very ineffective in some sort of appliations, so for instance in my case I had to add the additional "constructor" to allow creation of unsafe data provider and I guarantee the safety in my code by some other means.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/219)
<!-- Reviewable:end -->
2018-05-29 11:50:13 -04:00
Daniel Abramov ff9ff84066 Add the posibility to create a provider from slice 2018-05-28 13:46:08 +02:00
Daniel Abramov 1eec1419a9 Add rendering intent constants 2018-05-28 13:46:08 +02:00
Daniel Abramov c9740e7ddc Add a constructor for CGImage 2018-05-28 13:46:08 +02:00
bors-servo 4b18623515 Auto merge of #217 - jrmuizel:update-gleam, r=kvark
Update gleam to 0.5

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/217)
<!-- Reviewable:end -->
2018-05-08 10:55:25 -04:00
Jeff Muizelaar 02e5955e76 Update gleam to 0.5 2018-05-08 10:32:56 -04:00
bors-servo 7d83975dc5 Auto merge of #216 - jrmuizel:io-surface-new, r=kvark
Change io_surface::new() to take a typed CFDictionary.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/216)
<!-- Reviewable:end -->
2018-05-08 10:31:41 -04:00
Jeff Muizelaar 2d0199f1f5 Change io_surface::new() to take a typed CFDictionary. 2018-05-08 10:30:51 -04:00
bors-servo 2ba1ea2405 Auto merge of #158 - faern:unsound-casting, r=jrmuizel
BUG: Add test showing how downcasting to CFArray is unsound

This PR is not intended to me merged directly. It adds a test that causes undefined behavior without using `unsafe {}`. So it's more to show the problem and discuss a solution.

The problem here is that if you have a `CFArray<X>` you can cast it up to a `CFType` and then down to a `CFArray<Y>` for any `Y: TCFType`. It never checks that the elements in the array are of type `Y` or not. At this point `CFArray::iter` will happily give out `&Y` references, while in fact the pointers backing those objects are pointing to `XRef` instances. So doing anything with the `&Y` will likely cause invalid memory access.

How do we solve this?

Ping @jrmuizel

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/158)
<!-- Reviewable:end -->
2018-05-07 11:10:22 -04:00
bors-servo ec288cd3ee Auto merge of #214 - jrmuizel:c_void, r=jdm
Consistently use std::os::raw::c_void instead of libc::c_void

The major versions of cocoa and core-graphics are bumped as I believe
they are the only crates that meaningfully expose c_void.

Fixes #212

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/214)
<!-- Reviewable:end -->
2018-05-06 20:36:36 -04:00
Jeff Muizelaar 645779912b Consistently use std::os::raw::c_void instead of libc::c_void
The major versions of cocoa and core-graphics are bumped as I believe
they are the only crates that meaningfully expose c_void.

Fixes #212
2018-05-06 19:00:37 -04:00
bors-servo 0150e9b2b1 Auto merge of #213 - jrmuizel:variation-axes, r=jdm
Expose CTFontCopyVariationAxes.

WebRender uses this function so it's probably useful to expose.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/213)
<!-- Reviewable:end -->
2018-05-03 17:38:54 -04:00
Jeff Muizelaar 5e77c85500 Expose CTFontCopyVariationAxes.
WebRender uses this function so it's probably useful to expose.
2018-05-03 17:01:26 -04:00
bors-servo ef38ca1dea Auto merge of #210 - jrmuizel:update-ver, r=jdm
Update all of the major versions for the new releases

Basically everything needed to be bumped because of changes to
core-foundation-sys

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/210)
<!-- Reviewable:end -->
2018-05-02 17:48:08 -04:00
Jeff Muizelaar bb9ce9e8e1 Update all of the major versions for the new releases
Basically everything needed to be bumped because of changes to
core-foundation-sys
2018-05-02 17:46:00 -04:00
bors-servo b5923bb1e0 Auto merge of #202 - servo:typed-variations, r=jrmuizel
Only allow CFNumber font variations.

Until #201 this seems like a worthwhile improvement.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/202)
<!-- Reviewable:end -->
2018-05-02 17:05:44 -04:00
Josh Matthews e614c2df26 Only allow CFNumber font variations. 2018-05-02 16:56:27 -04:00
bors-servo 023d80bd57 Auto merge of #209 - msanders:ms/scroll-event, r=jrmuizel
Add CGEventCreateScrollWheelEvent binding

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/209)
<!-- Reviewable:end -->
2018-05-02 16:55:18 -04:00
Michael Sanders ca74318a75 Add CGEventCreateScrollWheelEvent binding 2018-05-02 13:46:08 -07:00
bors-servo 23d24f47ad Auto merge of #208 - edwin0cheng:fullscreen-mode-options, r=jdm
Add NSViewFullScreenModeOptionKey keys

This PR added NSViewFullScreenModeOptionKey values described in [here](https://developer.apple.com/documentation/appkit/nsviewfullscreenmodeoptionkey?language=objc)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/208)
<!-- Reviewable:end -->
2018-05-02 13:01:24 -04:00
Edwin Cheng 80b970b476 Add NSFullScreenModeApplicationPresentationOptions key and its options 2018-05-03 00:37:58 +08:00
bors-servo 8f4c416eb8 Auto merge of #207 - edwin0cheng:add_cg_funcs, r=jrmuizel
Adding CGGetDisplaysWithRect binding

- Added [CGGetDisplaysWithRect](https://developer.apple.com/documentation/coregraphics/1456071-cggetdisplayswithrect?language=objc) binding.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/207)
<!-- Reviewable:end -->
2018-04-18 22:08:13 -04:00
Edwin Cheng 5974b4c5dc Added CGGetDisplaysWithRect 2018-04-19 09:50:01 +08:00
bors-servo 794dd55fc9 Auto merge of #204 - vbo:presentation-options, r=jrmuizel
Adding NSApplicationPresentationOptions bindings

 - Adding bindings for NSApplicationPresentationOptions and related methods as discussed in #203.
 - Adding usage example.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/204)
<!-- Reviewable:end -->
2018-04-17 11:30:37 -04:00
Vadim Borodin b6f8e0b117 Adding NSApplicationPresentationOptions bindings 2018-04-15 18:22:51 -07:00
Linus Färnstrand 6c63acc55a Add test showing how downcasting to CFArray with generic is prohibited 2018-03-20 22:36:47 +01:00
bors-servo 680013abf1 Auto merge of #199 - jrmuizel:info-dict, r=jdm
Make info_dictionary() return a more specific CFDictionary

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/199)
<!-- Reviewable:end -->
2018-02-08 10:08:11 -05:00
bors-servo a2b24c9fc8 Auto merge of #198 - jrmuizel:set, r=jdm
Give CFSet a type parameter

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/198)
<!-- Reviewable:end -->
2018-02-08 10:04:51 -05:00
Jeff Muizelaar 5a438ccece Make info_dictionary() return a more specific CFDictionary 2018-02-08 07:55:30 -05:00
Jeff Muizelaar ff7d421c32 Give CFSet a type parameter 2018-02-08 07:48:36 -05:00
bors-servo 022d74218c Auto merge of #196 - jrmuizel:text-stronger-types, r=jdm
Use stronger types in the core-text CFDictionaries

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/196)
<!-- Reviewable:end -->
2018-02-07 14:19:17 -05:00
Jeff Muizelaar b7f60a3c9d Use stronger types in the CFDictionaries 2018-02-07 14:11:21 -05:00
bors-servo 4e499ab4d2 Auto merge of #195 - jrmuizel:backing, r=jdm
Add convertRectToBacking to NSView

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/195)
<!-- Reviewable:end -->
2018-02-07 14:05:26 -05:00