[Webkit-unassigned] [Bug 164437] Support TouchBar in WebKit

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Nov 5 15:37:29 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=164437

--- Comment #22 from mitz at webkit.org <mitz at webkit.org> ---
Comment on attachment 293990
  --> https://bugs.webkit.org/attachment.cgi?id=293990
Patch

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

> 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.

> 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?

> 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.

> 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?

> 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.

> 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?

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:107
> +NSString * const WKMediaExitFullScreenItem = @"WKMediaExitFullScreenItem";

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

> 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?

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:467
> +static const double listControlSegmentWidth = 67;
> +static const double exitFullScreenButtonWidth = 64;

These should be CGFloat.

> 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.

> 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:

> 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).

> 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.

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:642
> +    _webViewImpl->handleAcceptedCandidate((NSTextCheckingResult *)candidate);

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

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:688
> +    return (WKTextListTouchBarViewController *)[self textListViewController];

.textListViewController

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:744
> +    NSTextAlignment alignment = (NSTextAlignment)[self.textAlignments.cell tagForSegment:[self.textAlignments selectedSegment]];

.selectedSegment

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:802
> +namespace WebKit {

Newline after?

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:844
> +        if ([[item identifier] isEqualToString:NSTouchBarItemIdentifierTextFormat]) {

.identifier

> Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm:845
> +            for (NSTouchBarItem *childItem in [(NSGroupTouchBarItem *)item groupTouchBar].items) {

.groupTouchBar

> 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.

> 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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20161105/79591d0b/attachment.html>


More information about the webkit-unassigned mailing list