- Revision
- 209626
- Author
- [email protected]
- Date
- 2016-12-09 14:00:28 -0800 (Fri, 09 Dec 2016)
Log Message
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):
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (209625 => 209626)
--- 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)
@@ -1,3 +1,35 @@
+2016-12-09 Beth Dakin <[email protected]>
+
+ 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:
+
2016-12-08 Filip Pizlo <[email protected]>
Enable SharedArrayBuffer, remove the flag
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (209625 => 209626)
--- 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)
@@ -9362,6 +9362,11 @@
return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
}
+- (NSArray<NSString *> *)_passwordTextTouchBarDefaultItemIdentifiers
+{
+ return @[ NSTouchBarItemIdentifierCandidateList ];
+}
+
- (void)touchBarDidExitCustomization:(NSNotification *)notification
{
_private->_isCustomizingTouchBar = NO;
@@ -9381,19 +9386,36 @@
if (_private->_plainTextTouchBar)
[self setUpTextTouchBar:_private->_plainTextTouchBar.get()];
+ if (_private->_passwordTextTouchBar)
+ [self setUpTextTouchBar:_private->_passwordTextTouchBar.get()];
+
[self updateTouchBar];
}
- (void)setUpTextTouchBar:(NSTouchBar *)textTouchBar
{
- BOOL isRichTextTouchBar = textTouchBar == _private->_richTextTouchBar;
+ 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];
+ }
+
[textTouchBar setDelegate:self];
- [textTouchBar setTemplateItems:[NSMutableSet setWithObject:isRichTextTouchBar ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get()]];
- [textTouchBar setCustomizationAllowedItemIdentifiers:[self _textTouchBarCustomizationAllowedIdentifiers]];
+ [textTouchBar setTemplateItems:templateItems];
+ [textTouchBar setDefaultItemIdentifiers:defaultItemIdentifiers];
+ [textTouchBar setCustomizationAllowedItemIdentifiers:customizationAllowedItemIdentifiers];
- NSArray<NSString *> *defaultIdentifiers = isRichTextTouchBar ? [self _richTextTouchBarDefaultItemIdentifiers] : [self _plainTextTouchBarDefaultItemIdentifiers];
- [textTouchBar setDefaultItemIdentifiers:defaultIdentifiers];
-
if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[textTouchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
textFormatItem.groupTouchBar.customizationIdentifier = @"WebTextFormatTouchBar";
}
@@ -9410,10 +9432,14 @@
- (NSTouchBar *)textTouchBar
{
- if (self._isRichlyEditable)
- return _private->_richTextTouchBar.get();
+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return nil;
- return _private->_plainTextTouchBar.get();
+ if (coreFrame->selection().selection().isInPasswordField())
+ return _private->_passwordTextTouchBar.get();
+
+ return self._isRichlyEditable ? _private->_richTextTouchBar.get() : _private->_plainTextTouchBar.get();
}
static NSTextAlignment nsTextAlignmentFromRenderStyle(const RenderStyle* style)
@@ -9482,11 +9508,14 @@
_private->_startedListeningToCustomizationEvents = YES;
}
- if (!_private->_plainTextCandidateListTouchBarItem || !_private->_richTextCandidateListTouchBarItem) {
+ if (!_private->_plainTextCandidateListTouchBarItem || !_private->_richTextCandidateListTouchBarItem || !_private->_passwordTextCandidateListTouchBarItem) {
_private->_plainTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
[_private->_plainTextCandidateListTouchBarItem setDelegate:self];
_private->_richTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
[_private->_richTextCandidateListTouchBarItem setDelegate:self];
+ _private->_passwordTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [_private->_passwordTextCandidateListTouchBarItem setDelegate:self];
+
coreFrame->editor().client()->requestCandidatesForSelection(coreFrame->selection().selection());
}
@@ -9510,9 +9539,11 @@
if (coreFrame->selection().selection().isInPasswordField()) {
// We don't request candidates for password fields. If the user was previously in a non-password field, then the
// old candidates will still show by default, so we clear them here by setting an empty array of candidates.
- if (!_private->_emptyCandidatesArray)
- _private->_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
- [self.candidateList setCandidates:_private->_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
+ if (!_private->_passwordTextTouchBar) {
+ _private->_passwordTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ [self setUpTextTouchBar:_private->_passwordTextTouchBar.get()];
+ }
+ [_private->_passwordTextCandidateListTouchBarItem setCandidates:@[ ] forSelectedRange:NSMakeRange(0, 0) inString:nil];
}
NSTouchBar *textTouchBar = self.textTouchBar;
@@ -9634,6 +9665,13 @@
- (NSCandidateListTouchBarItem *)candidateList
{
+ Frame* coreFrame = core([self _selectedOrMainFrame]);
+ if (!coreFrame)
+ return nil;
+
+ if (coreFrame->selection().selection().isInPasswordField())
+ return _private->_passwordTextCandidateListTouchBarItem.get();
+
return self._isRichlyEditable ? _private->_richTextCandidateListTouchBarItem.get() : _private->_plainTextCandidateListTouchBarItem.get();
}
#else
Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (209625 => 209626)
--- 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)
@@ -185,10 +185,11 @@
RetainPtr<NSTouchBar> _currentTouchBar;
RetainPtr<NSTouchBar> _plainTextTouchBar;
RetainPtr<NSTouchBar> _richTextTouchBar;
+ RetainPtr<NSTouchBar> _passwordTextTouchBar;
RetainPtr<WebTextTouchBarItemController> _textTouchBarItemController;
RetainPtr<NSCandidateListTouchBarItem> _richTextCandidateListTouchBarItem;
RetainPtr<NSCandidateListTouchBarItem> _plainTextCandidateListTouchBarItem;
- RetainPtr<NSArray> _emptyCandidatesArray;
+ RetainPtr<NSCandidateListTouchBarItem> _passwordTextCandidateListTouchBarItem;
RetainPtr<AVFunctionBarPlaybackControlsProvider> mediaTouchBarProvider;
RetainPtr<AVFunctionBarScrubber> mediaPlaybackControlsView;
Modified: trunk/Source/WebKit2/ChangeLog (209625 => 209626)
--- 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)
@@ -1,3 +1,35 @@
+2016-12-09 Beth Dakin <[email protected]>
+
+ 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):
+
2016-12-09 Keith Rollin <[email protected]>
Fix string specification in print format
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (209625 => 209626)
--- 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)
@@ -541,10 +541,11 @@
RetainPtr<NSTouchBar> m_currentTouchBar;
RetainPtr<NSTouchBar> m_richTextTouchBar;
RetainPtr<NSTouchBar> m_plainTextTouchBar;
+ RetainPtr<NSTouchBar> m_passwordTextTouchBar;
RetainPtr<WKTextTouchBarItemController> m_textTouchBarItemController;
RetainPtr<NSCandidateListTouchBarItem> m_richTextCandidateListTouchBarItem;
RetainPtr<NSCandidateListTouchBarItem> m_plainTextCandidateListTouchBarItem;
- RetainPtr<NSArray> m_emptyCandidatesArray;
+ RetainPtr<NSCandidateListTouchBarItem> m_passwordTextCandidateListTouchBarItem;
RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
RetainPtr<NSCustomTouchBarItem> m_exitFullScreenButton;
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (209625 => 209626)
--- 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)
@@ -896,6 +896,8 @@
NSCandidateListTouchBarItem *WebViewImpl::candidateListTouchBarItem() const
{
+ if (m_page->editorState().isInPasswordField)
+ return m_passwordTextCandidateListTouchBarItem.get();
return isRichlyEditable() ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get();
}
@@ -956,6 +958,11 @@
return @[ NSTouchBarItemIdentifierCharacterPicker, NSTouchBarItemIdentifierTextFormat, NSTouchBarItemIdentifierCandidateList ];
}
+static NSArray<NSString *> *passwordTextTouchBarDefaultItemIdentifiers()
+{
+ return @[ NSTouchBarItemIdentifierCandidateList ];
+}
+
void WebViewImpl::updateTouchBarAndRefreshTextBarIdentifiers()
{
if (m_richTextTouchBar)
@@ -964,16 +971,35 @@
if (m_plainTextTouchBar)
setUpTextTouchBar(m_plainTextTouchBar.get());
+ if (m_passwordTextTouchBar)
+ setUpTextTouchBar(m_passwordTextTouchBar.get());
+
updateTouchBar();
}
void WebViewImpl::setUpTextTouchBar(NSTouchBar *touchBar)
{
- bool isRichTextTouchBar = touchBar == m_richTextTouchBar.get();
+ 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();
+ }
+
[touchBar setDelegate:m_textTouchBarItemController.get()];
- [touchBar setTemplateItems:[NSMutableSet setWithObject:isRichTextTouchBar ? m_richTextCandidateListTouchBarItem.get() : m_plainTextCandidateListTouchBarItem.get()]];
- [touchBar setCustomizationAllowedItemIdentifiers:textTouchBarCustomizationAllowedIdentifiers()];
- [touchBar setDefaultItemIdentifiers:isRichTextTouchBar ? richTextTouchBarDefaultItemIdentifiers() : plainTextTouchBarDefaultItemIdentifiers()];
+ [touchBar setTemplateItems:templateItems];
+ [touchBar setDefaultItemIdentifiers:defaultItemIdentifiers];
+ [touchBar setCustomizationAllowedItemIdentifiers:customizationAllowedItemIdentifiers];
if (NSGroupTouchBarItem *textFormatItem = (NSGroupTouchBarItem *)[touchBar itemForIdentifier:NSTouchBarItemIdentifierTextFormat])
textFormatItem.groupTouchBar.customizationIdentifier = @"WKTextFormatTouchBar";
@@ -986,6 +1012,8 @@
NSTouchBar *WebViewImpl::textTouchBar() const
{
+ if (m_page->editorState().isInPasswordField)
+ return m_passwordTextTouchBar.get();
return isRichlyEditable() ? m_richTextTouchBar.get() : m_plainTextTouchBar.get();
}
@@ -1036,11 +1064,13 @@
m_startedListeningToCustomizationEvents = true;
}
- if (!m_richTextCandidateListTouchBarItem || !m_plainTextCandidateListTouchBarItem) {
+ if (!m_richTextCandidateListTouchBarItem || !m_plainTextCandidateListTouchBarItem || !m_passwordTextCandidateListTouchBarItem) {
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()];
+ m_passwordTextCandidateListTouchBarItem = adoptNS([[NSCandidateListTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
+ [m_passwordTextCandidateListTouchBarItem setDelegate:m_textTouchBarItemController.get()];
requestCandidatesForSelectionIfNeeded();
}
@@ -1063,11 +1093,11 @@
}
if (m_page->editorState().isInPasswordField) {
- // We don't request candidates for password fields. If the user was previously in a non-password field, then the
- // old candidates will still show by default, so we clear them here by setting an empty array of candidates.
- if (!m_emptyCandidatesArray)
- m_emptyCandidatesArray = adoptNS([[NSArray alloc] init]);
- [candidateListTouchBarItem() setCandidates:m_emptyCandidatesArray.get() forSelectedRange:NSMakeRange(0, 0) inString:nil];
+ if (!m_passwordTextTouchBar) {
+ m_passwordTextTouchBar = adoptNS([[NSTouchBar alloc] init]);
+ setUpTextTouchBar(m_passwordTextTouchBar.get());
+ }
+ [m_passwordTextCandidateListTouchBarItem setCandidates:@[ ] forSelectedRange:NSMakeRange(0, 0) inString:nil];
}
NSTouchBar *textTouchBar = this->textTouchBar();