Title: [98589] branches/safari-534.52-branch/Source/WebKit2

Diff

Modified: branches/safari-534.52-branch/Source/WebKit2/ChangeLog (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/ChangeLog	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/ChangeLog	2011-10-27 16:26:50 UTC (rev 98589)
@@ -1,3 +1,66 @@
+2011-10-27  Lucas Forschler  <lforsch...@apple.com>
+
+    Merge 98369
+
+    2011-10-25  Anders Carlsson  <ander...@apple.com>
+
+            PDF SUBFRAMES: Incomplete repaint after pinch to zoom
+            https://bugs.webkit.org/show_bug.cgi?id=70821
+            <rdar://problem/10312733>
+
+            Reviewed by Simon Fraser.
+
+            Add a new pure virtual member function, Plugin::wantsWindowRelativeCoordinates.
+            If a plug-in subclass returns true, we'll keep giving the plug-in coordinates that
+            are relative to the containing window. If a plug-in subclass returns false, we'll give it
+            coordinates in a much more sane coordinate system, with the origin at the top left corner of the plug-in.
+
+            Change BuiltinPDFView to return false so that it'll work correctly with pinch to zoom.
+
+            * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+            (WebKit::NetscapePlugin::wantsWindowRelativeCoordinates):
+            Make wantsWindowRelativeCoordinates return true.
+
+            * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+            (WebKit::BuiltInPDFView::paint):
+            Remove translation since the graphics context is already set up in the right way.
+
+            (WebKit::BuiltInPDFView::paintContent):
+            No need to offset by the plug-in view location anymore.
+
+            (WebKit::BuiltInPDFView::paintControls):
+            Account for the scrollbars being children of the parent scroll view here.
+
+            (WebKit::BuiltInPDFView::wantsWindowRelativeCoordinates):
+            Return false.
+
+            (WebKit::BuiltInPDFView::convertFromContainingViewToScrollbar):
+            Implement this so that scrollbar hit testing works correctly.
+
+            * WebProcess/Plugins/Plugin.h:
+            Add wantsWindowRelativeCoordinates.
+
+            * WebProcess/Plugins/PluginProxy.cpp:
+            (WebKit::PluginProxy::wantsWindowRelativeCoordinates):
+            Return true for now.
+
+            * WebProcess/Plugins/PluginView.cpp:
+            (WebKit::PluginView::renderer):
+            Add simple getter.
+
+            (WebKit::PluginView::paint):
+            Handle the case when the plug-in doesn't want window relative coordinates.
+
+            (WebKit::PluginView::transformsAffectFrameRect):
+            Return true here.
+
+            (WebKit::PluginView::viewGeometryDidChange):
+            No need to adjust the bounds to account for the scale factor now, since the frame rect will always be the
+            same regardless of the transform.
+
+            (WebKit::PluginView::clipRectInWindowCoordinates):
+            Ditto.
+
 2011-10-26  Lucas Forschler  <lforsch...@apple.com>
 
     Merge 93720

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-10-27 16:26:50 UTC (rev 98589)
@@ -775,6 +775,11 @@
     return false;
 }
 
+bool NetscapePlugin::wantsWindowRelativeCoordinates()
+{
+    return true;
+}
+
 Scrollbar* NetscapePlugin::horizontalScrollbar()
 {
     return 0;

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-27 16:26:50 UTC (rev 98589)
@@ -190,6 +190,7 @@
 
     virtual void privateBrowsingStateChanged(bool);
     virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    virtual bool wantsWindowRelativeCoordinates();
     virtual WebCore::Scrollbar* horizontalScrollbar();
     virtual WebCore::Scrollbar* verticalScrollbar();
 

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-10-27 16:26:50 UTC (rev 98589)
@@ -38,6 +38,7 @@
 #include <WebCore/LocalizedStrings.h>
 #include <WebCore/Page.h>
 #include <WebCore/PluginData.h>
+#include <WebCore/RenderBoxModelObject.h>
 #include <WebCore/ScrollAnimator.h>
 #include <WebCore/ScrollbarTheme.h>
 
@@ -242,22 +243,15 @@
     m_pluginController = 0;
 }
 
-void BuiltInPDFView::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRectInWindowCoordinates)
+void BuiltInPDFView::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRect)
 {
     scrollAnimator()->contentAreaWillPaint();
 
-    paintBackground(graphicsContext, dirtyRectInWindowCoordinates);
+    paintBackground(graphicsContext, dirtyRect);
 
     if (!m_pdfDocument) // FIXME: Draw loading progress.
         return;
 
-    GraphicsContextStateSaver stateSaver(*graphicsContext);
-
-    // Undo translation to window coordinates performed by PluginView::paint().
-    IntRect dirtyRect = pluginView()->parent()->windowToContents(dirtyRectInWindowCoordinates);
-    IntPoint documentOriginInWindowCoordinates = pluginView()->parent()->windowToContents(IntPoint());
-    graphicsContext->translate(-documentOriginInWindowCoordinates.x(), -documentOriginInWindowCoordinates.y());
-
     paintContent(graphicsContext, dirtyRect);
     paintControls(graphicsContext, dirtyRect);
 }
