WebCore: WebCore part of
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Mar 2010 00:27:12 +0000 (00:27 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Mar 2010 00:27:12 +0000 (00:27 +0000)
<rdar://problem/7197736> Plug-in clip rect does not update when overflow
clip changes
https://bugs.webkit.org/show_bug.cgi?id=36479.

Reviewed by John Sullivan.

* manual-tests/plugin-visible-rect-change.html: Added.
* platform/mac/WidgetMac.mm:
(WebCore::WidgetPrivate::WidgetPrivate): Added previousVisibleRect.
(WebCore::Widget::setFrameRect): If the visible rect changed but the
frame rect did not, send a -visibleRectDidChange message to the view,
if it responds to it.
(WebCore::Widget::releasePlatformWidget): Reset previousVisibleRect.
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::setWidgetGeometry): Track changes to the clip rect
imposed by the enclosing layer. Call Widget::setFrameRect when it changes,
even if the frame rect did not.
* rendering/RenderWidget.h:
(WebCore::RenderWidget::windowClipRect): Added this accessor.

WebKit/mac: WebKit part of
<rdar://problem/7197736> Plug-in clip rect does not update when overflow
clip changes
https://bugs.webkit.org/show_bug.cgi?id=36479.

Reviewed by John Sullivan.

* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView visibleRectDidChange]): Added. Calls
WKSyncSurfaceToView().
* Plugins/WebBaseNetscapePluginView.h:
* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView _windowClipRect]): Changed to use Widget::windowClipRect().
(-[WebBaseNetscapePluginView visibleRectDidChange]): Added. Invokes -renewGState.

WebKitLibraries: WebKitSystemInterface part of
<rdar://problem/7197736> Plug-in clip rect does not update when overflow
clip changes
https://bugs.webkit.org/show_bug.cgi?id=36479.

Reviewed by John Sullivan.

* WebKitSystemInterface.h: Added WKSyncSurfaceToView().
* libWebKitSystemInterfaceSnowLeopard.a: Updated

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

13 files changed:
WebCore/ChangeLog
WebCore/manual-tests/plugin-visible-rect-change.html [new file with mode: 0644]
WebCore/platform/mac/WidgetMac.mm
WebCore/rendering/RenderWidget.cpp
WebCore/rendering/RenderWidget.h
WebKit/mac/ChangeLog
WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
WebKit/mac/Plugins/WebBaseNetscapePluginView.h
WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index 0158349..882d518 100644 (file)
@@ -1,3 +1,26 @@
+2010-03-23  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by John Sullivan.
+
+        WebCore part of
+        <rdar://problem/7197736> Plug-in clip rect does not update when overflow
+        clip changes
+        https://bugs.webkit.org/show_bug.cgi?id=36479.
+
+        * manual-tests/plugin-visible-rect-change.html: Added.
+        * platform/mac/WidgetMac.mm:
+        (WebCore::WidgetPrivate::WidgetPrivate): Added previousVisibleRect.
+        (WebCore::Widget::setFrameRect): If the visible rect changed but the
+        frame rect did not, send a -visibleRectDidChange message to the view,
+        if it responds to it.
+        (WebCore::Widget::releasePlatformWidget): Reset previousVisibleRect.
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::setWidgetGeometry): Track changes to the clip rect
+        imposed by the enclosing layer. Call Widget::setFrameRect when it changes,
+        even if the frame rect did not.
+        * rendering/RenderWidget.h:
+        (WebCore::RenderWidget::windowClipRect): Added this accessor.
+
 2010-03-23  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/manual-tests/plugin-visible-rect-change.html b/WebCore/manual-tests/plugin-visible-rect-change.html
