Bug 230792

Summary: base-palette can accept "light" or "dark"
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: TextAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: clopez, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, macpherson, menard, mmaxfield, simon.fraser, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 230800, 231029    
Bug Blocks: 230446    
Attachments:
Description Flags
Patch to make FontCreationContext optional
none
Patch to implement light/dark
none
Patch
none
Patch
none
Test font
none
Patch
none
Patch simon.fraser: review+

Description Myles C. Maxfield 2021-09-25 03:42:11 PDT
-
Comment 1 Radar WebKit Bug Importer 2021-09-25 03:43:08 PDT
<rdar://problem/83530228>
Comment 3 Myles C. Maxfield 2021-09-25 15:05:05 PDT
Created attachment 439273 [details]
Patch to make FontCreationContext optional
Comment 4 Myles C. Maxfield 2021-09-25 15:05:32 PDT
Created attachment 439274 [details]
Patch to implement light/dark
Comment 5 Myles C. Maxfield 2021-09-25 18:07:27 PDT
Comment on attachment 439273 [details]
Patch to make FontCreationContext optional

The FontCreationContext work is moved to https://bugs.webkit.org/show_bug.cgi?id=230800
Comment 6 Myles C. Maxfield 2021-09-25 18:25:42 PDT
Created attachment 439279 [details]
Patch

EWS will be red because this patch depends on https://bugs.webkit.org/show_bug.cgi?id=230800.
Comment 7 Myles C. Maxfield 2021-09-25 18:31:36 PDT
This patch needs tests.
Comment 8 Myles C. Maxfield 2021-09-28 22:32:12 PDT
Created attachment 439566 [details]
Patch
Comment 9 Myles C. Maxfield 2021-09-29 11:52:53 PDT
Created attachment 439636 [details]
Test font
Comment 10 Myles C. Maxfield 2021-09-30 11:55:04 PDT
Created attachment 439763 [details]
Patch
Comment 11 EWS Watchlist 2021-09-30 11:56:33 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 12 Myles C. Maxfield 2021-09-30 17:27:15 PDT
Comment on attachment 439763 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439763&action=review

> LayoutTests/imported/w3c/ChangeLog:9
> +        I will open a WPT PR for these posthaste.

https://github.com/web-platform-tests/wpt/pull/31044
Comment 13 Myles C. Maxfield 2021-09-30 17:39:58 PDT
Created attachment 439805 [details]
Patch
Comment 14 Simon Fraser (smfr) 2021-10-01 12:59:56 PDT
Comment on attachment 439805 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439805&action=review

> Source/WebCore/ChangeLog:26
> +            int64_t integer;

Does the spec require these be 64-bit?

> Source/WebCore/platform/graphics/FontPaletteValues.h:40
> +    FontPaletteIndex()

= default

> Source/WebCore/platform/graphics/FontPaletteValues.h:83
> +    enum class Type {

: uint8_t ?

> Source/WebCore/platform/graphics/FontPaletteValues.h:88
> +    } type { Type::String };

I like to use 'const' for members that can only ever be set in the constructor.

> Source/WebCore/platform/graphics/FontPaletteValues.h:90
> +    unsigned integer { 0 };

You had int64_t in the changelog

> Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:472
> +        int64_t rawIndex = basePalette.integer; // There is no kCFNumberUIntType.
> +        auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &rawIndex));
> +        CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get());

Can author-supplied values conflict with kCTFontPaletteLight, kCTFontPaletteDark?
Comment 15 Myles C. Maxfield 2021-10-01 13:06:41 PDT
Comment on attachment 439805 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439805&action=review

>> Source/WebCore/ChangeLog:26
>> +            int64_t integer;
> 
> Does the spec require these be 64-bit?

Nope. In fact, our parser clamps to 32-bit. I'll update the changelog to be "unsigned" to match the implementation.

>> Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:472
>> +        CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get());
> 
> Can author-supplied values conflict with kCTFontPaletteLight, kCTFontPaletteDark?

It depends if https://github.com/w3c/csswg-drafts/issues/6627 is accepted or not. If it's accepted (which I hope it is), there won't be a collision.
Comment 16 Myles C. Maxfield 2021-10-01 13:37:33 PDT
Comment on attachment 439805 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439805&action=review

>> Source/WebCore/platform/graphics/FontPaletteValues.h:88
>> +    } type { Type::String };
> 
> I like to use 'const' for members that can only ever be set in the constructor.

It looks like that, because this is used as a key in a hash map, and our hash map infrastructure uses operator= to overwrite the buckets in the table, all the fields have to be assignable. :(
Comment 17 Myles C. Maxfield 2021-10-01 14:01:00 PDT
Committed r283398 (242402@main): <https://commits.webkit.org/242402@main>