@@ -281,9 +275,8 @@
 
     graphicsContext->clip(dirtyRect);
     IntRect contentRect(dirtyRect);
-    contentRect.moveBy(-pluginView()->location());
     contentRect.moveBy(IntPoint(m_scrollOffset));
-    graphicsContext->translate(pluginView()->x() - m_scrollOffset.width(), pluginView()->y() - m_scrollOffset.height());
+    graphicsContext->translate(-m_scrollOffset.width(), -m_scrollOffset.height());
 
     CGContextScaleCTM(context, 1, -1);
 
@@ -317,11 +310,19 @@
 
 void BuiltInPDFView::paintControls(GraphicsContext* graphicsContext, const IntRect& dirtyRect)
 {
-    if (m_horizontalScrollbar)
-        m_horizontalScrollbar->paint(graphicsContext, dirtyRect);
-    if (m_verticalScrollbar)
-        m_verticalScrollbar->paint(graphicsContext, dirtyRect);
+    {
+        GraphicsContextStateSaver stateSaver(*graphicsContext);
+        IntRect scrollbarDirtyRect = dirtyRect;
+        scrollbarDirtyRect.moveBy(pluginView()->frameRect().location());
+        graphicsContext->translate(-pluginView()->frameRect().x(), -pluginView()->frameRect().y());
 
+        if (m_horizontalScrollbar)
+            m_horizontalScrollbar->paint(graphicsContext, scrollbarDirtyRect);
+
+        if (m_verticalScrollbar)
+            m_verticalScrollbar->paint(graphicsContext, scrollbarDirtyRect);
+    }
+
     IntRect dirtyCornerRect = intersection(scrollCornerRect(), dirtyRect);
     ScrollbarTheme::nativeTheme()->paintScrollCorner(0, graphicsContext, dirtyCornerRect);
 }
@@ -542,6 +543,11 @@
     return scroll(direction, granularity);
 }
 
+bool BuiltInPDFView::wantsWindowRelativeCoordinates()
+{
+    return false;
+}
+
 Scrollbar* BuiltInPDFView::horizontalScrollbar()
 {
     return m_horizontalScrollbar.get();
@@ -667,4 +673,12 @@
     scrollAnimator()->contentsResized();
 }
 
+IntPoint BuiltInPDFView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const
+{
+    IntPoint point = pluginView()->frame()->view()->convertToRenderer(pluginView()->renderer(), parentPoint);
+    point.move(pluginView()->location() - scrollbar->location());
+
+    return point;
+}
+
 } // namespace WebKit

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-10-27 16:26:50 UTC (rev 98589)
@@ -111,6 +111,7 @@
     virtual void privateBrowsingStateChanged(bool);
     virtual bool getFormValue(String& formValue);
     virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    virtual bool wantsWindowRelativeCoordinates();
     virtual WebCore::Scrollbar* horizontalScrollbar();
     virtual WebCore::Scrollbar* verticalScrollbar();
 
@@ -137,6 +138,9 @@
     virtual bool shouldSuspendScrollAnimations() const { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
     virtual void scrollbarStyleChanged();
 
+    // FIXME: Implement the other conversion functions; this one is enough to get scrollbar hit testing working. 
+    virtual WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntPoint& parentPoint) const;
+
     PluginController* m_pluginController;
 
     // In window coordinates.

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Plugin.h (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-10-27 16:26:50 UTC (rev 98589)
@@ -193,6 +193,10 @@
     // Tells the plug-in that it should scroll. The plug-in should return true if it did scroll.
     virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) = 0;
 
+    // Whether the plug-in wants its coordinates to be relative to the window.
+    // FIXME: No plug-ins should want window relative coordinates, so we should get rid of this.
+    virtual bool wantsWindowRelativeCoordinates() = 0;
+
     // A plug-in can use WebCore scroll bars. Make them known, so that hit testing can find them.
     // FIXME: This code should be in PluginView or its base class, not in individual plug-ins.
     virtual WebCore::Scrollbar* horizontalScrollbar() = 0;

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-27 16:26:50 UTC (rev 98589)
@@ -401,6 +401,11 @@
     return false;
 }
 
+bool PluginProxy::wantsWindowRelativeCoordinates()
+{
+    return true;
+}
+
 Scrollbar* PluginProxy::horizontalScrollbar()
 {
     return 0;

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-27 16:26:50 UTC (rev 98589)
@@ -103,6 +103,7 @@
 
     virtual void privateBrowsingStateChanged(bool);
     virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    virtual bool wantsWindowRelativeCoordinates();
     virtual WebCore::Scrollbar* horizontalScrollbar();
     virtual WebCore::Scrollbar* verticalScrollbar();
 

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-27 16:26:50 UTC (rev 98589)
@@ -381,6 +381,11 @@
     m_plugin->manualStreamDidFail(error.isCancellation());
 }
 
