Commit Graph

1748 Commits

Author SHA1 Message Date
Colin Rofls b205c0fe7e Add CTLine::get_typographic_bounds
This also adds a type, TypographicBounds, for reporting the result
of this method.
2020-05-09 11:42:27 -04:00
bors-servo 4b765df60c Auto merge of #378 - kornelski:compstr, r=jdm
Make CFString comparable

Fixes #104

The `PartialEq` has to be on `CFString`, not `CFStringRef` due to orphan rules.
2020-05-08 11:56:31 -04:00
bors-servo 2b1432698d Auto merge of #379 - kornelski:nsnum, r=jdm
Test 64-bit NSNumbers

on macOS 10.15.5 Beta the property list tests fails, because dictionary serializes a 32-bit NSNumber, but property list deserializes it to a 64-bit NSNumber. Apparently, they make dictionaries not equal, even though numeric value is the same!

Here's a workaround that forces the NSNumber to be 64-bit.
2020-05-08 10:08:09 -04:00
Kornel be0c03033b Test 64-bit NSNumbers 2020-05-08 14:07:03 +01:00
Jeff Muizelaar 4b1ccbb467 Merge pull request #377 from kornelski/style
Fix style warnings
2020-05-08 08:32:57 -04:00
Jeff Muizelaar 7bfd1e2c50 Merge pull request #376 from kornelski/bundleurl
CFBundleCopyBundleURL
2020-05-08 08:32:17 -04:00
Kornel 977d4bbebd Make CFString comparable 2020-05-08 13:03:14 +01:00
Kornel acf2c86930 Fix style warnings 2020-05-08 11:42:06 +01:00
Kornel 6ded5c360f CFBundleCopyBundleURL 2020-05-08 11:38:31 +01:00
bors-servo 76f9053a89 Auto merge of #375 - casperstorm:feat/extended-nsprogressinfo, r=jdm
feat: extended NSProgressInfo with more functions

I have extended `NSProgressInfo` with two new functions:

