Fix for bug 13972, quicktime doesn't respect CSS clip and overflow properties.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2007 07:04:17 +0000 (07:04 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2007 07:04:17 +0000 (07:04 +0000)
        Make sure that calls to [NSView visibleRect] will do the right thing for both
        Netscape plugins and WebKit plugins.

        Reviewed by olliej

        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView visibleRect]):
        (-[WebBaseNetscapePluginView saveAndSetNewPortStateForUpdate:]):
        (-[WebBaseNetscapePluginView isOpaque]):
        * Plugins/WebKitPluginContainerView.h: Added.
        * Plugins/WebKitPluginContainerView.mm: Added.
        (-[WebKitPluginContainerView initWithFrame:DOMElement:]):
        (-[WebKitPluginContainerView dealloc]):
        (-[WebKitPluginContainerView visibleRect]):
        * Plugins/WebPluginController.mm:
        (-[WebPluginController destroyAllPlugins]):
        * WebCoreSupport/WebFrameBridge.mm:
        (-[WebFrameBridge pluginViewWithPackage:attributeNames:attributeValues:baseURL:DOMElement:loadManually:]):
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebHTMLView.mm:
        (-[WebHTMLView addSubview:]):
        (-[WebHTMLView willRemoveSubview:]):

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

WebKit/ChangeLog
WebKit/Plugins/WebBaseNetscapePluginView.mm
WebKit/Plugins/WebKitPluginContainerView.h [new file with mode: 0644]
WebKit/Plugins/WebKitPluginContainerView.mm [new file with mode: 0644]
WebKit/Plugins/WebPluginController.mm
WebKit/WebCoreSupport/WebFrameBridge.mm
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebHTMLView.mm

index d8b6fc24d7df24d4fc8dcce603038c2540b63614..de041dc3cc904c9a3592a4932f00c96189f0edec 100644 (file)
@@ -1,3 +1,29 @@
+2007-06-06  David Hyatt  <hyatt@apple.com>
+
+        Fix for bug 13972, quicktime doesn't respect CSS clip and overflow properties.
+        Make sure that calls to [NSView visibleRect] will do the right thing for both
+        Netscape plugins and WebKit plugins.
+
+        Reviewed by olliej
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView visibleRect]):
+        (-[WebBaseNetscapePluginView saveAndSetNewPortStateForUpdate:]):
+        (-[WebBaseNetscapePluginView isOpaque]):
+        * Plugins/WebKitPluginContainerView.h: Added.
+        * Plugins/WebKitPluginContainerView.mm: Added.
+        (-[WebKitPluginContainerView initWithFrame:DOMElement:]):
+        (-[WebKitPluginContainerView dealloc]):
+        (-[WebKitPluginContainerView visibleRect]):
+        * Plugins/WebPluginController.mm:
+        (-[WebPluginController destroyAllPlugins]):
+        * WebCoreSupport/WebFrameBridge.mm:
+        (-[WebFrameBridge pluginViewWithPackage:attributeNames:attributeValues:baseURL:DOMElement:loadManually:]):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView addSubview:]):
+        (-[WebHTMLView willRemoveSubview:]):
+
 2007-06-04  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Geoff and Justin.
index 1918a755254af22f95297a19152c5fee57badc0f..f2e88fbec49d4737acc03747455a8d98a2604d70 100644 (file)
@@ -308,6 +308,13 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     npr.right = static_cast<uint16>(NSMaxX(nr));
 }
 
+- (NSRect)visibleRect
+{
+    // WebCore may impose an additional clip (via CSS overflow or clip properties).  Fetch
+    // that clip now.    
+    return NSIntersectionRect([self convertRect:[element _windowClipRect] fromView:nil], [super visibleRect]);
+}
+
 - (PortState)saveAndSetNewPortStateForUpdate:(BOOL)forUpdate
 {
     ASSERT([self currentWindow] != nil);
@@ -326,11 +333,6 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     NSRect boundsInWindow = [self convertRect:[self bounds] toView:nil];
     NSRect visibleRectInWindow = [self convertRect:[self visibleRect] toView:nil];
     
-    // WebCore may impose an additional clip (via CSS overflow or clip properties).  Fetch
-    // that clip now.
-    NSRect windowClipRect = [element _windowClipRect];
-    visibleRectInWindow = NSIntersectionRect(visibleRectInWindow, windowClipRect);
-
     // Flip Y to convert NSWindow coordinates to top-left-based window coordinates.
     float borderViewHeight = [[self currentWindow] frame].size.height;
     boundsInWindow.origin.y = borderViewHeight - NSMaxY(boundsInWindow);
@@ -2396,6 +2398,11 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
         (float)invalidRect->right - invalidRect->left, (float)invalidRect->bottom - invalidRect->top)];
 }
 
