Title: [202183] trunk
Revision
202183
Author
[email protected]
Date
2016-06-17 15:24:52 -0700 (Fri, 17 Jun 2016)

Log Message

Web video playback controls should have RTL volume slider
https://bugs.webkit.org/show_bug.cgi?id=158856
<rdar://problem/25971769>

Patch by Antoine Quint <[email protected]> on 2016-06-17
Reviewed by Tim Horton.

Source/WebCore:

We reproduce the system used to propagate the page scale factor from the WebPage to the media controls to
propagate the user interface layout direction.

The Page exposes a new setUserInterfaceLayoutDirection() method which is set by the WebPage. The Page
then notifies the Document of a change, which propagates down to registered media elements, and finally sets
the usesLTRUserInterfaceLayoutDirection property on the media controller object in the injected _javascript_.
Based on the value of that property we toggle a new .uses-ltr-user-interface-layout-direction CSS class on the
.volume-box which applies a translate to the right and flips the volume controls on the x axis.

Since we're setting a new JS property from HTMLMediaController, we refactor much of the code out of the existing
pageScaleFactorChanged() and setPageScaleFactorProperty() into the new setControllerJSProperty() method so that
can easily set a named JS property with a given JSValue.

For testing purposes, we expose the WebCore::Page::setUserInterfaceLayoutDirection() method through Internals.

Test: fullscreen/video-controls-rtl.html

* Modules/mediacontrols/mediaControlsApple.css:
(video:-webkit-full-screen::-webkit-media-controls-panel .volume-box:not(.uses-ltr-user-interface-layout-direction)):
* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.set usesLTRUserInterfaceLayoutDirection):
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::registerForUserInterfaceLayoutDirectionChangedCallbacks):
(WebCore::Document::unregisterForUserInterfaceLayoutDirectionChangedCallbacks):
(WebCore::Document::userInterfaceLayoutDirectionChanged):
* dom/Document.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::registerWithDocument):
(WebCore::HTMLMediaElement::unregisterWithDocument):
(WebCore::HTMLMediaElement::updatePageScaleFactorJSProperty):
(WebCore::HTMLMediaElement::updateUsesLTRUserInterfaceLayoutDirectionJSProperty):
(WebCore::HTMLMediaElement::setControllerJSProperty):
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
(WebCore::HTMLMediaElement::pageScaleFactorChanged):
(WebCore::HTMLMediaElement::userInterfaceLayoutDirectionChanged):
(WebCore::setPageScaleFactorProperty): Deleted.
* html/HTMLMediaElement.h:
* page/Page.cpp:
(WebCore::Page::setUserInterfaceLayoutDirection):
* page/Page.h:
(WebCore::Page::userInterfaceLayoutDirection):
* platform/UserInterfaceLayoutDirection.h: Renamed from Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h.
* testing/Internals.cpp:
(WebCore::Internals::setUserInterfaceLayoutDirection):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

We now call setUserInterfaceLayoutDirection() on WebCore::Page to propagate
the user interface layout direction down to the Web content. To facilitate this,
the UserInterfaceLayoutDirection enum is now defined in WebCore.

* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(convertSystemLayoutDirection):
(toUserInterfaceLayoutDirection):
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::toUserInterfaceLayoutDirection):
(WebKit::WebViewImpl::userInterfaceLayoutDirection):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::userInterfaceLayoutDirection):
(WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
* UIProcess/WebPageProxy.h:
* UIProcess/efl/WebView.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::userInterfaceLayoutDirection):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::userInterfaceLayoutDirection):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
(WebKit::ViewGestureController::isPhysicallySwipingLeft):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_userInterfaceLayoutDirection):
(WebKit::WebPage::setUserInterfaceLayoutDirection):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performNonEditingBehaviorForSelector):

LayoutTests:

New test that checks that the volume box has the correct CSS class name and the expected
CSS transform value applied to it when the user interface layout direction is right-to-left
and that changing the user interface layout direction dynamically update the media element
shadow tree as expected.

* fullscreen/video-controls-rtl-expected.txt: Added.
* fullscreen/video-controls-rtl.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202182 => 202183)


--- trunk/LayoutTests/ChangeLog	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/LayoutTests/ChangeLog	2016-06-17 22:24:52 UTC (rev 202183)
@@ -1,3 +1,19 @@
+2016-06-17  Antoine Quint  <[email protected]>
+
+        Web video playback controls should have RTL volume slider
+        https://bugs.webkit.org/show_bug.cgi?id=158856
+        <rdar://problem/25971769>
+
+        Reviewed by Tim Horton.
+
+        New test that checks that the volume box has the correct CSS class name and the expected
+        CSS transform value applied to it when the user interface layout direction is right-to-left
+        and that changing the user interface layout direction dynamically update the media element
+        shadow tree as expected.
+
+        * fullscreen/video-controls-rtl-expected.txt: Added.
+        * fullscreen/video-controls-rtl.html: Added.
+
 2016-06-17  Ryan Haddad  <[email protected]>
 
         Update LayoutTest fast/canvas/canvas-composite-text-alpha.html

Added: trunk/LayoutTests/fullscreen/video-controls-rtl-expected.txt (0 => 202183)