new file mode 100644 (file)
index 0000000..3f5393a
--- /dev/null
@@ -0,0 +1,25 @@
+<p>
+    This test requires that accelerated compositing be dsiabled. Clicking the Test button should completely reveal the black-bordered box.
+    The orange video should completely fill the box, with the controller visible and touching the bottom of the box. There should be
+    not ba any red visible.
+</p>
+<p>
+    <button onclick="test()">Test</button>
+</p>
+<div style="overflow: hidden; border: solid blue; position: relative;">
+    <div style="height: 100px; padding: 0 8px;">
+    </div>
+    <object type="video/quicktime" style="background-color: red; width: 300px; height: 241px; position: absolute; top: 50px; left: 40px; border: solid black;">
+        <param name="src" value="resources/orange.mov">
+        <param name="controller" value="true">
+        <param name="autoplay" value="false">
+        <param name="scale" value="tofit">
+    </object>
+    <div id="target"></div>
+    <script>
+        function test()
+        {
+            document.getElementById("target").style.height = "500px";
+        }
+    </script>
+</div>
index e473053..1aad76f 100644 (file)
 - (void)webPlugInSetIsSelected:(BOOL)isSelected;
 @end
 
+@interface NSView (Widget)
+- (void)visibleRectDidChange;
+@end
+
 namespace WebCore {
 
 class WidgetPrivate {
 public:
+    WidgetPrivate()
+        : previousVisibleRect(NSZeroRect)
+    {
+    }
+
     bool mustStayInWindow;
     bool removeFromSuperviewSoon;
+    NSRect previousVisibleRect;
 };
 
 static void safeRemoveFromSuperview(NSView *view)
@@ -162,11 +172,15 @@ void Widget::setFrameRect(const IntRect& rect)
     if (!v)
         return;
 
+    NSRect visibleRect = [v visibleRect];
     NSRect f = rect;
     if (!NSEqualRects(f, [v frame])) {
         [v setFrame:f];
-        [v setNeedsDisplay: NO];
-    }
+        [v setNeedsDisplay:NO];
+    } else if (!NSEqualRects(visibleRect, m_data->previousVisibleRect) && [v respondsToSelector:@selector(visibleRectDidChange)])
+        [v visibleRectDidChange];
+
+    m_data->previousVisibleRect = visibleRect;
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
@@ -339,6 +353,7 @@ IntPoint Widget::convertFromContainingWindowToRoot(const Widget* rootWidget, con
 void Widget::releasePlatformWidget()
 {
     HardRelease(m_widget);
+    m_data->previousVisibleRect = NSZeroRect;
 }
 
 void Widget::retainPlatformWidget()
index 96a2731..561bead 100644 (file)
@@ -151,13 +151,22 @@ RenderWidget::~RenderWidget()
 bool RenderWidget::setWidgetGeometry(const IntRect& frame)
 {
     ASSERT(!widgetHierarchyUpdateSuspendCount);
-    if (!node() || m_widget->frameRect() == frame)
+    if (!node())
         return false;
 
+    IntRect windowClipRect = m_frameView ? m_frameView->windowClipRectForLayer(enclosingLayer(), true) : IntRect();
+    bool clipChanged = m_windowClipRect != windowClipRect;
+    bool boundsChanged = m_widget->frameRect() != frame;
+
+    if (!boundsChanged && !clipChanged)
+        return false;
+
+    m_windowClipRect = windowClipRect;
+
     RenderWidgetProtector protector(this);
     RefPtr<Node> protectedNode(node());
     m_widget->setFrameRect(frame);
-    return true;
+    return boundsChanged;
 }
 
 void RenderWidget::setWidget(PassRefPtr<Widget> widget)
index fd6c807..e579556 100644 (file)
@@ -40,6 +40,7 @@ public:
 
     void updateWidgetPosition();
     void widgetPositionsUpdated();
+    IntRect windowClipRect() const { return m_windowClipRect; }
 
     void showSubstituteImage(PassRefPtr<Image>);
 
@@ -74,6 +75,7 @@ private:
     RefPtr<Widget> m_widget;
     RefPtr<Image> m_substituteImage;
     FrameView* m_frameView;
+    IntRect m_windowClipRect;
     int m_refCount;
 };
 
