<!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  &lt;bdakin@apple.com&gt;
+
+        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  &lt;cdumez@apple.com&gt;
</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 = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9332AB8C1653A97900D827EC /* NEONHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NEONHelpers.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEventWithKeyState.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                9335B49B1DCBEF7100ED468E /* NSTouchBarSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSTouchBarSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 933A142B0B7D188600A53FFD /* TextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 933A142C0B7D188600A53FFD /* TextEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TextEvent.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 933A142D0B7D188600A53FFD /* TextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEvent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</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) &amp;&amp; !PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+NS_ASSUME_NONNULL_BEGIN
+
</ins><span class="cx"> @interface AVValueTiming : NSObject &lt;NSCoding, NSCopying, NSMutableCopying&gt; 
</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 &lt;AVKit/AVFunctionBarPlaybackControlsProvider.h&gt;
+#import &lt;AVKit/AVFunctionBarScrubber.h&gt;
+#else
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol AVFunctionBarPlaybackControlsControlling &lt;NSObject&gt;
+@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&lt;AVFunctionBarPlaybackControlsControlling&gt; 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) &amp;&amp; HAVE(TOUCH_BAR)
+#if USE(APPLE_INTERNAL_SDK)
+
+#import &lt;AppKit/NSFunctionBar_Private.h&gt;
+#import &lt;AppKit/NSTextTouchBarItemController_WebKitSPI.h&gt;
+#import &lt;AppKit/NSTouchBar_Private.h&gt;
+
+#else
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSTouchBarItem : NSObject
+@end
+
+@interface NSColorPickerTouchBarItem : NSTouchBarItem
+@end
+
+@interface NSTouchBar : NSObject
+@property (readonly, copy, nullable) NSArray&lt;NSTouchBarItem *&gt; *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 @&quot;NSTouchBarWillEnterCustomization&quot;
+#define NSTouchBarDidExitCustomization @&quot;NSTouchBarDidExitCustomization&quot;
+
+NS_ASSUME_NONNULL_END
+
+#endif // USE(APPLE_INTERNAL_SDK)
+#endif // PLATFORM(MAC) &amp;&amp; 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&lt;NSString *, id&gt; *)options inSpellDocumentWithTag:(NSInteger)tag completionHandler:(void (^)(NSInteger sequenceNumber, NSArray&lt;NSTextCheckingResult *&gt; *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  &lt;bdakin@apple.com&gt;
+
+        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  &lt;wenson_hsieh@apple.com&gt;
</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&lt;WebDocumentView&gt; *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&lt;UndoStep&gt; 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) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebHTMLViewWebNSTextInputSupportAdditions.mm&gt;
</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 &lt;JavaScriptCore/APICast.h&gt;
</span><span class="cx"> #import &lt;JavaScriptCore/Exception.h&gt;
</span><span class="cx"> #import &lt;JavaScriptCore/JSValueRef.h&gt;
</span><ins>+#import &lt;WebCore/AVKitSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/AlternativeTextUIController.h&gt;
</span><span class="cx"> #import &lt;WebCore/AnimationController.h&gt;
</span><span class="cx"> #import &lt;WebCore/ApplicationCacheStorage.h&gt;
</span><span class="lines">@@ -144,6 +145,8 @@
</span><span class="cx"> #import &lt;WebCore/GeolocationController.h&gt;
</span><span class="cx"> #import &lt;WebCore/GeolocationError.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLNames.h&gt;
</span><ins>+#import &lt;WebCore/HTMLOListElement.h&gt;
+#import &lt;WebCore/HTMLUListElement.h&gt;
</ins><span class="cx"> #import &lt;WebCore/HTMLVideoElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/HistoryController.h&gt;
</span><span class="cx"> #import &lt;WebCore/HistoryItem.h&gt;
</span><span class="lines">@@ -153,11 +156,14 @@
</span><span class="cx"> #import &lt;WebCore/JSElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/JSNodeList.h&gt;
</span><span class="cx"> #import &lt;WebCore/JSNotification.h&gt;
</span><ins>+#import &lt;WebCore/LocalizedStrings.h&gt;
</ins><span class="cx"> #import &lt;WebCore/LogInitialization.h&gt;
</span><span class="cx"> #import &lt;WebCore/MIMETypeRegistry.h&gt;
</span><span class="cx"> #import &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #import &lt;WebCore/MemoryCache.h&gt;
</span><span class="cx"> #import &lt;WebCore/MemoryPressureHandler.h&gt;
</span><ins>+#import &lt;WebCore/NSSpellCheckerSPI.h&gt;
+#import &lt;WebCore/NSTouchBarSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/NSURLFileTypeMappingsSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NetworkStorageSession.h&gt;
</span><span class="cx"> #import &lt;WebCore/NodeList.h&gt;
</span><span class="lines">@@ -192,6 +198,7 @@
</span><span class="cx"> #import &lt;WebCore/WebCoreObjCExtras.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreView.h&gt;
</span><span class="cx"> #import &lt;WebCore/Widget.h&gt;
</span><ins>+#import &lt;WebCore/htmlediting.h&gt;
</ins><span class="cx"> #import &lt;WebKitLegacy/DOM.h&gt;
</span><span class="cx"> #import &lt;WebKitLegacy/DOMExtensions.h&gt;
</span><span class="cx"> #import &lt;WebKitLegacy/DOMPrivate.h&gt;
</span><span class="lines">@@ -213,6 +220,7 @@
</span><span class="cx"> #import &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> #import &lt;wtf/StdLibExtras.h&gt;
</span><ins>+#import &lt;wtf/TemporaryChange.h&gt;
</ins><span class="cx"> #import &lt;wtf/spi/darwin/dyldSPI.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -307,6 +315,12 @@
</span><span class="cx"> #import &lt;WebCore/WebPlaybackSessionModelMediaElement.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(TOUCH_BAR) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarPlaybackControlsProvider)
+SOFT_LINK_CLASS(AVKit, AVFunctionBarScrubber)
+#endif // HAVE(TOUCH_BAR) &amp;&amp; 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 &quot;-Wdeprecated-declarations&quot;
+    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 &quot;remove list&quot; 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&lt;NSColor&gt; _textColor;
+    RetainPtr&lt;WebTextListTouchBarViewController&gt; _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] &amp;&amp; [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:@&quot;ToggleBold&quot; value:@&quot;&quot;];
+    }
+
+    if ([self.textStyle isSelectedForSegment:1] != _textIsItalic) {
+        _textIsItalic = !_textIsItalic;
+        [_webView _executeCoreCommandByName:@&quot;ToggleItalic&quot; value:@&quot;&quot;];
+    }
+
+    if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined) {
+        _textIsUnderlined = !_textIsUnderlined;
+        [_webView _executeCoreCommandByName:@&quot;ToggleUnderline&quot; value:@&quot;&quot;];
+    }
+}
+
+- (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:@&quot;ForeColor&quot; 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-&gt;page-&gt;settings().setFontFallbackPrefersPictographs(flag);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if HAVE(TOUCH_BAR)
+
+- (void)showCandidates:(NSArray&lt;NSTextCheckingResult *&gt; *)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-&gt;selection().selection().isInPasswordField() &amp;&amp; self.candidateList.candidateListVisible;
+}
+
+- (void)forceRequestCandidatesForTesting
+{
+    _private-&gt;_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 () &lt;NSCandidateListTouchBarItemDelegate, NSTouchBarDelegate, NSTouchBarProvider&gt;
+@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-&gt;_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-&gt;_canCreateTouchBars) {
+        _private-&gt;_canCreateTouchBars = YES;
+        [self updateTouchBar];
+    }
+    return _private-&gt;_currentTouchBar.get();
+}
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSString *)identifier
+{
+    if (touchBar == _private-&gt;_richTextTouchBar || touchBar == _private-&gt;_plainTextTouchBar)
+        return [_private-&gt;_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 &gt;= candidates.count)
+        return;
+
+    id candidate = candidates[index];
+    ASSERT([candidate isKindOfClass:[NSTextCheckingResult class]]);
+
+    if (Frame* coreFrame = core(self._selectedOrMainFrame))
+        coreFrame-&gt;editor().client()-&gt;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-&gt;editor().client()-&gt;requestCandidatesForSelection(coreFrame-&gt;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) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewAdditions.mm&gt;
-#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) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; 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-&gt;playbackSessionInterface)
</span><span class="cx">         _private-&gt;playbackSessionInterface = WebPlaybackSessionInterfaceMac::create(*_private-&gt;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-&gt;playbackSessionModel = nullptr;
</span><span class="cx">     _private-&gt;playbackSessionInterface = nullptr;
</span><del>-    [self updateWebViewAdditions];
</del><ins>+    [self updateTouchBar];
</ins><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(MAC) &amp;&amp; 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&lt;NSString *&gt; *)_textTouchBarCustomizationAllowedIdentifiers
+{
+    return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextColorPicker, NSTouchBarItemIdentifierTextStyle, NSTouchBarItemIdentifierTextAlignment, NSTouchBarItemIdentifierTextList, NSTouchBarItemIdentifierFlexibleSpace ];
+}
+
+- (NSArray&lt;NSString *&gt; *)_plainTextTouchBarCustomizationDefaultItemIdentifiers
+{
+    return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierCandidateList ];
+}
+
+- (NSArray&lt;NSString *&gt; *)_richTextTouchBarCustomizationDefaultItemIdentifiers
+{
+    return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
+}
+
+- (void)touchBarDidExitCustomization:(NSNotification *)notification
+{
+    _private-&gt;_isCustomizingTouchBar = NO;
+    [self updateTouchBar];
+}
+
+- (void)touchBarWillEnterCustomization:(NSNotification *)notification
+{
+    _private-&gt;_isCustomizingTouchBar = YES;
+}
+
+- (void)didChangeAutomaticTextCompletion:(NSNotification *)notification
+{
+    if (_private-&gt;_richTextTouchBar)
+        [self setUpTextTouchBar:_private-&gt;_richTextTouchBar.get()];
+
+    if (_private-&gt;_plainTextTouchBar)
+        [self setUpTextTouchBar:_private-&gt;_plainTextTouchBar.get()];
+
+    [self updateTouchBar];
+}
+
+- (void)setUpTextTouchBar:(NSTouchBar *)textTouchBar
+{
+    BOOL isRichTextTouchBar = textTouchBar == _private-&gt;_richTextTouchBar;
+    [textTouchBar setDelegate:self];
+    [textTouchBar setDefaultItems:[NSMutableSet setWithObject:isRichTextTouchBar ? _private-&gt;_richTextCandidateListTouchBarItem.get() : _private-&gt;_plainTextCandidateListTouchBarItem.get()]];
+    [textTouchBar setCustomizationAllowedItemIdentifiers:[self _textTouchBarCustomizationAllowedIdentifiers]];
+
+    NSArray&lt;NSString *&gt; *defaultIdentifiers = isRichTextTouchBar ? [self _richTextTouchBarCustomizationDefaultItemIdentifiers] : [self _plainTextTouchBarCustomizationDefaultItemIdentifiers];
+    [textTouchBar setCustomizationDefaultItemIdentifiers:defaultIdentifiers];
+
+    if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[textTouchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
+        textFormatItem.groupTouchBar.customizationIdentifier = @&quot;WebTextFormatTouchBar&quot;;
+}
+
+- (BOOL)_isRichlyEditable
+{
+    NSView *documentView = self._selectedOrMainFrame.frameView.documentView;
+    if (![documentView isKindOfClass:[WebHTMLView class]])
+        return NO;
+
+    WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
+    return webHTMLView._isEditable &amp;&amp; webHTMLView._canEditRichly;
+}
+
+- (NSTouchBar *)textTouchBar
+{
+    if (self._isRichlyEditable)
+        return _private-&gt;_richTextTouchBar.get();
+
+    return _private-&gt;_plainTextTouchBar.get();
+}
+
+static NSTextAlignment nsTextAlignmentFromRenderStyle(const RenderStyle* style)
+{
+    NSTextAlignment textAlignment;
+    switch (style-&gt;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-&gt;isLeftToRightDirection() ? NSTextAlignmentLeft : NSTextAlignmentRight;
+        break;
+    case TAEND:
+        textAlignment = style-&gt;isLeftToRightDirection() ? NSTextAlignmentRight : NSTextAlignmentLeft;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+
+    return textAlignment;
+}
+
+- (void)updateTextTouchBar
+{
+    if (_private-&gt;_isDeferringTextTouchBarUpdates) {
+        _private-&gt;_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-&gt;_isUpdatingTextTouchBar)
+        return;
+
+    TemporaryChange&lt;BOOL&gt; isUpdatingTextTouchBar(_private-&gt;_isUpdatingTextTouchBar, YES);
+
+    if (!_private-&gt;_textTouchBarItemController)
+        _private-&gt;_textTouchBarItemController = adoptNS([[WebTextTouchBarItemController alloc] initWithWebView:self]);
+
+    if (!_private-&gt;_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-&gt;_startedListeningToCustomizationEvents = YES;
+    }
+
+    if (!_private-&gt;_plainTextCandidateListTouchBarItem || !_private-&gt;_richTextCandidateListTouchBarItem) {
+        _private-&gt;_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+        [_private-&gt;_plainTextCandidateListTouchBarItem setDelegate:self];
+        _private-&gt;_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+        [_private-&gt;_richTextCandidateListTouchBarItem setDelegate:self];
+        coreFrame-&gt;editor().client()-&gt;requestCandidatesForSelection(coreFrame-&gt;selection().selection());
+    }
+
+    if (!_private-&gt;_richTextTouchBar) {
+        _private-&gt;_richTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+        [self setUpTextTouchBar:_private-&gt;_richTextTouchBar.get()];
+        [_private-&gt;_richTextTouchBar setCustomizationIdentifier:@&quot;WebRichTextTouchBar&quot;];
+    }
+
+    if (!_private-&gt;_plainTextTouchBar) {
+        _private-&gt;_plainTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+        [self setUpTextTouchBar:_private-&gt;_plainTextTouchBar.get()];
+        [_private-&gt;_plainTextTouchBar setCustomizationIdentifier:@&quot;WebPlainTextTouchBar&quot;];
+    }
+
+    if ([NSSpellChecker isAutomaticTextCompletionEnabled] &amp;&amp; !_private-&gt;_isCustomizingTouchBar) {
+        BOOL shouldShowCandidateList = !coreFrame-&gt;selection().selection().isRange() || coreFrame-&gt;editor().ignoreCompositionSelectionChange();
+        [self.candidateList updateWithInsertionPointVisibility:shouldShowCandidateList];
+    }
+
+    if (coreFrame-&gt;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-&gt;_emptyCandidatesArray)
+            _private-&gt;_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
+        [self.candidateList setCandidates:_private-&gt;_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
+    }
+
+    NSTouchBar *textTouchBar = self.textTouchBar;
+    NSArray&lt;NSString *&gt; *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&amp; selection = coreFrame-&gt;selection().selection();
+        if (!selection.isNone()) {
+            Node* nodeToRemove;
+            if (auto* style = Editor::styleForSelectionStart(coreFrame, nodeToRemove)) {
+                [_private-&gt;_textTouchBarItemController setTextIsBold:(style-&gt;fontCascade().weight() &gt;= FontWeightBold)];
+                [_private-&gt;_textTouchBarItemController setTextIsItalic:(style-&gt;fontCascade().italic() == FontItalicOn)];
+
+                RefPtr&lt;EditingStyle&gt; typingStyle = coreFrame-&gt;selection().typingStyle();
+                if (typingStyle &amp;&amp; typingStyle-&gt;style()) {
+                    String value = typingStyle-&gt;style()-&gt;getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
+                    [_private-&gt;_textTouchBarItemController setTextIsUnderlined:value.contains(&quot;underline&quot;)];
+                } else
+                    [_private-&gt;_textTouchBarItemController setTextIsUnderlined:(style-&gt;textDecorationsInEffect() &amp; TextDecorationUnderline)];
+
+                if (style-&gt;visitedDependentColor(CSSPropertyColor).isValid())
+                    [_private-&gt;_textTouchBarItemController setTextColor:nsColor(style-&gt;visitedDependentColor(CSSPropertyColor))];
+
+                [_private-&gt;_textTouchBarItemController setCurrentTextAlignment:nsTextAlignmentFromRenderStyle(style)];
+
+                HTMLElement* enclosingListElement = enclosingList(selection.start().deprecatedNode());
+                if (enclosingListElement) {
+                    if (is&lt;HTMLUListElement&gt;(*enclosingListElement))
+                        [[_private-&gt;_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::Unordered];
+                    else if (is&lt;HTMLOListElement&gt;(*enclosingListElement))
+                        [[_private-&gt;_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::Ordered];
+                    else
+                        ASSERT_NOT_REACHED();
+                } else
+                    [[_private-&gt;_textTouchBarItemController webTextListTouchBarViewController] setCurrentListType:WebListType::None];
+
+                if (nodeToRemove)
+                    nodeToRemove-&gt;remove();
+            }
+        }
+        BOOL isShowingCandidateListItem = [itemIdentifiers containsObject:NSTouchBarItemIdentifierCandidateList] &amp;&amp; [NSSpellChecker isAutomaticTextCompletionEnabled];
+        [_private-&gt;_textTouchBarItemController setUsesNarrowTextStyleItem:isShowingCombinedTextFormatItem &amp;&amp; isShowingCandidateListItem];
+    }
+}
+
+- (void)updateMediaTouchBar
+{
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+    if (!_private-&gt;mediaTouchBarProvider)
+        _private-&gt;mediaTouchBarProvider = adoptNS([allocAVFunctionBarPlaybackControlsProviderInstance() init]);
+
+    if (![_private-&gt;mediaTouchBarProvider playbackControlsController]) {
+        ASSERT(_private-&gt;playbackSessionInterface);
+        WebPlaybackControlsManager *manager = _private-&gt;playbackSessionInterface-&gt;playBackControlsManager();
+        [_private-&gt;mediaTouchBarProvider setPlaybackControlsController:(id &lt;AVFunctionBarPlaybackControlsControlling&gt;)manager];
+        [_private-&gt;mediaPlaybackControlsView setPlaybackControlsController:(id &lt;AVFunctionBarPlaybackControlsControlling&gt;)manager];
+    }
+#endif
+}
+
+- (void)updateTouchBar
+{
+    if (!_private-&gt;_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-&gt;mediaTouchBarProvider respondsToSelector:@selector(touchBar)] ? [(id)_private-&gt;mediaTouchBarProvider touchBar] : [(id)_private-&gt;mediaTouchBarProvider touchBar];
+        } else if ([_private-&gt;mediaTouchBarProvider playbackControlsController]) {
+            [_private-&gt;mediaTouchBarProvider setPlaybackControlsController:nil];
+            [_private-&gt;mediaPlaybackControlsView setPlaybackControlsController:nil];
+        }
+#endif
+    }
+
+    if (touchBar == _private-&gt;_currentTouchBar)
+        return;
+
+    _private-&gt;_currentTouchBar = touchBar;
+    [self willChangeValueForKey:@&quot;touchBar&quot;];
+    [self setTouchBar:_private-&gt;_currentTouchBar.get()];
+    [self didChangeValueForKey:@&quot;touchBar&quot;];
+}
+
+- (void)prepareForMouseDown
+{
+    _private-&gt;_needsDeferredTextTouchBarUpdate = NO;
+    _private-&gt;_isDeferringTextTouchBarUpdates = YES;
+}
+
+- (void)prepareForMouseUp
+{
+    if (!_private-&gt;_isDeferringTextTouchBarUpdates)
+        return;
+
+    _private-&gt;_isDeferringTextTouchBarUpdates = NO;
+    if (_private-&gt;_needsDeferredTextTouchBarUpdate) {
+        // Only trigger another update if we attempted and bailed from an update during the deferral.
+        [self updateTouchBar];
+    }
+}
+
+- (NSCandidateListTouchBarItem *)candidateList
+{
+    return self._isRichlyEditable ? _private-&gt;_richTextCandidateListTouchBarItem.get() : _private-&gt;_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) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewDataAdditionsDeclarations.h&gt;
</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 &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewDataAdditions.h&gt;
-#endif
</del><ins>+#if HAVE(TOUCH_BAR)
+    RetainPtr&lt;NSTouchBar&gt; _currentTouchBar;
+    RetainPtr&lt;NSTouchBar&gt; _plainTextTouchBar;
+    RetainPtr&lt;NSTouchBar&gt; _richTextTouchBar;
+    RetainPtr&lt;WebTextTouchBarItemController&gt; _textTouchBarItemController;
+    RetainPtr&lt;NSCandidateListTouchBarItem&gt; _richTextCandidateListTouchBarItem;
+    RetainPtr&lt;NSCandidateListTouchBarItem&gt; _plainTextCandidateListTouchBarItem;
+    RetainPtr&lt;NSArray&gt; _emptyCandidatesArray;
+    RetainPtr&lt;AVFunctionBarPlaybackControlsProvider&gt; mediaTouchBarProvider;
+    RetainPtr&lt;AVFunctionBarScrubber&gt; 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&lt;WebCore::TextIndicatorWindow&gt; textIndicatorWindow;
</span><span class="cx">     BOOL hasInitializedLookupObserver;
</span><span class="cx">     RetainPtr&lt;WebWindowVisibilityObserver&gt; 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 &quot;C&quot; {
</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  &lt;bdakin@apple.com&gt;
+
+        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  &lt;cdumez@apple.com&gt;
</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 &lt;WebKit/WKView.h&gt;
</span><span class="cx"> #import &lt;WebKit/_WKOverlayScrollbarStyle.h&gt;
</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 () &lt;WebViewImplDelegate, NSTextInputClient&gt;
</span><span class="cx"> @end
</span><del>-#endif
</del><span class="cx"> 
</span><ins>+#if HAVE(TOUCH_BAR)
+@interface WKWebView () &lt;NSTouchBarProvider&gt;
+@end
+#endif // HAVE(TOUCH_BAR)
+#endif // PLATFORM(MAC)
+
</ins><span class="cx"> static HashMap&lt;WebKit::WebPageProxy*, WKWebView *&gt;&amp; pageToViewMap()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;HashMap&lt;WebKit::WebPageProxy*, WKWebView *&gt;&gt; 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-&gt;makeTouchBar();
+}
+
+- (NSCandidateListTouchBarItem *)candidateListTouchBarItem
+{
+    return _impl-&gt;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-&gt;setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)_wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+    return _impl-&gt;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-&gt;setClientWantsMediaPlaybackControlsView(wantsMediaPlaybackControlsView);
+#endif
+}
+
+- (AVFunctionBarScrubber *)_mediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+    return _impl-&gt;clientWantsMediaPlaybackControlsView() ? _impl-&gt;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 () &lt;WebViewImplDelegate&gt;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#if HAVE(TOUCH_BAR)
+@interface WKView () &lt;NSTouchBarProvider&gt;
+@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-&gt;_impl-&gt;makeTouchBar();
+}
+
+- (NSCandidateListTouchBarItem *)candidateListTouchBarItem
+{
+    return _data-&gt;_impl-&gt;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-&gt;_impl-&gt;setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-@end
</del><ins>+- (BOOL)_wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+    return _data-&gt;_impl-&gt;clientWantsMediaPlaybackControlsView();
+#else
+    return NO;
+#endif
+}
</ins><span class="cx"> 
</span><del>-#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WKViewAdditions.mm&gt;
</del><ins>+- (void)_setWantsMediaPlaybackControlsView:(BOOL)wantsMediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+    _data-&gt;_impl-&gt;setClientWantsMediaPlaybackControlsView(wantsMediaPlaybackControlsView);
</ins><span class="cx"> #endif
</span><ins>+}
</ins><span class="cx"> 
</span><ins>+- (AVFunctionBarScrubber *)_mediaPlaybackControlsView
+{
+#if HAVE(TOUCH_BAR)
+    return _data-&gt;_impl-&gt;clientWantsMediaPlaybackControlsView() ? _data-&gt;_impl-&gt;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) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
-#import &lt;WebKitAdditions/WebViewImplAdditionsDeclarations.h&gt;
-#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 &gt;= 101200 
</span><span class="cx">     void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
</span><del>-#if USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewImplAdditions.h&gt;
</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&lt;NSTouchBar&gt; m_currentTouchBar;
+    RetainPtr&lt;NSTouchBar&gt; m_richTextTouchBar;
+    RetainPtr&lt;NSTouchBar&gt; m_plainTextTouchBar;
+    RetainPtr&lt;WKTextTouchBarItemController&gt; m_textTouchBarItemController;
+    RetainPtr&lt;NSCandidateListTouchBarItem&gt; m_richTextCandidateListTouchBarItem;
+    RetainPtr&lt;NSCandidateListTouchBarItem&gt; m_plainTextCandidateListTouchBarItem;
+    RetainPtr&lt;NSArray&gt; m_emptyCandidatesArray;
+    RetainPtr&lt;WebPlaybackControlsManager&gt; m_playbackControlsManager;
+    RetainPtr&lt;NSCustomTouchBarItem&gt; m_exitFullScreenButton;
+
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+    RetainPtr&lt;AVFunctionBarPlaybackControlsProvider&gt; m_mediaTouchBarProvider;
+    RetainPtr&lt;AVFunctionBarScrubber&gt; m_mediaPlaybackControlsView;
+#endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+#endif // HAVE(TOUCH_BAR)
+
</ins><span class="cx">     WeakPtr&lt;WebViewImpl&gt; 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 &quot;WebEventFactory.h&quot;
</span><span class="cx"> #import &quot;WebInspectorProxy.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionManagerProxy.h&quot;
</ins><span class="cx"> #import &quot;WebProcessPool.h&quot;
</span><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><span class="cx"> #import &quot;_WKRemoteObjectRegistryInternal.h&quot;
</span><span class="cx"> #import &quot;_WKThumbnailViewInternal.h&quot;
</span><span class="cx"> #import &lt;HIToolbox/CarbonEventsCore.h&gt;
</span><ins>+#import &lt;WebCore/AVKitSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/AXObjectCache.h&gt;
</span><span class="cx"> #import &lt;WebCore/ActivityState.h&gt;
</span><span class="cx"> #import &lt;WebCore/ColorMac.h&gt;
</span><span class="lines">@@ -80,6 +82,7 @@
</span><span class="cx"> #import &lt;WebCore/NSImmediateActionGestureRecognizerSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSSpellCheckerSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/NSTextFinderSPI.h&gt;
</span><ins>+#import &lt;WebCore/NSTouchBarSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/NSWindowSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/PlatformEventFactoryMac.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><span class="lines">@@ -90,14 +93,20 @@
</span><span class="cx"> #import &lt;WebCore/WebCoreFullScreenPlaceholderView.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreFullScreenWindow.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreNSStringExtras.h&gt;
</span><ins>+#import &lt;WebCore/WebPlaybackControlsManager.h&gt;
</ins><span class="cx"> #import &lt;WebKitSystemInterface.h&gt;
</span><span class="cx"> #import &lt;sys/stat.h&gt;
</span><span class="cx"> #import &lt;wtf/NeverDestroyed.h&gt;
</span><ins>+#import &lt;wtf/TemporaryChange.h&gt;
</ins><span class="cx"> 
</span><del>-#if USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewImplIncludes.h&gt;
-#endif
</del><ins>+#if HAVE(TOUCH_BAR) &amp;&amp; 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 = @&quot;WKMediaExitFullScreenItem&quot;;
+#endif // HAVE(TOUCH_BAR) &amp;&amp; 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 &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebViewImplAdditions.mm&gt;
-#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 &quot;-Wdeprecated-declarations&quot;
+    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 &quot;remove list&quot; 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-&gt;page().executeEditCommand(@&quot;InsertOrderedList&quot;, @&quot;&quot;);
+        else if (_currentListType == UnorderedList)
+            _webViewImpl-&gt;page().executeEditCommand(@&quot;InsertUnorderedList&quot;, @&quot;&quot;);
+        break;
+    case unorderedListSegment:
+        _webViewImpl-&gt;page().executeEditCommand(@&quot;InsertUnorderedList&quot;, @&quot;&quot;);
+        break;
+    case orderedListSegment:
+        _webViewImpl-&gt;page().executeEditCommand(@&quot;InsertOrderedList&quot;, @&quot;&quot;);
+        break;
+    }
+
+    _webViewImpl-&gt;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 &lt;NSCandidateListTouchBarItemDelegate, NSTouchBarDelegate&gt; {
+@private
+    BOOL _textIsBold;
+    BOOL _textIsItalic;
+    BOOL _textIsUnderlined;
+    NSTextAlignment _currentTextAlignment;
+    RetainPtr&lt;NSColor&gt; _textColor;
+    RetainPtr&lt;WKTextListTouchBarViewController&gt; _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] &amp;&amp; [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 &gt;= candidates.count)
+        return;
+
+    NSTextCheckingResult *candidate = candidates[index];
+    ASSERT([candidate isKindOfClass:[NSTextCheckingResult class]]);
+
+    _webViewImpl-&gt;handleAcceptedCandidate(candidate);
+}
+
+- (void)candidateListTouchBarItem:(NSCandidateListTouchBarItem *)anItem changedCandidateListVisibility:(BOOL)isVisible
+{
+    if (!_webViewImpl)
+        return;
+
+    if (isVisible)
+        _webViewImpl-&gt;requestCandidatesForSelectionIfNeeded();
+
+    _webViewImpl-&gt;updateTouchBar();
+}
+
+#pragma mark NSNotificationCenter observers
+
+- (void)touchBarDidExitCustomization:(NSNotification *)notification
+{
+    if (!_webViewImpl)
+        return;
+
+    _webViewImpl-&gt;setIsCustomizingTouchBar(false);
+    _webViewImpl-&gt;updateTouchBar();
+}
+
+- (void)touchBarWillEnterCustomization:(NSNotification *)notification
+{
+    if (!_webViewImpl)
+        return;
+
+    _webViewImpl-&gt;setIsCustomizingTouchBar(true);
+}
+
+- (void)didChangeAutomaticTextCompletion:(NSNotification *)notification
+{
+    if (!_webViewImpl)
+        return;
+
+    _webViewImpl-&gt;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-&gt;page().executeEditCommand(@&quot;ToggleBold&quot;, @&quot;&quot;);
+    }
+
+    if ([self.textStyle isSelectedForSegment:1] != _textIsItalic) {
+        _textIsItalic = !_textIsItalic;
+        _webViewImpl-&gt;page().executeEditCommand(&quot;ToggleItalic&quot;, @&quot;&quot;);
+    }
+
+    if ([self.textStyle isSelectedForSegment:2] != _textIsUnderlined) {
+        _textIsUnderlined = !_textIsUnderlined;
+        _webViewImpl-&gt;page().executeEditCommand(&quot;ToggleUnderline&quot;, @&quot;&quot;);
+    }
+}
+
+- (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-&gt;page().executeEditCommand(&quot;AlignLeft&quot;, @&quot;&quot;);
+        break;
+    case NSTextAlignmentRight:
+        _currentTextAlignment = NSTextAlignmentRight;
+        _webViewImpl-&gt;page().executeEditCommand(&quot;AlignRight&quot;, @&quot;&quot;);
+        break;
+    case NSTextAlignmentCenter:
+        _currentTextAlignment = NSTextAlignmentCenter;
+        _webViewImpl-&gt;page().executeEditCommand(&quot;AlignCenter&quot;, @&quot;&quot;);
+        break;
+    case NSTextAlignmentJustified:
+        _currentTextAlignment = NSTextAlignmentJustified;
+        _webViewImpl-&gt;page().executeEditCommand(&quot;AlignJustified&quot;, @&quot;&quot;);
+        break;
+    default:
+        break;
+    }
+
+    _webViewImpl-&gt;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-&gt;page().executeEditCommand(&quot;ForeColor&quot;, 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-&gt;hasHadSelectionChangesFromUserInteraction() : true;
+    if (m_page-&gt;editorState().isContentEditable &amp;&amp; !m_page-&gt;needsHiddenContentEditableQuirk()) {
+        updateTextTouchBar();
+        if (userActionRequirementsHaveBeenMet)
+            touchBar = textTouchBar();
+    }
+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+    else if (m_page-&gt;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)] &amp;&amp; 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 &amp;&amp; touchBar != textTouchBar())
+        return;
+
+    m_currentTouchBar = touchBar;
+    [m_view willChangeValueForKey:@&quot;touchBar&quot;];
+    [m_view setTouchBar:m_currentTouchBar.get()];
+    [m_view didChangeValueForKey:@&quot;touchBar&quot;];
+}
+
+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-&gt;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&lt;NSString *&gt; *textTouchBarCustomizationAllowedIdentifiers()
+{
+    return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextColorPicker, NSTouchBarItemIdentifierTextStyle, NSTouchBarItemIdentifierTextAlignment, NSTouchBarItemIdentifierTextList, NSTouchBarItemIdentifierFlexibleSpace ];
+}
+
+static NSArray&lt;NSString *&gt; *plainTextTouchBarCustomizationDefaultItemIdentifiers()
+{
+    return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierCandidateList ];
+}
+
+static NSArray&lt;NSString *&gt; *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 = @&quot;WKTextFormatTouchBar&quot;;
+}
+
+bool WebViewImpl::isRichlyEditable() const
+{
+    return m_page-&gt;editorState().isContentRichlyEditable &amp;&amp; !m_page-&gt;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-&gt;editorState().isContentEditable)
+        return;
+
+    if (m_isUpdatingTextTouchBar)
+        return;
+
+    TemporaryChange&lt;bool&gt; 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:@&quot;WKRichTextTouchBar&quot;];
+    }
+
+    if (!m_plainTextTouchBar) {
+        m_plainTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+        setUpTextTouchBar(m_plainTextTouchBar.get());
+        [m_plainTextTouchBar setCustomizationIdentifier:@&quot;WKPlainTextTouchBar&quot;];
+    }
+
+    if ([NSSpellChecker isAutomaticTextCompletionEnabled] &amp;&amp; !m_isCustomizingTouchBar) {
+        BOOL showCandidatesList = !m_page-&gt;editorState().selectionIsRange || m_isHandlingAcceptedCandidate;
+        [candidateListTouchBarItem() updateWithInsertionPointVisibility:showCandidatesList];
+        [m_view _didUpdateCandidateListVisibility:showCandidatesList];
+    }
+
+    if (m_page-&gt;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-&gt;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&amp; editorState = m_page-&gt;editorState();
+        if (!editorState.isMissingPostLayoutData) {
+            [m_textTouchBarItemController setTextIsBold:(bool)(m_page-&gt;editorState().postLayoutData().typingAttributes &amp; AttributeBold)];
+            [m_textTouchBarItemController setTextIsItalic:(bool)(m_page-&gt;editorState().postLayoutData().typingAttributes &amp; AttributeItalics)];
+            [m_textTouchBarItemController setTextIsUnderlined:(bool)(m_page-&gt;editorState().postLayoutData().typingAttributes &amp; AttributeUnderline)];
+            [m_textTouchBarItemController setTextColor:nsColor(editorState.postLayoutData().textColor)];
+            [[m_textTouchBarItemController textListTouchBarViewController] setCurrentListType:(ListType)m_page-&gt;editorState().postLayoutData().enclosingListType];
+            [m_textTouchBarItemController setCurrentTextAlignment:nsTextAlignmentFromTextAlignment((TextAlignment)editorState.postLayoutData().textAlignment)];
+        }
+        BOOL isShowingCandidateListItem = [textTouchBar.itemIdentifiers containsObject:NSTouchBarItemIdentifierCandidateList] &amp;&amp; [NSSpellChecker isAutomaticTextReplacementEnabled];
+        [m_textTouchBarItemController setUsesNarrowTextStyleItem:isShowingCombinedTextFormatItem &amp;&amp; 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-&gt;playbackSessionManager()-&gt;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() &amp;&amp; [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 ? @&quot;&quot; : @&quot;Exit&quot; 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 &amp;&amp; m_view == m_view.window.firstResponder &amp;&amp; [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-&gt;editorState().isInPasswordField &amp;&amp; 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 &gt;= 101200 &amp;&amp; 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-&gt;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 &gt;= 101200
-    updateWebViewImplAdditions();
</del><ins>+#if HAVE(TOUCH_BAR)
+    updateTouchBar();
</ins><span class="cx">     if (!m_page-&gt;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 &gt;= 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  &lt;bdakin@apple.com&gt;
+
+        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  &lt;gyuyoung.kim@webkit.org&gt;
</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:@&quot;Debug&quot;]];
</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>