--- trunk/LayoutTests/fullscreen/video-controls-rtl-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/video-controls-rtl-expected.txt	2016-06-17 22:24:52 UTC (rev 202183)
@@ -0,0 +1,14 @@
+This tests that the video element's controls in full screen mode flip the layout of the volume controls in RTL mode.
+
+
+EVENT(webkitfullscreenchange)
+EXPECTED (shadowRoot = internals.shadowRoot(video) != 'null') OK
+EXPECTED (volumeBox = mediaControlsElement(shadowRoot.firstChild, '-webkit-media-controls-volume-slider-container') != 'null') OK
+EXPECTED (volumeBox.classList.contains('uses-ltr-user-interface-layout-direction') == 'true') OK
+EXPECTED (document.defaultView.getComputedStyle(volumeBox)['transform'] == 'none') OK
+EXPECTED (volumeBox.classList.contains('uses-ltr-user-interface-layout-direction') == 'false') OK
+EXPECTED (document.defaultView.getComputedStyle(volumeBox)['transform'] == 'matrix(-1, 0, 0, 1, 23, 0)') OK
+EXPECTED (volumeBox.classList.contains('uses-ltr-user-interface-layout-direction') == 'true') OK
+EXPECTED (document.defaultView.getComputedStyle(volumeBox)['transform'] == 'none') OK
+END OF TEST
+

Added: trunk/LayoutTests/fullscreen/video-controls-rtl.html (0 => 202183)


--- trunk/LayoutTests/fullscreen/video-controls-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/video-controls-rtl.html	2016-06-17 22:24:52 UTC (rev 202183)
@@ -0,0 +1,34 @@
+<body>
+    <p>This tests that the video element's controls in full screen mode flip the layout of the volume controls in RTL mode.</p>
+    <video id="video" width="300"></video>
+    <script src=""
+    <script src=""
+    <script>
+        var callback;
+        var shadowRoot;
+        var volumeBox;
+        var video = document.getElementById('video');
+
+        waitForEvent(document, 'webkitfullscreenchange', function() {
+            if (window.internals) {
+                testExpected("shadowRoot = internals.shadowRoot(video)", null, "!=");
+                testExpected("volumeBox = mediaControlsElement(shadowRoot.firstChild, '-webkit-media-controls-volume-slider-container')", null, "!=");
+                testExpected("volumeBox.classList.contains('uses-ltr-user-interface-layout-direction')", true, "==");
+                testExpected("document.defaultView.getComputedStyle(volumeBox)['transform']", 'none', "==");
+
+                window.internals.setUserInterfaceLayoutDirection("RTL");
+                testExpected("volumeBox.classList.contains('uses-ltr-user-interface-layout-direction')", false, "==");
+                testExpected("document.defaultView.getComputedStyle(volumeBox)['transform']", 'matrix(-1, 0, 0, 1, 23, 0)', "==");
+
+                window.internals.setUserInterfaceLayoutDirection("LTR");
+                testExpected("volumeBox.classList.contains('uses-ltr-user-interface-layout-direction')", true, "==");
+                testExpected("document.defaultView.getComputedStyle(volumeBox)['transform']", 'none', "==");
+            } else
+                logResult(false, "window.internals == undefined");
+
+            endTest();
+        });
+
+        runWithKeyDown(function() { video.webkitRequestFullScreen() });
+    </script>
+</body>

Modified: trunk/LayoutTests/platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt (202182 => 202183)


--- trunk/LayoutTests/platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/LayoutTests/platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt	2016-06-17 22:24:52 UTC (rev 202183)
@@ -15,7 +15,7 @@
 -webkit-media-controls-play-button: classes: [paused]
 -webkit-media-controls-status-display: classes: []
 none: classes: [mute-box]
--webkit-media-controls-volume-slider-container: classes: [volume-box]
+-webkit-media-controls-volume-slider-container: classes: [volume-box uses-ltr-user-interface-layout-direction]
 -webkit-media-controls-volume-slider-container-background: classes: []
 -webkit-media-controls-volume-slider-container-tint: classes: []
 -webkit-media-controls-volume-slider: classes: []

Modified: trunk/LayoutTests/platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt (202182 => 202183)


--- trunk/LayoutTests/platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/LayoutTests/platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt	2016-06-17 22:24:52 UTC (rev 202183)
@@ -15,7 +15,7 @@
 -webkit-media-controls-play-button: classes: [paused]
 -webkit-media-controls-status-display: classes: []
 none: classes: [mute-box]
--webkit-media-controls-volume-slider-container: classes: [volume-box]
+-webkit-media-controls-volume-slider-container: classes: [volume-box uses-ltr-user-interface-layout-direction]
 -webkit-media-controls-volume-slider-container-background: classes: []
 -webkit-media-controls-volume-slider-container-tint: classes: []
 -webkit-media-controls-volume-slider: classes: []

Modified: trunk/Source/WebCore/ChangeLog (202182 => 202183)