+-(bool)isOpaque
+{
+    return YES;
+}
+
 - (void)invalidateRegion:(NPRegion)invalidRegion
 {
     LOG(Plugins, "NPN_InvalidateRegion");
diff --git a/WebKit/Plugins/WebKitPluginContainerView.h b/WebKit/Plugins/WebKitPluginContainerView.h
new file mode 100644 (file)
index 0000000..7f062b7
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2007 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@class DOMElement;
+
+@interface WebKitPluginContainerView : NSView
+{   
+    DOMElement *_element;
+}
+
+- (id)initWithFrame:(NSRect)r
+         DOMElement:(DOMElement *)anElement;
+
+@end
diff --git a/WebKit/Plugins/WebKitPluginContainerView.mm b/WebKit/Plugins/WebKitPluginContainerView.mm
new file mode 100644 (file)
index 0000000..690f898
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2007 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
+ */
+
+#import "WebKitPluginContainerView.h"
+#import <WebKit/DOMPrivate.h>
+
+@implementation WebKitPluginContainerView
+- (id)initWithFrame:(NSRect)frame
+         DOMElement:(DOMElement *)anElement
+{
+    [super initWithFrame:frame];
+
+    _element = [anElement retain];
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [_element release];
+    [super dealloc];
+}
+
+- (NSRect)visibleRect
+{
+    // WebCore may impose an additional clip (via CSS overflow or clip properties).  Fetch
+    // that clip now.    
+    return NSIntersectionRect([self convertRect:[_element _windowClipRect] fromView:nil], [super visibleRect]);
+}
+
+@end
+
index 06c64e78099cd570f16a563aba8082bf189fe4e3..1bf17bfed2e61c2d7b7c7bbb1bd0919324936925 100644 (file)
@@ -275,8 +275,11 @@ static void cancelOutstandingCheck(const void *item, void *context)
             [aView pluginDestroy];
         }
         [pluginViews removeObject:aView];
+        
+        // Remove the containing view.
+        [[aView superview] removeFromSuperviewWithoutNeedingDisplay];
     }
-    [_views makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
+
     [_views release];
     _views = nil;
 
index 16ac318f62de25f14e22ebf7cc200e75e6393a80..0d7e09564d04f49ceb5baa647ab4ab4ea6de148c 100644 (file)
@@ -50,6 +50,7 @@
 #import "WebKitErrorsPrivate.h"
 #import "WebKitLogging.h"
 #import "WebKitNSStringExtras.h"
+#import "WebKitPluginContainerView.h"
 #import "WebKitStatisticsPrivate.h"
 #import "WebKitSystemBits.h"
 #import "WebLocalizableStrings.h"
@@ -417,9 +418,16 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     }
 
     view = [WebPluginController plugInViewWithArguments:arguments fromPluginPackage:pluginPackage];
-    
+    [view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+
     [attributes release];
-    return view;
+    
+    WebKitPluginContainerView* containerView = [[[WebKitPluginContainerView alloc] initWithFrame:NSZeroRect DOMElement:element] autorelease];
+    [view setFrame:NSZeroRect];
+    [containerView setAutoresizesSubviews:YES];
+    [containerView addSubview:view];
+    
+    return containerView;
 }
 
 - (NSString *)valueForKey:(NSString *)key keys:(NSArray *)keys values:(NSArray *)values
index 8355bfffc646f26bacd8ac32a28a182863fb3118..1c8021f638e44d645bfe1f01900e3d7e6a3a3590 100644 (file)
                A7D3C5BC0B5773C5002CA450 /* WebPasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */; };
                A7D3C5BD0B5773C5002CA450 /* WebPasteboardHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = A7D3C5BB0B5773C5002CA450 /* WebPasteboardHelper.mm */; };
                ABDDF20D08EB0DDC001E1241 /* WebDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */; };
