Title: [187183] trunk/Source/WebCore
Revision
187183
Author
commit-qu...@webkit.org
Date
2015-07-22 14:31:39 -0700 (Wed, 22 Jul 2015)

Log Message

Fix fullscreen and PiP video animation and sizing regressions.
https://bugs.webkit.org/show_bug.cgi?id=147189
<rdar://problem/21930899>

Patch by Jeremy Jones <jere...@apple.com> on 2015-07-22
Reviewed by Jer Noble.

Fixes WK1 specific regressions introduced by r187044. Flicker when entering fullscreen,
wrong animation and missing initial animation rects.

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(elementRectInWindow): Added.
(WebVideoFullscreenControllerContext::didSetupFullscreen): Clear background decreases flash.
(WebVideoFullscreenControllerContext::fullscreenMayReturnToInline): Use consistent inline rect.
(WebVideoFullscreenControllerContext::setVideoLayerFrame):
Clear the transform on the web thread instead of on the UI thread.
(WebVideoFullscreenControllerContext::setUpFullscreen): Use consistent inline rect.
(WebVideoFullscreenControllerContext::exitFullscreen): Use consistent inline rect.
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerLayer resolveBounds]): Clear transform after setting frame.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187182 => 187183)


--- trunk/Source/WebCore/ChangeLog	2015-07-22 21:29:16 UTC (rev 187182)
+++ trunk/Source/WebCore/ChangeLog	2015-07-22 21:31:39 UTC (rev 187183)
@@ -1,5 +1,27 @@
 2015-07-22  Jeremy Jones  <jere...@apple.com>
 
+        Fix fullscreen and PiP video animation and sizing regressions.
+        https://bugs.webkit.org/show_bug.cgi?id=147189
+        <rdar://problem/21930899>
+
+        Reviewed by Jer Noble.
+
+        Fixes WK1 specific regressions introduced by r187044. Flicker when entering fullscreen,
+        wrong animation and missing initial animation rects.
+
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (elementRectInWindow): Added.
+        (WebVideoFullscreenControllerContext::didSetupFullscreen): Clear background decreases flash.
+        (WebVideoFullscreenControllerContext::fullscreenMayReturnToInline): Use consistent inline rect.
+        (WebVideoFullscreenControllerContext::setVideoLayerFrame): 
+        Clear the transform on the web thread instead of on the UI thread.
+        (WebVideoFullscreenControllerContext::setUpFullscreen): Use consistent inline rect.
+        (WebVideoFullscreenControllerContext::exitFullscreen): Use consistent inline rect.
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm: 
+        (-[WebAVPlayerLayer resolveBounds]): Clear transform after setting frame.
+
+2015-07-22  Jeremy Jones  <jere...@apple.com>
+
         Adopt AVKit's AVSimplePlayerLayerView change for PiP.
         https://bugs.webkit.org/show_bug.cgi?id=147186
         <rdar://problem/21928170>

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (187182 => 187183)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2015-07-22 21:29:16 UTC (rev 187182)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2015-07-22 21:31:39 UTC (rev 187183)
@@ -36,7 +36,9 @@
 #import "WebVideoFullscreenInterfaceAVKit.h"
 #import "WebVideoFullscreenModelVideoElement.h"
 #import <QuartzCore/CoreAnimation.h>
+#import <WebCore/FrameView.h>
 #import <WebCore/HTMLVideoElement.h>
+#import <WebCore/RenderElement.h>
 #import <WebCore/WebCoreThreadRun.h>
 
 SOFT_LINK_FRAMEWORK(UIKit)
@@ -44,6 +46,14 @@
 
 using namespace WebCore;
 
+static IntRect elementRectInWindow(HTMLVideoElement* videoElement)
+{
+    if (!videoElement || !videoElement->renderer() || !videoElement->document().view())
+        return IntRect();
+    
+    return videoElement->document().view()->convertToContainingWindow(videoElement->renderer()->absoluteBoundingBoxRect());
+}
+
 #if __IPHONE_OS_VERSION_MIN_REQUIRED <= 80200 || !HAVE(AVKIT)
 
 @implementation WebVideoFullscreenController