--- trunk/Source/WebCore/ChangeLog	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/ChangeLog	2016-06-17 22:24:52 UTC (rev 202183)
@@ -1,3 +1,59 @@
+2016-06-17  Antoine Quint  <[email protected]>
+
+        Web video playback controls should have RTL volume slider
+        https://bugs.webkit.org/show_bug.cgi?id=158856
+        <rdar://problem/25971769>
+
+        Reviewed by Tim Horton.
+
+        We reproduce the system used to propagate the page scale factor from the WebPage to the media controls to
+        propagate the user interface layout direction.
+
+        The Page exposes a new setUserInterfaceLayoutDirection() method which is set by the WebPage. The Page
+        then notifies the Document of a change, which propagates down to registered media elements, and finally sets
+        the usesLTRUserInterfaceLayoutDirection property on the media controller object in the injected _javascript_.
+        Based on the value of that property we toggle a new .uses-ltr-user-interface-layout-direction CSS class on the
+        .volume-box which applies a translate to the right and flips the volume controls on the x axis.
+
+        Since we're setting a new JS property from HTMLMediaController, we refactor much of the code out of the existing
+        pageScaleFactorChanged() and setPageScaleFactorProperty() into the new setControllerJSProperty() method so that
+        can easily set a named JS property with a given JSValue.
+
+        For testing purposes, we expose the WebCore::Page::setUserInterfaceLayoutDirection() method through Internals.
+
+        Test: fullscreen/video-controls-rtl.html
+
+        * Modules/mediacontrols/mediaControlsApple.css:
+        (video:-webkit-full-screen::-webkit-media-controls-panel .volume-box:not(.uses-ltr-user-interface-layout-direction)):
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.set usesLTRUserInterfaceLayoutDirection):
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::registerForUserInterfaceLayoutDirectionChangedCallbacks):
+        (WebCore::Document::unregisterForUserInterfaceLayoutDirectionChangedCallbacks):
+        (WebCore::Document::userInterfaceLayoutDirectionChanged):
+        * dom/Document.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::registerWithDocument):
+        (WebCore::HTMLMediaElement::unregisterWithDocument):
+        (WebCore::HTMLMediaElement::updatePageScaleFactorJSProperty):
+        (WebCore::HTMLMediaElement::updateUsesLTRUserInterfaceLayoutDirectionJSProperty):
+        (WebCore::HTMLMediaElement::setControllerJSProperty):
+        (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
+        (WebCore::HTMLMediaElement::pageScaleFactorChanged):
+        (WebCore::HTMLMediaElement::userInterfaceLayoutDirectionChanged):
+        (WebCore::setPageScaleFactorProperty): Deleted.
+        * html/HTMLMediaElement.h:
+        * page/Page.cpp:
+        (WebCore::Page::setUserInterfaceLayoutDirection):
+        * page/Page.h:
+        (WebCore::Page::userInterfaceLayoutDirection):
+        * platform/UserInterfaceLayoutDirection.h: Renamed from Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h.
+        * testing/Internals.cpp:
+        (WebCore::Internals::setUserInterfaceLayoutDirection):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2016-06-17  Chris Dumez  <[email protected]>
 
         TouchEvent should have a constructor

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.css (202182 => 202183)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.css	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.css	2016-06-17 22:24:52 UTC (rev 202183)
@@ -764,6 +764,10 @@
     border: none;
 }
 
+video:-webkit-full-screen::-webkit-media-controls-panel .volume-box:not(.uses-ltr-user-interface-layout-direction) {
+    transform: translateX(23px) scaleX(-1);
+}
+
 video:-webkit-full-screen::-webkit-media-controls-volume-slider {
     -webkit-transform: none;
     background-color: transparent;

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (202182 => 202183)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-06-17 22:24:52 UTC (rev 202183)
@@ -117,6 +117,7 @@
         out: 'out',
         pictureInPictureButton: 'picture-in-picture-button',
         placeholderShowing: 'placeholder-showing',
+        usesLTRUserInterfaceLayoutDirection: 'uses-ltr-user-interface-layout-direction'
     },
     KeyCodes: {
         enter: 13,
@@ -2236,6 +2237,11 @@
         this._pageScaleFactor = newScaleFactor;
     },
 
+    set usesLTRUserInterfaceLayoutDirection(usesLTRUserInterfaceLayoutDirection)
+    {
+        this.controls.volumeBox.classList.toggle(this.ClassNames.usesLTRUserInterfaceLayoutDirection, usesLTRUserInterfaceLayoutDirection);
+    },
+
     handleRootResize: function(event)
     {
         this.updateLayoutForDisplayedWidth();

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202182 => 202183)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-17 22:24:52 UTC (rev 202183)
@@ -2597,6 +2597,7 @@
 		71A57DF2154BE25C0009D120 /* SVGPathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A57DF0154BE25C0009D120 /* SVGPathUtilities.h */; };
 		71B1E125164048F700B1880A /* InspectorLayerTreeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B1E124164048CC00B1880A /* InspectorLayerTreeAgent.h */; };
 		71B1E1261640491A00B1880A /* InspectorLayerTreeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71B1E123164048CC00B1880A /* InspectorLayerTreeAgent.cpp */; };
+		71C916081D1483A300ACA47D /* UserInterfaceLayoutDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 71C916071D1483A300ACA47D /* UserInterfaceLayoutDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		71CC7A20152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */; };
 		71DCB7011568197600862271 /* JSSVGZoomAndPan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71DCB6FF1568197600862271 /* JSSVGZoomAndPan.cpp */; };
 		71DCB7021568197600862271 /* JSSVGZoomAndPan.h in Headers */ = {isa = PBXBuildFile; fileRef = 71DCB7001568197600862271 /* JSSVGZoomAndPan.h */; };
