diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-03-06 00:32:12 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2018-03-07 17:31:01 -0800 |
commit | 6c0599b536cb3f2e6e583b3e33fc6bcc547cda37 (patch) | |
tree | 432d9c801f688d1b8b0e3b6aa76454256952af76 /platform/darwin | |
parent | 12664cd4c42b20e513146ddab1f17d8c3da0a6e7 (diff) | |
download | qtlocation-mapboxgl-6c0599b536cb3f2e6e583b3e33fc6bcc547cda37.tar.gz |
[macos] Assume sRGB for mbgl expressions, CSS in attribution
Assume mbgl needs colors in the sRGB color space rather than the calibrated RGB color space. Fixed link colors when creating attribution from HTML.
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLAttributionInfo.mm | 7 | ||||
-rw-r--r-- | platform/darwin/test/MGLTileSetTests.mm | 12 |
2 files changed, 16 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index 73147270c1..07d10e852b 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -49,7 +49,12 @@ CGFloat blue; CGFloat alpha; #if !TARGET_OS_IPHONE - linkColor = [linkColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + // CSS uses the sRGB color space. + if ([NSColor redColor].colorSpaceName == NSCalibratedRGBColorSpace) { + linkColor = [linkColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + } else { + linkColor = [linkColor colorUsingColorSpace:[NSColorSpace sRGBColorSpace]]; + } #endif [linkColor getRed:&red green:&green blue:&blue alpha:&alpha]; [css appendFormat: diff --git a/platform/darwin/test/MGLTileSetTests.mm b/platform/darwin/test/MGLTileSetTests.mm index 74c84184e1..2319f66447 100644 --- a/platform/darwin/test/MGLTileSetTests.mm +++ b/platform/darwin/test/MGLTileSetTests.mm @@ -66,8 +66,16 @@ // when the tile set has attribution infos MGLAttributionInfo *mapboxInfo = [[MGLAttributionInfo alloc] initWithTitle:[[NSAttributedString alloc] initWithString:@"Mapbox"] URL:[NSURL URLWithString:@"https://www.mapbox.com/"]]; +#if TARGET_OS_IPHONE + UIColor *redColor = [UIColor redColor]; +#else + // CSS uses the sRGB color space. In macOS 10.12 Sierra and below, + // -[NSColor redColor] is in the calibrated RGB space and has a slightly + // different sRGB value than on iOS and macOS 10.13 High Sierra. + NSColor *redColor = [NSColor colorWithSRGBRed:1 green:0 blue:0 alpha:1]; +#endif NSAttributedString *gl = [[NSAttributedString alloc] initWithString:@"GL" attributes:@{ - NSBackgroundColorAttributeName: [MGLColor redColor], + NSBackgroundColorAttributeName: redColor, }]; MGLAttributionInfo *glInfo = [[MGLAttributionInfo alloc] initWithTitle:gl URL:nil]; tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, @{ @@ -82,7 +90,7 @@ #else NSString *html = (@"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica\">" @"<a href=\"https://www.mapbox.com/\">Mapbox</a> </font>" - @"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica; background-color: #ff2600\">GL</font>\n"); + @"<font face=\"Helvetica\" size=\"3\" style=\"font: 12.0px Helvetica; background-color: #ff0000\">GL</font>\n"); #endif XCTAssertEqualObjects(@(tileSet.attribution.c_str()), html); |