+RenderBoxModelObject* PluginView::renderer() const 
+{ 
+        return toRenderBoxModelObject(m_pluginElement->renderer()); 
+}
+     
 #if PLATFORM(MAC)    
 void PluginView::setWindowIsVisible(bool windowIsVisible)
 {
@@ -560,24 +565,39 @@
         return;
     }
 
-    IntRect dirtyRectInWindowCoordinates = parent()->contentsToWindow(dirtyRect);
-    IntRect paintRectInWindowCoordinates = intersection(dirtyRectInWindowCoordinates, clipRectInWindowCoordinates());
-    if (paintRectInWindowCoordinates.isEmpty())
+    IntRect paintRect; 
+    if (m_plugin->wantsWindowRelativeCoordinates()) { 
+    IntRect dirtyRectInWindowCoordinates = parent()->contentsToWindow(dirtyRect); 
+    paintRect = intersection(dirtyRectInWindowCoordinates, clipRectInWindowCoordinates()); 
+    } else { 
+        // FIXME: We should try to intersect the dirty rect with the plug-in's clip rect here. 
+        paintRect = IntRect(IntPoint(), frameRect().size()); 
+    } 
+
+    if (paintRect.isEmpty()) 
+        return; 
+ 
+    if (m_snapshot) {
+        m_snapshot->paint(*context, frameRect().location(), m_snapshot->bounds());
         return;
+    }
 
-    if (m_snapshot)
-        m_snapshot->paint(*context, frameRect().location(), m_snapshot->bounds());
-    else {
+    GraphicsContextStateSaver stateSaver(*context); 
+
+    if (m_plugin->wantsWindowRelativeCoordinates()) {
         // The plugin is given a frame rect which is parent()->contentsToWindow(frameRect()),
         // and un-translates by the its origin when painting. The current CTM reflects
         // this widget's frame is its parent (the document), so we have to offset the CTM by
         // the document's window coordinates.
         IntPoint documentOriginInWindowCoordinates = parent()->contentsToWindow(IntPoint());
         
-        GraphicsContextStateSaver stateSaver(*context);
         context->translate(-documentOriginInWindowCoordinates.x(), -documentOriginInWindowCoordinates.y());
-        m_plugin->paint(context, paintRectInWindowCoordinates);
-    }
+    } else {
+        // Translate the coordinate system so that the origin is in the top-left corner of the plug-in. 
+         context->translate(frameRect().location().x(), frameRect().location().y()); 
+     } 
+          
+     m_plugin->paint(context, paintRect);
 }
 
 void PluginView::frameRectsChanged()
@@ -677,16 +697,20 @@
     Widget::hide();
 }
 
+bool PluginView::transformsAffectFrameRect() 
+{ 
+    return false; 
+}
+     
 void PluginView::viewGeometryDidChange()
 {
     if (!m_isInitialized || !m_plugin || !parent())
         return;
 
     // Get the frame rect in window coordinates.
+    // FIXME: Figure out what we should pass here when m_plugin->wantsWindowRelativeCoordinates() returns false. 
     IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
     
-    // Adjust bounds to account for pageScaleFactor
-    frameRectInWindowCoordinates.scale(1 / frame()->pageScaleFactor());
     m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates());
 }
 
@@ -704,6 +728,7 @@
     IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
 
     Frame* frame = this->frame();
+    
 
     // Get the window clip rect for the enclosing layer (in window coordinates).
     RenderLayer* layer = m_pluginElement->renderer()->enclosingLayer();
@@ -712,7 +737,6 @@
     // Intersect the two rects to get the view clip rect in window coordinates.
     frameRectInWindowCoordinates.intersect(windowClipRect);
 
-    frameRectInWindowCoordinates.scale(1 / frame->pageScaleFactor());
     return frameRectInWindowCoordinates;
 }
 

Modified: branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.h (98588 => 98589)


--- branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-27 16:24:41 UTC (rev 98588)
+++ branches/safari-534.52-branch/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-27 16:26:50 UTC (rev 98589)
@@ -67,6 +67,9 @@
     bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
 #endif
 
+    // FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself.
+    WebCore::RenderBoxModelObject* renderer() const;
+
 private:
     PluginView(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters& parameters);
     virtual ~PluginView();
@@ -118,6 +121,7 @@
     virtual void notifyWidget(WebCore::WidgetNotification);
     virtual void show();
     virtual void hide();
+    virtual bool transformsAffectFrameRect();
 
     // WebCore::MediaCanStartListener
     virtual void mediaCanStart();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to