@@ -10244,6 +10245,7 @@
 		71A57DF0154BE25C0009D120 /* SVGPathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathUtilities.h; sourceTree = "<group>"; };
 		71B1E123164048CC00B1880A /* InspectorLayerTreeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorLayerTreeAgent.cpp; sourceTree = "<group>"; };
 		71B1E124164048CC00B1880A /* InspectorLayerTreeAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorLayerTreeAgent.h; sourceTree = "<group>"; };
+		71C916071D1483A300ACA47D /* UserInterfaceLayoutDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInterfaceLayoutDirection.h; sourceTree = "<group>"; };
 		71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedEnumeration.cpp; sourceTree = "<group>"; };
 		71DCB6FF1568197600862271 /* JSSVGZoomAndPan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGZoomAndPan.cpp; sourceTree = "<group>"; };
 		71DCB7001568197600862271 /* JSSVGZoomAndPan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGZoomAndPan.h; sourceTree = "<group>"; };
@@ -23080,6 +23082,7 @@
 				BCBD21AA0E417AD400A070F2 /* URLHash.h */,
 				868160D1187669C40021E79D /* UserActivity.cpp */,
 				868160D2187669C40021E79D /* UserActivity.h */,
+				71C916071D1483A300ACA47D /* UserInterfaceLayoutDirection.h */,
 				2E3BBF051162DA1100B9409A /* UUID.cpp */,
 				2E3BBF061162DA1100B9409A /* UUID.h */,
 				9A1142031832D134000BB8AD /* ValueToString.h */,
@@ -28087,6 +28090,7 @@
 				A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
 				E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */,
 				A8EA800A0A19516E00A8EF5F /* StyleSheetList.h in Headers */,
+				71C916081D1483A300ACA47D /* UserInterfaceLayoutDirection.h in Headers */,
 				BC5EB5E50E81BF6D00B25965 /* StyleSurroundData.h in Headers */,
 				BC5EB8100E81F2CE00B25965 /* StyleTransformData.h in Headers */,
 				E4DEAA1817A93DC3000E0430 /* StyleTreeResolver.h in Headers */,

Modified: trunk/Source/WebCore/dom/Document.cpp (202182 => 202183)


--- trunk/Source/WebCore/dom/Document.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -4877,6 +4877,22 @@
     for (HTMLMediaElement* mediaElement : m_pageScaleFactorChangedElements)
         mediaElement->pageScaleFactorChanged();
 }
+
+void Document::registerForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement& element)
+{
+    m_userInterfaceLayoutDirectionChangedElements.add(&element);
+}
+
+void Document::unregisterForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement& element)
+{
+    m_userInterfaceLayoutDirectionChangedElements.remove(&element);
+}
+
+void Document::userInterfaceLayoutDirectionChanged()
+{
+    for (auto* mediaElement : m_userInterfaceLayoutDirectionChangedElements)
+        mediaElement->userInterfaceLayoutDirectionChanged();
+}
 #endif
 
 void Document::setShouldCreateRenderers(bool f)

Modified: trunk/Source/WebCore/dom/Document.h (202182 => 202183)


--- trunk/Source/WebCore/dom/Document.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/dom/Document.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -1038,6 +1038,9 @@
     void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
     void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
     void pageScaleFactorChangedAndStable();
+    void registerForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
+    void unregisterForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
+    void userInterfaceLayoutDirectionChanged();
 #endif
 
     void registerForVisibilityStateChangedCallbacks(Element*);
@@ -1607,6 +1610,7 @@
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
+    HashSet<HTMLMediaElement*> m_userInterfaceLayoutDirectionChangedElements;
 #endif
 
     HashSet<Element*> m_visibilityStateCallbackElements;

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (202182 => 202183)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -596,6 +596,7 @@
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     if (m_mediaControlsDependOnPageScaleFactor)
         document.registerForPageScaleFactorChangedCallbacks(this);
+    document.registerForUserInterfaceLayoutDirectionChangedCallbacks(*this);
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -630,6 +631,7 @@
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     if (m_mediaControlsDependOnPageScaleFactor)
         document.unregisterForPageScaleFactorChangedCallbacks(this);
+    document.unregisterForUserInterfaceLayoutDirectionChangedCallbacks(*this);
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -6488,13 +6490,40 @@
     return true;
 }
 
-static void setPageScaleFactorProperty(JSC::ExecState* exec, JSC::JSValue controllerValue, float pageScaleFactor)
+void HTMLMediaElement::updatePageScaleFactorJSProperty()
 {
+    Page* page = document().page();
+    if (!page)
+        return;
+
+    setControllerJSProperty("pageScaleFactor", JSC::jsNumber(page->pageScaleFactor()));
+}
+
+void HTMLMediaElement::updateUsesLTRUserInterfaceLayoutDirectionJSProperty()
+{
+    Page* page = document().page();
+    if (!page)
+        return;
+
+    bool usesLTRUserInterfaceLayoutDirectionProperty = page->userInterfaceLayoutDirection() == UserInterfaceLayoutDirection::LTR;
+    setControllerJSProperty("usesLTRUserInterfaceLayoutDirection", JSC::jsBoolean(usesLTRUserInterfaceLayoutDirectionProperty));
+}
+
+void HTMLMediaElement::setControllerJSProperty(const char* propertyName, JSC::JSValue propertyValue)
+{
+    DOMWrapperWorld& world = ensureIsolatedWorld();
+    ScriptController& scriptController = document().frame()->script();
+    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
+    JSC::ExecState* exec = globalObject->globalExec();
+    JSC::JSLockHolder lock(exec);
+
+    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
     JSC::PutPropertySlot propertySlot(controllerValue);
     JSC::JSObject* controllerObject = controllerValue.toObject(exec);
     if (!controllerObject)
         return;
-    controllerObject->methodTable()->put(controllerObject, exec, JSC::Identifier::fromString(exec, "pageScaleFactor"), JSC::jsNumber(pageScaleFactor), propertySlot);
+
+    controllerObject->methodTable()->put(controllerObject, exec, JSC::Identifier::fromString(exec, propertyName), propertyValue, propertySlot);
 }
 
 void HTMLMediaElement::didAddUserAgentShadowRoot(ShadowRoot* root)
