Bug 225839 - Move CFStringRef and NSString support from StringBuilder into StringConcatenateCF
Summary: Move CFStringRef and NSString support from StringBuilder into StringConcatena...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-14 20:36 PDT by Darin Adler
Modified: 2021-06-01 05:51 PDT (History)
35 users (show)

See Also:


Attachments
Patch (23.78 KB, patch)
2021-05-14 20:54 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (23.83 KB, patch)
2021-05-14 21:00 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (23.86 KB, patch)
2021-05-14 21:00 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (59.98 KB, patch)
2021-05-14 22:19 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (59.97 KB, patch)
2021-05-14 23:59 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (123.22 KB, patch)
2021-05-15 16:53 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (126.22 KB, patch)
2021-05-15 17:00 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (135.38 KB, patch)
2021-05-15 18:41 PDT, Darin Adler
sam: review+
Details | Formatted Diff | Diff
Patch (135.13 KB, patch)
2021-05-18 00:37 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (144.35 KB, patch)
2021-05-18 12:31 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (146.27 KB, patch)
2021-05-18 13:03 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (148.39 KB, patch)
2021-05-18 14:07 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2021-05-14 20:36:31 PDT
Move CFStringRef and NSString support from StringBuilder into StringConcatenateCF
Comment 1 Darin Adler 2021-05-14 20:54:08 PDT Comment hidden (obsolete)
Comment 2 Darin Adler 2021-05-14 21:00:01 PDT Comment hidden (obsolete)
Comment 3 Darin Adler 2021-05-14 21:00:33 PDT Comment hidden (obsolete)
Comment 4 Darin Adler 2021-05-14 22:19:42 PDT Comment hidden (obsolete)
Comment 5 Darin Adler 2021-05-14 23:59:39 PDT Comment hidden (obsolete)
Comment 6 Darin Adler 2021-05-15 08:57:16 PDT Comment hidden (obsolete)
Comment 7 Darin Adler 2021-05-15 16:53:43 PDT Comment hidden (obsolete)
Comment 8 Darin Adler 2021-05-15 17:00:55 PDT Comment hidden (obsolete)
Comment 9 Darin Adler 2021-05-15 18:41:40 PDT
Created attachment 428759 [details]
Patch
Comment 10 Sam Weinig 2021-05-16 09:49:49 PDT
Comment on attachment 428759 [details]
Patch

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

> Source/WTF/wtf/text/StringBuilder.h:124
> +    LChar* m_bufferCharacters { nullptr };

What is the intent of removing the union here and replacing its uses with reinterpret_casts<>? An alternative formulation we could consider (though it may have downsides I am not considering) is using a Variant<LChar*, UChar*> and removing the m_is8Bit bool.

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:327
>      Color textColor = captionsTextColor(important);

auto?
Comment 11 Darin Adler 2021-05-16 22:55:54 PDT
Comment on attachment 428759 [details]
Patch

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

>> Source/WTF/wtf/text/StringBuilder.h:124
>> +    LChar* m_bufferCharacters { nullptr };
> 
> What is the intent of removing the union here and replacing its uses with reinterpret_casts<>? An alternative formulation we could consider (though it may have downsides I am not considering) is using a Variant<LChar*, UChar*> and removing the m_is8Bit bool.

Your suggestion is excellent. To be honest I do not know why I chose to make the change I did, on reflection now. At one point I had changed it to a void* and was using static_cast.

I should probably switch back to the union.

I am tempted to switch to the Variant.

But one reason not to is the possibility of getting rid of m_is8Bit because m_string and m_buffer both already can answer that question, and there is no need to store the state redundantly.

It occurs to me that these bufferCharacters pointers don’t really have much value; they are used to optimize the fast path for append but I am not convinced the benefit is significant over calling m_buffer->characters() and chasing one more pointer; after all, we are already chasing the pointer to check m_buffer->length().

So likely could and should remove both m_bufferCharacters and m_is8Bit.

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:312
> +    Color textColor(adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior)).get());

Should use = style here instead of construction syntax I think.

>> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:327
>>      Color textColor = captionsTextColor(important);
> 
> auto?

Will do.

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:417
> +    auto name = adoptCF(CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute));

Should probably move the cast to CFStringRef up here because this is where we call the function guaranteed to return that type for this key.

> Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp:428
>              auto fontCascadeName = adoptCF(CTFontDescriptorCopyAttribute(fontCascade, kCTFontNameAttribute));

Here too. As is done just above for CFArrayRef.
Comment 12 Darin Adler 2021-05-18 00:37:47 PDT Comment hidden (obsolete)
Comment 13 Darin Adler 2021-05-18 12:31:36 PDT Comment hidden (obsolete)
Comment 14 Darin Adler 2021-05-18 13:03:04 PDT Comment hidden (obsolete)
Comment 15 Darin Adler 2021-05-18 14:07:24 PDT
Created attachment 428977 [details]
Patch
Comment 16 Darin Adler 2021-05-19 12:37:30 PDT
Committed r277744 (237916@main): <https://commits.webkit.org/237916@main>
Comment 17 Radar WebKit Bug Importer 2021-05-19 12:38:19 PDT
<rdar://problem/78218765>