Web video playback controls should have RTL volume slider
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jun 2016 22:24:52 +0000 (22:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Jun 2016 22:24:52 +0000 (22:24 +0000)
commit06931bc6be15ce3d00285523332df6daa8dc3036
tree75848070fa2db2b505b44dc66ba8b086de2bc02c
parente6c20e364b0c2254233f16061030b82147492375
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 <graouts@apple.com> 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
LayoutTests/ChangeLog
LayoutTests/fullscreen/video-controls-rtl-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/video-controls-rtl.html [new file with mode: 0644]
LayoutTests/platform/mac-yosemite/http/tests/media/hls/video-controls-live-stream-expected.txt
LayoutTests/platform/mac/http/tests/media/hls/video-controls-live-stream-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/mediaControlsApple.css
Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/UserInterfaceLayoutDirection.h [moved from Source/WebKit2/UIProcess/UserInterfaceLayoutDirection.h with 97% similarity]
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/efl/WebView.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm