<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Support TouchBar in WebKit"
   href="https://bugs.webkit.org/show_bug.cgi?id=164437#c22">Comment # 22</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Support TouchBar in WebKit"
   href="https://bugs.webkit.org/show_bug.cgi?id=164437">bug 164437</a>
              from <span class="vcard"><a class="email" href="mailto:mitz&#64;webkit.org" title="mitz&#64;webkit.org &lt;mitz&#64;webkit.org&gt;"> <span class="fn">mitz&#64;webkit.org</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=293990&amp;action=diff" name="attach_293990" title="Patch">attachment 293990</a> <a href="attachment.cgi?id=293990&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=293990&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=293990&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h:27
&gt; +#if USE(APPLE_INTERNAL_SDK) &amp;&amp; HAVE(TOUCH_BAR)</span >

Should this entire header be guarded with HAVE(TOUCH_BAR) regardless of whether you’re using the Apple-internal SDK? Seems unnecessary to have these Touch Bar things declared when the feature is not available.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4590
&gt; +    if (!_impl-&gt;clientWantsMediaPlaybackControlsView())
&gt; +        return nil;
&gt; +    return _impl-&gt;mediaPlaybackControlsView();</span >

Maybe write this as a single return statement using the ternary operator?

<span class="quote">&gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4602
&gt; +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
&gt; +{
&gt; +}
&gt; +
&gt; +- (void)_removeMediaPlaybackControlsView
&gt; +{
&gt; +}</span >

Maybe comment in these that they are for subclasses to override.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/mac/WKView.mm:1522
&gt; +    if (!_data-&gt;_impl-&gt;clientWantsMediaPlaybackControlsView())
&gt; +        return nil;
&gt; +    return _data-&gt;_impl-&gt;mediaPlaybackControlsView();</span >

Maybe write this as a single return statement using the ternary operator?

<span class="quote">&gt; Source/WebKit2/UIProcess/API/mac/WKView.mm:1534
&gt; +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
&gt; +{
&gt; +}
&gt; +
&gt; +- (void)_removeMediaPlaybackControlsView
&gt; +{
&gt; +}</span >

Maybe comment in these that they are for subclasses to override.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h:491
&gt; +    void updateTouchBar();</span >

Can this be in the HAVE(TOUCH_BAR) section so that you don’t have to add an empty implementation below?

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:107
&gt; +NSString * const WKMediaExitFullScreenItem = &#64;&quot;WKMediaExitFullScreenItem&quot;;</span >

Should this be static? Doesn’t seem to need external linkage.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:451
&gt; +    ListType _currentListType;
&gt; +</span >

Can this be &#64;private too? Do you even need to declare it if you &#64;synthesize it?

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:467
&gt; +static const double listControlSegmentWidth = 67;
&gt; +static const double exitFullScreenButtonWidth = 64;</span >

These should be CGFloat.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:471
&gt; +static const unsigned noListSegment = 0;
&gt; +static const unsigned unorderedListSegment = 1;
&gt; +static const unsigned orderedListSegment = 2;</span >

And these should be NSUInteger.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:493
&gt; +    [[segments objectAtIndex:noListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNone() forAttribute:NSAccessibilityDescriptionAttribute];
&gt; +    [[segments objectAtIndex:unorderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeBulletedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
&gt; +    [[segments objectAtIndex:orderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNumberedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];</span >

You can use array subscripting instead of -objectAtIndex: here:

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:512
&gt; +    if (insertListControl.selectedSegment == noListSegment) {</span >

Maybe use a switch statement here (and thus also avoid calling -selectedSegment up to three times).

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:554
&gt; +    BOOL _textIsBold;
&gt; +    BOOL _textIsItalic;
&gt; +    BOOL _textIsUnderlined;
&gt; +    NSTextAlignment _currentTextAlignment;
&gt; +    RetainPtr&lt;NSColor&gt; _textColor;
&gt; +    RetainPtr&lt;WKTextListTouchBarViewController&gt; _wkTextListTouchBarViewController;</span >

Can these all be &#64;private too? Can you omit the ones that you &#64;synthesize?
Probably don’t need wk in the name of the last one.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:642
&gt; +    _webViewImpl-&gt;handleAcceptedCandidate((NSTextCheckingResult *)candidate);</span >

I’d just declare candidate as NSTextCheckingResult * and avoid the cast here.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:688
&gt; +    return (WKTextListTouchBarViewController *)[self textListViewController];</span >

.textListViewController

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:744
&gt; +    NSTextAlignment alignment = (NSTextAlignment)[self.textAlignments.cell tagForSegment:[self.textAlignments selectedSegment]];</span >

.selectedSegment

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:802
&gt; +namespace WebKit {</span >

Newline after?

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:844
&gt; +        if ([[item identifier] isEqualToString:NSTouchBarItemIdentifierTextFormat]) {</span >

.identifier

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:845
&gt; +            for (NSTouchBarItem *childItem in [(NSGroupTouchBarItem *)item groupTouchBar].items) {</span >

.groupTouchBar

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:889
&gt; +    [touchBar setDefaultItems:[NSMutableSet setWithObjects:isRichTextTouchBar ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get(), nil]];</span >

Can use setWithObject: and drop the trailing nil.

<span class="quote">&gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:959
&gt; +        if (!m_emptyCandidatesArray)
&gt; +            m_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
&gt; +        [candidateListTouchBarItem() setCandidates:m_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];</span >

Why do we need a member variable for the empty NSArray? Pretty sure &#64;[ ] works just as well, and is always the same object.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>