<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#c23">Comment # 23</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:bdakin&#64;apple.com" title="Beth Dakin &lt;bdakin&#64;apple.com&gt;"> <span class="fn">Beth Dakin</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=164437#c22">comment #22</a>)
<span class="quote">&gt; 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>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <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>
&gt; 
&gt; &gt; Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h:27
&gt; &gt; +#if USE(APPLE_INTERNAL_SDK) &amp;&amp; HAVE(TOUCH_BAR)
&gt; 
&gt; Should this entire header be guarded with HAVE(TOUCH_BAR) regardless of
&gt; whether you’re using the Apple-internal SDK? Seems unnecessary to have these
&gt; Touch Bar things declared when the feature is not available.
&gt; </span >

Yes, I think so. Fixed.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4590
&gt; &gt; +    if (!_impl-&gt;clientWantsMediaPlaybackControlsView())
&gt; &gt; +        return nil;
&gt; &gt; +    return _impl-&gt;mediaPlaybackControlsView();
&gt; 
&gt; Maybe write this as a single return statement using the ternary operator?
&gt; </span >

Fixed.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4602
&gt; &gt; +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
&gt; &gt; +{
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +- (void)_removeMediaPlaybackControlsView
&gt; &gt; +{
&gt; &gt; +}
&gt; 
&gt; Maybe comment in these that they are for subclasses to override.
&gt; </span >

Added comments.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/API/mac/WKView.mm:1522
&gt; &gt; +    if (!_data-&gt;_impl-&gt;clientWantsMediaPlaybackControlsView())
&gt; &gt; +        return nil;
&gt; &gt; +    return _data-&gt;_impl-&gt;mediaPlaybackControlsView();
&gt; 
&gt; Maybe write this as a single return statement using the ternary operator?
&gt; </span >

Fixed.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/API/mac/WKView.mm:1534
&gt; &gt; +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
&gt; &gt; +{
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +- (void)_removeMediaPlaybackControlsView
&gt; &gt; +{
&gt; &gt; +}
&gt; 
&gt; Maybe comment in these that they are for subclasses to override.
&gt; </span >

Added comments.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h:491
&gt; &gt; +    void updateTouchBar();
&gt; 
&gt; Can this be in the HAVE(TOUCH_BAR) section so that you don’t have to add an
&gt; empty implementation below?
&gt; </span >

Yes, fixed. 

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:107
&gt; &gt; +NSString * const WKMediaExitFullScreenItem = &#64;&quot;WKMediaExitFullScreenItem&quot;;
&gt; 
&gt; Should this be static? Doesn’t seem to need external linkage.
&gt; </span >

Sure.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:451
&gt; &gt; +    ListType _currentListType;
&gt; &gt; +
&gt; 
&gt; Can this be &#64;private too? Do you even need to declare it if you &#64;synthesize
&gt; it?
&gt; </span >

Looks like &#64;synthesize takes care of it!

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

Fixed.

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

Fixed.

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

Fixed.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:512
&gt; &gt; +    if (insertListControl.selectedSegment == noListSegment) {
&gt; 
&gt; Maybe use a switch statement here (and thus also avoid calling
&gt; -selectedSegment up to three times).
&gt; </span >

Went with a switch.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:554
&gt; &gt; +    BOOL _textIsBold;
&gt; &gt; +    BOOL _textIsItalic;
&gt; &gt; +    BOOL _textIsUnderlined;
&gt; &gt; +    NSTextAlignment _currentTextAlignment;
&gt; &gt; +    RetainPtr&lt;NSColor&gt; _textColor;
&gt; &gt; +    RetainPtr&lt;WKTextListTouchBarViewController&gt; _wkTextListTouchBarViewController;
&gt; 
&gt; Can these all be &#64;private too? Can you omit the ones that you &#64;synthesize?
&gt; Probably don’t need wk in the name of the last one.
&gt; </span >

I made them &#64;private. The compiler wasn't happy with just &#64;synthesize.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:642
&gt; &gt; +    _webViewImpl-&gt;handleAcceptedCandidate((NSTextCheckingResult *)candidate);
&gt; 
&gt; I’d just declare candidate as NSTextCheckingResult * and avoid the cast here.
&gt; </span >

Fixed.

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

Fixed.

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

Fixed.

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

Added.

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

Fixed.

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

Fixed.

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

Fixed.

<span class="quote">&gt; &gt; Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:959
&gt; &gt; +        if (!m_emptyCandidatesArray)
&gt; &gt; +            m_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
&gt; &gt; +        [candidateListTouchBarItem() setCandidates:m_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
&gt; 
&gt; Why do we need a member variable for the empty NSArray? Pretty sure &#64;[ ]
&gt; works just as well, and is always the same object.</span >

So, it turns out this is broken! But &#64;[ ] is equally broken. I think I will leave it as-if for now, and fix it with a follow-up, at which time, maybe &#64;[ ] will work.

Patch coming soon.</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>