<!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>[209626] trunk/Source</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/209626">209626</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-12-09 14:00:28 -0800 (Fri, 09 Dec 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Password fields should not show the emoji button in TouchBar
https://bugs.webkit.org/show_bug.cgi?id=165673
-and corresponding-
rdar://problem/29235739
Reviewed by Wenson Hsieh.
Source/WebKit/mac:
This patch adds a new ivar for the password touch bar and password
candidateListTouchBarItem. Since this TouchBar will actually have a different set
of identifiers than the plain text TouchBar, it should just have its own variable.
The candidate list should be the only item for passwords.
* WebView/WebView.mm:
(-[WebView _passwordTextTouchBarDefaultItemIdentifiers]):
Account for _passwordTextTouchBar.
(-[WebView didChangeAutomaticTextCompletion:]):
(-[WebView setUpTextTouchBar:]):
(-[WebView textTouchBar]):
The empty candidates array is not needed. We can just set @[ ] as the candidates
for the _passwordTextCandidateListTouchBarItem. Safe guards already exist in the
other parts of the code to prevent us from requesting or setting other candidates
when in a password field.
(-[WebView updateTextTouchBar]):
Account for _passwordTextTouchBar.
(-[WebView candidateList]):
* WebView/WebViewData.h:
Source/WebKit2:
This patch adds a new member variable for the password touch bar and password
candidateListTouchBarItem. Since this TouchBar will actually have a different set
of identifiers than the plain text TouchBar, it should just have its own variable.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
Return m_passwordTextCandidateListTouchBarItem when appropriate.
(WebKit::WebViewImpl::candidateListTouchBarItem):
The candidate list should be the only item for passwords.
(WebKit::passwordTextTouchBarDefaultItemIdentifiers):
Account for m_passwordTextTouchBar.
(WebKit::WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers):
(WebKit::WebViewImpl::setUpTextTouchBar):
(WebKit::WebViewImpl::textTouchBar):
The empty candidates array is not needed. We can just set @[ ] as the candidates
for the m_passwordTextCandidateListTouchBarItem. Safe guards already exist in the
other parts of the code to prevent us from requesting or setting other candidates
when in a password field.
(WebKit::WebViewImpl::updateTextTouchBar):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-12-09 Beth Dakin <bdakin@apple.com>
+
+ Password fields should not show the emoji button in TouchBar
+ https://bugs.webkit.org/show_bug.cgi?id=165673
+ -and corresponding-
+ rdar://problem/29235739
+
+ Reviewed by Wenson Hsieh.
+
+ This patch adds a new ivar for the password touch bar and password
+ candidateListTouchBarItem. Since this TouchBar will actually have a different set
+ of identifiers than the plain text TouchBar, it should just have its own variable.
+
+ The candidate list should be the only item for passwords.
+ * WebView/WebView.mm:
+ (-[WebView _passwordTextTouchBarDefaultItemIdentifiers]):
+
+ Account for _passwordTextTouchBar.
+ (-[WebView didChangeAutomaticTextCompletion:]):
+ (-[WebView setUpTextTouchBar:]):
+ (-[WebView textTouchBar]):
+
+ The empty candidates array is not needed. We can just set @[ ] as the candidates
+ for the _passwordTextCandidateListTouchBarItem. Safe guards already exist in the
+ other parts of the code to prevent us from requesting or setting other candidates
+ when in a password field.
+ (-[WebView updateTextTouchBar]):
+
+ Account for _passwordTextTouchBar.
+ (-[WebView candidateList]):
+ * WebView/WebViewData.h:
+
</ins><span class="cx"> 2016-12-08 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> Enable SharedArrayBuffer, remove the flag
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -9362,6 +9362,11 @@
</span><span class="cx"> return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (NSArray<NSString *> *)_passwordTextTouchBarDefaultItemIdentifiers
+{
+ return @[ NSTouchBarItemIdentifierCandidateList ];
+}
+
</ins><span class="cx"> - (void)touchBarDidExitCustomization:(NSNotification *)notification
</span><span class="cx"> {
</span><span class="cx"> _private->_isCustomizingTouchBar = NO;
</span><span class="lines">@@ -9381,19 +9386,36 @@
</span><span class="cx"> if (_private->_plainTextTouchBar)
</span><span class="cx"> [self setUpTextTouchBar:_private->_plainTextTouchBar.get()];
</span><span class="cx">
</span><ins>+ if (_private->_passwordTextTouchBar)
+ [self setUpTextTouchBar:_private->_passwordTextTouchBar.get()];
+
</ins><span class="cx"> [self updateTouchBar];
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setUpTextTouchBar:(NSTouchBar *)textTouchBar
</span><span class="cx"> {
</span><del>- BOOL isRichTextTouchBar = textTouchBar == _private->_richTextTouchBar;
</del><ins>+ NSSet<NSTouchBarItem *> *templateItems = nil;
+ NSArray<NSTouchBarItemIdentifier> *defaultItemIdentifiers = nil;
+ NSArray<NSTouchBarItemIdentifier> *customizationAllowedItemIdentifiers = nil;
+
+ if (textTouchBar == _private->_passwordTextTouchBar) {
+ templateItems = [NSMutableSet setWithObject:_private->_passwordTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = [self _passwordTextTouchBarDefaultItemIdentifiers];
+ } else if (textTouchBar == _private->_richTextTouchBar) {
+ templateItems = [NSMutableSet setWithObject:_private->_richTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = [self _richTextTouchBarDefaultItemIdentifiers];
+ customizationAllowedItemIdentifiers = [self _textTouchBarCustomizationAllowedIdentifiers];
+ } else if (textTouchBar == _private->_plainTextTouchBar) {
+ templateItems = [NSMutableSet setWithObject:_private->_plainTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = [self _plainTextTouchBarDefaultItemIdentifiers];
+ customizationAllowedItemIdentifiers = [self _textTouchBarCustomizationAllowedIdentifiers];
+ }
+
</ins><span class="cx"> [textTouchBar setDelegate:self];
</span><del>- [textTouchBar setTemplateItems:[NSMutableSet setWithObject:isRichTextTouchBar ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get()]];
- [textTouchBar setCustomizationAllowedItemIdentifiers:[self _textTouchBarCustomizationAllowedIdentifiers]];
</del><ins>+ [textTouchBar setTemplateItems:templateItems];
+ [textTouchBar setDefaultItemIdentifiers:defaultItemIdentifiers];
+ [textTouchBar setCustomizationAllowedItemIdentifiers:customizationAllowedItemIdentifiers];
</ins><span class="cx">
</span><del>- NSArray<NSString *> *defaultIdentifiers = isRichTextTouchBar ? [self _richTextTouchBarDefaultItemIdentifiers] : [self _plainTextTouchBarDefaultItemIdentifiers];
- [textTouchBar setDefaultItemIdentifiers:defaultIdentifiers];
-
</del><span class="cx"> if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[textTouchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
</span><span class="cx"> textFormatItem.groupTouchBar.customizationIdentifier = @"WebTextFormatTouchBar";
</span><span class="cx"> }
</span><span class="lines">@@ -9410,10 +9432,14 @@
</span><span class="cx">
</span><span class="cx"> - (NSTouchBar *)textTouchBar
</span><span class="cx"> {
</span><del>- if (self._isRichlyEditable)
- return _private->_richTextTouchBar.get();
</del><ins>+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return nil;
</ins><span class="cx">
</span><del>- return _private->_plainTextTouchBar.get();
</del><ins>+ if (coreFrame->selection().selection().isInPasswordField())
+ return _private->_passwordTextTouchBar.get();
+
+ return self._isRichlyEditable ? _private->_richTextTouchBar.get() : _private->_plainTextTouchBar.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static NSTextAlignment nsTextAlignmentFromRenderStyle(const RenderStyle* style)
</span><span class="lines">@@ -9482,11 +9508,14 @@
</span><span class="cx"> _private->_startedListeningToCustomizationEvents = YES;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!_private->_plainTextCandidateListTouchBarItem || !_private->_richTextCandidateListTouchBarItem) {
</del><ins>+ if (!_private->_plainTextCandidateListTouchBarItem || !_private->_richTextCandidateListTouchBarItem || !_private->_passwordTextCandidateListTouchBarItem) {
</ins><span class="cx"> _private->_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
</span><span class="cx"> [_private->_plainTextCandidateListTouchBarItem setDelegate:self];
</span><span class="cx"> _private->_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
</span><span class="cx"> [_private->_richTextCandidateListTouchBarItem setDelegate:self];
</span><ins>+ _private->_passwordTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [_private->_passwordTextCandidateListTouchBarItem setDelegate:self];
+
</ins><span class="cx"> coreFrame->editor().client()->requestCandidatesForSelection(coreFrame->selection().selection());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -9510,9 +9539,11 @@
</span><span class="cx"> if (coreFrame->selection().selection().isInPasswordField()) {
</span><span class="cx"> // We don't request candidates for password fields. If the user was previously in a non-password field, then the
</span><span class="cx"> // old candidates will still show by default, so we clear them here by setting an empty array of candidates.
</span><del>- if (!_private->_emptyCandidatesArray)
- _private->_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
- [self.candidateList setCandidates:_private->_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
</del><ins>+ if (!_private->_passwordTextTouchBar) {
+ _private->_passwordTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ [self setUpTextTouchBar:_private->_passwordTextTouchBar.get()];
+ }
+ [_private->_passwordTextCandidateListTouchBarItem setCandidates:@[ ] forSelectedRange:NSMakeRange(0, 0) inString:nil];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NSTouchBar *textTouchBar = self.textTouchBar;
</span><span class="lines">@@ -9634,6 +9665,13 @@
</span><span class="cx">
</span><span class="cx"> - (NSCandidateListTouchBarItem *)candidateList
</span><span class="cx"> {
</span><ins>+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return nil;
+
+ if (coreFrame->selection().selection().isInPasswordField())
+ return _private->_passwordTextCandidateListTouchBarItem.get();
+
</ins><span class="cx"> return self._isRichlyEditable ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get();
</span><span class="cx"> }
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewData.h        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -185,10 +185,11 @@
</span><span class="cx"> RetainPtr<NSTouchBar> _currentTouchBar;
</span><span class="cx"> RetainPtr<NSTouchBar> _plainTextTouchBar;
</span><span class="cx"> RetainPtr<NSTouchBar> _richTextTouchBar;
</span><ins>+ RetainPtr<NSTouchBar> _passwordTextTouchBar;
</ins><span class="cx"> RetainPtr<WebTextTouchBarItemController> _textTouchBarItemController;
</span><span class="cx"> RetainPtr<NSCandidateListTouchBarItem> _richTextCandidateListTouchBarItem;
</span><span class="cx"> RetainPtr<NSCandidateListTouchBarItem> _plainTextCandidateListTouchBarItem;
</span><del>- RetainPtr<NSArray> _emptyCandidatesArray;
</del><ins>+ RetainPtr<NSCandidateListTouchBarItem> _passwordTextCandidateListTouchBarItem;
</ins><span class="cx"> RetainPtr<AVFunctionBarPlaybackControlsProvider> mediaTouchBarProvider;
</span><span class="cx"> RetainPtr<AVFunctionBarScrubber> mediaPlaybackControlsView;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit2/ChangeLog        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2016-12-09 Beth Dakin <bdakin@apple.com>
+
+ Password fields should not show the emoji button in TouchBar
+ https://bugs.webkit.org/show_bug.cgi?id=165673
+ -and corresponding-
+ rdar://problem/29235739
+
+ Reviewed by Wenson Hsieh.
+
+ This patch adds a new member variable for the password touch bar and password
+ candidateListTouchBarItem. Since this TouchBar will actually have a different set
+ of identifiers than the plain text TouchBar, it should just have its own variable.
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+
+ Return m_passwordTextCandidateListTouchBarItem when appropriate.
+ (WebKit::WebViewImpl::candidateListTouchBarItem):
+
+ The candidate list should be the only item for passwords.
+ (WebKit::passwordTextTouchBarDefaultItemIdentifiers):
+
+ Account for m_passwordTextTouchBar.
+ (WebKit::WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers):
+ (WebKit::WebViewImpl::setUpTextTouchBar):
+ (WebKit::WebViewImpl::textTouchBar):
+
+ The empty candidates array is not needed. We can just set @[ ] as the candidates
+ for the m_passwordTextCandidateListTouchBarItem. Safe guards already exist in the
+ other parts of the code to prevent us from requesting or setting other candidates
+ when in a password field.
+ (WebKit::WebViewImpl::updateTextTouchBar):
+
</ins><span class="cx"> 2016-12-09 Keith Rollin <krollin@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix string specification in print format
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -541,10 +541,11 @@
</span><span class="cx"> RetainPtr<NSTouchBar> m_currentTouchBar;
</span><span class="cx"> RetainPtr<NSTouchBar> m_richTextTouchBar;
</span><span class="cx"> RetainPtr<NSTouchBar> m_plainTextTouchBar;
</span><ins>+ RetainPtr<NSTouchBar> m_passwordTextTouchBar;
</ins><span class="cx"> RetainPtr<WKTextTouchBarItemController> m_textTouchBarItemController;
</span><span class="cx"> RetainPtr<NSCandidateListTouchBarItem> m_richTextCandidateListTouchBarItem;
</span><span class="cx"> RetainPtr<NSCandidateListTouchBarItem> m_plainTextCandidateListTouchBarItem;
</span><del>- RetainPtr<NSArray> m_emptyCandidatesArray;
</del><ins>+ RetainPtr<NSCandidateListTouchBarItem> m_passwordTextCandidateListTouchBarItem;
</ins><span class="cx"> RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
</span><span class="cx"> RetainPtr<NSCustomTouchBarItem> m_exitFullScreenButton;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (209625 => 209626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-12-09 21:59:21 UTC (rev 209625)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-12-09 22:00:28 UTC (rev 209626)
</span><span class="lines">@@ -896,6 +896,8 @@
</span><span class="cx">
</span><span class="cx"> NSCandidateListTouchBarItem *WebViewImpl::candidateListTouchBarItem() const
</span><span class="cx"> {
</span><ins>+ if (m_page->editorState().isInPasswordField)
+ return m_passwordTextCandidateListTouchBarItem.get();
</ins><span class="cx"> return isRichlyEditable() ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -956,6 +958,11 @@
</span><span class="cx"> return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static NSArray<NSString *> *passwordTextTouchBarDefaultItemIdentifiers()
+{
+ return @[ NSTouchBarItemIdentifierCandidateList ];
+}
+
</ins><span class="cx"> void WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers()
</span><span class="cx"> {
</span><span class="cx"> if (m_richTextTouchBar)
</span><span class="lines">@@ -964,16 +971,35 @@
</span><span class="cx"> if (m_plainTextTouchBar)
</span><span class="cx"> setUpTextTouchBar(m_plainTextTouchBar.get());
</span><span class="cx">
</span><ins>+ if (m_passwordTextTouchBar)
+ setUpTextTouchBar(m_passwordTextTouchBar.get());
+
</ins><span class="cx"> updateTouchBar();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebViewImpl::setUpTextTouchBar(NSTouchBar *touchBar)
</span><span class="cx"> {
</span><del>- bool isRichTextTouchBar = touchBar == m_richTextTouchBar.get();
</del><ins>+ NSSet<NSTouchBarItem *> *templateItems = nil;
+ NSArray<NSTouchBarItemIdentifier> *defaultItemIdentifiers = nil;
+ NSArray<NSTouchBarItemIdentifier> *customizationAllowedItemIdentifiers = nil;
+
+ if (touchBar == m_passwordTextTouchBar.get()) {
+ templateItems = [NSMutableSet setWithObject:m_passwordTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = passwordTextTouchBarDefaultItemIdentifiers();
+ } else if (touchBar == m_richTextTouchBar.get()) {
+ templateItems = [NSMutableSet setWithObject:m_richTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = richTextTouchBarDefaultItemIdentifiers();
+ customizationAllowedItemIdentifiers = textTouchBarCustomizationAllowedIdentifiers();
+ } else if (touchBar == m_plainTextTouchBar.get()) {
+ templateItems = [NSMutableSet setWithObject:m_plainTextCandidateListTouchBarItem.get()];
+ defaultItemIdentifiers = plainTextTouchBarDefaultItemIdentifiers();
+ customizationAllowedItemIdentifiers = textTouchBarCustomizationAllowedIdentifiers();
+ }
+
</ins><span class="cx"> [touchBar setDelegate:m_textTouchBarItemController.get()];
</span><del>- [touchBar setTemplateItems:[NSMutableSet setWithObject:isRichTextTouchBar ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get()]];
- [touchBar setCustomizationAllowedItemIdentifiers:textTouchBarCustomizationAllowedIdentifiers()];
- [touchBar setDefaultItemIdentifiers:isRichTextTouchBar ? richTextTouchBarDefaultItemIdentifiers() : plainTextTouchBarDefaultItemIdentifiers()];
</del><ins>+ [touchBar setTemplateItems:templateItems];
+ [touchBar setDefaultItemIdentifiers:defaultItemIdentifiers];
+ [touchBar setCustomizationAllowedItemIdentifiers:customizationAllowedItemIdentifiers];
</ins><span class="cx">
</span><span class="cx"> if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[touchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
</span><span class="cx"> textFormatItem.groupTouchBar.customizationIdentifier = @"WKTextFormatTouchBar";
</span><span class="lines">@@ -986,6 +1012,8 @@
</span><span class="cx">
</span><span class="cx"> NSTouchBar *WebViewImpl::textTouchBar() const
</span><span class="cx"> {
</span><ins>+ if (m_page->editorState().isInPasswordField)
+ return m_passwordTextTouchBar.get();
</ins><span class="cx"> return isRichlyEditable() ? m_richTextTouchBar.get() : m_plainTextTouchBar.get();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1036,11 +1064,13 @@
</span><span class="cx"> m_startedListeningToCustomizationEvents = true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!m_richTextCandidateListTouchBarItem || !m_plainTextCandidateListTouchBarItem) {
</del><ins>+ if (!m_richTextCandidateListTouchBarItem || !m_plainTextCandidateListTouchBarItem || !m_passwordTextCandidateListTouchBarItem) {
</ins><span class="cx"> m_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
</span><span class="cx"> [m_richTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
</span><span class="cx"> m_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
</span><span class="cx"> [m_plainTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
</span><ins>+ m_passwordTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [m_passwordTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
</ins><span class="cx"> requestCandidatesForSelectionIfNeeded();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1063,11 +1093,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_page->editorState().isInPasswordField) {
</span><del>- // 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];
</del><ins>+ if (!m_passwordTextTouchBar) {
+ m_passwordTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ setUpTextTouchBar(m_passwordTextTouchBar.get());
+ }
+ [m_passwordTextCandidateListTouchBarItem setCandidates:@[ ] forSelectedRange:NSMakeRange(0, 0) inString:nil];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NSTouchBar *textTouchBar = this->textTouchBar();
</span></span></pre>
</div>
</div>
</body>
</html>