@@ -154,6 +164,7 @@
     RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
     RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer];
     WebThreadRun([strongThis, this, videoFullscreenLayer] {
+        [videoFullscreenLayer setBackgroundColor:cachedCGColor(WebCore::Color::transparent, WebCore::ColorSpaceDeviceRGB)];
         m_model->setVideoFullscreenLayer(videoFullscreenLayer.get());
         dispatch_async(dispatch_get_main_queue(), [strongThis, this] {
             m_interface->enterFullscreen();
@@ -198,7 +209,7 @@
     ASSERT(isUIThread());
     RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
     WebThreadRun([strongThis, this] {
-        IntRect clientRect = m_videoElement->clientRect();
+        IntRect clientRect = elementRectInWindow(m_videoElement.get());
         dispatch_async(dispatch_get_main_queue(), [strongThis, this, clientRect] {
             m_interface->preparedToReturnToInline(true, clientRect);
         });
@@ -454,17 +465,21 @@
     ASSERT(isUIThread());
     RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
     RetainPtr<CALayer> videoFullscreenLayer = [m_videoFullscreenView layer];
+    
+    [videoFullscreenLayer setSublayerTransform:[videoFullscreenLayer transform]];
 
-    mach_port_name_t fencePort = [[videoFullscreenLayer context] createFencePort];
-    
-    WebThreadRun([strongThis, this, frame, fencePort, videoFullscreenLayer] {
-        [CATransaction begin];
-        [CATransaction setAnimationDuration:0];
-        if (m_model)
-            m_model->setVideoLayerFrame(frame);
-        [[videoFullscreenLayer context] setFencePort:fencePort];
-        mach_port_deallocate(mach_task_self(), fencePort);
-        [CATransaction commit];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        WebThreadRun([strongThis, this, frame, videoFullscreenLayer] {
+            [CATransaction begin];
+            [CATransaction setDisableActions:YES];
+            [CATransaction setAnimationDuration:0];
+            
+            [videoFullscreenLayer setSublayerTransform:CATransform3DIdentity];
+            
+            if (m_model)
+                m_model->setVideoLayerFrame(frame);
+            [CATransaction commit];
+        });
     });
 }
 
@@ -528,7 +543,10 @@
         m_model->setVideoElement(m_videoElement.get());
         
         bool allowsPictureInPicture = m_videoElement->mediaSession().allowsPictureInPicture(*m_videoElement.get());
-        IntRect videoElementClientRect = m_videoElement->clientRect();
+
+        IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get());
+        FloatRect videoLayerFrame = FloatRect(FloatPoint(), videoElementClientRect.size());
+        m_model->setVideoLayerFrame(videoLayerFrame);
         
         dispatch_async(dispatch_get_main_queue(), [strongThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] {
             m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture);
@@ -539,11 +557,11 @@
 void WebVideoFullscreenControllerContext::exitFullscreen()
 {
     ASSERT(WebThreadIsCurrent() || isMainThread());
-    IntRect screenRect = m_videoElement->screenRect();
+    IntRect clientRect = elementRectInWindow(m_videoElement.get());
     RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
-    dispatch_async(dispatch_get_main_queue(), [strongThis, this, screenRect] {
+    dispatch_async(dispatch_get_main_queue(), [strongThis, this, clientRect] {
         ASSERT(isUIThread());
-        m_interface->exitFullscreen(screenRect);
+        m_interface->exitFullscreen(clientRect);
     });
 }
 

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (187182 => 187183)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm	2015-07-22 21:29:16 UTC (rev 187182)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm	2015-07-22 21:31:39 UTC (rev 187183)
@@ -682,10 +682,11 @@
     
     [CATransaction begin];
     [CATransaction setAnimationDuration:0];
+    [CATransaction setDisableActions:YES];
     
-    [(UIView *)[_videoSublayer delegate] setTransform:CGAffineTransformIdentity];
     self.modelVideoLayerFrame = [self bounds];
     [_avPlayerController delegate]->setVideoLayerFrame(self.modelVideoLayerFrame);
+    [(UIView *)[_videoSublayer delegate] setTransform:CGAffineTransformIdentity];
     
     [CATransaction commit];
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to