* [`operatingSystemVersion`](https://developer.apple.com/documentation/foundation/nsprocessinfo/1410906-operatingsystemversion?language=objc) which returns a `NSOperatingSystemVersion` where you can get `majorVersion`, `minorVersion` and `patchVersion` from.

* [`isOperatingSystemAtLeastVersion`](https://developer.apple.com/documentation/foundation/nsprocessinfo/1414876-isoperatingsystematleastversion?language=objc) which takes a `NSOperatingSystemVersion` struct, and returns a `bool`.

Let me know if I missed something.
2020-05-06 10:08:38 -04:00
Casper Storm bdefcd927e feat: extended NSProgressInfo with more functions 2020-05-06 13:22:06 +02:00
bors-servo 16ec92e7c4 Auto merge of #374 - casperstorm:feat/nsuserdefaults-binding, r=jdm
feat: added bindings to NSUserDefaults

I have added bindings for [`NSUserDefaults`](https://developer.apple.com/documentation/foundation/nsuserdefaults). It is used in macOS for storing state, but it may also be used read/write state which is already set by the system. One example could be that an application would like to overwrite `CGFontRenderingFontSmoothingDisabled` for enabling sub-pixel antialiasing on > 10.14.

Let me know if I can improve anything.
2020-04-29 09:21:25 -04:00
Casper Storm 9c4b5c9310 feat: added binding to NSUserDefaults 2020-04-29 12:22:51 +02:00
bors-servo 508a372895 Auto merge of #370 - brunogouveia:attribute-string-set-attribute, r=jdm
Change CFMutableAttributedString::set_attribute argument type

Type of the argument `value` can be a reference as opposed to requiring the value's ownership.
2020-04-17 15:39:43 -04:00
brunohgouveia b68e9c782a Change CFMutableAttributedString::set_attribute argument type 2020-04-17 20:35:11 +01:00
bors-servo 1865cb8861 Auto merge of #369 - brunogouveia:context-from-ptr, r=jdm
Support to create CGContext from existing ptr

Add `CGContextRetain` and `CGContextRelease`
Add function to create CGContext from existing ::sys::CGContextRef pointer
2020-04-15 19:32:51 -04:00
brunohgouveia 8fb46bd58a Add CGContextRetain and CGContextRelease
Add function to create CGContext from existing ::sys::CGContextRef pointer
2020-04-16 00:21:03 +01:00
bors-servo 45692bd190 Auto merge of #368 - brunogouveia:shadows, r=jdm
Add CGContextSetShadow and CGContextSetShadowWithColor to CGContext
2020-04-13 19:37:22 -04:00
brunohgouveia 999128fc71 Add CGContextSetShadow and CGContextSetShadowWithColor to CGContext 2020-04-14 00:12:00 +01:00
bors-servo 1e06588c4b Auto merge of #365 - brunogouveia:add-cg-gradient, r=jdm
Add CGGradient and CGContext gradient draw functions

This PR adds the following missing APIs:
- Added [CGGradient](https://developer.apple.com/documentation/coregraphics/cggradient) in the `core_graphics::gradient` module.
- Added [CGContextDrawLinearGradient](https://developer.apple.com/documentation/coregraphics/1454782-cgcontextdrawlineargradient) and [CGContextDrawRadialGradient](https://developer.apple.com/documentation/coregraphics/1455923-cgcontextdrawradialgradient) in the `core_graphics::context` module.
2020-04-13 16:52:02 -04:00
bors-servo 8a02888d43 Auto merge of #367 - brunogouveia:add-text-line, r=jdm
Add missing APIs to CTLine

Added the following missing APIs to [CTLine](https://developer.apple.com/documentation/coretext/ctline):
- CTLineDraw
- CTLineGetImageBounds
- CTLineGetStringIndexForPosition
- CTLineGetOffsetForStringIndex

Added `CGContextSetTextPosition` to `CGContext`.

Added `CGTextFillStrokeClip` to `CGTextDrawingMode`.
2020-04-13 16:46:04 -04:00
brunohgouveia 1f4c983cee Add missing APIs to CTLine 2020-04-13 21:25:53 +01:00
bors-servo 051649eb94 Auto merge of #366 - brunogouveia:add-geometry, r=jdm
Add missing APIs to CGAffineTransform

Added the following missing APIs to [CGAffineTransform](https://developer.apple.com/documentation/coregraphics/cgaffinetransform-rb5):

- CGAffineTransformMakeTranslation
- CGAffineTransformMakeRotation
- CGAffineTransformMakeScale
- CGAffineTransformTranslate
- CGAffineTransformRotate
- CGAffineTransformScale
2020-04-13 16:07:47 -04:00
brunohgouveia ca3c41846e Add missing APIs to CGAffineTransform 2020-04-13 20:54:50 +01:00
brunohgouveia c503b4eddb Add CGGradient and CGContext gradient draw functions 2020-04-13 20:43:50 +01:00
bors-servo 24daecbe77 Auto merge of #360 - servo:jdm-patch-5, r=jdm
No more 32 bit apple targets.
2020-03-21 13:19:47 -04:00
Josh Matthews 23afe7d78e No more 32 bit apple targets. 2020-03-18 10:19:26 -04:00
bors-servo 394748d2b7 Auto merge of #358 - chrisduerr:isKeyWindow, r=jdm
Add isKeyWindow function to NSWindow
2020-03-01 15:52:17 -05:00
Christian Duerr c31f6bd166 Add isKeyWindow function to NSWindow 2020-03-01 21:39:01 +01:00
bors-servo 6c77b5a5e7 Auto merge of #357 - vbadanov:hotfix/fix-mutable-attributed-string-get-type-id, r=jdm
Fix for link error - undefined CFMutableAttributedStringGetTypeID

## Intention
Fix for https://github.com/rust-lang/rust/issues/63047 and https://github.com/intellij-rust/intellij-rust/issues/4605

## How to reproduce
The following program fails to compile:

```rust
use core_foundation::attributed_string::{CFAttributedString, CFMutableAttributedString};
use core_foundation::base::TCFType;

fn main() {
    dbg!(<CFAttributedString as TCFType>::type_id());
    dbg!(<CFMutableAttributedString as TCFType>::type_id());
}
```

```
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.198s3ihm7i58x886.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.29tmhebao6ewa0ll.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.2d9bu5z2mybg821y.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.47seajd45h5x4xvx.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.4m5r63z1bomeava7.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.dyb0rm2k46lhkz1.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.ux6g43y1awzd3xm.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.ysgemo5b5rzmi6m.rcgu.o" "-o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.25q0sul7ku3gti43.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps" "-L" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/libcore_foundation-3b681be94f15488f.rlib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/liblibc-e84db2977ac0591b.rlib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/libcore_foundation_sys-2e4eeadb22527df2.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-c9ffd87d7c2bccdf.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-b6d1e628327abbae.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-760b1a8bb4bcc351.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-1660704e36532385.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-c11c21cbed796daf.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-6c38e3c045a3a71f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-5bfb7cde712ed2a9.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-4540ebf06eb7e37e.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-0a35227c3d306cf2.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-c976a950e872076f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-ef822b0e650993e5.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-172ea43efe468d24.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-4d87cbd247e9505f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-3943751ba8f04dce.rlib" "-framework" "CoreFoundation" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: Undefined symbols for architecture x86_64:
            "_CFMutableAttributedStringGetTypeID", referenced from:
                _$LT$core_foundation..attributed_string..CFMutableAttributedString$u20$as$u20$core_foundation..base..TCFType$GT$::type_id::h9f6f71bdd347aca0 in foo-cef9f22f855ec251.198s3ihm7i58x886.rcgu.o
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
```

## Root cause
Core Foundation framework does not have `CFMutableAttributedStringGetTypeID()` function.
1. Documentation of [CFMutableAttributedString](https://developer.apple.com/documentation/corefoundation/cfmutableattributedstring-rqp) does not have function `CFMutableAttributedStringGetTypeID()` listed.
2. Documentation of [CFAttributedString](https://developer.apple.com/documentation/corefoundation/cfattributedstring-s1s) says that there is function `CFAttributedStringGetTypeID()` available (without word "Mutable").
3. Documentation of [CFAttributedStringGetTypeID()](https://developer.apple.com/documentation/corefoundation/1541715-cfattributedstringgettypeid) says the following:
    > CFMutableAttributedString objects have the same type identifier as CFAttributedString objects.
4. As a double check - there is no `CFMutableAttributedStringGetTypeID()` function in C/C++ headers on MacOS, but `CFAttributedStringGetTypeID()` is available. C/C++ test program (similar to Rust above) does not compile as well.

So, `CFAttributedStringGetTypeID()` must be used instead of `CFMutableAttributedStringGetTypeID()`

## Solution
1. In `core-foundation-sys`: Remove `extern CFMutableAttributedStringGetTypeID()`
2. In `core-foundation`:
    * Replace `CFMutableAttributedStringGetTypeID` with `CFAttributedStringGetTypeID`
    * Add test (compilation fails before the fix and is OK after the fix)
2020-02-21 16:27:12 -05:00
Vasiliy Badanov aa6d1cd4c1 Fix for link error "Undefined symbols for architecture x86_64: _CFMutableAttributedStringGetTypeID" 2020-02-21 23:40:36 +03:00
bors-servo 096f217cc6 Auto merge of #356 - not-a-seagull:master, r=jdm
Add new methods to NSView

https://developer.apple.com/documentation/appkit/nsview/

I have added setFrameOrigin and setFrameSize to the `NSView` trait and its `id` implementation.
2020-02-14 14:17:36 -05:00
not_a_seagull 0bc3b53667 Add new methods to NSView 2020-02-13 15:23:06 -08:00
bors-servo d386f28615 Auto merge of #353 - maxbrunsfeld:glyph-run-get-string-indices, r=jdm
Add binding for CTRunGetStringIndices

This PR adds a `CTRun::string_indices` method, which exposes CoreText's `CTRunGetStringIndices`/`CTRunGetStringIndicesPtr` API. The implementation is basically identical to `CTRun::glyphs` and `CTRun::positions`.

I added an assertion about the new method in the existing unit test.
2020-01-09 11:59:19 -05:00
Max Brunsfeld f763977a76 Move doc comment to struct inside bitflags invocation 2020-01-09 08:38:33 -08:00
Max Brunsfeld d95d3fa743 Fix miscellaneous compile warnings 2020-01-08 20:47:41 -08:00
Max Brunsfeld 8c932e649b Add binding for CTRunGetStringIndices (CTRun::string_indices) 2020-01-08 16:42:33 -08:00
bors-servo 0a3ac83c1b Auto merge of #349 - wez:timertypes, r=jdm
Fix CFRunLoop types to avoid UB

A number of callback functions associated with the CFRunLoop types are
allowed to be NULL to evoke default behavior.

Prior to this commit the definition of those structs prevented passing
in null which meant resorting to transmute or other tricks to
effectively set null, but with recent compiler versions the compiler
emits `ud2` instructions and triggers a fault at runtime.

The correct resolution for this is to define these fields as `Option`al
callbacks and that is what this commit does.

I've used this approach successfully here in another project:
Refs: https://github.com/wez/wezterm/commit/398f333c32fb1ff4ccd9cc001a66ae22522eb60c

I've bumped up the version for the crate as part of this commit
because it effectively changes the API around these structs.
2019-11-12 18:08:51 -05:00
Wez Furlong a11978895e even more version bumps 2019-11-12 14:30:56 -08:00
Wez Furlong 6574b12d4a more version bumps! 2019-11-12 14:16:35 -08:00
bors-servo 071812648a Auto merge of #350 - lqf96:fix-deprecated-usage, r=jdm
Fix deprecated usage of Rust features

This PR fixes some deprecated usage of Rust features. However, because of the use of `MaybeUninit` this PR will bump the minimum required Rust version to 1.36, which will need some discussion.
2019-11-12 15:44:44 -05:00
Qifan Lu 83b6f5d20a Use zero-initialized array in CFURL::to_path 2019-11-12 12:37:41 -08:00
Wez Furlong 3126f15fd6 adjust test 2019-11-11 22:46:10 -08:00
Qifan Lu d3a097f2a4 Use dyn for dynamic dispatch 2019-11-11 20:59:26 -08:00
Qifan Lu e438fc54b9 Use ? instead of try macro 2019-11-11 20:57:09 -08:00
Qifan Lu 727837f12e Use MaybeUninit instead of mem::uninitialized 2019-11-11 20:55:59 -08:00
Wez Furlong e7f687e3d4 moar version bumps 2019-11-11 20:29:01 -08:00
Wez Furlong 31d0d4e970 need to bump this version also 2019-11-11 20:22:49 -08:00
Wez Furlong cf3659fc6f Fix CFRunLoop types to avoid UB
A number of callback functions associated with the CFRunLoop types are
allowed to be NULL to evoke default behavior.

Prior to this commit the definition of those structs prevented passing
in null which meant resorting to transmute or other tricks to
effectively set null, but with recent compiler versions the compiler
emits `ud2` instructions and triggers a fault at runtime.

The correct resolution for this is to define these fields as `Option`al
callbacks and that is what this commit does.

I've used this approach successfully here in another project:
Refs: https://github.com/wez/wezterm/commit/398f333c32fb1ff4ccd9cc001a66ae22522eb60c

I've bumped up the version for the crate as part of this commit
because it effectively changes the API around these structs.
2019-11-11 19:57:48 -08:00
bors-servo 80a9bf00e4 Auto merge of #346 - servo:publish, r=nox
Publish core-foundation-sys, core-foundation, core-text
2019-11-05 06:55:42 -05:00