@@ -6571,7 +6600,8 @@
 
     mediaControlsHostJSWrapperObject->putDirect(exec->vm(), controller, controllerValue, JSC::DontDelete | JSC::DontEnum | JSC::ReadOnly);
 
-    setPageScaleFactorProperty(exec, controllerValue, page->pageScaleFactor());
+    updatePageScaleFactorJSProperty();
+    updateUsesLTRUserInterfaceLayoutDirectionJSProperty();
 
     if (exec->hadException())
         exec->clearException();
@@ -6635,20 +6665,12 @@
 
 void HTMLMediaElement::pageScaleFactorChanged()
 {
-    Page* page = document().page();
-    if (!page)
-        return;
+    updatePageScaleFactorJSProperty();
+}
 
-    LOG(Media, "HTMLMediaElement::pageScaleFactorChanged(%p) = %f", this, page->pageScaleFactor());
-    DOMWrapperWorld& world = ensureIsolatedWorld();
-    ScriptController& scriptController = document().frame()->script();
-    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
-    JSC::ExecState* exec = globalObject->globalExec();
-    JSC::JSLockHolder lock(exec);
-
-    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
-
-    setPageScaleFactorProperty(exec, controllerValue, page->pageScaleFactor());
+void HTMLMediaElement::userInterfaceLayoutDirectionChanged()
+{
+    updateUsesLTRUserInterfaceLayoutDirectionJSProperty();
 }
 
 String HTMLMediaElement::getCurrentMediaControlsStatus()

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (202182 => 202183)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -38,6 +38,7 @@
 #include "MediaElementSession.h"
 #include "MediaProducer.h"
 #include "PageThrottler.h"
+#include "UserInterfaceLayoutDirection.h"
 
 #if ENABLE(VIDEO_TRACK)
 #include "AudioTrack.h"
@@ -444,6 +445,7 @@
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     void pageScaleFactorChanged();
+    void userInterfaceLayoutDirectionChanged();
     WEBCORE_EXPORT String getCurrentMediaControlsStatus();
 #endif
 
@@ -781,6 +783,10 @@
 
     void updateRenderer();
 
+    void updatePageScaleFactorJSProperty();
+    void updateUsesLTRUserInterfaceLayoutDirectionJSProperty();
+    void setControllerJSProperty(const char*, JSC::JSValue);
+
     Timer m_pendingActionTimer;
     Timer m_progressEventTimer;
     Timer m_playbackProgressTimer;

Modified: trunk/Source/WebCore/page/Page.cpp (202182 => 202183)


--- trunk/Source/WebCore/page/Page.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/page/Page.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -897,6 +897,21 @@
     mainFrame().pageOverlayController().didChangeDeviceScaleFactor();
 }
 
+void Page::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection)
+{
+    if (m_userInterfaceLayoutDirection == userInterfaceLayoutDirection)
+        return;
+
+    m_userInterfaceLayoutDirection = userInterfaceLayoutDirection;
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+        if (!frame->document())
+            continue;
+        frame->document()->userInterfaceLayoutDirectionChanged();
+    }
+#endif
+}
+
 void Page::setTopContentInset(float contentInset)
 {
     if (m_topContentInset == contentInset)

Modified: trunk/Source/WebCore/page/Page.h (202182 => 202183)


--- trunk/Source/WebCore/page/Page.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/page/Page.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -33,6 +33,7 @@
 #include "ScrollTypes.h"
 #include "SessionID.h"
 #include "Supplementable.h"
+#include "UserInterfaceLayoutDirection.h"
 #include "ViewState.h"
 #include "ViewportArguments.h"
 #include "WheelEventTestTrigger.h"
@@ -281,6 +282,9 @@
     WEBCORE_EXPORT void setPageScaleFactor(float scale, const IntPoint& origin, bool inStableState = true);
     float pageScaleFactor() const { return m_pageScaleFactor; }
 
+    UserInterfaceLayoutDirection userInterfaceLayoutDirection() const { return m_userInterfaceLayoutDirection; }
+    WEBCORE_EXPORT void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
+
     // The view scale factor is multiplied into the page scale factor by all
     // callers of setPageScaleFactor.
     WEBCORE_EXPORT void setViewScaleFactor(float);
@@ -716,6 +720,7 @@
     bool m_showAllPlugins { false };
     bool m_controlledByAutomation { false };
     bool m_resourceCachingDisabled { false };
+    UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { UserInterfaceLayoutDirection::LTR };
 };
 
 inline PageGroup& Page::group()

Copied: trunk/Source/WebCore/platform/UserInterfaceLayoutDirection.h (from rev 202182, trunk/Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h) (0 => 202183)


--- trunk/Source/WebCore/platform/UserInterfaceLayoutDirection.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/UserInterfaceLayoutDirection.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef UserInterfaceLayoutDirection_h
+#define UserInterfaceLayoutDirection_h
+
+namespace WebCore {
+
+enum class UserInterfaceLayoutDirection { LTR, RTL };
+
+} // namespace WebCore
+
+#endif // UserInterfaceLayoutDirection_h

Modified: trunk/Source/WebCore/testing/Internals.cpp (202182 => 202183)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -3339,4 +3339,17 @@
     return GCObservation::create(value.getObject());
 }
 
