Changeset 202129 in webkit


Ignore:
Timestamp:
Jun 16, 2016, 10:54:33 AM (9 years ago)
Author:
weinig@apple.com
Message:

Forward/Back keyboard shortcuts need to flip for RTL
https://bugs.webkit.org/show_bug.cgi?id=158823
<rdar://problem/25975359>

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):

Location:
trunk
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r202120 r202129  
     12016-06-15  Sam Weinig  <sam@webkit.org>
     2
     3        Forward/Back keyboard shortcuts need to flip for RTL
     4        https://bugs.webkit.org/show_bug.cgi?id=158823
     5        <rdar://problem/25975359>
     6
     7        Reviewed by Darin Adler.
     8
     9        Pipe the UserInterfaceLayoutDirection down to the WebContentProcess on initialization
     10        and when it changes, and use it to flip the behavior of command-left and command-right
     11        when in RTL mode.
     12
     13        Tests:
     14            WebKit2_CommandBackForwardTestWKView.LTR
     15            WebKit2_CommandBackForwardTestWKView.RTL
     16            WebKit2_CommandBackForwardTestWKWebView.LTR
     17            WebKit2_CommandBackForwardTestWKWebView.RTL
     18
     19        * Shared/WebPageCreationParameters.cpp:
     20        (WebKit::WebPageCreationParameters::encode):
     21        (WebKit::WebPageCreationParameters::decode):
     22        * Shared/WebPageCreationParameters.h:
     23        * UIProcess/API/Cocoa/WKWebView.mm:
     24        (-[WKWebView _webViewPrintFormatter]):
     25        (-[WKWebView setSemanticContentAttribute:]):
     26        (-[WKWebView _printOperationWithPrintInfo:forFrame:]):
     27        (-[WKWebView setUserInterfaceLayoutDirection:]):
     28        * UIProcess/API/mac/WKView.mm:
     29        (-[WKView setUserInterfaceLayoutDirection:]):
     30        * UIProcess/Cocoa/WebViewImpl.h:
     31        * UIProcess/Cocoa/WebViewImpl.mm:
     32        (WebKit::WebViewImpl::windowIsFrontWindowUnderMouse):
     33        (WebKit::toUserInterfaceLayoutDirection):
     34        (WebKit::WebViewImpl::userInterfaceLayoutDirection):
     35        (WebKit::WebViewImpl::setUserInterfaceLayoutDirection):
     36        * UIProcess/WebPageProxy.cpp:
     37        (WebKit::WebPageProxy::creationParameters):
     38        (WebKit::WebPageProxy::userInterfaceLayoutDirection):
     39        (WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
     40        * UIProcess/WebPageProxy.h:
     41        (WebKit::WebPageProxy::hasHadSelectionChangesFromUserInteraction):
     42        * UIProcess/ios/WKContentView.mm:
     43        (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
     44        * WebProcess/WebPage/WebPage.cpp:
     45        (WebKit::m_userInterfaceLayoutDirection):
     46        (WebKit::WebPage::setResourceCachingDisabled):
     47        (WebKit::WebPage::setUserInterfaceLayoutDirection):
     48        (WebKit::m_shouldDispatchFakeMouseMoveEvents): Deleted.
     49        * WebProcess/WebPage/WebPage.h:
     50        * WebProcess/WebPage/WebPage.messages.in:
     51        * WebProcess/WebPage/mac/WebPageMac.mm:
     52        (WebKit::WebPage::performNonEditingBehaviorForSelector):
     53
    1542016-06-15  Tim Horton  <timothy_horton@apple.com>
    255
  • trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp

    r198901 r202129  
    8787    encoder << appleMailPaginationQuirkEnabled;
    8888    encoder << shouldScaleViewToFitDocument;
     89    encoder.encodeEnum(userInterfaceLayoutDirection);
    8990}
    9091
     
    195196        return false;
    196197
     198    if (!decoder.decodeEnum(parameters.userInterfaceLayoutDirection))
     199        return false;
     200
    197201    return true;
    198202}
  • trunk/Source/WebKit2/Shared/WebPageCreationParameters.h

    r198901 r202129  
    3030#include "LayerTreeContext.h"
    3131#include "SessionState.h"
     32#include "UserInterfaceLayoutDirection.h"
    3233#include "WebCoreArgumentCoders.h"
    3334#include "WebPageGroupData.h"
     
    134135    bool appleMailPaginationQuirkEnabled;
    135136    bool shouldScaleViewToFitDocument;
     137
     138    UserInterfaceLayoutDirection userInterfaceLayoutDirection;
    136139};
    137140
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r202120 r202129  
    42994299}
    43004300
     4301static WebKit::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISemanticContentAttribute contentAttribute)
     4302{
     4303    auto direction = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:contentAttribute];
     4304    switch (direction) {
     4305    case UIUserInterfaceLayoutDirectionLeftToRight:
     4306        return WebKit::UserInterfaceLayoutDirection::LTR;
     4307    case UIUserInterfaceLayoutDirectionRightToLeft:
     4308        return WebKit::UserInterfaceLayoutDirection::RTL;
     4309    }
     4310
     4311    ASSERT_NOT_REACHED();
     4312    return WebKit::UserInterfaceLayoutDirection::LTR;
     4313}
     4314
     4315- (void)setSemanticContentAttribute:(UISemanticContentAttribute)contentAttribute
     4316{
     4317    [super setSemanticContentAttribute:contentAttribute];
     4318
     4319    _page->setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(contentAttribute));
     4320}
     4321
    43014322#else // #if PLATFORM(IOS)
    43024323
     
    44234444        return _impl->printOperationWithPrintInfo(printInfo, *webFrameProxy);
    44244445    return nil;
     4446}
     4447
     4448- (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection
     4449{
     4450    [super setUserInterfaceLayoutDirection:userInterfaceLayoutDirection];
     4451
     4452    _impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
    44254453}
    44264454
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r201298 r202129  
    14361436}
    14371437
     1438- (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection
     1439{
     1440    [super setUserInterfaceLayoutDirection:userInterfaceLayoutDirection];
     1441
     1442    _data->_impl->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection);
     1443}
     1444
    14381445@end
    14391446
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h

    r201838 r202129  
    3030
    3131#include "PluginComplexTextInputState.h"
     32#include "UserInterfaceLayoutDirection.h"
    3233#include "WKLayoutMode.h"
    3334#include "WebPageProxy.h"
     
    486487    bool requiresUserActionForEditingControlsManager() const { return m_requiresUserActionForEditingControlsManager; }
    487488
     489    UserInterfaceLayoutDirection userInterfaceLayoutDirection();
     490    void setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection);
     491
    488492#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    489493    void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm

    r201441 r202129  
    40304030}
    40314031
    4032    
     4032static UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
     4033{
     4034    switch (direction) {
     4035    case NSUserInterfaceLayoutDirectionLeftToRight:
     4036        return UserInterfaceLayoutDirection::LTR;
     4037    case NSUserInterfaceLayoutDirectionRightToLeft:
     4038        return UserInterfaceLayoutDirection::RTL;
     4039    }
     4040
     4041    ASSERT_NOT_REACHED();
     4042    return UserInterfaceLayoutDirection::LTR;
     4043}
     4044
     4045UserInterfaceLayoutDirection WebViewImpl::userInterfaceLayoutDirection()
     4046{
     4047    return toUserInterfaceLayoutDirection(m_view.userInterfaceLayoutDirection);
     4048}
     4049
     4050void WebViewImpl::setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
     4051{
     4052    m_page->setUserInterfaceLayoutDirection(toUserInterfaceLayoutDirection(direction));
     4053}
     4054
    40334055} // namespace WebKit
    40344056
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r201958 r202129  
    52755275#endif
    52765276    parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
     5277    parameters.userInterfaceLayoutDirection = m_pageClient.userInterfaceLayoutDirection();
    52775278
    52785279    return parameters;
     
    63126313}
    63136314
     6315void WebPageProxy::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection)
     6316{
     6317    if (!isValid())
     6318        return;
     6319
     6320    m_process->send(Messages::WebPage::SetUserInterfaceLayoutDirection(static_cast<uint32_t>(userInterfaceLayoutDirection)), m_pageID);
     6321}
     6322
    63146323} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r201958 r202129  
    11131113
    11141114    UserInterfaceLayoutDirection userInterfaceLayoutDirection();
     1115    void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
    11151116
    11161117    bool hasHadSelectionChangesFromUserInteraction() const { return m_hasHadSelectionChangesFromUserInteraction; }
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r202105 r202129  
    378378    , m_mainFrameProgressCompleted(false)
    379379    , m_shouldDispatchFakeMouseMoveEvents(true)
     380    , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
    380381{
    381382    ASSERT(m_pageID);
     
    53695370}
    53705371
     5372void WebPage::setUserInterfaceLayoutDirection(uint32_t direction)
     5373{
     5374    m_userInterfaceLayoutDirection = static_cast<UserInterfaceLayoutDirection>(direction);
     5375}
     5376
    53715377} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r201888 r202129  
    2424 */
    2525
    26 #ifndef WebPage_h
    27 #define WebPage_h
     26#pragma once
    2827
    2928#include "APIInjectedBundleFormClient.h"
     
    4948#include "ShareableBitmap.h"
    5049#include "UserData.h"
     50#include "UserInterfaceLayoutDirection.h"
    5151#include "UserMediaPermissionRequestManager.h"
    5252#include <WebCore/DictationAlternative.h>
     
    12001200
    12011201    void setResourceCachingDisabled(bool);
     1202    void setUserInterfaceLayoutDirection(uint32_t);
    12021203
    12031204    uint64_t m_pageID;
     
    14691470    std::chrono::system_clock::time_point m_loadCommitTime;
    14701471#endif
     1472
     1473    UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { UserInterfaceLayoutDirection::LTR };
    14711474};
    14721475
    14731476} // namespace WebKit
    14741477
    1475 #endif // WebPage_h
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r201888 r202129  
    429429
    430430    SetResourceCachingDisabled(bool disabled)
     431
     432    SetUserInterfaceLayoutDirection(uint32_t direction)
    431433}
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r200957 r202129  
    552552        didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
    553553    else if (selector == "moveToLeftEndOfLine:")
    554         didPerformAction = m_page->backForward().goBack();
     554        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page->backForward().goBack() : m_page->backForward().goForward();
    555555    else if (selector == "moveRight:")
    556556        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
     
    558558        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
    559559    else if (selector == "moveToRightEndOfLine:")
    560         didPerformAction = m_page->backForward().goForward();
     560        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page->backForward().goForward() : m_page->backForward().goBack();
    561561
    562562    return didPerformAction;
  • trunk/Tools/ChangeLog

    r202120 r202129  
     12016-06-15  Sam Weinig  <sam@webkit.org>
     2
     3        Forward/Back keyboard shortcuts need to flip for RTL
     4        https://bugs.webkit.org/show_bug.cgi?id=158823
     5        <rdar://problem/25975359>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add tests for flipping the behavior of command-left and command-right
     10        under RTL mode.
     11
     12        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     13        * TestWebKitAPI/Tests/WebKit2Cocoa/CommandBackForward.mm: Added.
     14        (-[CommandBackForwardOffscreenWindow isKeyWindow]):
     15        (-[CommandBackForwardOffscreenWindow isVisible]):
     16        (simulateCommandArrow):
     17        (WebKit2_CommandBackForwardTest::SetUp):
     18        (WebKit2_CommandBackForwardTestWKView::didFinishLoadForFrame):
     19        (WebKit2_CommandBackForwardTestWKView::SetUp):
     20        (WebKit2_CommandBackForwardTestWKView::loadFiles):
     21        (-[CommandBackForwardNavigationDelegate webView:didFinishNavigation:]):
     22        (WebKit2_CommandBackForwardTestWKWebView::SetUp):
     23        (WebKit2_CommandBackForwardTestWKWebView::loadFiles):
     24
    1252016-06-15  Tim Horton  <timothy_horton@apple.com>
    226
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r201941 r202129  
    9999                7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; };
    100100                7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* Color.cpp */; };
     101                7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */; };
    101102                7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C486BA01AA1254B003F6F9B /* bundle-file.html */; };
    102103                7C54A4BE1AA11CCA00380F78 /* WKBundleFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */; };
     
    749750                7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = "<group>"; };
    750751                7C3965051CDD74F90094DBB8 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
     752                7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommandBackForward.mm; sourceTree = "<group>"; };
    751753                7C486BA01AA1254B003F6F9B /* bundle-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "bundle-file.html"; sourceTree = "<group>"; };
    752754                7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle.cpp; sourceTree = "<group>"; };
     
    11321134                                1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */,
    11331135                                1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */,
     1136                                7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */,
    11341137                                A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */,
    11351138                                A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
     
    21462149                                7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
    21472150                                7C83E04F1D0A641800FEBCF3 /* FileSystem.cpp in Sources */,
     2151                                7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */,
    21482152                                7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
    21492153                                7CCE7F171A411AE600447C4C /* UserMedia.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.