<!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>[244975] 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/244975">244975</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2019-05-06 13:41:02 -0700 (Mon, 06 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard
https://bugs.webkit.org/show_bug.cgi?id=197474
<rdar://problem/47219324>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Fix up some #if defs to compile more Mac code when building on iOS.

* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):

Source/WebKit:

Adopt UIKit SPI (added in <rdar://problem/50181162>) to ask the Input Manager to handle
the key event. If the Input Manager handled it then we pass along this information to
WebCore, just as we do for Mac, so that it can alter its event handling logic. Otherwise,
we handle the event as we do now.

A large part of this patch is fixing up #if defs to compile more Mac code when building
on iOS.

* Platform/spi/ios/UIKitSPI.h: Expose more SPI.
* Shared/NativeWebKeyboardEvent.h:
* Shared/WebEvent.h:
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent):
(WebKit::WebKeyboardEvent::encode const):
(WebKit::WebKeyboardEvent::decode):
* Shared/ios/NativeWebKeyboardEventIOS.mm:
(WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
* Shared/ios/WebIOSEventFactory.h:
* Shared/ios/WebIOSEventFactory.mm:
(WebIOSEventFactory::createWebKeyboardEvent):
Compile more Mac code on iOS. Just like on Mac we maintain some bookkeeping on
whether an event was handled by the Input Manager.

* UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
(WebKit::WebAutomationSession::sendSynthesizedEventsToPage): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
to keep the behavior we have now.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
(-[WKContentView shouldSuppressUpdateCandidateView]): Added. Used to tell UIKit whether to
suppress updating/showing the candidate view.
(-[WKContentView setMarkedText:selectedRange:]):
Bookkeeping to track whether we need to delay showing/updating the inline candidate view.
The concept in UIKit is deferment, but at the time of writing its simply a request to delay
the update for 0.4 seconds. We opt into this delay only for the first key that begins
marked text (i.e. the transition from no marked text to marked text). We do this because we
may not have up-to-date editor state at the time UIKit is ready to show/update the inline
candidate view for us to answer -textFirstRect and -textLastRect, which UIKit calls as part
of computing the frame rect for the inline candidate view on screen. Once we receive up-to-date
editor state, in -selectionChanged, we tell UIKit to layout the keyboard, which ultimately
causes it to re-compute the frame rect for the inline candidate view and show it.

(-[WKContentView handleKeyWebEvent:]): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
to keep the behavior we have now.
(-[WKContentView handleKeyWebEvent:withCompletionHandler:]): Ask the keyboard to handle the
event using the Input Manager. If it was handled then there is no need to delay calling the
completion handler, call it, then tell the web process about the key event and that it was
already handled by the Input Manager.
(-[WKContentView _selectionChanged]): Tell the keyboard to update the candidate view, if needed.
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::handleInputMethodKeydown): Mark the event as default handled if
the UI process told us that the event was handled by the Input Manager just like we do on Mac.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomKeyboardEventcpp">trunk/Source/WebCore/dom/KeyboardEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformPlatformKeyboardEventh">trunk/Source/WebCore/platform/PlatformKeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitPlatformspiiosUIKitSPIh">trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h</a></li>
<li><a href="#trunkSourceWebKitSharedNativeWebKeyboardEventh">trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebEventh">trunk/Source/WebKit/Shared/WebEvent.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebEventConversioncpp">trunk/Source/WebKit/Shared/WebEventConversion.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebKeyboardEventcpp">trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp</a></li>
<li><a href="#trunkSourceWebKitSharediosNativeWebKeyboardEventIOSmm">trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm</a></li>
<li><a href="#trunkSourceWebKitSharediosWebIOSEventFactoryh">trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.h</a></li>
<li><a href="#trunkSourceWebKitSharediosWebIOSEventFactorymm">trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAutomationiosWebAutomationSessionIOSmm">trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionh">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportiosWebEditorClientIOSmm">trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebCore/ChangeLog      2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2019-05-06  Daniel Bates  <dabates@apple.com>
+
+        Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=197474
+        <rdar://problem/47219324>
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix up some #if defs to compile more Mac code when building on iOS.
+
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * platform/PlatformKeyboardEvent.h:
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+
</ins><span class="cx"> 2019-05-06  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add assertions to CachedFrame to help figure out crash in CachedFrame constructor
</span></span></pre></div>
<a id="trunkSourceWebCoredomKeyboardEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/KeyboardEvent.cpp       2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp  2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -107,8 +107,10 @@
</span><span class="cx">     , m_location(keyLocationCode(key))
</span><span class="cx">     , m_repeat(key.isAutoRepeat())
</span><span class="cx">     , m_isComposing(view && is<DOMWindow>(view->window()) && downcast<DOMWindow>(*view->window()).frame() && downcast<DOMWindow>(*view->window()).frame()->editor().hasComposition())
</span><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS)
+    , m_handledByInputMethod(key.handledByInputMethod())
+#endif
</ins><span class="cx"> #if USE(APPKIT)
</span><del>-    , m_handledByInputMethod(key.handledByInputMethod())
</del><span class="cx">     , m_keypressCommands(key.commands())
</span><span class="cx"> #endif
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPlatformKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h    2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h       2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -53,9 +53,6 @@
</span><span class="cx">         PlatformKeyboardEvent()
</span><span class="cx">             : PlatformEvent(PlatformEvent::KeyDown)
</span><span class="cx">             , m_windowsVirtualKeyCode(0)
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
-            , m_handledByInputMethod(false)
-#endif
</del><span class="cx">             , m_autoRepeat(false)
</span><span class="cx">             , m_isKeypad(false)
</span><span class="cx">             , m_isSystemKey(false)
</span><span class="lines">@@ -84,9 +81,6 @@
</span><span class="cx"> #endif
</span><span class="cx">             , m_keyIdentifier(keyIdentifier)
</span><span class="cx">             , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
-            , m_handledByInputMethod(false)
-#endif
</del><span class="cx">             , m_autoRepeat(isAutoRepeat)
</span><span class="cx">             , m_isKeypad(isKeypad)
</span><span class="cx">             , m_isSystemKey(isSystemKey)
</span><span class="lines">@@ -122,7 +116,7 @@
</span><span class="cx">         int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
</span><span class="cx">         void setWindowsVirtualKeyCode(int code) { m_windowsVirtualKeyCode = code; }
</span><span class="cx"> 
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
</del><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
</ins><span class="cx">         bool handledByInputMethod() const { return m_handledByInputMethod; }
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(APPKIT)
</span><span class="lines">@@ -185,8 +179,8 @@
</span><span class="cx"> #endif
</span><span class="cx">         String m_keyIdentifier;
</span><span class="cx">         int m_windowsVirtualKeyCode;
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
-        bool m_handledByInputMethod;
</del><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
+        bool m_handledByInputMethod { false };
</ins><span class="cx"> #endif
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx">         Vector<KeypressCommand> m_commands;
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/ChangeLog       2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2019-05-06  Daniel Bates  <dabates@apple.com>
+
+        Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=197474
+        <rdar://problem/47219324>
+
+        Reviewed by Ryosuke Niwa.
+
+        Adopt UIKit SPI (added in <rdar://problem/50181162>) to ask the Input Manager to handle
+        the key event. If the Input Manager handled it then we pass along this information to
+        WebCore, just as we do for Mac, so that it can alter its event handling logic. Otherwise,
+        we handle the event as we do now.
+
+        A large part of this patch is fixing up #if defs to compile more Mac code when building
+        on iOS.
+
+        * Platform/spi/ios/UIKitSPI.h: Expose more SPI.
+        * Shared/NativeWebKeyboardEvent.h:
+        * Shared/WebEvent.h:
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+        (WebKit::WebKeyboardEvent::encode const):
+        (WebKit::WebKeyboardEvent::decode):
+        * Shared/ios/NativeWebKeyboardEventIOS.mm:
+        (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
+        * Shared/ios/WebIOSEventFactory.h:
+        * Shared/ios/WebIOSEventFactory.mm:
+        (WebIOSEventFactory::createWebKeyboardEvent):
+        Compile more Mac code on iOS. Just like on Mac we maintain some bookkeeping on
+        whether an event was handled by the Input Manager.
+
+        * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
+        (WebKit::WebAutomationSession::sendSynthesizedEventsToPage): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
+        to keep the behavior we have now.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanupInteraction]):
+        (-[WKContentView shouldSuppressUpdateCandidateView]): Added. Used to tell UIKit whether to
+        suppress updating/showing the candidate view.
+        (-[WKContentView setMarkedText:selectedRange:]):
+        Bookkeeping to track whether we need to delay showing/updating the inline candidate view.
+        The concept in UIKit is deferment, but at the time of writing its simply a request to delay
+        the update for 0.4 seconds. We opt into this delay only for the first key that begins
+        marked text (i.e. the transition from no marked text to marked text). We do this because we
+        may not have up-to-date editor state at the time UIKit is ready to show/update the inline
+        candidate view for us to answer -textFirstRect and -textLastRect, which UIKit calls as part
+        of computing the frame rect for the inline candidate view on screen. Once we receive up-to-date
+        editor state, in -selectionChanged, we tell UIKit to layout the keyboard, which ultimately
+        causes it to re-compute the frame rect for the inline candidate view and show it.
+
+        (-[WKContentView handleKeyWebEvent:]): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
+        to keep the behavior we have now. 
+        (-[WKContentView handleKeyWebEvent:withCompletionHandler:]): Ask the keyboard to handle the
+        event using the Input Manager. If it was handled then there is no need to delay calling the
+        completion handler, call it, then tell the web process about the key event and that it was
+        already handled by the Input Manager.
+        (-[WKContentView _selectionChanged]): Tell the keyboard to update the candidate view, if needed.
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::handleInputMethodKeydown): Mark the event as default handled if
+        the UI process told us that the event was handled by the Input Manager just like we do on Mac.
+
</ins><span class="cx"> 2019-05-06  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Null check m_mainFrame in WebPageProxy.cpp
</span></span></pre></div>
<a id="trunkSourceWebKitPlatformspiiosUIKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h  2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h     2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -386,6 +386,10 @@
</span><span class="cx"> @property (nonatomic, retain) UIColor *selectionHighlightColor;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@protocol UITextInputDelegatePrivate
+- (void)layoutHasChanged;
+@end
+
</ins><span class="cx"> @class UITextInputArrowKeyHistory;
</span><span class="cx"> 
</span><span class="cx"> @protocol UITextInputPrivate <UITextInput, UITextInputTokenizer, UITextInputTraits_Private>
</span><span class="lines">@@ -1121,6 +1125,7 @@
</span><span class="cx"> - (void)prepareKeyboardInputModeFromPreferences:(UIKeyboardInputMode *)lastUsedMode;
</span><span class="cx"> - (BOOL)handleKeyTextCommandForCurrentEvent;
</span><span class="cx"> - (BOOL)handleKeyAppCommandForCurrentEvent;
</span><ins>+- (BOOL)handleKeyInputMethodCommandForCurrentEvent;
</ins><span class="cx"> @property (nonatomic, readonly) UIKeyboardInputMode *currentInputModeInPreference;
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitSharedNativeWebKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h      2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h 2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -65,12 +65,14 @@
</span><span class="cx"> class NativeWebKeyboardEvent : public WebKeyboardEvent {
</span><span class="cx"> public:
</span><span class="cx"> #if USE(APPKIT)
</span><ins>+    // FIXME: Share iOS's HandledByInputMethod enum here instead of passing a boolean.
</ins><span class="cx">     NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&);
</span><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx">     NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
</span><span class="cx">     NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
</span><span class="cx"> #elif PLATFORM(IOS_FAMILY)
</span><del>-    NativeWebKeyboardEvent(::WebEvent *);
</del><ins>+    enum class HandledByInputMethod : bool { No, Yes };
+    NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod);
</ins><span class="cx"> #elif USE(LIBWPE)
</span><span class="cx">     NativeWebKeyboardEvent(struct wpe_input_keyboard_event*);
</span><span class="cx"> #elif PLATFORM(WIN)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebEvent.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebEvent.h    2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/WebEvent.h       2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -259,7 +259,7 @@
</span><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx">     WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
</span><span class="cx"> #elif PLATFORM(IOS_FAMILY)
</span><del>-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
</del><ins>+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);
</ins><span class="cx"> #elif USE(LIBWPE)
</span><span class="cx">     WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isKeypad, OptionSet<Modifier>, WallTime timestamp);
</span><span class="cx"> #else
</span><span class="lines">@@ -278,7 +278,7 @@
</span><span class="cx">     int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
</span><span class="cx">     int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
</span><span class="cx">     int32_t macCharCode() const { return m_macCharCode; }
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
</del><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
</ins><span class="cx">     bool handledByInputMethod() const { return m_handledByInputMethod; }
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(APPKIT)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">     int32_t m_windowsVirtualKeyCode;
</span><span class="cx">     int32_t m_nativeVirtualKeyCode;
</span><span class="cx">     int32_t m_macCharCode;
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
</del><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
</ins><span class="cx">     bool m_handledByInputMethod;
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(APPKIT)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebEventConversioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebEventConversion.cpp (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebEventConversion.cpp        2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/WebEventConversion.cpp   2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -221,8 +221,10 @@
</span><span class="cx"> #endif
</span><span class="cx">         m_keyIdentifier = webEvent.keyIdentifier();
</span><span class="cx">         m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode();
</span><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
+        m_handledByInputMethod = webEvent.handledByInputMethod();
+#endif
</ins><span class="cx"> #if USE(APPKIT) || PLATFORM(GTK)
</span><del>-        m_handledByInputMethod = webEvent.handledByInputMethod();
</del><span class="cx">         m_commands = webEvent.commands();
</span><span class="cx"> #endif
</span><span class="cx">         m_autoRepeat = webEvent.isAutoRepeat();
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebKeyboardEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp  2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp     2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> 
</span><span class="cx"> #elif PLATFORM(IOS_FAMILY)
</span><span class="cx"> 
</span><del>-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
</del><ins>+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
</ins><span class="cx">     : WebEvent(type, modifiers, timestamp)
</span><span class="cx">     , m_text(text)
</span><span class="cx">     , m_unmodifiedText(unmodifiedText)
</span><span class="lines">@@ -97,6 +97,9 @@
</span><span class="cx">     , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
</span><span class="cx">     , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
</span><span class="cx">     , m_macCharCode(macCharCode)
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    , m_handledByInputMethod(handledByInputMethod)
+#endif
</ins><span class="cx">     , m_isAutoRepeat(isAutoRepeat)
</span><span class="cx">     , m_isKeypad(isKeypad)
</span><span class="cx">     , m_isSystemKey(isSystemKey)
</span><span class="lines">@@ -166,8 +169,10 @@
</span><span class="cx">     encoder << m_windowsVirtualKeyCode;
</span><span class="cx">     encoder << m_nativeVirtualKeyCode;
</span><span class="cx">     encoder << m_macCharCode;
</span><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
+    encoder << m_handledByInputMethod;
+#endif
</ins><span class="cx"> #if USE(APPKIT) || PLATFORM(GTK)
</span><del>-    encoder << m_handledByInputMethod;
</del><span class="cx">     encoder << m_commands;
</span><span class="cx"> #endif
</span><span class="cx">     encoder << m_isAutoRepeat;
</span><span class="lines">@@ -200,9 +205,11 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.m_macCharCode))
</span><span class="cx">         return false;
</span><del>-#if USE(APPKIT) || PLATFORM(GTK)
</del><ins>+#if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK)
</ins><span class="cx">     if (!decoder.decode(result.m_handledByInputMethod))
</span><span class="cx">         return false;
</span><ins>+#endif
+#if USE(APPKIT) || PLATFORM(GTK)
</ins><span class="cx">     if (!decoder.decode(result.m_commands))
</span><span class="cx">         return false;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitSharediosNativeWebKeyboardEventIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm      2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm 2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-NativeWebKeyboardEvent::NativeWebKeyboardEvent(::WebEvent *event)
-    : WebKeyboardEvent(WebIOSEventFactory::createWebKeyboardEvent(event))
</del><ins>+NativeWebKeyboardEvent::NativeWebKeyboardEvent(::WebEvent *event, HandledByInputMethod handledByInputMethod)
+    : WebKeyboardEvent(WebIOSEventFactory::createWebKeyboardEvent(event, handledByInputMethod == HandledByInputMethod::Yes))
</ins><span class="cx">     , m_nativeEvent(event)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitSharediosWebIOSEventFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.h      2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.h 2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> class WebIOSEventFactory {
</span><span class="cx"> public:
</span><del>-    static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent *);
</del><ins>+    static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent *, bool handledByInputMethod);
</ins><span class="cx">     static WebKit::WebMouseEvent createWebMouseEvent(::WebEvent *);
</span><span class="cx"> 
</span><span class="cx">     static UIKeyModifierFlags toUIKeyModifierFlags(OptionSet<WebKit::WebEvent::Modifier>);
</span></span></pre></div>
<a id="trunkSourceWebKitSharediosWebIOSEventFactorymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm     2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm        2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     return modifiers;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *event)
</del><ins>+WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *event, bool handledByInputMethod)
</ins><span class="cx"> {
</span><span class="cx">     WebKit::WebEvent::Type type = (event.type == WebEventKeyUp) ? WebKit::WebEvent::KeyUp : WebKit::WebEvent::KeyDown;
</span><span class="cx">     String text;
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx">         unmodifiedText = text;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return WebKit::WebKeyboardEvent(type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp));
</del><ins>+    return WebKit::WebKeyboardEvent { type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebKit::WebMouseEvent WebIOSEventFactory::createWebMouseEvent(::WebEvent *event)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAutomationiosWebAutomationSessionIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm  2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm     2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> 
</span><span class="cx">         case WebEventKeyDown:
</span><span class="cx">         case WebEventKeyUp:
</span><del>-            page.handleKeyboardEvent(NativeWebKeyboardEvent(event));
</del><ins>+            page.handleKeyboardEvent(NativeWebKeyboardEvent(event, NativeWebKeyboardEvent::HandledByInputMethod::No));
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h     2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h        2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -324,6 +324,10 @@
</span><span class="cx"> 
</span><span class="cx">     BOOL _keyboardDidRequestDismissal;
</span><span class="cx"> 
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    BOOL _candidateViewNeedsUpdate;
+#endif
+
</ins><span class="cx">     BOOL _becomingFirstResponder;
</span><span class="cx">     BOOL _resigningFirstResponder;
</span><span class="cx">     BOOL _needsDeferredEndScrollingSelectionUpdate;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -839,6 +839,10 @@
</span><span class="cx"> 
</span><span class="cx">     _focusRequiresStrongPasswordAssistance = NO;
</span><span class="cx"> 
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    _candidateViewNeedsUpdate = NO;
+#endif
+
</ins><span class="cx">     if (_interactionViewsContainerView) {
</span><span class="cx">         [self.layer removeObserver:self forKeyPath:@"transform"];
</span><span class="cx">         [_interactionViewsContainerView removeFromSuperview];
</span><span class="lines">@@ -4040,6 +4044,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange
</span><span class="cx"> {
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    _candidateViewNeedsUpdate = !self.hasMarkedText;
+#endif
</ins><span class="cx">     _markedText = markedText;
</span><span class="cx">     _page->setCompositionAsync(markedText, Vector<WebCore::CompositionUnderline>(), selectedRange, WebKit::EditingRange());
</span><span class="cx"> }
</span><span class="lines">@@ -4423,6 +4430,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(UIKIT_KEYBOARD_ADDITIONS)
</span><ins>+
</ins><span class="cx"> - (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags
</span><span class="cx"> {
</span><span class="cx">     auto dispatchSyntheticFlagsChangedEvents = [&] (UIKeyModifierFlags flags, bool keyDown) {
</span><span class="lines">@@ -4439,6 +4447,12 @@
</span><span class="cx">     if (addedFlags)
</span><span class="cx">         dispatchSyntheticFlagsChangedEvents(addedFlags, true);
</span><span class="cx"> }
</span><ins>+
+- (BOOL)shouldSuppressUpdateCandidateView
+{
+    return _candidateViewNeedsUpdate;
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> // Web events.
</span><span class="lines">@@ -4483,7 +4497,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)handleKeyWebEvent:(::WebEvent *)theEvent
</span><span class="cx"> {
</span><del>-    _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent));
</del><ins>+    _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, WebKit::NativeWebKeyboardEvent::HandledByInputMethod::No));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)handleKeyWebEvent:(::WebEvent *)theEvent withCompletionHandler:(void (^)(::WebEvent *theEvent, BOOL wasHandled))completionHandler
</span><span class="lines">@@ -4490,8 +4504,17 @@
</span><span class="cx"> {
</span><span class="cx">     [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture];
</span><span class="cx"> 
</span><ins>+    using HandledByInputMethod = WebKit::NativeWebKeyboardEvent::HandledByInputMethod;
+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    auto* keyboard = [UIKeyboardImpl sharedInstance];
+    if ([keyboard respondsToSelector:@selector(handleKeyInputMethodCommandForCurrentEvent)] && [keyboard handleKeyInputMethodCommandForCurrentEvent]) {
+        completionHandler(theEvent, YES);
+        _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, HandledByInputMethod::Yes));
+        return;
+    }
+#endif
</ins><span class="cx">     _keyWebEventHandler = makeBlockPtr(completionHandler);
</span><del>-    _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent));
</del><ins>+    _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, HandledByInputMethod::No));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled
</span><span class="lines">@@ -5633,6 +5656,14 @@
</span><span class="cx">     if (_usingGestureForSelection)
</span><span class="cx">         [self _updateChangedSelection];
</span><span class="cx"> 
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    if (_candidateViewNeedsUpdate) {
+        _candidateViewNeedsUpdate = NO;
+        if ([self.inputDelegate respondsToSelector:@selector(layoutHasChanged)])
+            [(id <UITextInputDelegatePrivate>)self.inputDelegate layoutHasChanged];
+    }
+#endif
+
</ins><span class="cx">     [_webView _didChangeEditorState];
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportiosWebEditorClientIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm (244974 => 244975)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm  2019-05-06 20:39:28 UTC (rev 244974)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm     2019-05-06 20:41:02 UTC (rev 244975)
</span><span class="lines">@@ -44,7 +44,12 @@
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::handleInputMethodKeydown(KeyboardEvent&)
</span><span class="cx"> {
</span><ins>+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+    if (event->handledByInputMethod())
+        event->setDefaultHandled();
+#else
</ins><span class="cx">     notImplemented();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::setInsertionPasteboard(const String&)
</span></span></pre>
</div>
</div>

</body>
</html>