Diff
Modified: trunk/Source/WebKit2/ChangeLog (191507 => 191508)
--- trunk/Source/WebKit2/ChangeLog 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/ChangeLog 2015-10-23 20:49:38 UTC (rev 191508)
@@ -1,3 +1,40 @@
+2015-10-23 Tim Horton <[email protected]>
+
+ WKView being inside WKWebView leads to weird API issues
+ https://bugs.webkit.org/show_bug.cgi?id=150174
+
+ Reviewed by Anders Carlsson.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _interpretKeyEvent:completionHandler:]):
+ (-[WKView inputContext]):
+ (-[WKView performKeyEquivalent:]):
+ (-[WKView keyDown:]):
+ (-[WKView _doneWithKeyEvent:eventWasHandled:]):
+ (-[WKView _setPluginComplexTextInputState:]): Deleted.
+ (-[WKView _disableComplexTextInputIfNecessary]): Deleted.
+ (-[WKView _handlePluginComplexTextInputKeyDown:]): Deleted.
+ (-[WKView _tryHandlePluginComplexTextInputKeyDown:]): Deleted.
+ (-[WKView _tryPostProcessPluginComplexTextInputKeyDown:]): Deleted.
+ (-[WKView _pluginFocusOrWindowFocusChanged:pluginComplexTextInputIdentifier:]): Deleted.
+ (-[WKView _setPluginComplexTextInputState:pluginComplexTextInputIdentifier:]): Deleted.
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/Cocoa/WebViewImpl.h:
+ (WebKit::WebViewImpl::pluginComplexTextInputState):
+ (WebKit::WebViewImpl::pluginComplexTextInputIdentifier):
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::setPluginComplexTextInputState):
+ (WebKit::WebViewImpl::setPluginComplexTextInputStateAndIdentifier):
+ (WebKit::WebViewImpl::disableComplexTextInputIfNecessary):
+ (WebKit::WebViewImpl::handlePluginComplexTextInputKeyDown):
+ (WebKit::WebViewImpl::tryHandlePluginComplexTextInputKeyDown):
+ (WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
+ (WebKit::WebViewImpl::tryPostProcessPluginComplexTextInputKeyDown):
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::pluginFocusOrWindowFocusChanged):
+ (WebKit::PageClientImpl::setPluginComplexTextInputState):
+ Move a few more methods.
+
2015-10-23 Eric Carlson <[email protected]>
[MediaStream] Fix UserMediaPermissionRequestProxy::invalidate
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191507 => 191508)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-10-23 20:49:38 UTC (rev 191508)
@@ -201,15 +201,8 @@
WKViewInterpretKeyEventsParameters* _interpretKeyEventsParameters;
#endif
- // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
- uint64_t _pluginComplexTextInputIdentifier;
-
- // The state of complex text input for the plug-in.
- PluginComplexTextInputState _pluginComplexTextInputState;
-
BOOL _willBecomeFirstResponderAgain;
NSEvent *_mouseDownEvent;
- NSEvent *_pressureEvent;
BOOL _ignoringMouseDraggedEvents;
BOOL _hasSpellCheckerDocumentTag;
@@ -392,17 +385,6 @@
[super renewGState];
}
-- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState
-{
- _data->_pluginComplexTextInputState = pluginComplexTextInputState;
-
- if (_data->_pluginComplexTextInputState != PluginComplexTextInputDisabled)
- return;
-
- // Send back an empty string to the plug-in. This will disable text input.
- _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, String());
-}
-
typedef HashMap<SEL, String> SelectorNameMap;
// Map selectors into Editor command names.
@@ -1188,55 +1170,6 @@
return result;
}
-- (void)_disableComplexTextInputIfNecessary
-{
- if (!_data->_pluginComplexTextInputIdentifier)
- return;
-
- if (_data->_pluginComplexTextInputState != PluginComplexTextInputEnabled)
- return;
-
- // Check if the text input window has been dismissed.
- if (![[WKTextInputWindowController sharedTextInputWindowController] hasMarkedText])
- [self _setPluginComplexTextInputState:PluginComplexTextInputDisabled];
-}
-
-- (BOOL)_handlePluginComplexTextInputKeyDown:(NSEvent *)event
-{
- ASSERT(_data->_pluginComplexTextInputIdentifier);
- ASSERT(_data->_pluginComplexTextInputState != PluginComplexTextInputDisabled);
-
- BOOL usingLegacyCocoaTextInput = _data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy;
-
- NSString *string = nil;
- BOOL didHandleEvent = [[WKTextInputWindowController sharedTextInputWindowController] interpretKeyEvent:event usingLegacyCocoaTextInput:usingLegacyCocoaTextInput string:&string];
-
- if (string) {
- _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, string);
-
- if (!usingLegacyCocoaTextInput)
- _data->_pluginComplexTextInputState = PluginComplexTextInputDisabled;
- }
-
- return didHandleEvent;
-}
-
-- (BOOL)_tryHandlePluginComplexTextInputKeyDown:(NSEvent *)event
-{
- if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
- return NO;
-
- // Check if the text input window has been dismissed and let the plug-in process know.
- // This is only valid with the updated Cocoa text input spec.
- [self _disableComplexTextInputIfNecessary];
-
- // Try feeding the keyboard event directly to the plug-in.
- if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
- return [self _handlePluginComplexTextInputKeyDown:event];
-
- return NO;
-}
-
static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnderline>& result)
{
int length = [[string string] length];
@@ -1279,7 +1212,7 @@
{
// For regular Web content, input methods run before passing a keydown to DOM, but plug-ins get an opportunity to handle the event first.
// There is no need to collect commands, as the plug-in cannot execute them.
- if (_data->_pluginComplexTextInputIdentifier) {
+ if (_data->_impl->pluginComplexTextInputIdentifier()) {
completionHandler(NO, Vector<KeypressCommand>());
return;
}
@@ -1523,7 +1456,7 @@
- (NSTextInputContext *)inputContext
{
- if (_data->_pluginComplexTextInputIdentifier) {
+ if (_data->_impl->pluginComplexTextInputIdentifier()) {
ASSERT(!_data->_collectedKeypressCommands); // Should not get here from -_interpretKeyEvent:completionHandler:, we only use WKTextInputWindowController after giving the plug-in a chance to handle keydown natively.
return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
}
@@ -1638,7 +1571,7 @@
ASSERT(event == [NSApp currentEvent]);
- [self _disableComplexTextInputIfNecessary];
+ _data->_impl->disableComplexTextInputIfNecessary();
// Pass key combos through WebCore if there is a key binding available for
// this event. This lets webpages have a crack at intercepting key-modified keypresses.
@@ -1673,7 +1606,7 @@
LOG(TextInput, "keyDown:%p %@%s", theEvent, theEvent, (theEvent == _data->_keyDownEventBeingResent) ? " (re-sent)" : "");
- if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent]) {
+ if (_data->_impl->tryHandlePluginComplexTextInputKeyDown(theEvent)) {
LOG(TextInput, "...handled by plug-in");
return;
}
@@ -1859,7 +1792,7 @@
{
WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
- if (_data->_pluginComplexTextInputIdentifier && !parameters)
+ if (_data->_impl->pluginComplexTextInputIdentifier() && !parameters)
return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
// Disable text input machinery when in non-editable content. An invisible inline input area affects performance, and can prevent Expose from working.
@@ -2081,7 +2014,7 @@
ASSERT(event == [NSApp currentEvent]);
- [self _disableComplexTextInputIfNecessary];
+ _data->_impl->disableComplexTextInputIfNecessary();
// Pass key combos through WebCore if there is a key binding available for
// this event. This lets webpages have a crack at intercepting key-modified keypresses.
@@ -2118,7 +2051,7 @@
// the current event prevents that from causing a problem inside WebKit or AppKit code.
[[theEvent retain] autorelease];
- if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent]) {
+ if (_data->_impl->tryHandlePluginComplexTextInputKeyDown(theEvent)) {
LOG(TextInput, "...handled by plug-in");
return;
}
@@ -2541,24 +2474,12 @@
}
}
-- (BOOL)_tryPostProcessPluginComplexTextInputKeyDown:(NSEvent *)event
-{
- if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
- return NO;
-
- // In the legacy text input model, the event has already been sent to the input method.
- if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
- return NO;
-
- return [self _handlePluginComplexTextInputKeyDown:event];
-}
-
- (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled
{
if ([event type] != NSKeyDown)
return;
- if ([self _tryPostProcessPluginComplexTextInputKeyDown:event])
+ if (_data->_impl->tryPostProcessPluginComplexTextInputKeyDown(event))
return;
if (eventWasHandled) {
@@ -2840,44 +2761,6 @@
[self _updateRemoteAccessibilityRegistration:YES];
}
-- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
-{
- BOOL inputSourceChanged = _data->_pluginComplexTextInputIdentifier;
-
- if (pluginHasFocusAndWindowHasFocus) {
- // Check if we're already allowing text input for this plug-in.
- if (pluginComplexTextInputIdentifier == _data->_pluginComplexTextInputIdentifier)
- return;
-
- _data->_pluginComplexTextInputIdentifier = pluginComplexTextInputIdentifier;
-
- } else {
- // Check if we got a request to unfocus a plug-in that isn't focused.
- if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier)
- return;
-
- _data->_pluginComplexTextInputIdentifier = 0;
- }
-
- if (inputSourceChanged) {
- // The input source changed; discard any entered text.
- [[WKTextInputWindowController sharedTextInputWindowController] unmarkText];
- }
-
- // This will force the current input context to be updated to its correct value.
- [NSApp updateWindows];
-}
-
-- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
-{
- if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier) {
- // We're asked to update the state for a plug-in that doesn't have focus.
- return;
- }
-
- [self _setPluginComplexTextInputState:pluginComplexTextInputState];
-}
-
- (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
{
// The call below could release this WKView.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (191507 => 191508)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-10-23 20:49:38 UTC (rev 191508)
@@ -95,8 +95,6 @@
- (void)_setAccessibilityWebProcessToken:(NSData *)data;
-- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
-- (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
- (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
- (void)_setPromisedDataForImage:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName;
#if ENABLE(ATTACHMENT_ELEMENT)
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191507 => 191508)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2015-10-23 20:49:38 UTC (rev 191508)
@@ -28,6 +28,7 @@
#if PLATFORM(MAC)
+#include "PluginComplexTextInputState.h"
#include "WKLayoutMode.h"
#include "WebPageProxy.h"
#include <WebCore/TextIndicatorWindow.h>
@@ -159,6 +160,14 @@
void resetSecureInputState();
bool inSecureInputState() const { return m_inSecureInputState; }
void notifyInputContextAboutDiscardedComposition();
+ void setPluginComplexTextInputStateAndIdentifier(PluginComplexTextInputState, uint64_t identifier);
+ void disableComplexTextInputIfNecessary();
+ bool handlePluginComplexTextInputKeyDown(NSEvent *);
+ bool tryHandlePluginComplexTextInputKeyDown(NSEvent *);
+ void pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus, uint64_t pluginComplexTextInputIdentifier);
+ bool tryPostProcessPluginComplexTextInputKeyDown(NSEvent *);
+ PluginComplexTextInputState pluginComplexTextInputState() const { return m_pluginComplexTextInputState; }
+ uint64_t pluginComplexTextInputIdentifier() const { return m_pluginComplexTextInputIdentifier; }
void pressureChangeWithEvent(NSEvent *);
NSEvent *lastPressureEvent() { return m_lastPressureEvent.get(); }
@@ -218,6 +227,8 @@
void postFakeMouseMovedEventForFlagsChangedEvent(NSEvent *);
+ void setPluginComplexTextInputState(PluginComplexTextInputState);
+
NSView <WebViewImplDelegate> *m_view;
WebPageProxy& m_page;
PageClient& m_pageClient;
@@ -251,6 +262,12 @@
bool m_inSecureInputState { false };
RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
+ // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
+ uint64_t m_pluginComplexTextInputIdentifier;
+
+ // The state of complex text input for the plug-in.
+ PluginComplexTextInputState m_pluginComplexTextInputState;
+
#if ENABLE(FULLSCREEN_API)
RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController;
#endif
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (191507 => 191508)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2015-10-23 20:49:38 UTC (rev 191508)
@@ -36,6 +36,7 @@
#import "PageClient.h"
#import "WKFullScreenWindowController.h"
#import "WKImmediateActionController.h"
+#import "WKTextInputWindowController.h"
#import "WKViewLayoutStrategy.h"
#import "WKWebView.h"
#import "WebEditCommandProxy.h"
@@ -1015,6 +1016,116 @@
[[m_view _superInputContext] discardMarkedText]; // Inform the input method that we won't have an inline input area despite having been asked to.
}
+void WebViewImpl::setPluginComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState)
+{
+ m_pluginComplexTextInputState = pluginComplexTextInputState;
+
+ if (m_pluginComplexTextInputState != PluginComplexTextInputDisabled)
+ return;
+
+ // Send back an empty string to the plug-in. This will disable text input.
+ m_page.sendComplexTextInputToPlugin(m_pluginComplexTextInputIdentifier, String());
+}
+
+void WebViewImpl::setPluginComplexTextInputStateAndIdentifier(PluginComplexTextInputState pluginComplexTextInputState, uint64_t pluginComplexTextInputIdentifier)
+{
+ if (pluginComplexTextInputIdentifier != m_pluginComplexTextInputIdentifier) {
+ // We're asked to update the state for a plug-in that doesn't have focus.
+ return;
+ }
+
+ setPluginComplexTextInputState(pluginComplexTextInputState);
+}
+
+void WebViewImpl::disableComplexTextInputIfNecessary()
+{
+ if (!m_pluginComplexTextInputIdentifier)
+ return;
+
+ if (m_pluginComplexTextInputState != PluginComplexTextInputEnabled)
+ return;
+
+ // Check if the text input window has been dismissed.
+ if (![[WKTextInputWindowController sharedTextInputWindowController] hasMarkedText])
+ setPluginComplexTextInputState(PluginComplexTextInputDisabled);
+}
+
+bool WebViewImpl::handlePluginComplexTextInputKeyDown(NSEvent *event)
+{
+ ASSERT(m_pluginComplexTextInputIdentifier);
+ ASSERT(m_pluginComplexTextInputState != PluginComplexTextInputDisabled);
+
+ BOOL usingLegacyCocoaTextInput = m_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy;
+
+ NSString *string = nil;
+ BOOL didHandleEvent = [[WKTextInputWindowController sharedTextInputWindowController] interpretKeyEvent:event usingLegacyCocoaTextInput:usingLegacyCocoaTextInput string:&string];
+
+ if (string) {
+ m_page.sendComplexTextInputToPlugin(m_pluginComplexTextInputIdentifier, string);
+
+ if (!usingLegacyCocoaTextInput)
+ m_pluginComplexTextInputState = PluginComplexTextInputDisabled;
+ }
+
+ return didHandleEvent;
+}
+
+bool WebViewImpl::tryHandlePluginComplexTextInputKeyDown(NSEvent *event)
+{
+ if (!m_pluginComplexTextInputIdentifier || m_pluginComplexTextInputState == PluginComplexTextInputDisabled)
+ return NO;
+
+ // Check if the text input window has been dismissed and let the plug-in process know.
+ // This is only valid with the updated Cocoa text input spec.
+ disableComplexTextInputIfNecessary();
+
+ // Try feeding the keyboard event directly to the plug-in.
+ if (m_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
+ return handlePluginComplexTextInputKeyDown(event);
+
+ return NO;
+}
+
+void WebViewImpl::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus, uint64_t pluginComplexTextInputIdentifier)
+{
+ BOOL inputSourceChanged = m_pluginComplexTextInputIdentifier;
+
+ if (pluginHasFocusAndWindowHasFocus) {
+ // Check if we're already allowing text input for this plug-in.
+ if (pluginComplexTextInputIdentifier == m_pluginComplexTextInputIdentifier)
+ return;
+
+ m_pluginComplexTextInputIdentifier = pluginComplexTextInputIdentifier;
+
+ } else {
+ // Check if we got a request to unfocus a plug-in that isn't focused.
+ if (pluginComplexTextInputIdentifier != m_pluginComplexTextInputIdentifier)
+ return;
+
+ m_pluginComplexTextInputIdentifier = 0;
+ }
+
+ if (inputSourceChanged) {
+ // The input source changed; discard any entered text.
+ [[WKTextInputWindowController sharedTextInputWindowController] unmarkText];
+ }
+
+ // This will force the current input context to be updated to its correct value.
+ [NSApp updateWindows];
+}
+
+bool WebViewImpl::tryPostProcessPluginComplexTextInputKeyDown(NSEvent *event)
+{
+ if (!m_pluginComplexTextInputIdentifier || m_pluginComplexTextInputState == PluginComplexTextInputDisabled)
+ return NO;
+
+ // In the legacy text input model, the event has already been sent to the input method.
+ if (m_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
+ return NO;
+
+ return handlePluginComplexTextInputKeyDown(event);
+}
+
void WebViewImpl::pressureChangeWithEvent(NSEvent *event)
{
#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (191507 => 191508)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2015-10-23 20:21:54 UTC (rev 191507)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2015-10-23 20:49:38 UTC (rev 191508)
@@ -536,12 +536,12 @@
void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
{
- [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
+ m_impl->pluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus, pluginComplexTextInputIdentifier);
}
void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
{
- [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
+ m_impl->setPluginComplexTextInputStateAndIdentifier(pluginComplexTextInputState, pluginComplexTextInputIdentifier);
}
void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)