index bff0179..2da922c 100644 (file)
@@ -1,3 +1,20 @@
+2010-03-23  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by John Sullivan.
+
+        WebKit part of
+        <rdar://problem/7197736> Plug-in clip rect does not update when overflow
+        clip changes
+        https://bugs.webkit.org/show_bug.cgi?id=36479.
+
+        * Plugins/Hosted/WebHostedNetscapePluginView.mm:
+        (-[WebHostedNetscapePluginView visibleRectDidChange]): Added. Calls
+        WKSyncSurfaceToView().
+        * Plugins/WebBaseNetscapePluginView.h:
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView _windowClipRect]): Changed to use Widget::windowClipRect().
+        (-[WebBaseNetscapePluginView visibleRectDidChange]): Added. Invokes -renewGState.
+
 2010-03-22  Kevin Decker  <kdecker@apple.com>
 
         Reviewed by Simon Fraser.
index 0e099f9..e80172c 100644 (file)
@@ -366,6 +366,11 @@ extern "C" {
     [self invalidatePluginContentRect:[self bounds]];
 }
 
+- (void)visibleRectDidChange
+{
+    [super visibleRectDidChange];
+    WKSyncSurfaceToView(self);
+}
 
 - (void)drawRect:(NSRect)rect
 {
index 090bc4f..af3ffc2 100644 (file)
@@ -48,6 +48,11 @@ namespace WebCore {
 
 class WebHaltablePlugin;
 
+// Also declared in WebCore/WidgetMac.mm
+@interface NSView (Widget)
+- (void)visibleRectDidChange;
+@end
+
 @interface WebBaseNetscapePluginView : NSView
 {
     RetainPtr<WebNetscapePluginPackage> _pluginPackage;
index 34a8464..bd3eb34 100644 (file)
@@ -337,13 +337,10 @@ String WebHaltablePlugin::pluginName() const
 - (NSRect)_windowClipRect
 {
     RenderObject* renderer = _element->renderer();
-    
-    if (renderer && renderer->view()) {
-        if (FrameView* frameView = renderer->view()->frameView())
-            return frameView->windowClipRectForLayer(renderer->enclosingLayer(), true);
-    }
-    
-    return NSZeroRect;
+    if (!renderer || !renderer->view())
+        return NSZeroRect;
+
+    return toRenderWidget(renderer)->windowClipRect();
 }
 
 - (NSRect)visibleRect
@@ -353,6 +350,11 @@ String WebHaltablePlugin::pluginName() const
     return NSIntersectionRect([self convertRect:[self _windowClipRect] fromView:nil], [super visibleRect]);
 }
 
+- (void)visibleRectDidChange
+{
+    [self renewGState];
+}
+
 - (BOOL)acceptsFirstResponder
 {
     return YES;
index 639f3c1..97438eb 100644 (file)
@@ -270,9 +270,9 @@ static void fixMenusReceivedFromOldClients(NSMutableArray *newMenuItems, NSMutab
 
 NSMutableArray* WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* defaultMenu)
 {
-    id delegate = [m_webView UIDelegate];
+//    id delegate = [m_webView UIDelegate];
     SEL selector = @selector(webView:contextMenuItemsForElement:defaultMenuItems:);
-    if (![delegate respondsToSelector:selector])
+//    if (![delegate respondsToSelector:selector])
         return defaultMenu->platformDescription();
 
     NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:defaultMenu->hitTestResult()] autorelease];
index 9c0e0cb..c2bb565 100644 (file)
@@ -1,3 +1,15 @@
+2010-03-23  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by John Sullivan.
+
+        WebKitSystemInterface part of
+        <rdar://problem/7197736> Plug-in clip rect does not update when overflow
+        clip changes
+        https://bugs.webkit.org/show_bug.cgi?id=36479.
+
+        * WebKitSystemInterface.h: Added WKSyncSurfaceToView().
+        * libWebKitSystemInterfaceSnowLeopard.a: Updated
+
 2010-03-16  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Sam Weinig.
index 50815aa..66bd2fb 100644 (file)
@@ -294,6 +294,7 @@ void WKWindowSetScaledFrame(NSWindow *window, NSRect scaleFrame, NSRect nonScale
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
 NSMutableArray *WKNoteOpenPanelFiles(NSArray *paths);
+void WKSyncSurfaceToView(NSView *view);
 #endif
 
 #ifdef __cplusplus
index 27a113a..bca9e6d 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