[Mac] MediaPlayerPrivateQTKit should not use FrameView
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Sep 2014 14:30:34 +0000 (14:30 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Sep 2014 14:30:34 +0000 (14:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137119

Reviewed by Carlos Garcia Campos.

Remove obsolete QTKit code that would fall back to rendering into an NSView.
Aside from being dead code, it was only used when accelerated compositing
was not enabled and tha hasn't been possible for a long time, it required a
layering violation to get the FrameView.

* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::currentRenderingMode):
(WebCore::MediaPlayerPrivateQTKit::preferredRenderingMode):
(WebCore::MediaPlayerPrivateQTKit::setUpVideoRendering):
(WebCore::MediaPlayerPrivateQTKit::tearDownVideoRendering):
(WebCore::MediaPlayerPrivateQTKit::hasSetUpVideoRendering):
(WebCore::MediaPlayerPrivateQTKit::setSize):
(WebCore::MediaPlayerPrivateQTKit::paint):
(WebCore::mainThreadSetNeedsDisplay): Deleted.
(WebCore::MediaPlayerPrivateQTKit::createQTMovieView): Deleted.
(WebCore::MediaPlayerPrivateQTKit::detachQTMovieView): Deleted.
(-[WebCoreMovieObserver menuForEventDelegate:]): Deleted.
(-[WebCoreMovieObserver setView:]): Deleted.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

index a292077..ddd97a1 100644 (file)
@@ -1,3 +1,30 @@
+2014-09-30  Eric Carlson  <eric.carlson@apple.com>
+
+        [Mac] MediaPlayerPrivateQTKit should not use FrameView
+        https://bugs.webkit.org/show_bug.cgi?id=137119
+
+        Reviewed by Carlos Garcia Campos.
+
+        Remove obsolete QTKit code that would fall back to rendering into an NSView.
+        Aside from being dead code, it was only used when accelerated compositing
+        was not enabled and tha hasn't been possible for a long time, it required a
+        layering violation to get the FrameView.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::currentRenderingMode):
+        (WebCore::MediaPlayerPrivateQTKit::preferredRenderingMode):
+        (WebCore::MediaPlayerPrivateQTKit::setUpVideoRendering):
+        (WebCore::MediaPlayerPrivateQTKit::tearDownVideoRendering):
+        (WebCore::MediaPlayerPrivateQTKit::hasSetUpVideoRendering):
+        (WebCore::MediaPlayerPrivateQTKit::setSize):
+        (WebCore::MediaPlayerPrivateQTKit::paint):
+        (WebCore::mainThreadSetNeedsDisplay): Deleted.
+        (WebCore::MediaPlayerPrivateQTKit::createQTMovieView): Deleted.
+        (WebCore::MediaPlayerPrivateQTKit::detachQTMovieView): Deleted.
+        (-[WebCoreMovieObserver menuForEventDelegate:]): Deleted.
+        (-[WebCoreMovieObserver setView:]): Deleted.
+
 2014-09-30  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Move GtkPopupMenu implementation to WebPopupMenuProxyGtk
index 07bb08c..80c2cea 100644 (file)
@@ -42,7 +42,6 @@ class QTTime;
 OBJC_CLASS NSDictionary;
 OBJC_CLASS NSMutableDictionary;
 OBJC_CLASS QTMovie;
-OBJC_CLASS QTMovieView;
 OBJC_CLASS QTMovieLayer;
 OBJC_CLASS QTVideoRendererWebKitOnly;
 OBJC_CLASS WebCoreMovieObserver;
@@ -139,7 +138,7 @@ private:
     void createQTMovie(const String& url);
     void createQTMovie(NSURL *, NSDictionary *movieAttributes);
 