+void Internals::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection)
+{
+    Document* document = contextDocument();
+    if (!document)
+        return;
+
+    Page* page = document->page();
+    if (!page)
+        return;
+
+    page->setUserInterfaceLayoutDirection(userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (202182 => 202183)


--- trunk/Source/WebCore/testing/Internals.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/testing/Internals.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -486,6 +486,9 @@
 
     RefPtr<GCObservation> observeGC(JSC::JSValue);
 
+    enum class UserInterfaceLayoutDirection { LTR, RTL };
+    void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (202182 => 202183)


--- trunk/Source/WebCore/testing/Internals.idl	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-06-17 22:24:52 UTC (rev 202183)
@@ -65,6 +65,11 @@
     "AutoFillButtonTypeCredentials"
 };
 
+enum UserInterfaceLayoutDirection {
+    "LTR",
+    "RTL"
+};
+
 [
     ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
     NoInterfaceObject,
@@ -458,4 +463,6 @@
     boolean isProcessingUserGesture();
 
     GCObservation observeGC(any observed);
+
+    void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection);
 };

Modified: trunk/Source/WebKit2/ChangeLog (202182 => 202183)


--- trunk/Source/WebKit2/ChangeLog	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/ChangeLog	2016-06-17 22:24:52 UTC (rev 202183)
@@ -1,3 +1,46 @@
+2016-06-17  Antoine Quint  <[email protected]>
+
+        Web video playback controls should have RTL volume slider
+        https://bugs.webkit.org/show_bug.cgi?id=158856
+        <rdar://problem/25971769>
+
+        Reviewed by Tim Horton.
+
+        We now call setUserInterfaceLayoutDirection() on WebCore::Page to propagate
+        the user interface layout direction down to the Web content. To facilitate this,
+        the UserInterfaceLayoutDirection enum is now defined in WebCore.
+
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (convertSystemLayoutDirection):
+        (toUserInterfaceLayoutDirection):
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::toUserInterfaceLayoutDirection):
+        (WebKit::WebViewImpl::userInterfaceLayoutDirection):
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::userInterfaceLayoutDirection):
+        (WebKit::WebPageProxy::setUserInterfaceLayoutDirection):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/efl/WebView.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::userInterfaceLayoutDirection):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::userInterfaceLayoutDirection):
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
+        (WebKit::ViewGestureController::isPhysicallySwipingLeft):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_userInterfaceLayoutDirection):
+        (WebKit::WebPage::setUserInterfaceLayoutDirection):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performNonEditingBehaviorForSelector):
+
 2016-06-17  Dean Jackson  <[email protected]>
 
         REGRESSION: Double tap to zoom does not work on yahoo finance

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (202182 => 202183)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -29,7 +29,6 @@
 #include "DrawingAreaInfo.h"
 #include "LayerTreeContext.h"
 #include "SessionState.h"
-#include "UserInterfaceLayoutDirection.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebPageGroupData.h"
 #include "WebPreferencesStore.h"
@@ -39,6 +38,7 @@
 #include <WebCore/Pagination.h>
 #include <WebCore/ScrollTypes.h>
 #include <WebCore/SessionID.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
 #include <WebCore/ViewState.h>
 #include <wtf/text/WTFString.h>
 
@@ -135,7 +135,7 @@
     bool appleMailPaginationQuirkEnabled;
     bool shouldScaleViewToFitDocument;
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection;
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -377,11 +377,11 @@
 {
     switch (direction) {
     case NSUserInterfaceLayoutDirectionLeftToRight:
-        return static_cast<uint32_t>(WebCore::LTR);
+        return static_cast<uint32_t>(WebCore::UserInterfaceLayoutDirection::LTR);
     case NSUserInterfaceLayoutDirectionRightToLeft:
-        return static_cast<uint32_t>(WebCore::RTL);
+        return static_cast<uint32_t>(WebCore::UserInterfaceLayoutDirection::RTL);
     }
-    return static_cast<uint32_t>(WebCore::LTR);
+    return static_cast<uint32_t>(WebCore::UserInterfaceLayoutDirection::LTR);
 }
 #endif
 
@@ -4303,18 +4303,18 @@
     return (_WKWebViewPrintFormatter *)viewPrintFormatter;
 }
 
-static WebKit::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISemanticContentAttribute contentAttribute)
+static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISemanticContentAttribute contentAttribute)
 {
     auto direction = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:contentAttribute];
     switch (direction) {
     case UIUserInterfaceLayoutDirectionLeftToRight:
-        return WebKit::UserInterfaceLayoutDirection::LTR;
+        return WebCore::UserInterfaceLayoutDirection::LTR;
     case UIUserInterfaceLayoutDirectionRightToLeft:
-        return WebKit::UserInterfaceLayoutDirection::RTL;
+        return WebCore::UserInterfaceLayoutDirection::RTL;
     }
 
     ASSERT_NOT_REACHED();
-    return WebKit::UserInterfaceLayoutDirection::LTR;
+    return WebCore::UserInterfaceLayoutDirection::LTR;
 }
 
 - (void)setSemanticContentAttribute:(UISemanticContentAttribute)contentAttribute

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -144,7 +144,7 @@
     bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
 #endif
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return UserInterfaceLayoutDirection::LTR; }
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
 
     // Members of PageClientImpl class
     GtkWidget* m_viewWidget;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -29,11 +29,11 @@
 #if PLATFORM(MAC)
 
 #include "PluginComplexTextInputState.h"