+               BCDFA8F90C10B6F500D3A10C /* WebKitPluginContainerView.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDFA8F80C10B6F500D3A10C /* WebKitPluginContainerView.h */; };
+               BCDFA9130C10B93E00D3A10C /* WebKitPluginContainerView.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCDFA9120C10B93E00D3A10C /* WebKitPluginContainerView.mm */; };
                DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; };
                DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
                DD89682109AA87240097E7F0 /* WebElementDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */; };
                A7D3C5BA0B5773C5002CA450 /* WebPasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPasteboardHelper.h; sourceTree = "<group>"; };
                A7D3C5BB0B5773C5002CA450 /* WebPasteboardHelper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPasteboardHelper.mm; sourceTree = "<group>"; };
                ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDownloadInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               BCDFA8F80C10B6F500D3A10C /* WebKitPluginContainerView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebKitPluginContainerView.h; sourceTree = "<group>"; };
+               BCDFA9120C10B93E00D3A10C /* WebKitPluginContainerView.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitPluginContainerView.mm; sourceTree = "<group>"; };
                BE4FBECB0653DF47005EDE15 /* WebEditingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebEditingDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BE6DC39904C62C4E004D0EF6 /* WebNSURLExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSURLExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BE6DC39A04C62C4E004D0EF6 /* WebNSURLExtras.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSURLExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                F5A672B90263866E01000102 /* WebBaseNetscapePluginStream.h */,
                                F5A672BA0263866E01000102 /* WebBaseNetscapePluginStream.mm */,
                                F5EBC45502134BC301CA1520 /* WebBaseNetscapePluginView.h */,
+                               BCDFA8F80C10B6F500D3A10C /* WebKitPluginContainerView.h */,
                                2203984A0922D765009C3FFC /* WebBaseNetscapePluginViewInternal.h */,
                                931A72D203265920008635CE /* WebBaseNetscapePluginViewPrivate.h */,
                                F5EBC45602134BC301CA1520 /* WebBaseNetscapePluginView.mm */,
+                               BCDFA9120C10B93E00D3A10C /* WebKitPluginContainerView.mm */,
                                84D4BFF70348EF7600CA2ACA /* WebNetscapePluginEmbeddedView.h */,
                                84D4BFF80348EF7600CA2ACA /* WebNetscapePluginEmbeddedView.mm */,
                                F5F7171E0288493C018635CA /* WebNetscapePluginPackage.h */,
                                A7D3C5BC0B5773C5002CA450 /* WebPasteboardHelper.h in Headers */,
                                EDE983800BCDF5FE00FDAE28 /* WebNSArrayExtras.h in Headers */,
                                5DE92FEF0BD7017E0059A5FD /* WebAssertions.h in Headers */,
+                               BCDFA8F90C10B6F500D3A10C /* WebKitPluginContainerView.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A70936B00B5608DC00CDB48E /* WebDragClient.mm in Sources */,
                                A7D3C5BD0B5773C5002CA450 /* WebPasteboardHelper.mm in Sources */,
                                EDE983810BCDF5FE00FDAE28 /* WebNSArrayExtras.m in Sources */,
+                               BCDFA9130C10B93E00D3A10C /* WebKitPluginContainerView.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 27c4015b24986f0ae9479d142d09078c26004231..b8e9c86fcb2f344d80d2f5e792284a2098ed6ebf 100644 (file)
@@ -49,6 +49,7 @@
 #import "WebHTMLViewInternal.h"
 #import "WebKitLogging.h"
 #import "WebKitNSStringExtras.h"
+#import "WebKitPluginContainerView.h"
 #import "WebKitVersionChecks.h"
 #import "WebLocalizableStrings.h"
 #import "WebNSAttributedStringExtras.h"
@@ -2438,15 +2439,14 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
 {
     [super addSubview:view];
 
-    if ([WebPluginController isPlugInView:view]) {
-        [[self _pluginController] addPlugin:view];
-    }
+    if ([view isKindOfClass:[WebKitPluginContainerView class]])
+        [[self _pluginController] addPlugin:[[view subviews] objectAtIndex:0]];
 }
 
 - (void)willRemoveSubview:(NSView *)subview
 {
-    if ([WebPluginController isPlugInView:subview])
-        [[self _pluginController] destroyPlugin:subview];
+    if ([subview isKindOfClass:[WebKitPluginContainerView class]])
+        [[self _pluginController] destroyPlugin:[[subview subviews] objectAtIndex:0]];
     [super willRemoveSubview:subview];
 }