Use the video element's video box when getting the inline video rect in WebVideoFulls...
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 04:37:06 +0000 (04:37 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 04:37:06 +0000 (04:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158351
<rdar://problem/26567938>

Reviewed by Darin Adler.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
Change the visibility of RenderVideo.h and RenderMedia.h since we'll be importing RenderVideo.h from WebKit2.
* rendering/RenderVideo.h:

Source/WebKit2:

* WebProcess/cocoa/WebVideoFullscreenManager.mm:
(WebKit::inlineVideoFrame):
(WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
(WebKit::WebVideoFullscreenManager::exitVideoFullscreenForVideoElement):
(WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline):
(WebKit::WebVideoFullscreenManager::setVideoLayerFrameFenced):
(WebKit::clientRectForElement): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201963 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderVideo.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm

index 6d6a44c..afdbb7a 100644 (file)
@@ -1,3 +1,15 @@
+2016-06-10  Ada Chan  <adachan@apple.com>
+
+        Use the video element's video box when getting the inline video rect in WebVideoFullscreenManager
+        https://bugs.webkit.org/show_bug.cgi?id=158351
+        <rdar://problem/26567938>
+
+        Reviewed by Darin Adler.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Change the visibility of RenderVideo.h and RenderMedia.h since we'll be importing RenderVideo.h from WebKit2.
+        * rendering/RenderVideo.h:
+
 2016-06-10  Benjamin Poulain  <bpoulain@apple.com>
 
         Add support for passive event listeners on touch events
index bbbe99d..fb7aab8 100644 (file)
                E446143B0CD689CC00FADA75 /* JSHTMLSourceElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B423710CBFB6E000AF2ECE /* JSHTMLSourceElement.cpp */; };
                E446143C0CD689CC00FADA75 /* JSHTMLSourceElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B423720CBFB6E000AF2ECE /* JSHTMLSourceElement.h */; };
                E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B41E330CBFB60900AF2ECE /* RenderVideo.cpp */; };
-               E44614520CD68A3500FADA75 /* RenderVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E340CBFB60900AF2ECE /* RenderVideo.h */; };
+               E44614520CD68A3500FADA75 /* RenderVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E340CBFB60900AF2ECE /* RenderVideo.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E44B4BB3141650D7002B1D8B /* SelectorChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44B4BB1141650D7002B1D8B /* SelectorChecker.cpp */; };
                E44B4BB4141650D7002B1D8B /* SelectorChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = E44B4BB2141650D7002B1D8B /* SelectorChecker.h */; };
                E44EE3A817577EBD00EEE8CF /* FontGenericFamilies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */; };
                E4C1789A0EE6903800824D69 /* CSSSelectorList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C178950EE6903800824D69 /* CSSSelectorList.cpp */; };
                E4C1789B0EE6903800824D69 /* CSSSelectorList.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C178960EE6903800824D69 /* CSSSelectorList.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C279560CF9741900E97B98 /* RenderMedia.cpp */; };
-               E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; };
+               E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4C3B1FC0F0E4170009693F6 /* LegacyTileCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4C3B1FB0F0E4170009693F6 /* LegacyTileCache.mm */; };
                E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A0D1802343100A17F6D /* TextPaintStyle.h */; };
index 4dae609..29d00a3 100644 (file)
@@ -39,7 +39,7 @@ public:
 
     HTMLVideoElement& videoElement() const;
 
-    IntRect videoBox() const;
+    WEBCORE_EXPORT IntRect videoBox() const;
 
     static IntSize defaultSize();
 
