<!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>[202129] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202129">202129</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2016-06-16 10:54:33 -0700 (Thu, 16 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Forward/Back keyboard shortcuts need to flip for RTL
https://bugs.webkit.org/show_bug.cgi?id=158823
&lt;rdar://problem/25975359&gt;

Reviewed by Darin Adler.

Source/WebKit2:

Pipe the UserInterfaceLayoutDirection down to the WebContentProcess on initialization
and when it changes, and use it to flip the behavior of command-left and command-right
when in RTL mode.

Tests:
    WebKit2_CommandBackForwardTestWKView.LTR
    WebKit2_CommandBackForwardTestWKView.RTL
    WebKit2_CommandBackForwardTestWKWebView.LTR
    WebKit2_CommandBackForwardTestWKWebView.RTL

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _webViewPrintFormatter]):
(-[WKWebView setSemanticContentAttribute:]):
(-[WKWebView _printOperationWithPrintInfo:forFrame:]):
(-[WKWebView setUserInterfaceLayoutDirection:]):
* UIProcess/API/mac/WKView.mm:
(-[WKView setUserInterfaceLayoutDirection:]):
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::windowIsFrontWindowUnderMouse):
(WebKit::toUserInterfaceLayoutDirection):
(WebKit::WebViewImpl::userInterfaceLayoutDirection):
(WebKit::WebViewImpl::setUserInterfaceLayoutDirection):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::userInterfaceLayoutDirection):
(WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::hasHadSelectionChangesFromUserInteraction):
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_userInterfaceLayoutDirection):
(WebKit::WebPage::setResourceCachingDisabled):
(WebKit::WebPage::setUserInterfaceLayoutDirection):
(WebKit::m_shouldDispatchFakeMouseMoveEvents): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performNonEditingBehaviorForSelector):

Tools:

Add tests for flipping the behavior of command-left and command-right
under RTL mode.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm: Added.
(-[CommandBackForwardOffscreenWindow isKeyWindow]):
(-[CommandBackForwardOffscreenWindow isVisible]):
(simulateCommandArrow):
(WebKit2_CommandBackForwardTest::SetUp):
(WebKit2_CommandBackForwardTestWKView::didFinishLoadForFrame):
(WebKit2_CommandBackForwardTestWKView::SetUp):
(WebKit2_CommandBackForwardTestWKView::loadFiles):
(-[CommandBackForwardNavigationDelegate webView:didFinishNavigation:]):
(WebKit2_CommandBackForwardTestWKWebView::SetUp):
(WebKit2_CommandBackForwardTestWKWebView::loadFiles):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParameterscpp">trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPageCreationParametersh">trunk/Source/WebKit2/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaCommandBackForwardmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2016-06-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Forward/Back keyboard shortcuts need to flip for RTL
+        https://bugs.webkit.org/show_bug.cgi?id=158823
+        &lt;rdar://problem/25975359&gt;
+
+        Reviewed by Darin Adler.
+
+        Pipe the UserInterfaceLayoutDirection down to the WebContentProcess on initialization
+        and when it changes, and use it to flip the behavior of command-left and command-right
+        when in RTL mode.
+
+        Tests:
+            WebKit2_CommandBackForwardTestWKView.LTR
+            WebKit2_CommandBackForwardTestWKView.RTL
+            WebKit2_CommandBackForwardTestWKWebView.LTR
+            WebKit2_CommandBackForwardTestWKWebView.RTL
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _webViewPrintFormatter]):
+        (-[WKWebView setSemanticContentAttribute:]):
+        (-[WKWebView _printOperationWithPrintInfo:forFrame:]):
+        (-[WKWebView setUserInterfaceLayoutDirection:]):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView setUserInterfaceLayoutDirection:]):
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::windowIsFrontWindowUnderMouse):
+        (WebKit::toUserInterfaceLayoutDirection):
+        (WebKit::WebViewImpl::userInterfaceLayoutDirection):
+        (WebKit::WebViewImpl::setUserInterfaceLayoutDirection):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        (WebKit::WebPageProxy::userInterfaceLayoutDirection):
+        (WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::hasHadSelectionChangesFromUserInteraction):
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_userInterfaceLayoutDirection):
+        (WebKit::WebPage::setResourceCachingDisabled):
+        (WebKit::WebPage::setUserInterfaceLayoutDirection):
+        (WebKit::m_shouldDispatchFakeMouseMoveEvents): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performNonEditingBehaviorForSelector):
+
</ins><span class="cx"> 2016-06-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expose _shouldExpandContentToViewHeightForAutoLayout SPI on WKWebView
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -86,6 +86,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     encoder &lt;&lt; appleMailPaginationQuirkEnabled;
</span><span class="cx">     encoder &lt;&lt; shouldScaleViewToFitDocument;
</span><ins>+    encoder.encodeEnum(userInterfaceLayoutDirection);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPageCreationParameters::decode(IPC::ArgumentDecoder&amp; decoder, WebPageCreationParameters&amp; parameters)
</span><span class="lines">@@ -194,6 +195,9 @@
</span><span class="cx">     if (!decoder.decode(parameters.shouldScaleViewToFitDocument))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decodeEnum(parameters.userInterfaceLayoutDirection))
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;DrawingAreaInfo.h&quot;
</span><span class="cx"> #include &quot;LayerTreeContext.h&quot;
</span><span class="cx"> #include &quot;SessionState.h&quot;
</span><ins>+#include &quot;UserInterfaceLayoutDirection.h&quot;
</ins><span class="cx"> #include &quot;WebCoreArgumentCoders.h&quot;
</span><span class="cx"> #include &quot;WebPageGroupData.h&quot;
</span><span class="cx"> #include &quot;WebPreferencesStore.h&quot;
</span><span class="lines">@@ -133,6 +134,8 @@
</span><span class="cx"> #endif
</span><span class="cx">     bool appleMailPaginationQuirkEnabled;
</span><span class="cx">     bool shouldScaleViewToFitDocument;
</span><ins>+
+    UserInterfaceLayoutDirection userInterfaceLayoutDirection;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -4298,6 +4298,27 @@
</span><span class="cx">     return (_WKWebViewPrintFormatter *)viewPrintFormatter;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static WebKit::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISemanticContentAttribute contentAttribute)
+{
+    auto direction = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:contentAttribute];
+    switch (direction) {
+    case UIUserInterfaceLayoutDirectionLeftToRight:
+        return WebKit::UserInterfaceLayoutDirection::LTR;
+    case UIUserInterfaceLayoutDirectionRightToLeft:
+        return WebKit::UserInterfaceLayoutDirection::RTL;
+    }
+
+    ASSERT_NOT_REACHED();
+    return WebKit::UserInterfaceLayoutDirection::LTR;
+}
+
+- (void)setSemanticContentAttribute:(UISemanticContentAttribute)contentAttribute
+{
+    [super setSemanticContentAttribute:contentAttribute];
+
+    _page-&gt;setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(contentAttribute));
+}
+
</ins><span class="cx"> #else // #if PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - OS X-specific methods
</span><span class="lines">@@ -4424,6 +4445,13 @@
</span><span class="cx">     return nil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection
+{
+    [super setUserInterfaceLayoutDirection:userInterfaceLayoutDirection];
+
+    _impl-&gt;setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -1435,6 +1435,13 @@
</span><span class="cx">     return _data-&gt;_impl-&gt;automaticallyAdjustsContentInsets();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection
+{
+    [super setUserInterfaceLayoutDirection:userInterfaceLayoutDirection];
+
+    _data-&gt;_impl-&gt;setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PluginComplexTextInputState.h&quot;
</span><ins>+#include &quot;UserInterfaceLayoutDirection.h&quot;
</ins><span class="cx"> #include &quot;WKLayoutMode.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> #include &quot;_WKOverlayScrollbarStyle.h&quot;
</span><span class="lines">@@ -485,6 +486,9 @@
</span><span class="cx">     void setRequiresUserActionForEditingControlsManager(bool requiresUserActionForEditingControlsManager) { m_requiresUserActionForEditingControlsManager = requiresUserActionForEditingControlsManager; }
</span><span class="cx">     bool requiresUserActionForEditingControlsManager() const { return m_requiresUserActionForEditingControlsManager; }
</span><span class="cx"> 
</span><ins>+    UserInterfaceLayoutDirection userInterfaceLayoutDirection();
+    void setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection);
+
</ins><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 
</span><span class="cx">     void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -4029,7 +4029,29 @@
</span><span class="cx">     return m_view.window.windowNumber != eventWindowNumber;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-    
</del><ins>+static UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
+{
+    switch (direction) {
+    case NSUserInterfaceLayoutDirectionLeftToRight:
+        return UserInterfaceLayoutDirection::LTR;
+    case NSUserInterfaceLayoutDirectionRightToLeft:
+        return UserInterfaceLayoutDirection::RTL;
+    }
+
+    ASSERT_NOT_REACHED();
+    return UserInterfaceLayoutDirection::LTR;
+}
+
+UserInterfaceLayoutDirection WebViewImpl::userInterfaceLayoutDirection()
+{
+    return toUserInterfaceLayoutDirection(m_view.userInterfaceLayoutDirection);
+}
+
+void WebViewImpl::setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
+{
+    m_page-&gt;setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(direction));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -5274,6 +5274,7 @@
</span><span class="cx">     parameters.appleMailPaginationQuirkEnabled = false;
</span><span class="cx"> #endif
</span><span class="cx">     parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
</span><ins>+    parameters.userInterfaceLayoutDirection = m_pageClient.userInterfaceLayoutDirection();
</ins><span class="cx"> 
</span><span class="cx">     return parameters;
</span><span class="cx"> }
</span><span class="lines">@@ -6311,4 +6312,12 @@
</span><span class="cx">     return m_pageClient.userInterfaceLayoutDirection();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection)
+{
+    if (!isValid())
+        return;
+
+    m_process-&gt;send(Messages::WebPage::SetUserInterfaceLayoutDirection(static_cast&lt;uint32_t&gt;(userInterfaceLayoutDirection)), m_pageID);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -1112,6 +1112,7 @@
</span><span class="cx">     void setResourceCachingDisabled(bool);
</span><span class="cx"> 
</span><span class="cx">     UserInterfaceLayoutDirection userInterfaceLayoutDirection();
</span><ins>+    void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
</ins><span class="cx"> 
</span><span class="cx">     bool hasHadSelectionChangesFromUserInteraction() const { return m_hasHadSelectionChangesFromUserInteraction; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -377,6 +377,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     , m_mainFrameProgressCompleted(false)
</span><span class="cx">     , m_shouldDispatchFakeMouseMoveEvents(true)
</span><ins>+    , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_pageID);
</span><span class="cx"> 
</span><span class="lines">@@ -5368,4 +5369,9 @@
</span><span class="cx">     m_page-&gt;setResourceCachingDisabled(disabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::setUserInterfaceLayoutDirection(uint32_t direction)
+{
+    m_userInterfaceLayoutDirection = static_cast&lt;UserInterfaceLayoutDirection&gt;(direction);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -23,8 +23,7 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef WebPage_h
-#define WebPage_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;APIInjectedBundleFormClient.h&quot;
</span><span class="cx"> #include &quot;APIInjectedBundlePageContextMenuClient.h&quot;
</span><span class="lines">@@ -48,6 +47,7 @@
</span><span class="cx"> #include &quot;SandboxExtension.h&quot;
</span><span class="cx"> #include &quot;ShareableBitmap.h&quot;
</span><span class="cx"> #include &quot;UserData.h&quot;
</span><ins>+#include &quot;UserInterfaceLayoutDirection.h&quot;
</ins><span class="cx"> #include &quot;UserMediaPermissionRequestManager.h&quot;
</span><span class="cx"> #include &lt;WebCore/DictationAlternative.h&gt;
</span><span class="cx"> #include &lt;WebCore/DictionaryPopupInfo.h&gt;
</span><span class="lines">@@ -1199,6 +1199,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void setResourceCachingDisabled(bool);
</span><ins>+    void setUserInterfaceLayoutDirection(uint32_t);
</ins><span class="cx"> 
</span><span class="cx">     uint64_t m_pageID;
</span><span class="cx"> 
</span><span class="lines">@@ -1468,8 +1469,9 @@
</span><span class="cx"> #if USE(OS_STATE)
</span><span class="cx">     std::chrono::system_clock::time_point m_loadCommitTime;
</span><span class="cx"> #endif
</span><ins>+
+    UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { UserInterfaceLayoutDirection::LTR };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><del>-#endif // WebPage_h
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -428,4 +428,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     SetResourceCachingDisabled(bool disabled)
</span><ins>+
+    SetUserInterfaceLayoutDirection(uint32_t direction)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -551,13 +551,13 @@
</span><span class="cx">     else if (selector == &quot;moveWordLeft:&quot;)
</span><span class="cx">         didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
</span><span class="cx">     else if (selector == &quot;moveToLeftEndOfLine:&quot;)
</span><del>-        didPerformAction = m_page-&gt;backForward().goBack();
</del><ins>+        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page-&gt;backForward().goBack() : m_page-&gt;backForward().goForward();
</ins><span class="cx">     else if (selector == &quot;moveRight:&quot;)
</span><span class="cx">         didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
</span><span class="cx">     else if (selector == &quot;moveWordRight:&quot;)
</span><span class="cx">         didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
</span><span class="cx">     else if (selector == &quot;moveToRightEndOfLine:&quot;)
</span><del>-        didPerformAction = m_page-&gt;backForward().goForward();
</del><ins>+        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page-&gt;backForward().goForward() : m_page-&gt;backForward().goBack();
</ins><span class="cx"> 
</span><span class="cx">     return didPerformAction;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Tools/ChangeLog        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-06-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Forward/Back keyboard shortcuts need to flip for RTL
+        https://bugs.webkit.org/show_bug.cgi?id=158823
+        &lt;rdar://problem/25975359&gt;
+
+        Reviewed by Darin Adler.
+
+        Add tests for flipping the behavior of command-left and command-right
+        under RTL mode.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm: Added.
+        (-[CommandBackForwardOffscreenWindow isKeyWindow]):
+        (-[CommandBackForwardOffscreenWindow isVisible]):
+        (simulateCommandArrow):
+        (WebKit2_CommandBackForwardTest::SetUp):
+        (WebKit2_CommandBackForwardTestWKView::didFinishLoadForFrame):
+        (WebKit2_CommandBackForwardTestWKView::SetUp):
+        (WebKit2_CommandBackForwardTestWKView::loadFiles):
+        (-[CommandBackForwardNavigationDelegate webView:didFinishNavigation:]):
+        (WebKit2_CommandBackForwardTestWKWebView::SetUp):
+        (WebKit2_CommandBackForwardTestWKWebView::loadFiles):
+
</ins><span class="cx"> 2016-06-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expose _shouldExpandContentToViewHeightForAutoLayout SPI on WKWebView
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (202128 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-06-16 17:43:43 UTC (rev 202128)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx">                 7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7A1458FB1AD5C03500E06772 /* mouse-button-listener.html */; };
</span><span class="cx">                 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; };
</span><span class="cx">                 7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* Color.cpp */; };
</span><ins>+                7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */; };
</ins><span class="cx">                 7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C486BA01AA1254B003F6F9B /* bundle-file.html */; };
</span><span class="cx">                 7C54A4BE1AA11CCA00380F78 /* WKBundleFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */; };
</span><span class="cx">                 7C54A4C11AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */; };
</span><span class="lines">@@ -748,6 +749,7 @@
</span><span class="cx">                 7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C3965051CDD74F90094DBB8 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommandBackForward.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7C486BA01AA1254B003F6F9B /* bundle-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = &quot;bundle-file.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1131,6 +1133,7 @@
</span><span class="cx">                                 A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
</span><span class="cx">                                 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */,
</span><span class="cx">                                 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */,
</span><ins>+                                7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */,
</ins><span class="cx">                                 A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */,
</span><span class="cx">                                 A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
</span><span class="cx">                                 A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
</span><span class="lines">@@ -2145,6 +2148,7 @@
</span><span class="cx">                                 7C882E0A1C80C764006BF731 /* UserContentWorld.mm in Sources */,
</span><span class="cx">                                 7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
</span><span class="cx">                                 7C83E04F1D0A641800FEBCF3 /* FileSystem.cpp in Sources */,
</span><ins>+                                7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */,
</ins><span class="cx">                                 7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
</span><span class="cx">                                 7CCE7F171A411AE600447C4C /* UserMedia.cpp in Sources */,
</span><span class="cx">                                 7C83E0C41D0A654200FEBCF3 /* RequiresUserActionForPlayback.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaCommandBackForwardmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm (0 => 202129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm        2016-06-16 17:54:33 UTC (rev 202129)
</span><span class="lines">@@ -0,0 +1,301 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+
+#if PLATFORM(MAC)
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;Test.h&quot;
+#import &lt;Carbon/Carbon.h&gt; // for GetCurrentEventTime()
+#import &lt;WebKit/WKRetainPtr.h&gt;
+#import &lt;WebKit/WKViewPrivate.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+@interface CommandBackForwardOffscreenWindow : NSWindow
+@end
+
+@implementation CommandBackForwardOffscreenWindow
+- (BOOL)isKeyWindow
+{
+    return YES;
+}
+- (BOOL)isVisible
+{
+    return YES;
+}
+@end
+
+enum ArrowDirection {
+    Left,
+    Right
+};
+
+static void simulateCommandArrow(NSView *view, ArrowDirection direction)
+{
+    const unichar right = NSRightArrowFunctionKey;
+    const unichar left = NSLeftArrowFunctionKey;
+
+    NSString *eventCharacter = (direction == Left) ? [NSString stringWithCharacters:&amp;left length:1] : [NSString stringWithCharacters:&amp;right length:1];
+    unsigned short keyCode = (direction == Left) ? 0x7B : 0x7C;
+
+    NSEvent *event = [NSEvent keyEventWithType:NSKeyDown
+                                      location:NSMakePoint(5, 5)
+                                 modifierFlags:NSCommandKeyMask
+                                     timestamp:GetCurrentEventTime()
+                                  windowNumber:[view.window windowNumber]
+                                       context:[NSGraphicsContext currentContext]
+                                    characters:eventCharacter
+                   charactersIgnoringModifiers:eventCharacter
+                                     isARepeat:NO
+                                       keyCode:keyCode];
+
+    [view keyDown:event];
+
+    event = [NSEvent keyEventWithType:NSKeyUp
+                             location:NSMakePoint(5, 5)
+                        modifierFlags:NSCommandKeyMask
+                            timestamp:GetCurrentEventTime()
+                         windowNumber:[view.window windowNumber]
+                              context:[NSGraphicsContext currentContext]
+                           characters:eventCharacter
+          charactersIgnoringModifiers:eventCharacter
+                            isARepeat:NO
+                              keyCode:keyCode];
+
+    [view keyUp:event];
+}
+
+class WebKit2_CommandBackForwardTest : public testing::Test {
+public:
+    RetainPtr&lt;NSWindow&gt; window;
+
+    virtual void SetUp()
+    {
+        NSWindow *window = [[CommandBackForwardOffscreenWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+        [window setColorSpace:[[NSScreen mainScreen] colorSpace]];
+        [window orderBack:nil];
+        [window setAutodisplay:NO];
+        [window setReleasedWhenClosed:NO];
+    }
+};
+
+static bool didFinishNavigation;
+
+class WebKit2_CommandBackForwardTestWKView : public WebKit2_CommandBackForwardTest {
+public:
+    RetainPtr&lt;WKView&gt; webView;
+    WKRetainPtr&lt;WKURLRef&gt; file1;
+    WKRetainPtr&lt;WKURLRef&gt; file2;
+
+    static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo)
+    {
+        didFinishNavigation = true;
+    }
+
+    virtual void SetUp()
+    {
+        WebKit2_CommandBackForwardTest::SetUp();
+
+        WKRetainPtr&lt;WKContextRef&gt; context = adoptWK(WKContextCreate());
+        WKRetainPtr&lt;WKPageConfigurationRef&gt; configuration = adoptWK(WKPageConfigurationCreate());        
+        WKPageConfigurationSetContext(configuration.get(), context.get());
+
+        webView = [[WKView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configurationRef:configuration.get()];
+
+        WKPageLoaderClientV6 loaderClient;
+        memset(&amp;loaderClient, 0, sizeof(loaderClient));
+
+        loaderClient.base.version = 6;
+        loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+        WKPageSetPageLoaderClient([webView pageRef], &amp;loaderClient.base);
+        
+        file1 = adoptWK(TestWebKitAPI::Util::createURLForResource(&quot;simple&quot;, &quot;html&quot;));
+        file2 = adoptWK(TestWebKitAPI::Util::createURLForResource(&quot;simple2&quot;, &quot;html&quot;));
+
+    }
+
+    void loadFiles()
+    {
+        WKPageLoadFile([webView pageRef], file1.get(), nullptr);
+        TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+        didFinishNavigation = false;
+
+        WKPageLoadFile([webView pageRef], file2.get(), nullptr);
+        TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+        didFinishNavigation = false;
+    }
+};
+
+#if WK_API_ENABLED
+
+@interface CommandBackForwardNavigationDelegate : NSObject &lt;WKNavigationDelegate&gt;
+@end
+
+@implementation CommandBackForwardNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    didFinishNavigation = true;
+}
+
+@end
+
+
+class WebKit2_CommandBackForwardTestWKWebView : public WebKit2_CommandBackForwardTest {
+public:
+    RetainPtr&lt;WKWebView&gt; webView;
+
+    virtual void SetUp()
+    {
+        WebKit2_CommandBackForwardTest::SetUp();
+
+        webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
+        [[window contentView] addSubview:webView.get()];
+
+        CommandBackForwardNavigationDelegate *delegate = [[CommandBackForwardNavigationDelegate alloc] init];
+        [webView setNavigationDelegate:delegate];
+    }
+    
+    void loadFiles()
+    {
+        NSURL *file1 = [[NSBundle mainBundle] URLForResource:@&quot;simple&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;];
+        [webView loadFileURL:file1 allowingReadAccessToURL:file1];
+
+        TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+        didFinishNavigation = false;
+
+        NSURL *file2 = [[NSBundle mainBundle] URLForResource:@&quot;simple2&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;];
+        [webView loadFileURL:file2 allowingReadAccessToURL:file2];
+
+        TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+        didFinishNavigation = false;
+    }
+};
+
+TEST_F(WebKit2_CommandBackForwardTestWKWebView, LTR)
+{
+    EXPECT_EQ(NSUserInterfaceLayoutDirectionLeftToRight, [webView userInterfaceLayoutDirection]);
+    
+    loadFiles();
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple2.html&quot;);
+
+    // Attempt to go back (using command-left).
+    simulateCommandArrow(webView.get(), Left);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple.html&quot;);
+
+    // Attempt to go back (using command-right).
+    simulateCommandArrow(webView.get(), Right);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple2.html&quot;);
+}
+
+TEST_F(WebKit2_CommandBackForwardTestWKWebView, RTL)
+{
+    // Override the layout direction to be RTL.
+    [webView setUserInterfaceLayoutDirection:NSUserInterfaceLayoutDirectionRightToLeft];
+    
+    loadFiles();
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple2.html&quot;);
+
+    // Attempt to go back (using command-right)
+    simulateCommandArrow(webView.get(), Right);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple.html&quot;);
+
+    // Attempt to go back (using command-left).
+    simulateCommandArrow(webView.get(), Left);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    EXPECT_WK_STREQ([webView URL].path.lastPathComponent, @&quot;simple2.html&quot;);
+}
+
+#endif
+
+TEST_F(WebKit2_CommandBackForwardTestWKView, LTR)
+{
+    EXPECT_EQ(NSUserInterfaceLayoutDirectionLeftToRight, [webView userInterfaceLayoutDirection]);
+    
+    loadFiles();
+
+    auto currentURL = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file2.get(), currentURL.get()));
+
+    // Attempt to go back (using command-left).
+    simulateCommandArrow(webView.get(), Left);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    auto currentURL2 = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file1.get(), currentURL2.get()));
+
+    // Attempt to go back (using command-right).
+    simulateCommandArrow(webView.get(), Right);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    auto currentURL3 = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file2.get(), currentURL3.get()));
+}
+
+TEST_F(WebKit2_CommandBackForwardTestWKView, RTL)
+{
+    // Override the layout direction to be RTL.
+    [webView setUserInterfaceLayoutDirection:NSUserInterfaceLayoutDirectionRightToLeft];
+    
+    loadFiles();
+
+    auto currentURL = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file2.get(), currentURL.get()));
+
+    // Attempt to go back (using command-right)
+    simulateCommandArrow(webView.get(), Right);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    auto currentURL2 = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file1.get(), currentURL2.get()));
+
+    // Attempt to go back (using command-left).
+    simulateCommandArrow(webView.get(), Left);
+    TestWebKitAPI::Util::run(&amp;didFinishNavigation);
+    didFinishNavigation = false;
+
+    auto currentURL3 = adoptWK(WKPageCopyActiveURL([webView pageRef]));
+    EXPECT_TRUE(WKURLIsEqual(file2.get(), currentURL3.get()));
+}
+
+#endif // PLATFORM(MAC)
</ins></span></pre>
</div>
</div>

</body>
</html>