<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208452] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208452">208452</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-11-09 11:16:09 -0800 (Wed, 09 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Support TouchBar in WebKit
https://bugs.webkit.org/show_bug.cgi?id=164437
-and corresponding-
rdar://problem/28876524
Reviewed by Darin Adler.
Source/WebCore:
* WebCore.xcodeproj/project.pbxproj:
* platform/spi/cocoa/AVKitSPI.h:
* platform/spi/cocoa/NSTouchBarSPI.h: Added.
* platform/spi/mac/NSSpellCheckerSPI.h:
Source/WebKit/mac:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::respondToChangedSelection):
(WebEditorClient::updateEditorStateAfterLayoutIfEditabilityChanged):
* WebView/WebHTMLView.mm:
(-[WebHTMLView candidateListTouchBarItem]):
* WebView/WebView.mm:
(-[_WebTextListTouchBarViewController initWithWebView:]):
(-[_WebTextListTouchBarViewController _selectList:]):
(-[_WebTextListTouchBarViewController setCurrentListType:]):
(-[WebTextTouchBarItemController initWithWebView:]):
(-[WebTextTouchBarItemController itemForIdentifier:]):
(-[WebTextTouchBarItemController webTextListTouchBarViewController]):
(-[WebTextTouchBarItemController setTextIsBold:]):
(-[WebTextTouchBarItemController setTextIsItalic:]):
(-[WebTextTouchBarItemController setTextIsUnderlined:]):
(-[WebTextTouchBarItemController _webChangeTextStyle:]):
(-[WebTextTouchBarItemController setCurrentTextAlignment:]):
(-[WebTextTouchBarItemController _webChangeTextAlignment:]):
(-[WebTextTouchBarItemController textColor]):
(-[WebTextTouchBarItemController setTextColor:]):
(-[WebTextTouchBarItemController _webChangeColor:]):
(-[WebTextTouchBarItemController textListViewController]):
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView showCandidates:forString:inRect:forSelectedRange:view:completionHandler:]):
(-[WebView shouldRequestCandidates]):
(-[WebView forceRequestCandidatesForTesting]):
(-[WebView makeTouchBar]):
(-[WebView touchBar:makeItemForIdentifier:]):
(textCheckingResultFromNSTextCheckingResult):
(-[WebView candidateListTouchBarItem:endSelectingCandidateAtIndex:]):
(-[WebView candidateListTouchBarItem:changedCandidateListVisibility:]):
(-[WebView _setUpPlaybackControlsManagerForMediaElement:]):
(-[WebView _clearPlaybackControlsManager]):
(-[WebView _dismissTextTouchBarPopoverItemWithIdentifier:]):
(-[WebView _textTouchBarCustomizationAllowedIdentifiers]):
(-[WebView _plainTextTouchBarCustomizationDefaultItemIdentifiers]):
(-[WebView _richTextTouchBarCustomizationDefaultItemIdentifiers]):
(-[WebView touchBarDidExitCustomization:]):
(-[WebView touchBarWillEnterCustomization:]):
(-[WebView didChangeAutomaticTextCompletion:]):
(-[WebView setUpTextTouchBar:]):
(-[WebView _isRichlyEditable]):
(-[WebView textTouchBar]):
(-[WebView updateTextTouchBar]):
(-[WebView updateMediaTouchBar]):
(-[WebView updateTouchBar]):
(-[WebView prepareForMouseDown]):
(-[WebView prepareForMouseUp]):
(-[WebView webViewAdditionsWillDestroyView]):
(-[WebView candidateList]):
(-[WebView updateWebViewAdditions]): Deleted.
* WebView/WebViewData.h:
* WebView/WebViewInternal.h:
* WebView/WebViewPrivate.h:
Source/WebKit2:
* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView makeTouchBar]):
(-[WKWebView candidateListTouchBarItem]):
(-[WKWebView _web_didAddMediaControlsManager:]):
(-[WKWebView _web_didRemoveMediaControlsManager]):
(-[WKWebView _interactWithMediaControlsForTesting]):
(-[WKWebView _wantsMediaPlaybackControlsView]):
(-[WKWebView _setWantsMediaPlaybackControlsView:]):
(-[WKWebView _mediaPlaybackControlsView]):
(-[WKWebView _addMediaPlaybackControlsView:]):
(-[WKWebView _removeMediaPlaybackControlsView]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView makeTouchBar]):
(-[WKView candidateListTouchBarItem]):
(-[WKView _web_didAddMediaControlsManager:]):
(-[WKView _web_didRemoveMediaControlsManager]):
(-[WKView _wantsMediaPlaybackControlsView]):
(-[WKView _setWantsMediaPlaybackControlsView:]):
(-[WKView _mediaPlaybackControlsView]):
(-[WKView _addMediaPlaybackControlsView:]):
(-[WKView _removeMediaPlaybackControlsView]):
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::currentTouchBar):
(WebKit::WebViewImpl::clientWantsMediaPlaybackControlsView):
(WebKit::WebViewImpl::setClientWantsMediaPlaybackControlsView):
(WebKit::WebViewImpl::setIsCustomizingTouchBar):
* UIProcess/Cocoa/WebViewImpl.mm:
(-[WKTextListTouchBarViewController initWithWebViewImpl:]):
(-[WKTextListTouchBarViewController didDestroyView]):
(-[WKTextListTouchBarViewController _selectList:]):
(-[WKTextListTouchBarViewController setCurrentListType:]):
(-[WKTextTouchBarItemController initWithWebViewImpl:]):
(-[WKTextTouchBarItemController didDestroyView]):
(-[WKTextTouchBarItemController touchBar:makeItemForIdentifier:]):
(-[WKTextTouchBarItemController itemForIdentifier:]):
(-[WKTextTouchBarItemController candidateListTouchBarItem:endSelectingCandidateAtIndex:]):
(-[WKTextTouchBarItemController candidateListTouchBarItem:changedCandidateListVisibility:]):
(-[WKTextTouchBarItemController textListTouchBarViewController]):
(-[WKTextTouchBarItemController setTextIsBold:]):
(-[WKTextTouchBarItemController setTextIsItalic:]):
(-[WKTextTouchBarItemController setTextIsUnderlined:]):
(-[WKTextTouchBarItemController _wkChangeTextStyle:]):
(-[WKTextTouchBarItemController setCurrentTextAlignment:]):
(-[WKTextTouchBarItemController _wkChangeTextAlignment:]):
(-[WKTextTouchBarItemController textColor]):
(-[WKTextTouchBarItemController setTextColor:]):
(-[WKTextTouchBarItemController _wkChangeColor:]):
(-[WKTextTouchBarItemController textListViewController]):
(WebKit::WebViewImpl::makeTouchBar):
(WebKit::WebViewImpl::candidateListTouchBarItem):
(WebKit::WebViewImpl::mediaPlaybackControlsView):
(WebKit::WebViewImpl::useMediaPlaybackControlsView):
(WebKit::WebViewImpl::dismissTextTouchBarPopoverItemWithIdentifier):
(WebKit::textTouchBarCustomizationAllowedIdentifiers):
(WebKit::plainTextTouchBarCustomizationDefaultItemIdentifiers):
(WebKit::richTextTouchBarCustomizationDefaultItemIdentifiers):
(WebKit::touchBarDidExitCustomization):
(WebKit::touchBarWillEnterCustomization):
(WebKit::didChangeAutomaticTextCompletion):
(WebKit::WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers):
(WebKit::WebViewImpl::setUpTextTouchBar):
(WebKit::WebViewImpl::isRichlyEditable):
(WebKit::WebViewImpl::textTouchBar):
(WebKit::WebViewImpl::updateTextTouchBar):
(WebKit::WebViewImpl::updateMediaTouchBar):
(WebKit::WebViewImpl::forceRequestCandidatesForTesting):
(WebKit::WebViewImpl::updateTouchBar):
(WebKit::WebViewImpl::shouldRequestCandidates):
(WebKit::WebViewImpl::showCandidates):
(WebKit::WebViewImpl::webViewImplAdditionsWillDestroyView):
(WebKit::WebViewImpl::setEditableElementIsFocused):
(WebKit::WebViewImpl::becomeFirstResponder):
(WebKit::WebViewImpl::selectionDidChange):
(WebKit::WebViewImpl::videoControlsManagerDidChange):
(WebKit::WebViewImpl::updateWebViewImplAdditions): Deleted.
Tools:
This makes MiniBrowser support TouchBar customization.
* MiniBrowser/mac/AppDelegate.m:
(-[BrowserAppDelegate awakeFromNib]):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformspicocoaAVKitSPIh">trunk/Source/WebCore/platform/spi/cocoa/AVKitSPI.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh">trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewDatah">trunk/Source/WebKit/mac/WebView/WebViewData.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewInternalh">trunk/Source/WebKit/mac/WebView/WebViewInternal.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewPrivateh">trunk/Source/WebKit/mac/WebView/WebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacAppDelegatem">trunk/Tools/MiniBrowser/mac/AppDelegate.m</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformspicocoaNSTouchBarSPIh">trunk/Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebCore/ChangeLog        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-11-09 Beth Dakin <bdakin@apple.com>
+
+ Support TouchBar in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=164437
+ -and corresponding-
+ rdar://problem/28876524
+
+ Reviewed by Darin Adler.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/spi/cocoa/AVKitSPI.h:
+ * platform/spi/cocoa/NSTouchBarSPI.h: Added.
+ * platform/spi/mac/NSSpellCheckerSPI.h:
+
</ins><span class="cx"> 2016-11-09 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Use Blob URL instead of webkit-fake-url when pasting an image
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -3274,6 +3274,7 @@
</span><span class="cx">                 93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309EA0099EB78C0056E581 /* SharedTimer.h */; };
</span><span class="cx">                 93309EA4099EB78C0056E581 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93309EA1099EB78C0056E581 /* Timer.cpp */; };
</span><span class="cx">                 93354A3C0B24F8C9003F6DEA /* UIEventWithKeyState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */; };
</span><ins>+                9335B49D1DCBEF7C00ED468E /* NSTouchBarSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9335B49B1DCBEF7100ED468E /* NSTouchBarSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 933A142E0B7D188600A53FFD /* TextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A142B0B7D188600A53FFD /* TextEvent.cpp */; };
</span><span class="cx">                 933A14300B7D188600A53FFD /* TextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A142D0B7D188600A53FFD /* TextEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 933A14B80B7D1D5200A53FFD /* JSTextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */; };
</span><span class="lines">@@ -10724,6 +10725,7 @@
</span><span class="cx">                 9332AB8B1653A97900D827EC /* FELightingNEON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FELightingNEON.h; sourceTree = "<group>"; };
</span><span class="cx">                 9332AB8C1653A97900D827EC /* NEONHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NEONHelpers.h; sourceTree = "<group>"; };
</span><span class="cx">                 93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEventWithKeyState.cpp; sourceTree = "<group>"; };
</span><ins>+                9335B49B1DCBEF7100ED468E /* NSTouchBarSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSTouchBarSPI.h; sourceTree = "<group>"; };
</ins><span class="cx">                 933A142B0B7D188600A53FFD /* TextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEvent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 933A142C0B7D188600A53FFD /* TextEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextEvent.idl; sourceTree = "<group>"; };
</span><span class="cx">                 933A142D0B7D188600A53FFD /* TextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEvent.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -17257,6 +17259,7 @@
</span><span class="cx">                                 2DDB97F319F9AECA002025D8 /* NSExtensionSPI.h */,
</span><span class="cx">                                 CE12523A1A16711000864480 /* NSFileManagerSPI.h */,
</span><span class="cx">                                 CE1252521A1BEC0600864480 /* NSStringSPI.h */,
</span><ins>+                                9335B49B1DCBEF7100ED468E /* NSTouchBarSPI.h */,
</ins><span class="cx">                                 31B313DA1B69871600F2AABC /* NSURLConnectionSPI.h */,
</span><span class="cx">                                 CE1252541A1BEC0E00864480 /* NSURLDownloadSPI.h */,
</span><span class="cx">                                 653EF83819A043AE0052202C /* NSURLFileTypeMappingsSPI.h */,
</span><span class="lines">@@ -27874,6 +27877,7 @@
</span><span class="cx">                                 1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */,
</span><span class="cx">                                 1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */,
</span><span class="cx">                                 1A569D1B0D7E2B82007C3983 /* WebScriptObjectProtocol.h in Headers */,
</span><ins>+                                9335B49D1DCBEF7C00ED468E /* NSTouchBarSPI.h in Headers */,
</ins><span class="cx">                                 97AABD1B14FA09D5007457AE /* WebSocket.h in Headers */,
</span><span class="cx">                                 97AABD1E14FA09D5007457AE /* WebSocketChannel.h in Headers */,
</span><span class="cx">                                 97AABD1F14FA09D5007457AE /* WebSocketChannelClient.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicocoaAVKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cocoa/AVKitSPI.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cocoa/AVKitSPI.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebCore/platform/spi/cocoa/AVKitSPI.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -61,6 +61,8 @@
</span><span class="cx"> @property (NS_NONATOMIC_IOSONLY, readonly) AVPlayerControllerStatus status;
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+NS_ASSUME_NONNULL_BEGIN
+
</ins><span class="cx"> @class AVPlayerLayer;
</span><span class="cx">
</span><span class="cx"> @interface AVPictureInPicturePlayerLayerView : UIView
</span><span class="lines">@@ -95,11 +97,13 @@
</span><span class="cx"> - (void)startPictureInPicture;
</span><span class="cx"> - (void)stopPictureInPicture;
</span><span class="cx">
</span><del>-@property (nonatomic, strong) AVPlayerController *playerController;
</del><ins>+@property (nonatomic, strong, nullable) AVPlayerController *playerController;
</ins><span class="cx"> @property (nonatomic, readonly, getter=isPictureInPictureActive) BOOL pictureInPictureActive;
</span><span class="cx"> @property (nonatomic, readonly) BOOL pictureInPictureWasStartedWhenEnteringBackground;
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+NS_ASSUME_NONNULL_END
+
</ins><span class="cx"> #endif // USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx">
</span><span class="lines">@@ -132,6 +136,8 @@
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
</span><span class="cx">
</span><ins>+NS_ASSUME_NONNULL_BEGIN
+
</ins><span class="cx"> @interface AVValueTiming : NSObject <NSCoding, NSCopying, NSMutableCopying>
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="lines">@@ -139,3 +145,32 @@
</span><span class="cx"> + (AVValueTiming *)valueTimingWithAnchorValue:(double)anchorValue anchorTimeStamp:(NSTimeInterval)timeStamp rate:(double)rate;
</span><span class="cx"> @property (NS_NONATOMIC_IOSONLY, readonly) double currentValue;
</span><span class="cx"> @end
</span><ins>+
+NS_ASSUME_NONNULL_END
+
+#if PLATFORM(MAC)
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+#import <AVKit/AVFunctionBarPlaybackControlsProvider.h>
+#import <AVKit/AVFunctionBarScrubber.h>
+#else
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol AVFunctionBarPlaybackControlsControlling <NSObject>
+@property (readonly) NSTimeInterval contentDuration;
+@property (readonly, nullable) AVValueTiming *timing;
+@property (readonly, getter=isSeeking) BOOL seeking;
+@property (readonly) NSTimeInterval seekToTime;
+- (void)seekToTime:(NSTimeInterval)time toleranceBefore:(NSTimeInterval)toleranceBefore toleranceAfter:(NSTimeInterval)toleranceAfter;
+@property (readonly) BOOL hasEnabledAudio;
+@property (readonly) BOOL hasEnabledVideo;
+@end
+
+@interface AVFunctionBarScrubber : NSView
+@property (assign, nullable) id<AVFunctionBarPlaybackControlsControlling> playbackControlsController;
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+#endif // PLATFORM(MAC)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformspicocoaNSTouchBarSPIh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h (0 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h         (rev 0)
+++ trunk/Source/WebCore/platform/spi/cocoa/NSTouchBarSPI.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(MAC) && HAVE(TOUCH_BAR)
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSFunctionBar_Private.h>
+#import <AppKit/NSTextTouchBarItemController_WebKitSPI.h>
+#import <AppKit/NSTouchBar_Private.h>
+
+#else
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSTouchBarItem : NSObject
+@end
+
+@interface NSColorPickerTouchBarItem : NSTouchBarItem
+@end
+
+@interface NSTouchBar : NSObject
+@property (readonly, copy, nullable) NSArray<NSTouchBarItem *> *items;
+@property (strong, nullable) NSTouchBarItem *escapeKeyReplacementItem;
+@end
+
+@interface NSTextTouchBarItemController : NSObject
+
+@property (readonly, strong, nullable) NSColorPickerTouchBarItem *colorPickerItem;
+@property (readonly, strong, nullable) NSSegmentedControl *textStyle;
+@property (readonly, strong, nullable) NSSegmentedControl *textAlignments;
+@property (nullable, strong) NSViewController *textListViewController;
+@property BOOL usesNarrowTextStyleItem;
+
+- (nullable NSTouchBarItem *)itemForIdentifier:(nullable NSString *)identifier;
+
+@end
+
+#define NSTouchBarWillEnterCustomization @"NSTouchBarWillEnterCustomization"
+#define NSTouchBarDidExitCustomization @"NSTouchBarDidExitCustomization"
+
+NS_ASSUME_NONNULL_END
+
+#endif // USE(APPLE_INTERNAL_SDK)
+#endif // PLATFORM(MAC) && HAVE(TOUCH_BAR)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> // FIXME: This header should include system headers when possible.
</span><span class="cx">
</span><span class="cx"> extern NSString *NSTextCheckingInsertionPointKey;
</span><ins>+extern NSNotificationName const NSSpellCheckerDidChangeAutomaticTextCompletionNotification;
</ins><span class="cx">
</span><span class="cx"> @interface NSSpellChecker ()
</span><span class="cx"> - (NSInteger)requestCandidatesForSelectedRange:(NSRange)selectedRange inString:(NSString *)stringToCheck types:(NSTextCheckingTypes)checkingTypes options:(NSDictionary<NSString *, id> *)options inSpellDocumentWithTag:(NSInteger)tag completionHandler:(void (^)(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates))completionHandler;
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2016-11-09 Beth Dakin <bdakin@apple.com>
+
+ Support TouchBar in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=164437
+ -and corresponding-
+ rdar://problem/28876524
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::respondToChangedSelection):
+ (WebEditorClient::updateEditorStateAfterLayoutIfEditabilityChanged):
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView candidateListTouchBarItem]):
+ * WebView/WebView.mm:
+ (-[_WebTextListTouchBarViewController initWithWebView:]):
+ (-[_WebTextListTouchBarViewController _selectList:]):
+ (-[_WebTextListTouchBarViewController setCurrentListType:]):
+ (-[WebTextTouchBarItemController initWithWebView:]):
+ (-[WebTextTouchBarItemController itemForIdentifier:]):
+ (-[WebTextTouchBarItemController webTextListTouchBarViewController]):
+ (-[WebTextTouchBarItemController setTextIsBold:]):
+ (-[WebTextTouchBarItemController setTextIsItalic:]):
+ (-[WebTextTouchBarItemController setTextIsUnderlined:]):
+ (-[WebTextTouchBarItemController _webChangeTextStyle:]):
+ (-[WebTextTouchBarItemController setCurrentTextAlignment:]):
+ (-[WebTextTouchBarItemController _webChangeTextAlignment:]):
+ (-[WebTextTouchBarItemController textColor]):
+ (-[WebTextTouchBarItemController setTextColor:]):
+ (-[WebTextTouchBarItemController _webChangeColor:]):
+ (-[WebTextTouchBarItemController textListViewController]):
+ (-[WebView _commonInitializationWithFrameName:groupName:]):
+ (-[WebView showCandidates:forString:inRect:forSelectedRange:view:completionHandler:]):
+ (-[WebView shouldRequestCandidates]):
+ (-[WebView forceRequestCandidatesForTesting]):
+ (-[WebView makeTouchBar]):
+ (-[WebView touchBar:makeItemForIdentifier:]):
+ (textCheckingResultFromNSTextCheckingResult):
+ (-[WebView candidateListTouchBarItem:endSelectingCandidateAtIndex:]):
+ (-[WebView candidateListTouchBarItem:changedCandidateListVisibility:]):
+ (-[WebView _setUpPlaybackControlsManagerForMediaElement:]):
+ (-[WebView _clearPlaybackControlsManager]):
+ (-[WebView _dismissTextTouchBarPopoverItemWithIdentifier:]):
+ (-[WebView _textTouchBarCustomizationAllowedIdentifiers]):
+ (-[WebView _plainTextTouchBarCustomizationDefaultItemIdentifiers]):
+ (-[WebView _richTextTouchBarCustomizationDefaultItemIdentifiers]):
+ (-[WebView touchBarDidExitCustomization:]):
+ (-[WebView touchBarWillEnterCustomization:]):
+ (-[WebView didChangeAutomaticTextCompletion:]):
+ (-[WebView setUpTextTouchBar:]):
+ (-[WebView _isRichlyEditable]):
+ (-[WebView textTouchBar]):
+ (-[WebView updateTextTouchBar]):
+ (-[WebView updateMediaTouchBar]):
+ (-[WebView updateTouchBar]):
+ (-[WebView prepareForMouseDown]):
+ (-[WebView prepareForMouseUp]):
+ (-[WebView webViewAdditionsWillDestroyView]):
+ (-[WebView candidateList]):
+ (-[WebView updateWebViewAdditions]): Deleted.
+ * WebView/WebViewData.h:
+ * WebView/WebViewInternal.h:
+ * WebView/WebViewPrivate.h:
+
</ins><span class="cx"> 2016-11-04 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Safari does not emit composition end if blurred for dead key / Japanese IME
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -347,7 +347,7 @@
</span><span class="cx"> NSView<WebDocumentView> *documentView = [[kit(frame) frameView] documentView];
</span><span class="cx"> if ([documentView isKindOfClass:[WebHTMLView class]]) {
</span><span class="cx"> [(WebHTMLView *)documentView _selectionChanged];
</span><del>- [m_webView updateWebViewAdditions];
</del><ins>+ [m_webView updateTouchBar];
</ins><span class="cx"> m_lastEditorStateWasContentEditable = [(WebHTMLView *)documentView _isEditable] ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -674,7 +674,7 @@
</span><span class="cx">
</span><span class="cx"> EditorStateIsContentEditable editorStateIsContentEditable = [(WebHTMLView *)documentView _isEditable] ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
</span><span class="cx"> if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
</span><del>- [m_webView updateWebViewAdditions];
</del><ins>+ [m_webView updateTouchBar];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebEditorClient::registerUndoStep(PassRefPtr<UndoStep> cmd)
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -7230,8 +7230,11 @@
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebHTMLViewWebNSTextInputSupportAdditions.mm>
</del><ins>+#if HAVE(TOUCH_BAR)
+- (NSCandidateListTouchBarItem *)candidateListTouchBarItem
+{
+ return [[self _webView] candidateList];
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -118,6 +118,7 @@
</span><span class="cx"> #import <JavaScriptCore/APICast.h>
</span><span class="cx"> #import <JavaScriptCore/Exception.h>
</span><span class="cx"> #import <JavaScriptCore/JSValueRef.h>
</span><ins>+#import <WebCore/AVKitSPI.h>
</ins><span class="cx"> #import <WebCore/AlternativeTextUIController.h>
</span><span class="cx"> #import <WebCore/AnimationController.h>
</span><span class="cx"> #import <WebCore/ApplicationCacheStorage.h>
</span><span class="lines">@@ -144,6 +145,8 @@
</span><span class="cx"> #import <WebCore/GeolocationController.h>
</span><span class="cx"> #import <WebCore/GeolocationError.h>
</span><span class="cx"> #import <WebCore/HTMLNames.h>
</span><ins>+#import <WebCore/HTMLOListElement.h>
+#import <WebCore/HTMLUListElement.h>
</ins><span class="cx"> #import <WebCore/HTMLVideoElement.h>
</span><span class="cx"> #import <WebCore/HistoryController.h>
</span><span class="cx"> #import <WebCore/HistoryItem.h>
</span><span class="lines">@@ -153,11 +156,14 @@
</span><span class="cx"> #import <WebCore/JSElement.h>
</span><span class="cx"> #import <WebCore/JSNodeList.h>
</span><span class="cx"> #import <WebCore/JSNotification.h>
</span><ins>+#import <WebCore/LocalizedStrings.h>
</ins><span class="cx"> #import <WebCore/LogInitialization.h>
</span><span class="cx"> #import <WebCore/MIMETypeRegistry.h>
</span><span class="cx"> #import <WebCore/MainFrame.h>
</span><span class="cx"> #import <WebCore/MemoryCache.h>
</span><span class="cx"> #import <WebCore/MemoryPressureHandler.h>
</span><ins>+#import <WebCore/NSSpellCheckerSPI.h>
+#import <WebCore/NSTouchBarSPI.h>
</ins><span class="cx"> #import <WebCore/NSURLFileTypeMappingsSPI.h>
</span><span class="cx"> #import <WebCore/NetworkStorageSession.h>
</span><span class="cx"> #import <WebCore/NodeList.h>
</span><span class="lines">@@ -192,6 +198,7 @@
</span><span class="cx"> #import <WebCore/WebCoreObjCExtras.h>
</span><span class="cx"> #import <WebCore/WebCoreView.h>
</span><span class="cx"> #import <WebCore/Widget.h>
</span><ins>+#import <WebCore/htmlediting.h>
</ins><span class="cx"> #import <WebKitLegacy/DOM.h>
</span><span class="cx"> #import <WebKitLegacy/DOMExtensions.h>
</span><span class="cx"> #import <WebKitLegacy/DOMPrivate.h>
</span><span class="lines">@@ -213,6 +220,7 @@
</span><span class="cx"> #import <wtf/RefPtr.h>
</span><span class="cx"> #import <wtf/RunLoop.h>
</span><span class="cx"> #import <wtf/StdLibExtras.h>
</span><ins>+#import <wtf/TemporaryChange.h>
</ins><span class="cx"> #import <wtf/spi/darwin/dyldSPI.h>
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -307,6 +315,12 @@
</span><span class="cx"> #import <WebCore/WebPlaybackSessionModelMediaElement.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarPlaybackControlsProvider)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarScrubber)
+#endif // HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
</span><span class="cx"> #endif
</span><span class="lines">@@ -662,6 +676,279 @@
</span><span class="cx"> static BOOL automaticSpellingCorrectionEnabled;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+
+enum class WebListType {
+ None = 0,
+ Ordered,
+ Unordered
+};
+
+@interface WebTextListTouchBarViewController : NSViewController {
+@private
+ WebView *_webView;
+}
+
+@property (nonatomic) WebListType currentListType;
+
+- (instancetype)initWithWebView:(WebView *)webView;
+
+@end
+
+@implementation WebTextListTouchBarViewController
+
+@synthesize currentListType=_currentListType;
+
+static const CGFloat listControlSegmentWidth = 67.0;
+
+static const NSUInteger noListSegment = 0;
+static const NSUInteger unorderedListSegment = 1;
+static const NSUInteger orderedListSegment = 2;
+
+- (instancetype)initWithWebView:(WebView *)webView
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _webView = webView;
+
+ NSSegmentedControl *insertListControl = [NSSegmentedControl segmentedControlWithLabels:@[ WebCore::insertListTypeNone(), WebCore::insertListTypeBulleted(), WebCore::insertListTypeNumbered() ] trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(_selectList:)];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:noListSegment];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:unorderedListSegment];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:orderedListSegment];
+ insertListControl.font = [NSFont systemFontOfSize:15];
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ id segmentElement = NSAccessibilityUnignoredDescendant(insertListControl);
+ NSArray *segments = [segmentElement accessibilityAttributeValue:NSAccessibilityChildrenAttribute];
+ ASSERT(segments.count == 3);
+ [segments[noListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNone() forAttribute:NSAccessibilityDescriptionAttribute];
+ [segments[unorderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeBulletedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
+ [segments[orderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNumberedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
+#pragma clang diagnostic pop
+
+ self.view = insertListControl;
+
+ return self;
+}
+
+- (void)_selectList:(id)sender
+{
+ NSView *documentView = [[[_webView _selectedOrMainFrame] frameView] documentView];
+ if (![documentView isKindOfClass:[WebHTMLView class]])
+ return;
+
+ WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
+ NSSegmentedControl *insertListControl = (NSSegmentedControl *)self.view;
+ switch (insertListControl.selectedSegment) {
+ case noListSegment:
+ // There is no "remove list" edit command, but _insertOrderedList and _insertUnorderedList both
+ // behave as toggles, so we can invoke the appropriate method depending on our _currentListType
+ // to remove an existing list. We don't have to do anything if _currentListType is WebListType::None.
+ if (_currentListType == WebListType::Ordered)
+ [webHTMLView _insertOrderedList];
+ else if (_currentListType == WebListType::Unordered)
+ [webHTMLView _insertUnorderedList];
+ break;
+ case unorderedListSegment:
+ [webHTMLView _insertUnorderedList];
+ break;
+ case orderedListSegment:
+ [webHTMLView _insertOrderedList];
+ break;
+ }
+
+ [_webView _dismissTextTouchBarPopoverItemWithIdentifier:NSTouchBarItemIdentifierTextList];
+}
+
+- (void)setCurrentListType:(WebListType)listType
+{
+ NSSegmentedControl *insertListControl = (NSSegmentedControl *)self.view;
+ switch (listType) {
+ case WebListType::None:
+ [insertListControl setSelected:YES forSegment:noListSegment];
+ break;
+ case WebListType::Ordered:
+ [insertListControl setSelected:YES forSegment:orderedListSegment];
+ break;
+ case WebListType::Unordered:
+ [insertListControl setSelected:YES forSegment:unorderedListSegment];
+ break;
+ }
+
+ _currentListType = listType;
+}
+
+@end
+
+@interface WebTextTouchBarItemController : NSTextTouchBarItemController {
+@private
+ BOOL _textIsBold;
+ BOOL _textIsItalic;
+ BOOL _textIsUnderlined;
+ NSTextAlignment _currentTextAlignment;
+ RetainPtr<NSColor> _textColor;
+ RetainPtr<WebTextListTouchBarViewController> _textListTouchBarViewController;
+ WebView *_webView;
+}
+
+@property (nonatomic) BOOL textIsBold;
+@property (nonatomic) BOOL textIsItalic;
+@property (nonatomic) BOOL textIsUnderlined;
+@property (nonatomic) NSTextAlignment currentTextAlignment;
+@property (nonatomic, retain, readwrite) NSColor *textColor;
+
+- (instancetype)initWithWebView:(WebView *)webView;
+@end
+
+@implementation WebTextTouchBarItemController
+
+@synthesize textIsBold=_textIsBold;
+@synthesize textIsItalic=_textIsItalic;
+@synthesize textIsUnderlined=_textIsUnderlined;
+@synthesize currentTextAlignment=_currentTextAlignment;
+
+- (instancetype)initWithWebView:(WebView *)webView
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _webView = webView;
+
+ return self;
+}
+
+- (NSTouchBarItem *)itemForIdentifier:(NSString *)identifier
+{
+ NSTouchBarItem *item = [super itemForIdentifier:identifier];
+ BOOL isTextFormatItem = [identifier isEqualToString:NSTouchBarItemIdentifierTextFormat];
+
+ if (isTextFormatItem || [identifier isEqualToString:NSTouchBarItemIdentifierTextStyle])
+ self.textStyle.action = @selector(_webChangeTextStyle:);
+
+ if (isTextFormatItem || [identifier isEqualToString:NSTouchBarItemIdentifierTextAlignment])
+ self.textAlignments.action = @selector(_webChangeTextAlignment:);
+
+ NSColorPickerTouchBarItem *colorPickerItem = nil;
+ if ([identifier isEqualToString:NSTouchBarItemIdentifierTextColorPicker] && [item isKindOfClass:[NSColorPickerTouchBarItem class]])
+ colorPickerItem = (NSColorPickerTouchBarItem *)item;
+ if (isTextFormatItem)
+ colorPickerItem = self.colorPickerItem;
+ if (colorPickerItem) {
+ colorPickerItem.target = self;
+ colorPickerItem.action = @selector(_webChangeColor:);
+ colorPickerItem.showsAlpha = NO;
+ }
+
+ return item;
+}
+
+- (WebTextListTouchBarViewController *)webTextListTouchBarViewController
+{
+ return (WebTextListTouchBarViewController *)self.textListViewController;
+}
+
+- (void)setTextIsBold:(BOOL)bold
+{
+ _textIsBold = bold;
+ if ([self.textStyle isSelectedForSegment:0] != _textIsBold)
+ [self.textStyle setSelected:_textIsBold forSegment:0];
+}
+
+- (void)setTextIsItalic:(BOOL)italic
+{
+ _textIsItalic = italic;
+ if ([self.textStyle isSelectedForSegment:1] != _textIsItalic)
+ [self.textStyle setSelected:_textIsItalic forSegment:1];
+}
+
+- (void)setTextIsUnderlined:(BOOL)underlined
+{
+ _textIsUnderlined = underlined;
+ if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined)
+ [self.textStyle setSelected:_textIsUnderlined forSegment:2];
+}
+
+- (void)_webChangeTextStyle:(id)sender
+{
+ if ([self.textStyle isSelectedForSegment:0] != _textIsBold) {
+ _textIsBold = !_textIsBold;
+ [_webView _executeCoreCommandByName:@"ToggleBold" value:@""];
+ }
+
+ if ([self.textStyle isSelectedForSegment:1] != _textIsItalic) {
+ _textIsItalic = !_textIsItalic;
+ [_webView _executeCoreCommandByName:@"ToggleItalic" value:@""];
+ }
+
+ if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined) {
+ _textIsUnderlined = !_textIsUnderlined;
+ [_webView _executeCoreCommandByName:@"ToggleUnderline" value:@""];
+ }
+}
+
+- (void)setCurrentTextAlignment:(NSTextAlignment)alignment
+{
+ _currentTextAlignment = alignment;
+ [self.textAlignments selectSegmentWithTag:_currentTextAlignment];
+}
+
+- (void)_webChangeTextAlignment:(id)sender
+{
+ NSTextAlignment alignment = (NSTextAlignment)[self.textAlignments.cell tagForSegment:self.textAlignments.selectedSegment];
+ switch (alignment) {
+ case NSTextAlignmentLeft:
+ _currentTextAlignment = NSTextAlignmentLeft;
+ [_webView alignLeft:sender];
+ break;
+ case NSTextAlignmentRight:
+ _currentTextAlignment = NSTextAlignmentRight;
+ [_webView alignRight:sender];
+ break;
+ case NSTextAlignmentCenter:
+ _currentTextAlignment = NSTextAlignmentCenter;
+ [_webView alignCenter:sender];
+ break;
+ case NSTextAlignmentJustified:
+ _currentTextAlignment = NSTextAlignmentJustified;
+ [_webView alignJustified:sender];
+ break;
+ default:
+ break;
+ }
+
+ [_webView _dismissTextTouchBarPopoverItemWithIdentifier:NSTouchBarItemIdentifierTextAlignment];
+}
+
+- (NSColor *)textColor
+{
+ return _textColor.get();
+}
+
+- (void)setTextColor:(NSColor *)color
+{
+ _textColor = color;
+ self.colorPickerItem.color = _textColor.get();
+}
+
+- (void)_webChangeColor:(id)sender
+{
+ _textColor = self.colorPickerItem.color;
+ [_webView _executeCoreCommandByName:@"ForeColor" value: WebCore::colorFromNSColor(_textColor.get()).serialized()];
+}
+
+- (NSViewController *)textListViewController
+{
+ if (!_textListTouchBarViewController)
+ _textListTouchBarViewController = adoptNS([[WebTextListTouchBarViewController alloc] initWithWebView:_webView]);
+ return _textListTouchBarViewController.get();
+}
+
+@end
+
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> @implementation WebView (AllWebViews)
</span><span class="cx">
</span><span class="cx"> static CFSetCallBacks NonRetainingSetCallbacks = {
</span><span class="lines">@@ -970,7 +1257,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- [self updateWebViewAdditions];
</del><ins>+ [self updateTouchBar];
</ins><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> static bool didOneTimeInitialization = false;
</span><span class="lines">@@ -4692,6 +4979,45 @@
</span><span class="cx"> _private->page->settings().setFontFallbackPrefersPictographs(flag);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+
+- (void)showCandidates:(NSArray<NSTextCheckingResult *> *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
+{
+ [self.candidateList setCandidates:candidates forSelectedRange:range inString:string];
+}
+
+- (BOOL)shouldRequestCandidates
+{
+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return NO;
+
+ return !coreFrame->selection().selection().isInPasswordField() && self.candidateList.candidateListVisible;
+}
+
+- (void)forceRequestCandidatesForTesting
+{
+ _private->_canCreateTouchBars = YES;
+ [self updateTouchBar];
+}
+
+#else
+
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
+{
+}
+
+- (void)forceRequestCandidatesForTesting
+{
+}
+
+- (BOOL)shouldRequestCandidates
+{
+ return NO;
+}
+
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation _WebSafeForwarder
</span><span class="lines">@@ -4804,6 +5130,11 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+@interface WebView () <NSCandidateListTouchBarItemDelegate, NSTouchBarDelegate, NSTouchBarProvider>
+@end
+#endif
+
</ins><span class="cx"> @implementation WebView
</span><span class="cx">
</span><span class="cx"> + (void)initialize
</span><span class="lines">@@ -5257,7 +5588,7 @@
</span><span class="cx"> [_private->_geolocationProvider stopTrackingWebView:self];
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- [self webViewAdditionsWillDestroyView];
</del><ins>+ [[NSNotificationCenter defaultCenter] removeObserver:self];
</ins><span class="cx">
</span><span class="cx"> // call close to ensure we tear-down completely
</span><span class="cx"> // this maintains our old behavior for existing applications
</span><span class="lines">@@ -6488,6 +6819,87 @@
</span><span class="cx"> return [previousView previousValidKeyView];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+
+@dynamic touchBar;
+
+- (NSTouchBar *)makeTouchBar
+{
+ if (!_private->_canCreateTouchBars) {
+ _private->_canCreateTouchBars = YES;
+ [self updateTouchBar];
+ }
+ return _private->_currentTouchBar.get();
+}
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSString *)identifier
+{
+ if (touchBar == _private->_richTextTouchBar || touchBar == _private->_plainTextTouchBar)
+ return [_private->_textTouchBarItemController itemForIdentifier:identifier];
+
+ return nil;
+}
+
+static TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
+{
+ WebCore::TextCheckingResult result;
+
+ switch ([nsResult resultType]) {
+ case NSTextCheckingTypeSpelling:
+ result.type = WebCore::TextCheckingTypeSpelling;
+ break;
+ case NSTextCheckingTypeReplacement:
+ result.type = WebCore::TextCheckingTypeReplacement;
+ break;
+ case NSTextCheckingTypeCorrection:
+ result.type = WebCore::TextCheckingTypeCorrection;
+ break;
+ default:
+ result.type = WebCore::TextCheckingTypeNone;
+ }
+
+ NSRange resultRange = nsResult.range;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = nsResult.replacementString;
+
+ return result;
+}
+
+- (void)candidateListTouchBarItem:(NSCandidateListTouchBarItem *)anItem endSelectingCandidateAtIndex:(NSInteger)index
+{
+ if (index == NSNotFound)
+ return;
+
+ if (anItem != self.candidateList)
+ return;
+
+ NSArray *candidates = anItem.candidates;
+ if ((NSUInteger)index >= candidates.count)
+ return;
+
+ id candidate = candidates[index];
+ ASSERT([candidate isKindOfClass:[NSTextCheckingResult class]]);
+
+ if (Frame* coreFrame = core(self._selectedOrMainFrame))
+ coreFrame->editor().client()->handleAcceptedCandidateWithSoftSpaces(textCheckingResultFromNSTextCheckingResult((NSTextCheckingResult *)candidate));
+}
+
+- (void)candidateListTouchBarItem:(NSCandidateListTouchBarItem *)anItem changedCandidateListVisibility:(BOOL)isVisible
+{
+ if (anItem != self.candidateList)
+ return;
+
+ if (isVisible) {
+ if (Frame* coreFrame = core([self _selectedOrMainFrame]))
+ coreFrame->editor().client()->requestCandidatesForSelection(coreFrame->selection().selection());
+ }
+
+ [self updateTouchBar];
+}
+
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WebView (WebIBActions)
</span><span class="lines">@@ -6746,48 +7158,6 @@
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewAdditions.mm>
-#else
-@implementation WebView (WebUpdateWebViewAdditions)
-
-- (void)updateWebViewAdditions
-{
-}
-
-- (void)prepareForMouseDown
-{
-}
-
-- (void)prepareForMouseUp
-{
-}
-
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
-{
-}
-
-- (void)forceRequestCandidatesForTesting
-{
-}
-
-- (BOOL)shouldRequestCandidates
-{
- return NO;
-}
-
-- (void)webViewAdditionsWillDestroyView
-{
-}
-
-- (id)candidateList
-{
- return nil;
-}
-
-@end
-#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-
</del><span class="cx"> @implementation WebView (WebPendingPublic)
</span><span class="cx">
</span><span class="cx"> - (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode
</span><span class="lines">@@ -8656,7 +9026,7 @@
</span><span class="cx"> if (!_private->playbackSessionInterface)
</span><span class="cx"> _private->playbackSessionInterface = WebPlaybackSessionInterfaceMac::create(*_private->playbackSessionModel);
</span><span class="cx">
</span><del>- [self updateWebViewAdditions];
</del><ins>+ [self updateTouchBar];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_clearPlaybackControlsManager
</span><span class="lines">@@ -8669,7 +9039,7 @@
</span><span class="cx">
</span><span class="cx"> _private->playbackSessionModel = nullptr;
</span><span class="cx"> _private->playbackSessionInterface = nullptr;
</span><del>- [self updateWebViewAdditions];
</del><ins>+ [self updateTouchBar];
</ins><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx"> #endif // ENABLE(VIDEO)
</span><span class="lines">@@ -8898,6 +9268,341 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+- (void)_dismissTextTouchBarPopoverItemWithIdentifier:(NSString *)identifier
+{
+ NSTouchBarItem *foundItem = nil;
+ for (NSTouchBarItem *item in self.textTouchBar.items) {
+ if ([item.identifier isEqualToString:identifier]) {
+ foundItem = item;
+ break;
+ }
+
+ if ([item.identifier isEqualToString:NSTouchBarItemIdentifierTextFormat]) {
+ for (NSTouchBarItem *childItem in ((NSGroupTouchBarItem *)item).groupTouchBar.items) {
+ if ([childItem.identifier isEqualToString:identifier]) {
+ foundItem = childItem;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ if ([foundItem isKindOfClass:[NSPopoverTouchBarItem class]])
+ [(NSPopoverTouchBarItem *)foundItem dismissPopover:nil];
+}
+
+- (NSArray<NSString *> *)_textTouchBarCustomizationAllowedIdentifiers
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextColorPicker, NSTouchBarItemIdentifierTextStyle, NSTouchBarItemIdentifierTextAlignment, NSTouchBarItemIdentifierTextList, NSTouchBarItemIdentifierFlexibleSpace ];
+}
+
+- (NSArray<NSString *> *)_plainTextTouchBarCustomizationDefaultItemIdentifiers
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierCandidateList ];
+}
+
+- (NSArray<NSString *> *)_richTextTouchBarCustomizationDefaultItemIdentifiers
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
+}
+
+- (void)touchBarDidExitCustomization:(NSNotification *)notification
+{
+ _private->_isCustomizingTouchBar = NO;
+ [self updateTouchBar];
+}
+
+- (void)touchBarWillEnterCustomization:(NSNotification *)notification
+{
+ _private->_isCustomizingTouchBar = YES;
+}
+
+- (void)didChangeAutomaticTextCompletion:(NSNotification *)notification
+{
+ if (_private->_richTextTouchBar)
+ [self setUpTextTouchBar:_private->_richTextTouchBar.get()];
+
+ if (_private->_plainTextTouchBar)
+ [self setUpTextTouchBar:_private->_plainTextTouchBar.get()];
+
+ [self updateTouchBar];
+}
+
+- (void)setUpTextTouchBar:(NSTouchBar *)textTouchBar
+{
+ BOOL isRichTextTouchBar = textTouchBar == _private->_richTextTouchBar;
+ [textTouchBar setDelegate:self];
+ [textTouchBar setDefaultItems:[NSMutableSet setWithObject:isRichTextTouchBar ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get()]];
+ [textTouchBar setCustomizationAllowedItemIdentifiers:[self _textTouchBarCustomizationAllowedIdentifiers]];
+
+ NSArray<NSString *> *defaultIdentifiers = isRichTextTouchBar ? [self _richTextTouchBarCustomizationDefaultItemIdentifiers] : [self _plainTextTouchBarCustomizationDefaultItemIdentifiers];
+ [textTouchBar setCustomizationDefaultItemIdentifiers:defaultIdentifiers];
+
+ if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[textTouchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
+ textFormatItem.groupTouchBar.customizationIdentifier = @"WebTextFormatTouchBar";
+}
+
+- (BOOL)_isRichlyEditable
+{
+ NSView *documentView = self._selectedOrMainFrame.frameView.documentView;
+ if (![documentView isKindOfClass:[WebHTMLView class]])
+ return NO;
+
+ WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
+ return webHTMLView._isEditable && webHTMLView._canEditRichly;
+}
+
+- (NSTouchBar *)textTouchBar
+{
+ if (self._isRichlyEditable)
+ return _private->_richTextTouchBar.get();
+
+ return _private->_plainTextTouchBar.get();
+}
+
+static NSTextAlignment nsTextAlignmentFromRenderStyle(const RenderStyle* style)
+{
+ NSTextAlignment textAlignment;
+ switch (style->textAlign()) {
+ case RIGHT:
+ case WEBKIT_RIGHT:
+ textAlignment = NSTextAlignmentRight;
+ break;
+ case LEFT:
+ case WEBKIT_LEFT:
+ textAlignment = NSTextAlignmentLeft;
+ break;
+ case CENTER:
+ case WEBKIT_CENTER:
+ textAlignment = NSTextAlignmentCenter;
+ break;
+ case JUSTIFY:
+ textAlignment = NSTextAlignmentJustified;
+ break;
+ case TASTART:
+ textAlignment = style->isLeftToRightDirection() ? NSTextAlignmentLeft : NSTextAlignmentRight;
+ break;
+ case TAEND:
+ textAlignment = style->isLeftToRightDirection() ? NSTextAlignmentRight : NSTextAlignmentLeft;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return textAlignment;
+}
+
+- (void)updateTextTouchBar
+{
+ if (_private->_isDeferringTextTouchBarUpdates) {
+ _private->_needsDeferredTextTouchBarUpdate = YES;
+ return;
+ }
+
+ NSView *documentView = [[[self _selectedOrMainFrame] frameView] documentView];
+ if (![documentView isKindOfClass:[WebHTMLView class]])
+ return;
+
+ WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
+ if (![webHTMLView _isEditable])
+ return;
+
+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return;
+
+ if (_private->_isUpdatingTextTouchBar)
+ return;
+
+ TemporaryChange<BOOL> isUpdatingTextTouchBar(_private->_isUpdatingTextTouchBar, YES);
+
+ if (!_private->_textTouchBarItemController)
+ _private->_textTouchBarItemController = adoptNS([[WebTextTouchBarItemController alloc] initWithWebView:self]);
+
+ if (!_private->_startedListeningToCustomizationEvents) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(touchBarDidExitCustomization:) name:NSTouchBarDidExitCustomization object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(touchBarWillEnterCustomization:) name:NSTouchBarWillEnterCustomization object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeAutomaticTextCompletion:) name:NSSpellCheckerDidChangeAutomaticTextCompletionNotification object:nil];
+ _private->_startedListeningToCustomizationEvents = YES;
+ }
+
+ if (!_private->_plainTextCandidateListTouchBarItem || !_private->_richTextCandidateListTouchBarItem) {
+ _private->_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [_private->_plainTextCandidateListTouchBarItem setDelegate:self];
+ _private->_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [_private->_richTextCandidateListTouchBarItem setDelegate:self];
+ coreFrame->editor().client()->requestCandidatesForSelection(coreFrame->selection().selection());
+ }
+
+ if (!_private->_richTextTouchBar) {
+ _private->_richTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ [self setUpTextTouchBar:_private->_richTextTouchBar.get()];
+ [_private->_richTextTouchBar setCustomizationIdentifier:@"WebRichTextTouchBar"];
+ }
+
+ if (!_private->_plainTextTouchBar) {
+ _private->_plainTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ [self setUpTextTouchBar:_private->_plainTextTouchBar.get()];
+ [_private->_plainTextTouchBar setCustomizationIdentifier:@"WebPlainTextTouchBar"];
+ }
+
+ if ([NSSpellChecker isAutomaticTextCompletionEnabled] && !_private->_isCustomizingTouchBar) {
+ BOOL shouldShowCandidateList = !coreFrame->selection().selection().isRange() || coreFrame->editor().ignoreCompositionSelectionChange();
+ [self.candidateList updateWithInsertionPointVisibility:shouldShowCandidateList];
+ }
+
+ if (coreFrame->selection().selection().isInPasswordField()) {
+ // We don't request candidates for password fields. If the user was previously in a non-password field, then the
+ // old candidates will still show by default, so we clear them here by setting an empty array of candidates.
+ if (!_private->_emptyCandidatesArray)
+ _private->_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
+ [self.candidateList setCandidates:_private->_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
+ }
+
+ NSTouchBar *textTouchBar = self.textTouchBar;
+ NSArray<NSString *> *itemIdentifiers = textTouchBar.itemIdentifiers;
+ BOOL isShowingCombinedTextFormatItem = [itemIdentifiers containsObject:NSTouchBarItemIdentifierTextFormat];
+ [textTouchBar setPrincipalItemIdentifier:isShowingCombinedTextFormatItem ? NSTouchBarItemIdentifierTextFormat : nil];
+
+ // Set current typing attributes for rich text. This will ensure that the buttons reflect the state of
+ // the text when changing selection throughout the document.
+ if (webHTMLView._canEditRichly) {
+ const VisibleSelection& selection = coreFrame->selection().selection();
+ if (!selection.isNone()) {
+ Node* nodeToRemove;
+ if (auto* style = Editor::styleForSelectionStart(coreFrame, nodeToRemove)) {
+ [_private->_textTouchBarItemController setTextIsBold:(style->fontCascade().weight() >= FontWeightBold)];
+ [_private->_textTouchBarItemController setTextIsItalic:(style->fontCascade().italic() == FontItalicOn)];
+
+ RefPtr<EditingStyle> typingStyle = coreFrame->selection().typingStyle();
+ if (typingStyle && typingStyle->style()) {
+ String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
+ [_private->_textTouchBarItemController setTextIsUnderlined:value.contains("underline")];
+ } else
+ [_private->_textTouchBarItemController setTextIsUnderlined:(style->textDecorationsInEffect() & TextDecorationUnderline)];
+
+ if (style->visitedDependentColor(CSSPropertyColor).isValid())
+ [_private->_textTouchBarItemController setTextColor:nsColor(style->visitedDependentColor(CSSPropertyColor))];
+
+ [_private->_textTouchBarItemController setCurrentTextAlignment:nsTextAlignmentFromRenderStyle(style)];
+
+ HTMLElement* enclosingListElement = enclosingList(selection.start().deprecatedNode());
+ if (enclosingListElement) {
+ if (is<HTMLUListElement>(*enclosingListElement))
+ [[_private->_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::Unordered];
+ else if (is<HTMLOListElement>(*enclosingListElement))
+ [[_private->_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::Ordered];
+ else
+ ASSERT_NOT_REACHED();
+ } else
+ [[_private->_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::None];
+
+ if (nodeToRemove)
+ nodeToRemove->remove();
+ }
+ }
+ BOOL isShowingCandidateListItem = [itemIdentifiers containsObject:NSTouchBarItemIdentifierCandidateList] && [NSSpellChecker isAutomaticTextCompletionEnabled];
+ [_private->_textTouchBarItemController setUsesNarrowTextStyleItem:isShowingCombinedTextFormatItem && isShowingCandidateListItem];
+ }
+}
+
+- (void)updateMediaTouchBar
+{
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ if (!_private->mediaTouchBarProvider)
+ _private->mediaTouchBarProvider = adoptNS([allocAVFunctionBarPlaybackControlsProviderInstance() init]);
+
+ if (![_private->mediaTouchBarProvider playbackControlsController]) {
+ ASSERT(_private->playbackSessionInterface);
+ WebPlaybackControlsManager *manager = _private->playbackSessionInterface->playBackControlsManager();
+ [_private->mediaTouchBarProvider setPlaybackControlsController:(id <AVFunctionBarPlaybackControlsControlling>)manager];
+ [_private->mediaPlaybackControlsView setPlaybackControlsController:(id <AVFunctionBarPlaybackControlsControlling>)manager];
+ }
+#endif
+}
+
+- (void)updateTouchBar
+{
+ if (!_private->_canCreateTouchBars)
+ return;
+
+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return;
+
+ NSTouchBar *touchBar = nil;
+ NSView *documentView = [[[self _selectedOrMainFrame] frameView] documentView];
+ if ([documentView isKindOfClass:[WebHTMLView class]]) {
+ WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
+ if ([webHTMLView _isEditable]) {
+ [self updateTextTouchBar];
+ touchBar = [self textTouchBar];
+ }
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ else if ([self _hasActiveVideoForControlsInterface]) {
+ [self updateMediaTouchBar];
+ touchBar = [_private->mediaTouchBarProvider respondsToSelector:@selector(touchBar)] ? [(id)_private->mediaTouchBarProvider touchBar] : [(id)_private->mediaTouchBarProvider touchBar];
+ } else if ([_private->mediaTouchBarProvider playbackControlsController]) {
+ [_private->mediaTouchBarProvider setPlaybackControlsController:nil];
+ [_private->mediaPlaybackControlsView setPlaybackControlsController:nil];
+ }
+#endif
+ }
+
+ if (touchBar == _private->_currentTouchBar)
+ return;
+
+ _private->_currentTouchBar = touchBar;
+ [self willChangeValueForKey:@"touchBar"];
+ [self setTouchBar:_private->_currentTouchBar.get()];
+ [self didChangeValueForKey:@"touchBar"];
+}
+
+- (void)prepareForMouseDown
+{
+ _private->_needsDeferredTextTouchBarUpdate = NO;
+ _private->_isDeferringTextTouchBarUpdates = YES;
+}
+
+- (void)prepareForMouseUp
+{
+ if (!_private->_isDeferringTextTouchBarUpdates)
+ return;
+
+ _private->_isDeferringTextTouchBarUpdates = NO;
+ if (_private->_needsDeferredTextTouchBarUpdate) {
+ // Only trigger another update if we attempted and bailed from an update during the deferral.
+ [self updateTouchBar];
+ }
+}
+
+- (NSCandidateListTouchBarItem *)candidateList
+{
+ return self._isRichlyEditable ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get();
+}
+#else
+
+- (void)updateTouchBar
+{
+}
+
+- (void)prepareForMouseDown
+{
+}
+
+- (void)prepareForMouseUp
+{
+}
+
+- (id)candidateList
+{
+ return nil;
+}
+
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WebView (WebViewDeviceOrientation)
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewData.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -101,8 +101,10 @@
</span><span class="cx"> class WebSelectionServiceController;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewDataAdditionsDeclarations.h>
</del><ins>+#if HAVE(TOUCH_BAR)
+@class WebTextTouchBarItemController;
+@class AVFunctionBarPlaybackControlsProvider;
+@class AVFunctionBarScrubber;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> class WebViewLayerFlushScheduler : public WebCore::LayerFlushScheduler {
</span><span class="lines">@@ -178,10 +180,25 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> WebImmediateActionController *immediateActionController;
</span><span class="cx">
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewDataAdditions.h>
-#endif
</del><ins>+#if HAVE(TOUCH_BAR)
+ RetainPtr<NSTouchBar> _currentTouchBar;
+ RetainPtr<NSTouchBar> _plainTextTouchBar;
+ RetainPtr<NSTouchBar> _richTextTouchBar;
+ RetainPtr<WebTextTouchBarItemController> _textTouchBarItemController;
+ RetainPtr<NSCandidateListTouchBarItem> _richTextCandidateListTouchBarItem;
+ RetainPtr<NSCandidateListTouchBarItem> _plainTextCandidateListTouchBarItem;
+ RetainPtr<NSArray> _emptyCandidatesArray;
+ RetainPtr<AVFunctionBarPlaybackControlsProvider> mediaTouchBarProvider;
+ RetainPtr<AVFunctionBarScrubber> mediaPlaybackControlsView;
</ins><span class="cx">
</span><ins>+ BOOL _canCreateTouchBars;
+ BOOL _isUpdatingTextTouchBar;
+ BOOL _startedListeningToCustomizationEvents;
+ BOOL _isCustomizingTouchBar;
+ BOOL _isDeferringTextTouchBarUpdates;
+ BOOL _needsDeferredTextTouchBarUpdate;
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> std::unique_ptr<WebCore::TextIndicatorWindow> textIndicatorWindow;
</span><span class="cx"> BOOL hasInitializedLookupObserver;
</span><span class="cx"> RetainPtr<WebWindowVisibilityObserver> windowVisibilityObserver;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+@class NSCandidateListTouchBarItem;
</ins><span class="cx"> @class WebBasePluginPackage;
</span><span class="cx"> @class WebDownload;
</span><span class="cx"> @class WebImmediateActionController;
</span><span class="lines">@@ -293,12 +294,10 @@
</span><span class="cx"> - (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-@end
-
-@interface WebView (WebUpdateWebViewAdditions)
</del><span class="cx"> - (void)prepareForMouseUp;
</span><span class="cx"> - (void)prepareForMouseDown;
</span><del>-- (void)updateWebViewAdditions;
-- (void)webViewAdditionsWillDestroyView;
-- (id)candidateList;
</del><ins>+- (void)updateTouchBar;
+- (void)_dismissTextTouchBarPopoverItemWithIdentifier:(NSString *)identifier;
+- (NSCandidateListTouchBarItem *)candidateList;
+
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -889,6 +889,10 @@
</span><span class="cx">
</span><span class="cx"> - (void)_setFontFallbackPrefersPictographs:(BOOL)flag;
</span><span class="cx">
</span><ins>+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
+- (void)forceRequestCandidatesForTesting;
+- (BOOL)shouldRequestCandidates;
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #if !TARGET_OS_IPHONE
</span><span class="lines">@@ -1061,12 +1065,6 @@
</span><span class="cx"> - (NSCachedURLResponse *)webView:(WebView *)sender resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface WebView (WebShowCandidates)
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
-- (void)forceRequestCandidatesForTesting;
-- (BOOL)shouldRequestCandidates;
-@end
-
</del><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> extern "C" {
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/ChangeLog        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -1,3 +1,90 @@
</span><ins>+2016-11-09 Beth Dakin <bdakin@apple.com>
+
+ Support TouchBar in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=164437
+ -and corresponding-
+ rdar://problem/28876524
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/API/Cocoa/WKViewPrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView makeTouchBar]):
+ (-[WKWebView candidateListTouchBarItem]):
+ (-[WKWebView _web_didAddMediaControlsManager:]):
+ (-[WKWebView _web_didRemoveMediaControlsManager]):
+ (-[WKWebView _interactWithMediaControlsForTesting]):
+ (-[WKWebView _wantsMediaPlaybackControlsView]):
+ (-[WKWebView _setWantsMediaPlaybackControlsView:]):
+ (-[WKWebView _mediaPlaybackControlsView]):
+ (-[WKWebView _addMediaPlaybackControlsView:]):
+ (-[WKWebView _removeMediaPlaybackControlsView]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView makeTouchBar]):
+ (-[WKView candidateListTouchBarItem]):
+ (-[WKView _web_didAddMediaControlsManager:]):
+ (-[WKView _web_didRemoveMediaControlsManager]):
+ (-[WKView _wantsMediaPlaybackControlsView]):
+ (-[WKView _setWantsMediaPlaybackControlsView:]):
+ (-[WKView _mediaPlaybackControlsView]):
+ (-[WKView _addMediaPlaybackControlsView:]):
+ (-[WKView _removeMediaPlaybackControlsView]):
+ * UIProcess/Cocoa/WebViewImpl.h:
+ (WebKit::WebViewImpl::currentTouchBar):
+ (WebKit::WebViewImpl::clientWantsMediaPlaybackControlsView):
+ (WebKit::WebViewImpl::setClientWantsMediaPlaybackControlsView):
+ (WebKit::WebViewImpl::setIsCustomizingTouchBar):
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (-[WKTextListTouchBarViewController initWithWebViewImpl:]):
+ (-[WKTextListTouchBarViewController didDestroyView]):
+ (-[WKTextListTouchBarViewController _selectList:]):
+ (-[WKTextListTouchBarViewController setCurrentListType:]):
+ (-[WKTextTouchBarItemController initWithWebViewImpl:]):
+ (-[WKTextTouchBarItemController didDestroyView]):
+ (-[WKTextTouchBarItemController touchBar:makeItemForIdentifier:]):
+ (-[WKTextTouchBarItemController itemForIdentifier:]):
+ (-[WKTextTouchBarItemController candidateListTouchBarItem:endSelectingCandidateAtIndex:]):
+ (-[WKTextTouchBarItemController candidateListTouchBarItem:changedCandidateListVisibility:]):
+ (-[WKTextTouchBarItemController textListTouchBarViewController]):
+ (-[WKTextTouchBarItemController setTextIsBold:]):
+ (-[WKTextTouchBarItemController setTextIsItalic:]):
+ (-[WKTextTouchBarItemController setTextIsUnderlined:]):
+ (-[WKTextTouchBarItemController _wkChangeTextStyle:]):
+ (-[WKTextTouchBarItemController setCurrentTextAlignment:]):
+ (-[WKTextTouchBarItemController _wkChangeTextAlignment:]):
+ (-[WKTextTouchBarItemController textColor]):
+ (-[WKTextTouchBarItemController setTextColor:]):
+ (-[WKTextTouchBarItemController _wkChangeColor:]):
+ (-[WKTextTouchBarItemController textListViewController]):
+ (WebKit::WebViewImpl::makeTouchBar):
+ (WebKit::WebViewImpl::candidateListTouchBarItem):
+ (WebKit::WebViewImpl::mediaPlaybackControlsView):
+ (WebKit::WebViewImpl::useMediaPlaybackControlsView):
+ (WebKit::WebViewImpl::dismissTextTouchBarPopoverItemWithIdentifier):
+ (WebKit::textTouchBarCustomizationAllowedIdentifiers):
+ (WebKit::plainTextTouchBarCustomizationDefaultItemIdentifiers):
+ (WebKit::richTextTouchBarCustomizationDefaultItemIdentifiers):
+ (WebKit::touchBarDidExitCustomization):
+ (WebKit::touchBarWillEnterCustomization):
+ (WebKit::didChangeAutomaticTextCompletion):
+ (WebKit::WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers):
+ (WebKit::WebViewImpl::setUpTextTouchBar):
+ (WebKit::WebViewImpl::isRichlyEditable):
+ (WebKit::WebViewImpl::textTouchBar):
+ (WebKit::WebViewImpl::updateTextTouchBar):
+ (WebKit::WebViewImpl::updateMediaTouchBar):
+ (WebKit::WebViewImpl::forceRequestCandidatesForTesting):
+ (WebKit::WebViewImpl::updateTouchBar):
+ (WebKit::WebViewImpl::shouldRequestCandidates):
+ (WebKit::WebViewImpl::showCandidates):
+ (WebKit::WebViewImpl::webViewImplAdditionsWillDestroyView):
+ (WebKit::WebViewImpl::setEditableElementIsFocused):
+ (WebKit::WebViewImpl::becomeFirstResponder):
+ (WebKit::WebViewImpl::selectionDidChange):
+ (WebKit::WebViewImpl::videoControlsManagerDidChange):
+ (WebKit::WebViewImpl::updateWebViewImplAdditions): Deleted.
+
</ins><span class="cx"> 2016-11-09 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> [WK2][NETWORK_SESSION] Add support for downloading file backed blobs
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -31,6 +31,8 @@
</span><span class="cx"> #import <WebKit/WKView.h>
</span><span class="cx"> #import <WebKit/_WKOverlayScrollbarStyle.h>
</span><span class="cx">
</span><ins>+@class AVFunctionBarScrubber;
+
</ins><span class="cx"> @interface WKView (Private)
</span><span class="cx">
</span><span class="cx"> /* C SPI support. */
</span><span class="lines">@@ -132,6 +134,11 @@
</span><span class="cx">
</span><span class="cx"> - (void)_gestureEventWasNotHandledByWebCore:(NSEvent *)event;
</span><span class="cx">
</span><ins>+@property (nonatomic, readwrite, setter=_setWantsMediaPlaybackControlsView:) BOOL _wantsMediaPlaybackControlsView;
+@property (nonatomic, readonly) AVFunctionBarScrubber *_mediaPlaybackControlsView;
+- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView;
+- (void)_removeMediaPlaybackControlsView;
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // !TARGET_OS_IPHONE
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -174,8 +174,13 @@
</span><span class="cx">
</span><span class="cx"> @interface WKWebView () <WebViewImplDelegate, NSTextInputClient>
</span><span class="cx"> @end
</span><del>-#endif
</del><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+@interface WKWebView () <NSTouchBarProvider>
+@end
+#endif // HAVE(TOUCH_BAR)
+#endif // PLATFORM(MAC)
+
</ins><span class="cx"> static HashMap<WebKit::WebPageProxy*, WKWebView *>& pageToViewMap()
</span><span class="cx"> {
</span><span class="cx"> static NeverDestroyed<HashMap<WebKit::WebPageProxy*, WKWebView *>> map;
</span><span class="lines">@@ -3155,6 +3160,38 @@
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+
+@dynamic touchBar;
+
+- (NSTouchBar *)makeTouchBar
+{
+ return _impl->makeTouchBar();
+}
+
+- (NSCandidateListTouchBarItem *)candidateListTouchBarItem
+{
+ return _impl->candidateListTouchBarItem();
+}
+
+- (void)_web_didAddMediaControlsManager:(id)controlsManager
+{
+ [self _addMediaPlaybackControlsView:controlsManager];
+}
+
+- (void)_web_didRemoveMediaControlsManager
+{
+ [self _removeMediaPlaybackControlsView];
+}
+
+- (void)_interactWithMediaControlsForTesting
+{
+ [self _setWantsMediaPlaybackControlsView:YES];
+ [self makeTouchBar];
+}
+
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WKWebView (WKPrivate)
</span><span class="lines">@@ -4529,8 +4566,43 @@
</span><span class="cx"> _impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (BOOL)_wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ return _impl->clientWantsMediaPlaybackControlsView();
+#else
+ return NO;
</ins><span class="cx"> #endif
</span><ins>+}
</ins><span class="cx">
</span><ins>+- (void)_setWantsMediaPlaybackControlsView:(BOOL)wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ _impl->setClientWantsMediaPlaybackControlsView(wantsMediaPlaybackControlsView);
+#endif
+}
+
+- (AVFunctionBarScrubber *)_mediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ return _impl->clientWantsMediaPlaybackControlsView() ? _impl->mediaPlaybackControlsView() : nil;
+#else
+ return nil;
+#endif
+}
+
+// This method is for subclasses to override.
+- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
+{
+}
+
+// This method is for subclasses to override.
+- (void)_removeMediaPlaybackControlsView
+{
+}
+
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+@class AVFunctionBarScrubber;
</ins><span class="cx"> @class WKBrowsingContextHandle;
</span><span class="cx"> @class _WKFrameHandle;
</span><span class="cx"> @class _WKHitTestResult;
</span><span class="lines">@@ -202,6 +203,12 @@
</span><span class="cx"> - (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
</span><span class="cx"> - (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(_WKFrameHandle *)frameHandle WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx">
</span><ins>+// FIXME: This SPI should become a part of the WKUIDelegate. rdar://problem/26561537
+@property (nonatomic, readwrite, setter=_setWantsMediaPlaybackControlsView:) BOOL _wantsMediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+@property (nonatomic, readonly) AVFunctionBarScrubber *_mediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_removeMediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> - (WKNavigation *)_reloadWithoutContentBlockers WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -55,6 +55,11 @@
</span><span class="cx"> @interface WKView () <WebViewImplDelegate>
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+@interface WKView () <NSTouchBarProvider>
+@end
+#endif
+
</ins><span class="cx"> @implementation WKView
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="lines">@@ -977,6 +982,32 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+
+@dynamic touchBar;
+
+- (NSTouchBar *)makeTouchBar
+{
+ return _data->_impl->makeTouchBar();
+}
+
+- (NSCandidateListTouchBarItem *)candidateListTouchBarItem
+{
+ return _data->_impl->candidateListTouchBarItem();
+}
+
+- (void)_web_didAddMediaControlsManager:(id)controlsManager
+{
+ [self _addMediaPlaybackControlsView:controlsManager];
+}
+
+- (void)_web_didRemoveMediaControlsManager
+{
+ [self _removeMediaPlaybackControlsView];
+}
+
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation WKView (Private)
</span><span class="lines">@@ -1467,10 +1498,41 @@
</span><span class="cx"> _data->_impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-@end
</del><ins>+- (BOOL)_wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ return _data->_impl->clientWantsMediaPlaybackControlsView();
+#else
+ return NO;
+#endif
+}
</ins><span class="cx">
</span><del>-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKViewAdditions.mm>
</del><ins>+- (void)_setWantsMediaPlaybackControlsView:(BOOL)wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ _data->_impl->setClientWantsMediaPlaybackControlsView(wantsMediaPlaybackControlsView);
</ins><span class="cx"> #endif
</span><ins>+}
</ins><span class="cx">
</span><ins>+- (AVFunctionBarScrubber *)_mediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+ return _data->_impl->clientWantsMediaPlaybackControlsView() ? _data->_impl->mediaPlaybackControlsView() : nil;
+#else
+ return nil;
+#endif
+}
+
+// This method is for subclasses to override.
+- (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView
+{
+}
+
+// This method is for subclasses to override.
+- (void)_removeMediaPlaybackControlsView
+{
+}
+
+@end
+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -52,9 +52,17 @@
</span><span class="cx"> OBJC_CLASS WKWindowVisibilityObserver;
</span><span class="cx"> OBJC_CLASS _WKThumbnailView;
</span><span class="cx">
</span><del>-#if USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-#import <WebKitAdditions/WebViewImplAdditionsDeclarations.h>
-#endif
</del><ins>+#if HAVE(TOUCH_BAR)
+OBJC_CLASS AVFunctionBarPlaybackControlsProvider;
+OBJC_CLASS AVFunctionBarScrubber;
+OBJC_CLASS NSCandidateListTouchBarItem;
+OBJC_CLASS NSCustomTouchBarItem;
+OBJC_CLASS NSTouchBar;
+OBJC_CLASS NSTouchBarItem;
+OBJC_CLASS NSPopoverTouchBarItem;
+OBJC_CLASS WKTextTouchBarItemController;
+OBJC_CLASS WebPlaybackControlsManager;
+#endif // HAVE(TOUCH_BAR)
</ins><span class="cx">
</span><span class="cx"> @protocol WebViewImplDelegate
</span><span class="cx">
</span><span class="lines">@@ -480,11 +488,9 @@
</span><span class="cx"> void rightMouseDragged(NSEvent *);
</span><span class="cx"> void rightMouseUp(NSEvent *);
</span><span class="cx">
</span><del>- void updateWebViewImplAdditions();
</del><span class="cx"> void forceRequestCandidatesForTesting();
</span><span class="cx"> bool shouldRequestCandidates() const;
</span><span class="cx"> void showCandidates(NSArray *candidates, NSString *, NSRect rectOfTypedString, NSRange selectedRange, NSView *, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate));
</span><del>- void webViewImplAdditionsWillDestroyView();
</del><span class="cx">
</span><span class="cx"> bool windowIsFrontWindowUnderMouse(NSEvent *);
</span><span class="cx">
</span><span class="lines">@@ -496,12 +502,55 @@
</span><span class="cx">
</span><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
</span><span class="cx"> void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
</span><del>-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewImplAdditions.h>
</del><span class="cx"> #endif
</span><del>-#endif
</del><span class="cx">
</span><ins>+#if HAVE(TOUCH_BAR)
+ NSTouchBar *makeTouchBar();
+ void updateTouchBar();
+ NSTouchBar *currentTouchBar() const { return m_currentTouchBar.get(); }
+ NSCandidateListTouchBarItem *candidateListTouchBarItem() const;
+ AVFunctionBarScrubber *mediaPlaybackControlsView() const;
+ NSTouchBar *textTouchBar() const;
+ void dismissTextTouchBarPopoverItemWithIdentifier(NSString *);
+
+ bool clientWantsMediaPlaybackControlsView() const { return m_clientWantsMediaPlaybackControlsView; }
+ void setClientWantsMediaPlaybackControlsView(bool clientWantsMediaPlaybackControlsView) { m_clientWantsMediaPlaybackControlsView = clientWantsMediaPlaybackControlsView; }
+
+ void updateTouchBarAndRefreshTextBarIdentifiers();
+ void setIsCustomizingTouchBar(bool isCustomizingTouchBar) { m_isCustomizingTouchBar = isCustomizingTouchBar; };
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> private:
</span><ins>+#if HAVE(TOUCH_BAR)
+ void setUpTextTouchBar(NSTouchBar *);
+ void updateTextTouchBar();
+ void updateMediaTouchBar();
+
+ bool useMediaPlaybackControlsView() const;
+ bool isRichlyEditable() const;
+
+ bool m_clientWantsMediaPlaybackControlsView { false };
+ bool m_canCreateTouchBars { false };
+ bool m_startedListeningToCustomizationEvents { false };
+ bool m_isUpdatingTextTouchBar { false };
+ bool m_isCustomizingTouchBar { false };
+
+ RetainPtr<NSTouchBar> m_currentTouchBar;
+ RetainPtr<NSTouchBar> m_richTextTouchBar;
+ RetainPtr<NSTouchBar> m_plainTextTouchBar;
+ RetainPtr<WKTextTouchBarItemController> m_textTouchBarItemController;
+ RetainPtr<NSCandidateListTouchBarItem> m_richTextCandidateListTouchBarItem;
+ RetainPtr<NSCandidateListTouchBarItem> m_plainTextCandidateListTouchBarItem;
+ RetainPtr<NSArray> m_emptyCandidatesArray;
+ RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
+ RetainPtr<NSCustomTouchBarItem> m_exitFullScreenButton;
+
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ RetainPtr<AVFunctionBarPlaybackControlsProvider> m_mediaTouchBarProvider;
+ RetainPtr<AVFunctionBarScrubber> m_mediaPlaybackControlsView;
+#endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx"> WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
</span><span class="cx">
</span><span class="cx"> bool supportsArbitraryLayoutModes() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -60,11 +60,13 @@
</span><span class="cx"> #import "WebEventFactory.h"
</span><span class="cx"> #import "WebInspectorProxy.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><ins>+#import "WebPlaybackSessionManagerProxy.h"
</ins><span class="cx"> #import "WebProcessPool.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import "_WKRemoteObjectRegistryInternal.h"
</span><span class="cx"> #import "_WKThumbnailViewInternal.h"
</span><span class="cx"> #import <HIToolbox/CarbonEventsCore.h>
</span><ins>+#import <WebCore/AVKitSPI.h>
</ins><span class="cx"> #import <WebCore/AXObjectCache.h>
</span><span class="cx"> #import <WebCore/ActivityState.h>
</span><span class="cx"> #import <WebCore/ColorMac.h>
</span><span class="lines">@@ -80,6 +82,7 @@
</span><span class="cx"> #import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
</span><span class="cx"> #import <WebCore/NSSpellCheckerSPI.h>
</span><span class="cx"> #import <WebCore/NSTextFinderSPI.h>
</span><ins>+#import <WebCore/NSTouchBarSPI.h>
</ins><span class="cx"> #import <WebCore/NSWindowSPI.h>
</span><span class="cx"> #import <WebCore/PlatformEventFactoryMac.h>
</span><span class="cx"> #import <WebCore/SoftLinking.h>
</span><span class="lines">@@ -90,14 +93,20 @@
</span><span class="cx"> #import <WebCore/WebCoreFullScreenPlaceholderView.h>
</span><span class="cx"> #import <WebCore/WebCoreFullScreenWindow.h>
</span><span class="cx"> #import <WebCore/WebCoreNSStringExtras.h>
</span><ins>+#import <WebCore/WebPlaybackControlsManager.h>
</ins><span class="cx"> #import <WebKitSystemInterface.h>
</span><span class="cx"> #import <sys/stat.h>
</span><span class="cx"> #import <wtf/NeverDestroyed.h>
</span><ins>+#import <wtf/TemporaryChange.h>
</ins><span class="cx">
</span><del>-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewImplIncludes.h>
-#endif
</del><ins>+#if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarPlaybackControlsProvider)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarScrubber)
</ins><span class="cx">
</span><ins>+static NSString * const WKMediaExitFullScreenItem = @"WKMediaExitFullScreenItem";
+#endif // HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+
</ins><span class="cx"> SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
</span><span class="cx">
</span><span class="cx"> @interface NSApplication ()
</span><span class="lines">@@ -433,32 +442,710 @@
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebViewImplAdditions.mm>
-#else
</del><ins>+using namespace WebKit;
+
+#if HAVE(TOUCH_BAR)
+
+@interface WKTextListTouchBarViewController : NSViewController {
+@private
+ WebViewImpl* _webViewImpl;
+}
+
+@property (nonatomic) ListType currentListType;
+
+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl;
+
+@end
+
+@implementation WKTextListTouchBarViewController
+
+@synthesize currentListType=_currentListType;
+
+static const CGFloat listControlSegmentWidth = 67;
+static const CGFloat exitFullScreenButtonWidth = 64;
+
+static const NSUInteger noListSegment = 0;
+static const NSUInteger unorderedListSegment = 1;
+static const NSUInteger orderedListSegment = 2;
+
+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _webViewImpl = webViewImpl;
+
+ NSSegmentedControl *insertListControl = [NSSegmentedControl segmentedControlWithLabels:@[ WebCore::insertListTypeNone(), WebCore::insertListTypeBulleted(), WebCore::insertListTypeNumbered() ] trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(_selectList:)];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:noListSegment];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:unorderedListSegment];
+ [insertListControl setWidth:listControlSegmentWidth forSegment:orderedListSegment];
+ insertListControl.font = [NSFont systemFontOfSize:15];
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ id segmentElement = NSAccessibilityUnignoredDescendant(insertListControl);
+ NSArray *segments = [segmentElement accessibilityAttributeValue:NSAccessibilityChildrenAttribute];
+ ASSERT(segments.count == 3);
+ [segments[noListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNone() forAttribute:NSAccessibilityDescriptionAttribute];
+ [segments[unorderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeBulletedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
+ [segments[orderedListSegment] accessibilitySetOverrideValue:WebCore::insertListTypeNumberedAccessibilityTitle() forAttribute:NSAccessibilityDescriptionAttribute];
+#pragma clang diagnostic pop
+
+ self.view = insertListControl;
+
+ return self;
+}
+
+- (void)didDestroyView
+{
+ _webViewImpl = nullptr;
+}
+
+- (void)_selectList:(id)sender
+{
+ if (!_webViewImpl)
+ return;
+
+ NSSegmentedControl *insertListControl = (NSSegmentedControl *)self.view;
+ switch (insertListControl.selectedSegment) {
+ case noListSegment:
+ // There is no "remove list" edit command, but InsertOrderedList and InsertUnorderedList both
+ // behave as toggles, so we can invoke the appropriate edit command depending on our _currentListType
+ // to remove an existing list. We don't have to do anything if _currentListType is NoList.
+ if (_currentListType == OrderedList)
+ _webViewImpl->page().executeEditCommand(@"InsertOrderedList", @"");
+ else if (_currentListType == UnorderedList)
+ _webViewImpl->page().executeEditCommand(@"InsertUnorderedList", @"");
+ break;
+ case unorderedListSegment:
+ _webViewImpl->page().executeEditCommand(@"InsertUnorderedList", @"");
+ break;
+ case orderedListSegment:
+ _webViewImpl->page().executeEditCommand(@"InsertOrderedList", @"");
+ break;
+ }
+
+ _webViewImpl->dismissTextTouchBarPopoverItemWithIdentifier(NSTouchBarItemIdentifierTextList);
+}
+
+- (void)setCurrentListType:(ListType)listType
+{
+ NSSegmentedControl *insertListControl = (NSSegmentedControl *)self.view;
+ switch (listType) {
+ case NoList:
+ [insertListControl setSelected:YES forSegment:noListSegment];
+ break;
+ case OrderedList:
+ [insertListControl setSelected:YES forSegment:orderedListSegment];
+ break;
+ case UnorderedList:
+ [insertListControl setSelected:YES forSegment:unorderedListSegment];
+ break;
+ }
+
+ _currentListType = listType;
+}
+
+@end
+
+@interface WKTextTouchBarItemController : NSTextTouchBarItemController <NSCandidateListTouchBarItemDelegate, NSTouchBarDelegate> {
+@private
+ BOOL _textIsBold;
+ BOOL _textIsItalic;
+ BOOL _textIsUnderlined;
+ NSTextAlignment _currentTextAlignment;
+ RetainPtr<NSColor> _textColor;
+ RetainPtr<WKTextListTouchBarViewController> _textListTouchBarViewController;
+
+@private
+ WebViewImpl* _webViewImpl;
+}
+
+@property (nonatomic) BOOL textIsBold;
+@property (nonatomic) BOOL textIsItalic;
+@property (nonatomic) BOOL textIsUnderlined;
+@property (nonatomic) NSTextAlignment currentTextAlignment;
+@property (nonatomic, retain, readwrite) NSColor *textColor;
+
+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl;
+@end
+
+@implementation WKTextTouchBarItemController
+
+@synthesize textIsBold=_textIsBold;
+@synthesize textIsItalic=_textIsItalic;
+@synthesize textIsUnderlined=_textIsUnderlined;
+@synthesize currentTextAlignment=_currentTextAlignment;
+
+- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _webViewImpl = webViewImpl;
+
+ return self;
+}
+
+- (void)didDestroyView
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ _webViewImpl = nullptr;
+ [_textListTouchBarViewController didDestroyView];
+}
+
+#pragma mark NSTouchBarDelegate
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSString *)identifier
+{
+ return [self itemForIdentifier:identifier];
+}
+
+- (nullable NSTouchBarItem *)itemForIdentifier:(NSString *)identifier
+{
+ NSTouchBarItem *item = [super itemForIdentifier:identifier];
+ BOOL isTextFormatItem = [identifier isEqualToString:NSTouchBarItemIdentifierTextFormat];
+
+ if (isTextFormatItem || [identifier isEqualToString:NSTouchBarItemIdentifierTextStyle])
+ self.textStyle.action = @selector(_wkChangeTextStyle:);
+
+ if (isTextFormatItem || [identifier isEqualToString:NSTouchBarItemIdentifierTextAlignment])
+ self.textAlignments.action = @selector(_wkChangeTextAlignment:);
+
+ NSColorPickerTouchBarItem *colorPickerItem = nil;
+ if ([identifier isEqualToString:NSTouchBarItemIdentifierTextColorPicker] && [item isKindOfClass:[NSColorPickerTouchBarItem class]])
+ colorPickerItem = (NSColorPickerTouchBarItem *)item;
+ if (isTextFormatItem)
+ colorPickerItem = self.colorPickerItem;
+ if (colorPickerItem) {
+ colorPickerItem.target = self;
+ colorPickerItem.action = @selector(_wkChangeColor:);
+ colorPickerItem.showsAlpha = NO;
+ }
+
+ return item;
+}
+
+#pragma mark NSCandidateListTouchBarItemDelegate
+
+- (void)candidateListTouchBarItem:(NSCandidateListTouchBarItem *)anItem endSelectingCandidateAtIndex:(NSInteger)index
+{
+ if (index == NSNotFound)
+ return;
+
+ if (!_webViewImpl)
+ return;
+
+ NSArray *candidates = anItem.candidates;
+ if ((NSUInteger)index >= candidates.count)
+ return;
+
+ NSTextCheckingResult *candidate = candidates[index];
+ ASSERT([candidate isKindOfClass:[NSTextCheckingResult class]]);
+
+ _webViewImpl->handleAcceptedCandidate(candidate);
+}
+
+- (void)candidateListTouchBarItem:(NSCandidateListTouchBarItem *)anItem changedCandidateListVisibility:(BOOL)isVisible
+{
+ if (!_webViewImpl)
+ return;
+
+ if (isVisible)
+ _webViewImpl->requestCandidatesForSelectionIfNeeded();
+
+ _webViewImpl->updateTouchBar();
+}
+
+#pragma mark NSNotificationCenter observers
+
+- (void)touchBarDidExitCustomization:(NSNotification *)notification
+{
+ if (!_webViewImpl)
+ return;
+
+ _webViewImpl->setIsCustomizingTouchBar(false);
+ _webViewImpl->updateTouchBar();
+}
+
+- (void)touchBarWillEnterCustomization:(NSNotification *)notification
+{
+ if (!_webViewImpl)
+ return;
+
+ _webViewImpl->setIsCustomizingTouchBar(true);
+}
+
+- (void)didChangeAutomaticTextCompletion:(NSNotification *)notification
+{
+ if (!_webViewImpl)
+ return;
+
+ _webViewImpl->updateTouchBarAndRefreshTextBarIdentifiers();
+}
+
+
+#pragma mark NSTextTouchBarItemController
+
+- (WKTextListTouchBarViewController *)textListTouchBarViewController
+{
+ return (WKTextListTouchBarViewController *)self.textListViewController;
+}
+
+- (void)setTextIsBold:(BOOL)bold
+{
+ _textIsBold = bold;
+ if ([self.textStyle isSelectedForSegment:0] != _textIsBold)
+ [self.textStyle setSelected:_textIsBold forSegment:0];
+}
+
+- (void)setTextIsItalic:(BOOL)italic
+{
+ _textIsItalic = italic;
+ if ([self.textStyle isSelectedForSegment:1] != _textIsItalic)
+ [self.textStyle setSelected:_textIsItalic forSegment:1];
+}
+
+- (void)setTextIsUnderlined:(BOOL)underlined
+{
+ _textIsUnderlined = underlined;
+ if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined)
+ [self.textStyle setSelected:_textIsUnderlined forSegment:2];
+}
+
+- (void)_wkChangeTextStyle:(id)sender
+{
+ if (!_webViewImpl)
+ return;
+
+ if ([self.textStyle isSelectedForSegment:0] != _textIsBold) {
+ _textIsBold = !_textIsBold;
+ _webViewImpl->page().executeEditCommand(@"ToggleBold", @"");
+ }
+
+ if ([self.textStyle isSelectedForSegment:1] != _textIsItalic) {
+ _textIsItalic = !_textIsItalic;
+ _webViewImpl->page().executeEditCommand("ToggleItalic", @"");
+ }
+
+ if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined) {
+ _textIsUnderlined = !_textIsUnderlined;
+ _webViewImpl->page().executeEditCommand("ToggleUnderline", @"");
+ }
+}
+
+- (void)setCurrentTextAlignment:(NSTextAlignment)alignment
+{
+ _currentTextAlignment = alignment;
+ [self.textAlignments selectSegmentWithTag:_currentTextAlignment];
+}
+
+- (void)_wkChangeTextAlignment:(id)sender
+{
+ if (!_webViewImpl)
+ return;
+
+ NSTextAlignment alignment = (NSTextAlignment)[self.textAlignments.cell tagForSegment:self.textAlignments.selectedSegment];
+ switch (alignment) {
+ case NSTextAlignmentLeft:
+ _currentTextAlignment = NSTextAlignmentLeft;
+ _webViewImpl->page().executeEditCommand("AlignLeft", @"");
+ break;
+ case NSTextAlignmentRight:
+ _currentTextAlignment = NSTextAlignmentRight;
+ _webViewImpl->page().executeEditCommand("AlignRight", @"");
+ break;
+ case NSTextAlignmentCenter:
+ _currentTextAlignment = NSTextAlignmentCenter;
+ _webViewImpl->page().executeEditCommand("AlignCenter", @"");
+ break;
+ case NSTextAlignmentJustified:
+ _currentTextAlignment = NSTextAlignmentJustified;
+ _webViewImpl->page().executeEditCommand("AlignJustified", @"");
+ break;
+ default:
+ break;
+ }
+
+ _webViewImpl->dismissTextTouchBarPopoverItemWithIdentifier(NSTouchBarItemIdentifierTextAlignment);
+}
+
+- (NSColor *)textColor
+{
+ return _textColor.get();
+}
+
+- (void)setTextColor:(NSColor *)color
+{
+ _textColor = color;
+ self.colorPickerItem.color = _textColor.get();
+}
+
+- (void)_wkChangeColor:(id)sender
+{
+ if (!_webViewImpl)
+ return;
+
+ _textColor = self.colorPickerItem.color;
+ _webViewImpl->page().executeEditCommand("ForeColor", WebCore::colorFromNSColor(_textColor.get()).serialized());
+}
+
+- (NSViewController *)textListViewController
+{
+ if (!_textListTouchBarViewController)
+ _textListTouchBarViewController = adoptNS([[WKTextListTouchBarViewController alloc] initWithWebViewImpl:_webViewImpl]);
+ return _textListTouchBarViewController.get();
+}
+
+@end
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><del>-void WebViewImpl::updateWebViewImplAdditions()
</del><ins>+NSTouchBar *WebViewImpl::makeTouchBar()
</ins><span class="cx"> {
</span><ins>+ if (!m_canCreateTouchBars) {
+ m_canCreateTouchBars = true;
+ updateTouchBar();
+ }
+ return m_currentTouchBar.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebViewImpl::updateTouchBar()
+{
+ if (!m_canCreateTouchBars)
+ return;
+
+ NSTouchBar *touchBar = nil;
+ bool userActionRequirementsHaveBeenMet = m_requiresUserActionForEditingControlsManager ? m_page->hasHadSelectionChangesFromUserInteraction() : true;
+ if (m_page->editorState().isContentEditable && !m_page->needsHiddenContentEditableQuirk()) {
+ updateTextTouchBar();
+ if (userActionRequirementsHaveBeenMet)
+ touchBar = textTouchBar();
+ }
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ else if (m_page->hasActiveVideoForControlsManager()) {
+ updateMediaTouchBar();
+ // If useMediaPlaybackControlsView() is true, then we are relying on the API client to display a popover version
+ // of the media timeline in their own function bar. If it is false, then we will display the media timeline in our
+ // function bar.
+ if (!useMediaPlaybackControlsView())
+ touchBar = [m_mediaTouchBarProvider respondsToSelector:@selector(touchBar)] ? [(id)m_mediaTouchBarProvider.get() touchBar] : [(id)m_mediaTouchBarProvider.get() touchBar];
+ } else if ([m_mediaTouchBarProvider playbackControlsController]) {
+ if (m_clientWantsMediaPlaybackControlsView) {
+ if ([m_view respondsToSelector:@selector(_web_didRemoveMediaControlsManager)] && m_view == m_view.window.firstResponder)
+ [m_view _web_didRemoveMediaControlsManager];
+ }
+ [m_mediaTouchBarProvider setPlaybackControlsController:nil];
+ [m_mediaPlaybackControlsView setPlaybackControlsController:nil];
+ }
+#endif
+
+ if (touchBar == m_currentTouchBar)
+ return;
+
+ // If m_editableElementIsFocused is true, then we may have a non-editable selection right now just because
+ // the user is clicking or tabbing between editable fields.
+ if (m_editableElementIsFocused && touchBar != textTouchBar())
+ return;
+
+ m_currentTouchBar = touchBar;
+ [m_view willChangeValueForKey:@"touchBar"];
+ [m_view setTouchBar:m_currentTouchBar.get()];
+ [m_view didChangeValueForKey:@"touchBar"];
+}
+
+NSCandidateListTouchBarItem *WebViewImpl::candidateListTouchBarItem() const
+{
+ return isRichlyEditable() ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get();
+}
+
+AVFunctionBarScrubber *WebViewImpl::mediaPlaybackControlsView() const
+{
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ if (m_page->hasActiveVideoForControlsManager())
+ return m_mediaPlaybackControlsView.get();
+#endif
+ return nil;
+}
+
+bool WebViewImpl::useMediaPlaybackControlsView() const
+{
+#if ENABLE(FULLSCREEN_API)
+ if (hasFullScreenWindowController())
+ return ![m_fullScreenWindowController isFullScreen];
+#endif
+ return m_clientWantsMediaPlaybackControlsView;
+}
+
+void WebViewImpl::dismissTextTouchBarPopoverItemWithIdentifier(NSString *identifier)
+{
+ NSTouchBarItem *foundItem = nil;
+ for (NSTouchBarItem *item in textTouchBar().items) {
+ if ([item.identifier isEqualToString:identifier]) {
+ foundItem = item;
+ break;
+ }
+
+ if ([item.identifier isEqualToString:NSTouchBarItemIdentifierTextFormat]) {
+ for (NSTouchBarItem *childItem in ((NSGroupTouchBarItem *)item).groupTouchBar.items) {
+ if ([childItem.identifier isEqualToString:identifier]) {
+ foundItem = childItem;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ if ([foundItem isKindOfClass:[NSPopoverTouchBarItem class]])
+ [(NSPopoverTouchBarItem *)foundItem dismissPopover:nil];
+}
+
+static NSArray<NSString *> *textTouchBarCustomizationAllowedIdentifiers()
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextColorPicker, NSTouchBarItemIdentifierTextStyle, NSTouchBarItemIdentifierTextAlignment, NSTouchBarItemIdentifierTextList, NSTouchBarItemIdentifierFlexibleSpace ];
+}
+
+static NSArray<NSString *> *plainTextTouchBarCustomizationDefaultItemIdentifiers()
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierCandidateList ];
+}
+
+static NSArray<NSString *> *richTextTouchBarCustomizationDefaultItemIdentifiers()
+{
+ return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
+}
+
+void WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers()
+{
+ if (m_richTextTouchBar)
+ setUpTextTouchBar(m_richTextTouchBar.get());
+
+ if (m_plainTextTouchBar)
+ setUpTextTouchBar(m_plainTextTouchBar.get());
+
+ updateTouchBar();
+}
+
+void WebViewImpl::setUpTextTouchBar(NSTouchBar *touchBar)
+{
+ bool isRichTextTouchBar = touchBar == m_richTextTouchBar.get();
+ [touchBar setDelegate:m_textTouchBarItemController.get()];
+ [touchBar setDefaultItems:[NSMutableSet setWithObject:isRichTextTouchBar ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get()]];
+ [touchBar setCustomizationAllowedItemIdentifiers:textTouchBarCustomizationAllowedIdentifiers()];
+ [touchBar setCustomizationDefaultItemIdentifiers:isRichTextTouchBar ? richTextTouchBarCustomizationDefaultItemIdentifiers() : plainTextTouchBarCustomizationDefaultItemIdentifiers()];
+
+ if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[touchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
+ textFormatItem.groupTouchBar.customizationIdentifier = @"WKTextFormatTouchBar";
+}
+
+bool WebViewImpl::isRichlyEditable() const
+{
+ return m_page->editorState().isContentRichlyEditable && !m_page->needsPlainTextQuirk();
+}
+
+NSTouchBar *WebViewImpl::textTouchBar() const
+{
+ return isRichlyEditable() ? m_richTextTouchBar.get() : m_plainTextTouchBar.get();
+}
+
+static NSTextAlignment nsTextAlignmentFromTextAlignment(TextAlignment textAlignment)
+{
+ NSTextAlignment nsTextAlignment;
+ switch (textAlignment) {
+ case NoAlignment:
+ nsTextAlignment = NSTextAlignmentNatural;
+ break;
+ case LeftAlignment:
+ nsTextAlignment = NSTextAlignmentLeft;
+ break;
+ case RightAlignment:
+ nsTextAlignment = NSTextAlignmentRight;
+ break;
+ case CenterAlignment:
+ nsTextAlignment = NSTextAlignmentCenter;
+ break;
+ case JustifiedAlignment:
+ nsTextAlignment = NSTextAlignmentJustified;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return nsTextAlignment;
+}
+
+void WebViewImpl::updateTextTouchBar()
+{
+ if (!m_page->editorState().isContentEditable)
+ return;
+
+ if (m_isUpdatingTextTouchBar)
+ return;
+
+ TemporaryChange<bool> isUpdatingTextFunctionBar(m_isUpdatingTextTouchBar, true);
+
+ if (!m_textTouchBarItemController)
+ m_textTouchBarItemController = adoptNS([[WKTextTouchBarItemController alloc] initWithWebViewImpl:this]);
+
+ if (!m_startedListeningToCustomizationEvents) {
+ [[NSNotificationCenter defaultCenter] addObserver:m_textTouchBarItemController.get() selector:@selector(touchBarDidExitCustomization:) name:NSTouchBarDidExitCustomization object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:m_textTouchBarItemController.get() selector:@selector(touchBarWillEnterCustomization:) name:NSTouchBarWillEnterCustomization object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:m_textTouchBarItemController.get() selector:@selector(didChangeAutomaticTextCompletion:) name:NSSpellCheckerDidChangeAutomaticTextCompletionNotification object:nil];
+
+ m_startedListeningToCustomizationEvents = true;
+ }
+
+ if (!m_richTextCandidateListTouchBarItem || !m_plainTextCandidateListTouchBarItem) {
+ m_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [m_richTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
+ m_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [m_plainTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
+ requestCandidatesForSelectionIfNeeded();
+ }
+
+ if (!m_richTextTouchBar) {
+ m_richTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ setUpTextTouchBar(m_richTextTouchBar.get());
+ [m_richTextTouchBar setCustomizationIdentifier:@"WKRichTextTouchBar"];
+ }
+
+ if (!m_plainTextTouchBar) {
+ m_plainTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ setUpTextTouchBar(m_plainTextTouchBar.get());
+ [m_plainTextTouchBar setCustomizationIdentifier:@"WKPlainTextTouchBar"];
+ }
+
+ if ([NSSpellChecker isAutomaticTextCompletionEnabled] && !m_isCustomizingTouchBar) {
+ BOOL showCandidatesList = !m_page->editorState().selectionIsRange || m_isHandlingAcceptedCandidate;
+ [candidateListTouchBarItem() updateWithInsertionPointVisibility:showCandidatesList];
+ [m_view _didUpdateCandidateListVisibility:showCandidatesList];
+ }
+
+ if (m_page->editorState().isInPasswordField) {
+ // We don't request candidates for password fields. If the user was previously in a non-password field, then the
+ // old candidates will still show by default, so we clear them here by setting an empty array of candidates.
+ if (!m_emptyCandidatesArray)
+ m_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
+ [candidateListTouchBarItem() setCandidates:m_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
+ }
+
+ NSTouchBar *textTouchBar = this->textTouchBar();
+ BOOL isShowingCombinedTextFormatItem = [textTouchBar.itemIdentifiers containsObject:NSTouchBarItemIdentifierTextFormat];
+ [textTouchBar setPrincipalItemIdentifier:isShowingCombinedTextFormatItem ? NSTouchBarItemIdentifierTextFormat : nil];
+
+ // Set current typing attributes for rich text. This will ensure that the buttons reflect the state of
+ // the text when changing selection throughout the document.
+ if (isRichlyEditable()) {
+ const EditorState& editorState = m_page->editorState();
+ if (!editorState.isMissingPostLayoutData) {
+ [m_textTouchBarItemController setTextIsBold:(bool)(m_page->editorState().postLayoutData().typingAttributes & AttributeBold)];
+ [m_textTouchBarItemController setTextIsItalic:(bool)(m_page->editorState().postLayoutData().typingAttributes & AttributeItalics)];
+ [m_textTouchBarItemController setTextIsUnderlined:(bool)(m_page->editorState().postLayoutData().typingAttributes & AttributeUnderline)];
+ [m_textTouchBarItemController setTextColor:nsColor(editorState.postLayoutData().textColor)];
+ [[m_textTouchBarItemController textListTouchBarViewController] setCurrentListType:(ListType)m_page->editorState().postLayoutData().enclosingListType];
+ [m_textTouchBarItemController setCurrentTextAlignment:nsTextAlignmentFromTextAlignment((TextAlignment)editorState.postLayoutData().textAlignment)];
+ }
+ BOOL isShowingCandidateListItem = [textTouchBar.itemIdentifiers containsObject:NSTouchBarItemIdentifierCandidateList] && [NSSpellChecker isAutomaticTextReplacementEnabled];
+ [m_textTouchBarItemController setUsesNarrowTextStyleItem:isShowingCombinedTextFormatItem && isShowingCandidateListItem];
+ }
+}
+
+void WebViewImpl::updateMediaTouchBar()
+{
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ if (!m_mediaTouchBarProvider)
+ m_mediaTouchBarProvider = adoptNS([allocAVFunctionBarPlaybackControlsProviderInstance() init]);
+
+ if (!m_mediaPlaybackControlsView)
+ m_mediaPlaybackControlsView = adoptNS([allocAVFunctionBarScrubberInstance() init]);
+
+ if (!m_playbackControlsManager)
+ m_playbackControlsManager = adoptNS([[WebPlaybackControlsManager alloc] init]);
+
+ if (PlatformWebPlaybackSessionInterface* interface = m_page->playbackSessionManager()->controlsManagerInterface())
+ [m_playbackControlsManager setWebPlaybackSessionInterfaceMac:interface];
+
+ [m_mediaTouchBarProvider setPlaybackControlsController:m_playbackControlsManager.get()];
+ [m_mediaPlaybackControlsView setPlaybackControlsController:m_playbackControlsManager.get()];
+
+ if (!useMediaPlaybackControlsView()) {
+#if ENABLE(FULLSCREEN_API)
+ // If we can't have a media popover function bar item, it might be because we are in full screen.
+ // If so, customize the escape key.
+ NSTouchBar *touchBar = [m_mediaTouchBarProvider respondsToSelector:@selector(touchBar)] ? [(id)m_mediaTouchBarProvider.get() touchBar] : [(id)m_mediaTouchBarProvider.get() touchBar];
+ if (hasFullScreenWindowController() && [m_fullScreenWindowController isFullScreen]) {
+ if (!m_exitFullScreenButton) {
+ m_exitFullScreenButton = adoptNS([[NSCustomTouchBarItem alloc] initWithIdentifier:WKMediaExitFullScreenItem]);
+
+ NSImage *image = [NSImage imageNamed:NSImageNameTouchBarExitFullScreenTemplate];
+ [image setTemplate:YES];
+
+ NSButton *exitFullScreenButton = [NSButton buttonWithTitle:image ? @"" : @"Exit" image:image target:m_fullScreenWindowController.get() action:@selector(requestExitFullScreen)];
+ [exitFullScreenButton setAccessibilityTitle:WebCore::exitFullScreenButtonAccessibilityTitle()];
+
+ [[exitFullScreenButton.widthAnchor constraintLessThanOrEqualToConstant:exitFullScreenButtonWidth] setActive:YES];
+ [m_exitFullScreenButton setView:exitFullScreenButton];
+ }
+ touchBar.escapeKeyReplacementItem = m_exitFullScreenButton.get();
+ } else
+ touchBar.escapeKeyReplacementItem = nil;
+#endif
+ // The rest of the work to update the media function bar only applies to the popover version, so return early.
+ return;
+ }
+
+ if (m_playbackControlsManager && m_view == m_view.window.firstResponder && [m_view respondsToSelector:@selector(_web_didAddMediaControlsManager:)])
+ [m_view _web_didAddMediaControlsManager:m_mediaPlaybackControlsView.get()];
+#endif
+}
+
</ins><span class="cx"> void WebViewImpl::forceRequestCandidatesForTesting()
</span><span class="cx"> {
</span><ins>+ m_canCreateTouchBars = true;
+#if HAVE(TOUCH_BAR)
+ updateTouchBar();
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebViewImpl::shouldRequestCandidates() const
</span><span class="cx"> {
</span><del>- return false;
</del><ins>+ return !m_page->editorState().isInPasswordField && candidateListTouchBarItem().candidateListVisible;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebViewImpl::showCandidates(NSArray *candidates, NSString *string, NSRect rectOfTypedString, NSRange selectedRange, NSView *view, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate))
</span><span class="cx"> {
</span><ins>+ [candidateListTouchBarItem() setCandidates:candidates forSelectedRange:selectedRange inString:string];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebViewImpl::webViewImplAdditionsWillDestroyView()
</del><ins>+void WebViewImpl::setEditableElementIsFocused(bool editableElementIsFocused)
</ins><span class="cx"> {
</span><ins>+ m_editableElementIsFocused = editableElementIsFocused;
+
+#if HAVE(TOUCH_BAR)
+ // If the editable elements have blurred, then we might need to get rid of the editing function bar.
+ if (!m_editableElementIsFocused)
+ updateTouchBar();
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+} // namespace WebKit
+#else
+namespace WebKit {
+
+void WebViewImpl::forceRequestCandidatesForTesting()
+{
+}
+
+bool WebViewImpl::shouldRequestCandidates() const
+{
+ return false;
+}
+
+void WebViewImpl::showCandidates(NSArray *candidates, NSString *string, NSRect rectOfTypedString, NSRange selectedRange, NSView *view, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate))
+{
+}
+
</ins><span class="cx"> void WebViewImpl::setEditableElementIsFocused(bool editableElementIsFocused)
</span><span class="cx"> {
</span><span class="cx"> m_editableElementIsFocused = editableElementIsFocused;
</span><span class="lines">@@ -465,7 +1152,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span><del>-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 && USE(APPLE_INTERNAL_SDK)
</del><ins>+#endif // HAVE(TOUCH_BAR)
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -540,8 +1227,15 @@
</span><span class="cx"> [m_layoutStrategy invalidate];
</span><span class="cx">
</span><span class="cx"> [m_immediateActionController willDestroyView:m_view];
</span><del>- webViewImplAdditionsWillDestroyView();
</del><span class="cx">
</span><ins>+#if HAVE(DFR)
+ [m_textTouchBarItemController didDestroyView];
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+ [m_mediaTouchBarProvider setPlaybackControlsController:nil];
+ [m_mediaPlaybackControlsView setPlaybackControlsController:nil];
+#endif
+#endif
+
</ins><span class="cx"> m_page->close();
</span><span class="cx">
</span><span class="cx"> WebProcessPool::statistics().wkViewCount--;
</span><span class="lines">@@ -615,7 +1309,9 @@
</span><span class="cx">
</span><span class="cx"> m_inBecomeFirstResponder = false;
</span><span class="cx">
</span><del>- updateWebViewImplAdditions();
</del><ins>+#if HAVE(TOUCH_BAR)
+ updateTouchBar();
+#endif
</ins><span class="cx">
</span><span class="cx"> if (direction != NSDirectSelection) {
</span><span class="cx"> NSEvent *event = [NSApp currentEvent];
</span><span class="lines">@@ -1807,8 +2503,8 @@
</span><span class="cx"> updateFontPanelIfNeeded();
</span><span class="cx"> if (!m_isHandlingAcceptedCandidate)
</span><span class="cx"> m_softSpaceRange = NSMakeRange(NSNotFound, 0);
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
- updateWebViewImplAdditions();
</del><ins>+#if HAVE(TOUCH_BAR)
+ updateTouchBar();
</ins><span class="cx"> if (!m_page->editorState().isMissingPostLayoutData)
</span><span class="cx"> requestCandidatesForSelectionIfNeeded();
</span><span class="cx"> #endif
</span><span class="lines">@@ -2447,8 +3143,8 @@
</span><span class="cx">
</span><span class="cx"> void WebViewImpl::videoControlsManagerDidChange()
</span><span class="cx"> {
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
- updateWebViewImplAdditions();
</del><ins>+#if HAVE(TOUCH_BAR)
+ updateTouchBar();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Tools/ChangeLog        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-11-09 Beth Dakin <bdakin@apple.com>
+
+ Support TouchBar in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=164437
+ -and corresponding-
+ rdar://problem/28876524
+
+ Reviewed by Darin Adler.
+
+ This makes MiniBrowser support TouchBar customization.
+
+ * MiniBrowser/mac/AppDelegate.m:
+ (-[BrowserAppDelegate awakeFromNib]):
+
</ins><span class="cx"> 2016-11-09 Gyuyoung Kim <gyuyoung.kim@webkit.org>
</span><span class="cx">
</span><span class="cx"> [EFL] Use libgcrypt instead of GnuTLS for CryptoDigest
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacAppDelegatem"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/AppDelegate.m (208451 => 208452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/AppDelegate.m        2016-11-09 19:14:17 UTC (rev 208451)
+++ trunk/Tools/MiniBrowser/mac/AppDelegate.m        2016-11-09 19:16:09 UTC (rev 208452)
</span><span class="lines">@@ -47,6 +47,10 @@
</span><span class="cx"> WebKit2NewWindowTag = 2
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+@interface NSApplication (TouchBar)
+@property (getter=isAutomaticCustomizeTouchBarMenuItemEnabled) BOOL automaticCustomizeTouchBarMenuItemEnabled;
+@end
+
</ins><span class="cx"> @implementation BrowserAppDelegate
</span><span class="cx">
</span><span class="cx"> - (id)init
</span><span class="lines">@@ -73,6 +77,9 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> [[NSApp mainMenu] insertItem:[item autorelease] atIndex:[[NSApp mainMenu] indexOfItemWithTitle:@"Debug"]];
</span><ins>+
+ if ([NSApp respondsToSelector:@selector(setAutomaticCustomizeTouchBarMenuItemEnabled:)])
+ [NSApp setAutomaticCustomizeTouchBarMenuItemEnabled:YES];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span></span></pre>
</div>
</div>
</body>
</html>