<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@apple.com" title="Beth Dakin <bdakin@apple.com>"> <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">> Comment on <span class=""><a href="attachment.cgi?id=293990&action=diff" name="attach_293990" title="Patch">attachment 293990</a> <a href="attachment.cgi?id=293990&action=edit" title="Patch">[details]</a></span>
> Patch
>
> View in context:
> <a href="https://bugs.webkit.org/attachment.cgi?id=293990&action=review">https://bugs.webkit.org/attachment.cgi?id=293990&action=review</a>
>
> > Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h:27
> > +#if USE(APPLE_INTERNAL_SDK) && HAVE(TOUCH_BAR)
>
> 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 >
Yes, I think so. Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4590
> > + if (!_impl->clientWantsMediaPlaybackControlsView())
> > + return nil;
> > + return _impl->mediaPlaybackControlsView();
>
> Maybe write this as a single return statement using the ternary operator?
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:4602
> > +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
> > +{
> > +}
> > +
> > +- (void)_removeMediaPlaybackControlsView
> > +{
> > +}
>
> Maybe comment in these that they are for subclasses to override.
> </span >
Added comments.
<span class="quote">> > Source/WebKit2/UIProcess/API/mac/WKView.mm:1522
> > + if (!_data->_impl->clientWantsMediaPlaybackControlsView())
> > + return nil;
> > + return _data->_impl->mediaPlaybackControlsView();
>
> Maybe write this as a single return statement using the ternary operator?
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/API/mac/WKView.mm:1534
> > +- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
> > +{
> > +}
> > +
> > +- (void)_removeMediaPlaybackControlsView
> > +{
> > +}
>
> Maybe comment in these that they are for subclasses to override.
> </span >
Added comments.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h:491
> > + void updateTouchBar();
>
> Can this be in the HAVE(TOUCH_BAR) section so that you don’t have to add an
> empty implementation below?
> </span >
Yes, fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:107
> > +NSString * const WKMediaExitFullScreenItem = @"WKMediaExitFullScreenItem";
>
> Should this be static? Doesn’t seem to need external linkage.
> </span >
Sure.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:451
> > + ListType _currentListType;
> > +
>
> Can this be @private too? Do you even need to declare it if you @synthesize
> it?
> </span >
Looks like @synthesize takes care of it!
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:467
> > +static const double listControlSegmentWidth = 67;
> > +static const double exitFullScreenButtonWidth = 64;
>
> These should be CGFloat.</span >
Fixed.
<span class="quote">>
> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:471
> > +static const unsigned noListSegment = 0;
> > +static const unsigned unorderedListSegment = 1;
> > +static const unsigned orderedListSegment = 2;
>
> And these should be NSUInteger.
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:493
> > + [[segments objectAtIndex:noListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNone() forAttribute:NSAccessibilityDescriptionAttribute];
> > + [[segments objectAtIndex:unorderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeBulletedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
> > + [[segments objectAtIndex:orderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNumberedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
>
> You can use array subscripting instead of -objectAtIndex: here:
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:512
> > + if (insertListControl.selectedSegment == noListSegment) {
>
> Maybe use a switch statement here (and thus also avoid calling
> -selectedSegment up to three times).
> </span >
Went with a switch.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:554
> > + BOOL _textIsBold;
> > + BOOL _textIsItalic;
> > + BOOL _textIsUnderlined;
> > + NSTextAlignment _currentTextAlignment;
> > + RetainPtr<NSColor> _textColor;
> > + RetainPtr<WKTextListTouchBarViewController> _wkTextListTouchBarViewController;
>
> Can these all be @private too? Can you omit the ones that you @synthesize?
> Probably don’t need wk in the name of the last one.
> </span >
I made them @private. The compiler wasn't happy with just @synthesize.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:642
> > + _webViewImpl->handleAcceptedCandidate((NSTextCheckingResult *)candidate);
>
> I’d just declare candidate as NSTextCheckingResult * and avoid the cast here.
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:688
> > + return (WKTextListTouchBarViewController *)[self textListViewController];
>
> .textListViewController
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:744
> > + NSTextAlignment alignment = (NSTextAlignment)[self.textAlignments.cell tagForSegment:[self.textAlignments selectedSegment]];
>
> .selectedSegment
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:802
> > +namespace WebKit {
>
> Newline after?
> </span >
Added.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:844
> > + if ([[item identifier] isEqualToString:NSTouchBarItemIdentifierTextFormat]) {
>
> .identifier
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:845
> > + for (NSTouchBarItem *childItem in [(NSGroupTouchBarItem *)item groupTouchBar].items) {
>
> .groupTouchBar
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:889
> > + [touchBar setDefaultItems:[NSMutableSet setWithObjects:isRichTextTouchBar ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get(), nil]];
>
> Can use setWithObject: and drop the trailing nil.
> </span >
Fixed.
<span class="quote">> > Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:959
> > + if (!m_emptyCandidatesArray)
> > + m_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
> > + [candidateListTouchBarItem() setCandidates:m_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
>
> Why do we need a member variable for the empty NSArray? Pretty sure @[ ]
> works just as well, and is always the same object.</span >
So, it turns out this is broken! But @[ ] is equally broken. I think I will leave it as-if for now, and fix it with a follow-up, at which time, maybe @[ ] 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>