-    enum MediaRenderingMode { MediaRenderingNone, MediaRenderingMovieView, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
+    enum MediaRenderingMode { MediaRenderingNone, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
     MediaRenderingMode currentRenderingMode() const;
     MediaRenderingMode preferredRenderingMode() const;
     
@@ -147,9 +146,6 @@ private:
     void tearDownVideoRendering();
     bool hasSetUpVideoRendering() const;
     
-    void createQTMovieView();
-    void detachQTMovieView();
-    
     enum QTVideoRendererMode { QTVideoRendererModeDefault, QTVideoRendererModeListensForNewImages };
     void createQTVideoRenderer(QTVideoRendererMode rendererMode);
     void destroyQTVideoRenderer();
@@ -180,7 +176,6 @@ private:
 
     MediaPlayer* m_player;
     RetainPtr<QTMovie> m_qtMovie;
-    RetainPtr<QTMovieView> m_qtMovieView;
     RetainPtr<QTVideoRendererWebKitOnly> m_qtVideoRenderer;
     RetainPtr<WebCoreMovieObserver> m_objcObserver;
     String m_movieURL;
index d552558..737472d 100644 (file)
@@ -32,7 +32,6 @@
 #import "BlockExceptions.h"
 #import "DocumentLoader.h"
 #import "Frame.h"
-#import "FrameView.h"
 #import "HostWindow.h"
 #import "GraphicsContext.h"
 #import "URL.h"
@@ -52,7 +51,6 @@ SOFT_LINK_FRAMEWORK(QTKit)
 SOFT_LINK(QTKit, QTMakeTime, QTTime, (long long timeValue, long timeScale), (timeValue, timeScale))
 
 SOFT_LINK_CLASS(QTKit, QTMovie)
-SOFT_LINK_CLASS(QTKit, QTMovieView)
 SOFT_LINK_CLASS(QTKit, QTMovieLayer)
 
 SOFT_LINK_POINTER(QTKit, QTTrackMediaTypeAttribute, NSString *)
@@ -97,7 +95,6 @@ SOFT_LINK_POINTER_OPTIONAL(QTKit, QTSecurityPolicyNoRemoteToLocalSiteAttribute,
 @end
 
 #define QTMovie getQTMovieClass()
-#define QTMovieView getQTMovieViewClass()
 #define QTMovieLayer getQTMovieLayerClass()
 
 #define QTTrackMediaTypeAttribute getQTTrackMediaTypeAttribute()
@@ -145,21 +142,15 @@ enum {
 };
 #endif
 
-@interface FakeQTMovieView : NSObject
-- (WebCoreMovieObserver *)delegate;
-@end
-
 using namespace WebCore;
 
 @interface WebCoreMovieObserver : NSObject
 {
     MediaPlayerPrivateQTKit* m_callback;
-    NSView* m_view;
     BOOL m_delayCallbacks;
 }
 -(id)initWithCallback:(MediaPlayerPrivateQTKit*)callback;
 -(void)disconnect;
--(void)setView:(NSView*)view;
 -(void)repaint;
 -(void)setDelayCallbacks:(BOOL)shouldDelay;
 -(void)loadStateChanged:(NSNotification *)notification;
@@ -381,81 +372,12 @@ void MediaPlayerPrivateQTKit::createQTMovie(NSURL *url, NSDictionary *movieAttri
                                                object:m_qtMovie.get()];
 }
 
-static void mainThreadSetNeedsDisplay(id self, SEL)
-{
-    id view = [self superview];
-    ASSERT(!view || [view isKindOfClass:[QTMovieView class]]);
-    if (!view || ![view isKindOfClass:[QTMovieView class]])
-        return;
-
-    FakeQTMovieView *movieView = static_cast<FakeQTMovieView *>(view);
-    WebCoreMovieObserver* delegate = [movieView delegate];
-    ASSERT(!delegate || [delegate isKindOfClass:[WebCoreMovieObserver class]]);
-    if (!delegate || ![delegate isKindOfClass:[WebCoreMovieObserver class]])
-        return;
-
-    [delegate repaint];
-}
-
 static Class QTVideoRendererClass()
 {
      static Class QTVideoRendererWebKitOnlyClass = NSClassFromString(@"QTVideoRendererWebKitOnly");
      return QTVideoRendererWebKitOnlyClass;
 }
 
-void MediaPlayerPrivateQTKit::createQTMovieView()
-{
-    LOG(Media, "MediaPlayerPrivateQTKit::createQTMovieView(%p)", this);
-    detachQTMovieView();
-
-    static bool addedCustomMethods = false;
-    if (!m_player->inMediaDocument() && !addedCustomMethods) {
-        Class QTMovieContentViewClass = NSClassFromString(@"QTMovieContentView");
-        ASSERT(QTMovieContentViewClass);
-
-        Method mainThreadSetNeedsDisplayMethod = class_getInstanceMethod(QTMovieContentViewClass, @selector(_mainThreadSetNeedsDisplay));
-        ASSERT(mainThreadSetNeedsDisplayMethod);
-
-        method_setImplementation(mainThreadSetNeedsDisplayMethod, reinterpret_cast<IMP>(mainThreadSetNeedsDisplay));
-        addedCustomMethods = true;
-    }
-
-    // delay callbacks as we *will* get notifications during setup
-    [m_objcObserver.get() setDelayCallbacks:YES];
-
-    m_qtMovieView = adoptNS([[QTMovieView alloc] init]);
-    setSize(m_player->size());
-    NSView* parentView = 0;
-    parentView = m_player->frameView()->documentView();
-    [parentView addSubview:m_qtMovieView.get()];
-    [m_qtMovieView.get() setDelegate:m_objcObserver.get()];
-    [m_objcObserver.get() setView:m_qtMovieView.get()];
-    [m_qtMovieView.get() setMovie:m_qtMovie.get()];
-    [m_qtMovieView.get() setControllerVisible:NO];
-    [m_qtMovieView.get() setPreservesAspectRatio:NO];
-    // the area not covered by video should be transparent
-    [m_qtMovieView.get() setFillColor:[NSColor clearColor]];
-
-    // If we're in a media document, allow QTMovieView to render in its default mode;
-    // otherwise tell it to draw synchronously.
-    // Note that we expect mainThreadSetNeedsDisplay to be invoked only when synchronous drawing is requested.
-    if (!m_player->inMediaDocument())
-        wkQTMovieViewSetDrawSynchronously(m_qtMovieView.get(), YES);
-
-    [m_objcObserver.get() setDelayCallbacks:NO];
-}
-
-void MediaPlayerPrivateQTKit::detachQTMovieView()
-{
-    LOG(Media, "MediaPlayerPrivateQTKit::detachQTMovieView(%p)", this);
-    if (m_qtMovieView) {
-        [m_objcObserver.get() setView:nil];
-        [m_qtMovieView.get() setDelegate:nil];
-        [m_qtMovieView.get() removeFromSuperview];
-        m_qtMovieView = nil;
-    }
-}
-
 void MediaPlayerPrivateQTKit::createQTVideoRenderer(QTVideoRendererMode rendererMode)
 {
     LOG(Media, "MediaPlayerPrivateQTKit::createQTVideoRenderer(%p)", this);
@@ -528,9 +450,6 @@ void MediaPlayerPrivateQTKit::destroyQTMovieLayer()
 
 MediaPlayerPrivateQTKit::MediaRenderingMode MediaPlayerPrivateQTKit::currentRenderingMode() const
 {
-    if (m_qtMovieView)
-        return MediaRenderingMovieView;
-    
     if (m_qtVideoLayer)
         return MediaRenderingMovieLayer;
 
@@ -542,14 +461,14 @@ MediaPlayerPrivateQTKit::MediaRenderingMode MediaPlayerPrivateQTKit::currentRend
 
 MediaPlayerPrivateQTKit::MediaRenderingMode MediaPlayerPrivateQTKit::preferredRenderingMode() const
 {
-    if (!m_player->frameView() || !m_qtMovie)
+    if (!m_qtMovie)
         return MediaRenderingNone;
 
     if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
         return MediaRenderingMovieLayer;
 
     if (!QTVideoRendererClass())
-        return MediaRenderingMovieView;
+        return MediaRenderingNone;
     
     return MediaRenderingSoftwareRenderer;
 }
@@ -569,9 +488,6 @@ void MediaPlayerPrivateQTKit::setUpVideoRendering()
         tearDownVideoRendering();
 
     switch (preferredMode) {
-    case MediaRenderingMovieView:
-        createQTMovieView();
-        break;
     case MediaRenderingNone:
     case MediaRenderingSoftwareRenderer:
         createQTVideoRenderer(QTVideoRendererModeListensForNewImages);
@@ -589,8 +505,6 @@ void MediaPlayerPrivateQTKit::setUpVideoRendering()
 void MediaPlayerPrivateQTKit::tearDownVideoRendering()
 {
     LOG(Media, "MediaPlayerPrivateQTKit::tearDownVideoRendering(%p)", this);
-    if (m_qtMovieView)
-        detachQTMovieView();
     if (m_qtVideoRenderer)
         destroyQTVideoRenderer();
     if (m_qtVideoLayer)
@@ -599,8 +513,7 @@ void MediaPlayerPrivateQTKit::tearDownVideoRendering()
 
 bool MediaPlayerPrivateQTKit::hasSetUpVideoRendering() const
 {
-    return m_qtMovieView
-        || m_qtVideoLayer
+    return m_qtVideoLayer
         || m_qtVideoRenderer;
 }
 
@@ -1219,13 +1132,6 @@ void MediaPlayerPrivateQTKit::layerHostChanged(PlatformLayer* rootLayer)
 
 void MediaPlayerPrivateQTKit::setSize(const IntSize&) 
 { 
-    // Don't resize the view now because [view setFrame] also resizes the movie itself, and because
-    // the renderer calls this function immediately when we report a size change (QTMovieSizeDidChangeNotification)
-    // we can get into a feedback loop observing the size change and resetting the size, and this can cause
-    // QuickTime to miss resetting a movie's size when the media size changes (as happens with an rtsp movie
-    // once the rtsp server sends the track sizes). Instead we remember the size passed to paint() and resize
-    // the view when it changes.
-    // <rdar://problem/6336092> REGRESSION: rtsp movie does not resize correctly
 }
 
 void MediaPlayerPrivateQTKit::setVisible(bool b)
@@ -1280,9 +1186,8 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
 {
     if (context->paintingDisabled() || m_hasUnsupportedTracks)
         return;
-    NSView *view = m_qtMovieView.get();
     id qtVideoRenderer = m_qtVideoRenderer.get();
-    if (!view && !qtVideoRenderer)
+    if (!qtVideoRenderer)
         return;
 
     [m_objcObserver.get() setDelayCallbacks:YES];
@@ -1298,36 +1203,10 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
 
     newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
 
-    // draw the current video frame
-    if (qtVideoRenderer) {
-        [NSGraphicsContext saveGraphicsState];
-        [NSGraphicsContext setCurrentContext:newContext];
-        [(id<WebKitVideoRenderingDetails>)qtVideoRenderer drawInRect:paintRect];
-        [NSGraphicsContext restoreGraphicsState];
-    } else {
-        if (m_rect != r) {
-             m_rect = r;
-            if (m_player->inMediaDocument()) {
-                // the QTMovieView needs to be placed in the proper location for document mode
-                [view setFrame:m_rect];
-            }
-            else {
-                // We don't really need the QTMovieView in any specific location so let's just get it out of the way
-                // where it won't intercept events or try to bring up the context menu.
-                IntRect farAwayButCorrectSize(m_rect);
-                farAwayButCorrectSize.move(-1000000, -1000000);
-                [view setFrame:farAwayButCorrectSize];
-            }
-        }
-
-        if (m_player->inMediaDocument()) {
-            // If we're using a QTMovieView in a media document, the view may get layer-backed. AppKit won't update
-            // the layer hosting correctly if we call displayRectIgnoringOpacity:inContext:, so use displayRectIgnoringOpacity:
-            // in this case. See <rdar://problem/6702882>.
-            [view displayRectIgnoringOpacity:paintRect];
-        } else
-            [view displayRectIgnoringOpacity:paintRect inContext:newContext];
-    }
+    [NSGraphicsContext saveGraphicsState];
+    [NSGraphicsContext setCurrentContext:newContext];
+    [(id<WebKitVideoRenderingDetails>)qtVideoRenderer drawInRect:paintRect];
+    [NSGraphicsContext restoreGraphicsState];
 
     END_BLOCK_OBJC_EXCEPTIONS;
     [m_objcObserver.get() setDelayCallbacks:NO];
@@ -1642,17 +1521,6 @@ void MediaPlayerPrivateQTKit::setPrivateBrowsingMode(bool privateBrowsing)
     m_callback = 0;
 }
 
--(NSMenu*)menuForEventDelegate:(NSEvent*)theEvent
-{
-    // Get the contextual menu from the QTMovieView's superview, the frame view
-    return [[m_view superview] menuForEvent:theEvent];
-}
-
--(void)setView:(NSView*)view
-{
-    m_view = view;
-}
-
 -(void)repaint
 {
     if (m_delayCallbacks)