index 0df34f4..052c175 100644 (file)
@@ -1,3 +1,19 @@
+2016-06-10  Ada Chan  <adachan@apple.com>
+
+        Use the video element's video box when getting the inline video rect in WebVideoFullscreenManager
+        https://bugs.webkit.org/show_bug.cgi?id=158351
+        <rdar://problem/26567938>
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/cocoa/WebVideoFullscreenManager.mm:
+        (WebKit::inlineVideoFrame):
+        (WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
+        (WebKit::WebVideoFullscreenManager::exitVideoFullscreenForVideoElement):
+        (WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline):
+        (WebKit::WebVideoFullscreenManager::setVideoLayerFrameFenced):
+        (WebKit::clientRectForElement): Deleted.
+
 2016-06-10  Benjamin Poulain  <bpoulain@apple.com>
 
         Add support for passive event listeners on touch events
index eeecc64..6ef6f5b 100644 (file)
@@ -43,6 +43,7 @@
 #import <WebCore/PlatformCALayer.h>
 #import <WebCore/RenderLayer.h>
 #import <WebCore/RenderLayerBacking.h>
+#import <WebCore/RenderVideo.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/Settings.h>
 #import <WebCore/TimeRanges.h>
@@ -52,12 +53,15 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static IntRect clientRectForElement(HTMLElement* element)
+static IntRect inlineVideoFrame(HTMLVideoElement& element)
 {
-    if (!element)
-        return IntRect();
-
-    return element->clientRect();
+    element.document().updateLayoutIgnorePendingStylesheets();
+    auto* renderer = element.renderer();
+    if (!renderer)
+        return { };
+    auto rect = renderer->videoBox();
+    rect.moveBy(renderer->absoluteBoundingBoxRect().location());
+    return element.document().view()->contentsToRootView(rect);
 }
 
 #pragma mark - WebVideoFullscreenInterfaceContext
@@ -275,8 +279,8 @@ void WebVideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoEle
     if (!interface->layerHostingContext())
         interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
 
-    FloatRect clientRect = clientRectForElement(&videoElement);
-    FloatRect videoLayerFrame = FloatRect(0, 0, clientRect.width(), clientRect.height());
+    auto videoRect = inlineVideoFrame(videoElement);
+    FloatRect videoLayerFrame = FloatRect(0, 0, videoRect.width(), videoRect.height());
 
     HTMLMediaElementEnums::VideoFullscreenMode oldMode = interface->fullscreenMode();
     interface->setTargetIsFullscreen(true);
@@ -291,7 +295,7 @@ void WebVideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoEle
 
     bool allowsPictureInPicture = videoElement.mediaSession().allowsPictureInPicture(videoElement);
     
-    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), clientRectForElement(&videoElement), m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture), m_page->pageID());
 }
 
 void WebVideoFullscreenManager::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement)
@@ -307,7 +311,7 @@ void WebVideoFullscreenManager::exitVideoFullscreenForVideoElement(WebCore::HTML
         return;
 
     interface.setIsAnimating(true);
-    m_page->send(Messages::WebVideoFullscreenManagerProxy::ExitFullscreen(contextId, clientRectForElement(&videoElement)), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManagerProxy::ExitFullscreen(contextId, inlineVideoFrame(videoElement)), m_page->pageID());
 }
 
 void WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement& videoElement, WebCore::HTMLMediaElementEnums::VideoFullscreenMode targetMode)
@@ -464,7 +468,7 @@ void WebVideoFullscreenManager::fullscreenMayReturnToInline(uint64_t contextId,
 
     if (!isPageVisible)
         model.videoElement()->scrollIntoViewIfNotVisible(false);
-    m_page->send(Messages::WebVideoFullscreenManagerProxy::PreparedToReturnToInline(contextId, true, clientRectForElement(model.videoElement())), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManagerProxy::PreparedToReturnToInline(contextId, true, inlineVideoFrame(*model.videoElement())), m_page->pageID());
 }
     
 void WebVideoFullscreenManager::setVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
@@ -474,8 +478,8 @@ void WebVideoFullscreenManager::setVideoLayerFrameFenced(uint64_t contextId, Web
     std::tie(model, interface) = ensureModelAndInterface(contextId);
 
     if (std::isnan(bounds.x()) || std::isnan(bounds.y()) || std::isnan(bounds.width()) || std::isnan(bounds.height())) {
-        FloatRect clientRect = clientRectForElement(model->videoElement());
-        bounds = FloatRect(0, 0, clientRect.width(), clientRect.height());
+        auto videoRect = inlineVideoFrame(*model->videoElement());
+        bounds = FloatRect(0, 0, videoRect.width(), videoRect.height());
     }
     
     [CATransaction begin];