-#include "UserInterfaceLayoutDirection.h"
 #include "WKLayoutMode.h"
 #include "WebPageProxy.h"
 #include "_WKOverlayScrollbarStyle.h"
 #include <WebCore/TextIndicatorWindow.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
 #include <functional>
 #include <wtf/RetainPtr.h>
 #include <wtf/WeakPtr.h>
@@ -486,7 +486,7 @@
     void setRequiresUserActionForEditingControlsManager(bool requiresUserActionForEditingControlsManager) { m_requiresUserActionForEditingControlsManager = requiresUserActionForEditingControlsManager; }
     bool requiresUserActionForEditingControlsManager() const { return m_requiresUserActionForEditingControlsManager; }
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection();
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection();
     void setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection);
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -4029,20 +4029,20 @@
     return m_view.window.windowNumber != eventWindowNumber;
 }
 
-static UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
+static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection direction)
 {
     switch (direction) {
     case NSUserInterfaceLayoutDirectionLeftToRight:
-        return UserInterfaceLayoutDirection::LTR;
+        return WebCore::UserInterfaceLayoutDirection::LTR;
     case NSUserInterfaceLayoutDirectionRightToLeft:
-        return UserInterfaceLayoutDirection::RTL;
+        return WebCore::UserInterfaceLayoutDirection::RTL;
     }
 
     ASSERT_NOT_REACHED();
-    return UserInterfaceLayoutDirection::LTR;
+    return WebCore::UserInterfaceLayoutDirection::LTR;
 }
 
-UserInterfaceLayoutDirection WebViewImpl::userInterfaceLayoutDirection()
+WebCore::UserInterfaceLayoutDirection WebViewImpl::userInterfaceLayoutDirection()
 {
     return toUserInterfaceLayoutDirection(m_view.userInterfaceLayoutDirection);
 }

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -27,12 +27,12 @@
 #define PageClient_h
 
 #include "ShareableBitmap.h"
-#include "UserInterfaceLayoutDirection.h"
 #include "WebColorPicker.h"
 #include "WebPageProxy.h"
 #include "WebPopupMenuProxy.h"
 #include <WebCore/AlternativeTextClient.h>
 #include <WebCore/EditorClient.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
 #include <wtf/Forward.h>
 
 #if PLATFORM(COCOA)
@@ -364,7 +364,7 @@
 
     virtual bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) { return false; }
 
-    virtual UserInterfaceLayoutDirection userInterfaceLayoutDirection() = 0;
+    virtual WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() = 0;
 };
 
 } // namespace WebKit

Deleted: trunk/Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef UserInterfaceLayoutDirection_h
-#define UserInterfaceLayoutDirection_h
-
-namespace WebKit {
-
-enum class UserInterfaceLayoutDirection { LTR, RTL };
-
-} // namespace WebKit
-
-#endif // UserInterfaceLayoutDirection_h

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -6307,12 +6307,12 @@
     m_process->send(Messages::WebPage::SetResourceCachingDisabled(disabled), m_pageID);
 }
 
-UserInterfaceLayoutDirection WebPageProxy::userInterfaceLayoutDirection()
+WebCore::UserInterfaceLayoutDirection WebPageProxy::userInterfaceLayoutDirection()
 {
     return m_pageClient.userInterfaceLayoutDirection();
 }
 
-void WebPageProxy::setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection)
+void WebPageProxy::setUserInterfaceLayoutDirection(WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection)
 {
     if (!isValid())
         return;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -44,7 +44,6 @@
 #include "ProcessThrottler.h"
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
-#include "UserInterfaceLayoutDirection.h"
 #include "UserMediaPermissionRequestManagerProxy.h"
 #include "VisibleContentRectUpdateInfo.h"
 #include "WKBase.h"
@@ -73,6 +72,7 @@
 #include <WebCore/SearchPopupMenu.h>
 #include <WebCore/TextChecking.h>
 #include <WebCore/TextGranularity.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
 #include <WebCore/ViewState.h>
 #include <WebCore/VisibleSelection.h>
 #include <memory>
@@ -1111,8 +1111,8 @@
     bool isResourceCachingDisabled() const { return m_isResourceCachingDisabled; }
     void setResourceCachingDisabled(bool);
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection();
-    void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection();
+    void setUserInterfaceLayoutDirection(WebCore::UserInterfaceLayoutDirection);
 
     bool hasHadSelectionChangesFromUserInteraction() const { return m_hasHadSelectionChangesFromUserInteraction; }
 

Modified: trunk/Source/WebKit2/UIProcess/efl/WebView.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/efl/WebView.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/efl/WebView.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -262,7 +262,7 @@
     void beganExitFullScreen(const WebCore::IntRect&, const WebCore::IntRect&) override { }
 #endif
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return UserInterfaceLayoutDirection::LTR; }
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
 
     EwkView* m_ewkView;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -191,7 +191,7 @@
 
     void didRestoreScrollPosition() override;
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
 
     WKContentView *m_contentView;
     WKWebView *m_webView;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -740,11 +740,11 @@
 {
 }
 
-UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
+WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
 {
     if (!m_webView)
-        return UserInterfaceLayoutDirection::LTR;
-    return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:[m_webView semanticContentAttribute]] == UIUserInterfaceLayoutDirectionLeftToRight) ? UserInterfaceLayoutDirection::LTR : UserInterfaceLayoutDirection::RTL;
+        return WebCore::UserInterfaceLayoutDirection::LTR;
+    return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:[m_webView semanticContentAttribute]] == UIUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -220,7 +220,7 @@
     void startWindowDrag() override;
     NSWindow *platformWindow() override;
 
-    UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
+    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
 
 #if WK_API_ENABLED
     NSView *inspectorAttachmentView() override;

Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -840,11 +840,11 @@
     return m_impl->windowIsFrontWindowUnderMouse(event.nativeEvent());
 }
 
-UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
+WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
 {
     if (!m_view)
-        return UserInterfaceLayoutDirection::LTR;
-    return (m_view.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) ? UserInterfaceLayoutDirection::LTR : UserInterfaceLayoutDirection::RTL;
+        return WebCore::UserInterfaceLayoutDirection::LTR;
+    return (m_view.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (202182 => 202183)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -31,7 +31,6 @@
 #import "FrameLoadState.h"
 #import "Logging.h"
 #import "NativeWebWheelEvent.h"
-#import "UserInterfaceLayoutDirection.h"
 #import "ViewGestureControllerMessages.h"
 #import "ViewGestureGeometryCollectorMessages.h"
 #import "ViewSnapshotStore.h"
@@ -300,7 +299,7 @@
 
     bool willSwipeBack = false;
     bool willSwipeForward = false;
-    if (m_webPageProxy.userInterfaceLayoutDirection() == UserInterfaceLayoutDirection::LTR) {
+    if (m_webPageProxy.userInterfaceLayoutDirection() == WebCore::UserInterfaceLayoutDirection::LTR) {
         willSwipeBack = event.scrollingDeltaX > 0 && isPinnedToLeft && m_webPageProxy.backForwardList().backItem();
         willSwipeForward = event.scrollingDeltaX < 0 && isPinnedToRight && m_webPageProxy.backForwardList().forwardItem();
     } else {
@@ -678,7 +677,7 @@
 
 bool ViewGestureController::isPhysicallySwipingLeft(SwipeDirection direction) const
 {
-    bool isLTR = m_webPageProxy.userInterfaceLayoutDirection() == UserInterfaceLayoutDirection::LTR;
+    bool isLTR = m_webPageProxy.userInterfaceLayoutDirection() == WebCore::UserInterfaceLayoutDirection::LTR;
     bool isSwipingForward = direction == SwipeDirection::Forward;
     return isLTR != isSwipingForward;
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (202182 => 202183)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-06-17 22:24:52 UTC (rev 202183)
@@ -464,6 +464,7 @@
 
     m_page->setGroupName(m_pageGroup->identifier());
     m_page->setDeviceScaleFactor(parameters.deviceScaleFactor);
+    m_page->setUserInterfaceLayoutDirection(m_userInterfaceLayoutDirection);
 #if PLATFORM(IOS)
     m_page->setTextAutosizingWidth(parameters.textAutosizingWidth);
 #endif
@@ -5371,7 +5372,8 @@
 
 void WebPage::setUserInterfaceLayoutDirection(uint32_t direction)
 {
-    m_userInterfaceLayoutDirection = static_cast<UserInterfaceLayoutDirection>(direction);
+    m_userInterfaceLayoutDirection = static_cast<WebCore::UserInterfaceLayoutDirection>(direction);
+    m_page->setUserInterfaceLayoutDirection(m_userInterfaceLayoutDirection);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (202182 => 202183)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-06-17 22:24:52 UTC (rev 202183)
@@ -47,7 +47,6 @@
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
 #include "UserData.h"
-#include "UserInterfaceLayoutDirection.h"
 #include "UserMediaPermissionRequestManager.h"
 #include <WebCore/DictationAlternative.h>
 #include <WebCore/DictionaryPopupInfo.h>
@@ -66,6 +65,7 @@
 #include <WebCore/TextIndicator.h>
 #include <WebCore/UserActivity.h>
 #include <WebCore/UserContentTypes.h>
+#include <WebCore/UserInterfaceLayoutDirection.h>
 #include <WebCore/UserScriptTypes.h>
 #include <WebCore/ViewState.h>
 #include <WebCore/ViewportConfiguration.h>
@@ -1470,7 +1470,7 @@
     std::chrono::system_clock::time_point m_loadCommitTime;
 #endif
 
-    UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { UserInterfaceLayoutDirection::LTR };
+    WebCore::UserInterfaceLayoutDirection m_userInterfaceLayoutDirection { WebCore::UserInterfaceLayoutDirection::LTR };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (202182 => 202183)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-06-17 21:46:20 UTC (rev 202182)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-06-17 22:24:52 UTC (rev 202183)
@@ -551,13 +551,13 @@
     else if (selector == "moveWordLeft:")
         didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
     else if (selector == "moveToLeftEndOfLine:")
-        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page->backForward().goBack() : m_page->backForward().goForward();
+        didPerformAction = m_userInterfaceLayoutDirection == WebCore::UserInterfaceLayoutDirection::LTR ? m_page->backForward().goBack() : m_page->backForward().goForward();
     else if (selector == "moveRight:")
         didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
     else if (selector == "moveWordRight:")
         didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
     else if (selector == "moveToRightEndOfLine:")
-        didPerformAction = m_userInterfaceLayoutDirection == UserInterfaceLayoutDirection::LTR ? m_page->backForward().goForward() : m_page->backForward().goBack();
+        didPerformAction = m_userInterfaceLayoutDirection == WebCore::UserInterfaceLayoutDirection::LTR ? m_page->backForward().goForward() : m_page->backForward().goBack();
 
     return didPerformAction;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to