Title: [130977] trunk/Source
Revision
130977
Author
jon...@apple.com
Date
2012-10-10 16:23:13 -0700 (Wed, 10 Oct 2012)

Log Message

[WK2] Activate plugins when user clicks on snapshot
https://bugs.webkit.org/show_bug.cgi?id=98328
<rdar://problem/12426681>

Reviewed by Brady Eidson.

Source/WebCore:

Extend the default event handler to deal with plugins with snapshots.
When the user clicks on the placeholder, the plugin is recreated and displayed.

* loader/FrameLoaderClient.h: Add new client function recreatePlugin(), which is
expected to re-create the plugin with the same parameters as when it was run to
obtain the plugin's snapshot placeholder.

* loader/EmptyClients.cpp: Stub implementation of recreatePlugin().
* loader/EmptyClients.h:
* WebCore.exp.in: Expose HTMLPlugInElement::pluginWidget().

* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::defaultEventHandler): Update to look for
RenderSnapshottedPlugIn. If the plugin is not playing, have the renderer handle the
event.

* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugin::getCursor): Set to hand cursor when the plugin is not
playing.
(WebCore::RenderSnapshottedPlugIn::handleEvent): If the user clicked on the plugin using the
left button, update the state of the element to playing. Recreate the plugin if the widget exists
to begin with. The cached snapshot image will be saved for possible reuse on back/forward navigation.
* rendering/RenderSnapshottedPlugIn.h:
(RenderSnapshottedPlugIn):

Source/WebKit/chromium:

* src/FrameLoaderClientImpl.h:
(WebKit::FrameLoaderClientImpl::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/efl:

* WebCoreSupport/FrameLoaderClientEfl.h:
(WebCore::FrameLoaderClientEfl::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/gtk:

* WebCoreSupport/FrameLoaderClientGtk.h:
(WebKit::FrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/qt:

* WebCoreSupport/FrameLoaderClientQt.h:
(WebCore::FrameLoaderClientQt::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit/wince:

* WebCoreSupport/FrameLoaderClientWinCE.h:
(WebKit::FrameLoaderClientWinCE::recreatePlugin): Stub implementation of recreatePlugin().

Source/WebKit2:

Implement the recreation of the plugin.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::recreateAndInitialize): We can run into a situation where the user
decided to run the plugin before the snapshot was ready to be taken. In this case, the
plugin member variable is non-null, and the timer is still active. Turn off the timer, and
destroy that instance of the plugin. We set the plugin to the instance provided in the
first parameter to this function, and reset the member variables so that the PluginView is
in a state similar to when it was first created. We also immediately initialize the plugin,
which may happen synchronously or asynchronously.

* WebProcess/Plugins/PluginView.h:
(WebKit::PluginView::initialParameters): Expose the initial parameters. Used to recreate
the plugin.
(WebKit::PluginView::pluginElement): Expose the element associated with the widget. Used to
recreate the plugin.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::recreatePlugin): Create a new Plugin instance using the same
parameters used to create the plugin for snapshotting. Forward that instance to the widget.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient): Implement recreatePlugin().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130976 => 130977)


--- trunk/Source/WebCore/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,36 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        Extend the default event handler to deal with plugins with snapshots.
+        When the user clicks on the placeholder, the plugin is recreated and displayed.
+
+        * loader/FrameLoaderClient.h: Add new client function recreatePlugin(), which is
+        expected to re-create the plugin with the same parameters as when it was run to
+        obtain the plugin's snapshot placeholder.
+
+        * loader/EmptyClients.cpp: Stub implementation of recreatePlugin().
+        * loader/EmptyClients.h:
+        * WebCore.exp.in: Expose HTMLPlugInElement::pluginWidget().
+
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::defaultEventHandler): Update to look for
+        RenderSnapshottedPlugIn. If the plugin is not playing, have the renderer handle the
+        event.
+
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugin::getCursor): Set to hand cursor when the plugin is not
+        playing.
+        (WebCore::RenderSnapshottedPlugIn::handleEvent): If the user clicked on the plugin using the
+        left button, update the state of the element to playing. Recreate the plugin if the widget exists
+        to begin with. The cached snapshot image will be saved for possible reuse on back/forward navigation.
+        * rendering/RenderSnapshottedPlugIn.h:
+        (RenderSnapshottedPlugIn):
+
 2012-10-10  Kenichi Ishibashi  <ba...@chromium.org>
 
         FontVerticalDataCache should allow zero as a key value

Modified: trunk/Source/WebCore/WebCore.exp.in (130976 => 130977)


--- trunk/Source/WebCore/WebCore.exp.in	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1233,6 +1233,7 @@
 __ZNK7WebCore16VisibleSelection19rootEditableElementEv
 __ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
 __ZNK7WebCore16VisibleSelection5isAllENS_27EditingBoundaryCrossingRuleE
+__ZNK7WebCore17HTMLPlugInElement12pluginWidgetEv
 __ZNK7WebCore17JSDOMGlobalObject22scriptExecutionContextEv
 __ZNK7WebCore17RegularExpression13matchedLengthEv
 __ZNK7WebCore17RegularExpression5matchERKN3WTF6StringEiPi

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (130976 => 130977)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2012-10-10 23:23:13 UTC (rev 130977)
@@ -35,6 +35,7 @@
 #include "Page.h"
 #include "PluginViewBase.h"
 #include "RenderEmbeddedObject.h"
+#include "RenderSnapshottedPlugIn.h"
 #include "RenderWidget.h"
 #include "Settings.h"
 #include "Widget.h"
@@ -177,9 +178,15 @@
     // FIXME: Mouse down and scroll events are passed down to plug-in via custom code in EventHandler; these code paths should be united.
 
     RenderObject* r = renderer();
-    if (r && r->isEmbeddedObject() && toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) {
-        toRenderEmbeddedObject(r)->handleUnavailablePluginIndicatorEvent(event);
-        return;
+    if (r && r->isEmbeddedObject()) {
+        if (toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) {
+            toRenderEmbeddedObject(r)->handleUnavailablePluginIndicatorEvent(event);
+            return;
+        }
+        if (r->isSnapshottedPlugIn() && displayState() < Playing) {
+            toRenderSnapshottedPlugIn(r)->handleEvent(event);
+            return;
+        }
     }
 
     if (!r || !r->isWidget())

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (130976 => 130977)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2006 Eric Seidel <e...@webkit.org>
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved.
  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -146,6 +146,10 @@
     return 0;
 }
 
+void EmptyFrameLoaderClient::recreatePlugin(Widget*)
+{
+}
+
 PassRefPtr<Widget> EmptyFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&)
 {
     return 0;

Modified: trunk/Source/WebCore/loader/EmptyClients.h (130976 => 130977)


--- trunk/Source/WebCore/loader/EmptyClients.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2006 Eric Seidel (e...@webkit.org)
- * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
@@ -344,6 +344,7 @@
     virtual void didDetectXSS(const KURL&, bool) { }
     virtual PassRefPtr<Frame> createFrame(const KURL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int) OVERRIDE;
     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) OVERRIDE;
+    virtual void recreatePlugin(Widget*) OVERRIDE;
     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE;
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     virtual PassRefPtr<Widget> createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&) OVERRIDE;

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (130976 => 130977)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -262,6 +262,7 @@
 
         virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
         virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
+        virtual void recreatePlugin(Widget*) = 0;
         virtual void redirectDataToPlugin(Widget* pluginWidget) = 0;
 
         virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (130976 => 130977)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2012-10-10 23:23:13 UTC (rev 130977)
@@ -27,9 +27,11 @@
 #include "RenderSnapshottedPlugIn.h"
 
 #include "Cursor.h"
+#include "FrameLoaderClient.h"
 #include "FrameView.h"
 #include "Gradient.h"
 #include "HTMLPlugInImageElement.h"
+#include "MouseEvent.h"
 #include "PaintInfo.h"
 #include "Path.h"
 
@@ -115,4 +117,30 @@
     context->drawImage(image.get(), style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
 }
 
+CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cursor& overrideCursor) const
+{
+    if (plugInImageElement()->displayState() < HTMLPlugInElement::Playing) {
+        overrideCursor = handCursor();
+        return SetCursor;
+    }
+    return RenderEmbeddedObject::getCursor(point, overrideCursor);
+}
+
+void RenderSnapshottedPlugIn::handleEvent(Event* event)
+{
+    if (!event->isMouseEvent())
+        return;
+
+    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+    if (event->type() == eventNames().clickEvent && mouseEvent->button() == LeftButton) {
+        plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
+        if (widget()) {
+            if (Frame* frame = document()->frame())
+                frame->loader()->client()->recreatePlugin(widget());
+            repaint();
+        }
+        event->setDefaultHandled();
+    }
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (130976 => 130977)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -42,10 +42,13 @@
 
     void updateSnapshot(PassRefPtr<Image>);
 
+    void handleEvent(Event*);
+
 private:
     HTMLPlugInImageElement* plugInImageElement() const;
     virtual const char* renderName() const { return "RenderSnapshottedPlugIn"; }
 
+    virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const OVERRIDE;
     virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
     virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;

Modified: trunk/Source/WebKit/chromium/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * src/FrameLoaderClientImpl.h:
+        (WebKit::FrameLoaderClientImpl::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  David Barton  <dbar...@mathscribe.com>
 
         Turn on ENABLE_MATHML for Chromium

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h (130976 => 130977)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -182,6 +182,7 @@
         const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&,
         const Vector<WTF::String>&, const Vector<WTF::String>&,
         const WTF::String&, bool loadManually);
+    virtual void recreatePlugin(WebCore::Widget*) { }
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
         const WebCore::IntSize&,

Modified: trunk/Source/WebKit/efl/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/efl/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/FrameLoaderClientEfl.h:
+        (WebCore::FrameLoaderClientEfl::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  Ryuan Choi  <ryuan.c...@samsung.com>
 
         [EFL] Use ewk_view_paint instead of ewk_view_paint_contents in ewk_view_single.

Modified: trunk/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h (130976 => 130977)


--- trunk/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -132,6 +132,7 @@
                                const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
 
     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const WTF::Vector<String>&, const WTF::Vector<String>&, const String&, bool);
+    virtual void recreatePlugin(Widget*) { }
     virtual void redirectDataToPlugin(Widget* pluginWidget);
     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const WTF::Vector<String>& paramNames, const WTF::Vector<String>& paramValues);
     virtual String overrideMediaType() const;

Modified: trunk/Source/WebKit/gtk/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/FrameLoaderClientGtk.h:
+        (WebKit::FrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r130853.

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h (130976 => 130977)


--- trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -114,6 +114,7 @@
         virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
                                    const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
         virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const WTF::Vector<WTF::String>&, const WTF::Vector<WTF::String>&, const WTF::String&, bool);
+        virtual void recreatePlugin(WebCore::Widget*) { }
         virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
         virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const WTF::Vector<WTF::String>& paramNames, const WTF::Vector<WTF::String>& paramValues);
         virtual WTF::String overrideMediaType() const;

Modified: trunk/Source/WebKit/mac/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/mac/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,15 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  Brady Eidson  <beid...@apple.com>
 
         Switch CachedResource over from SharedBuffer to a new ResourceBuffer

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h (130976 => 130977)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -198,6 +198,7 @@
                                         const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) OVERRIDE;
     virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WTF::String>&,
                                           const Vector<WTF::String>&, const WTF::String&, bool) OVERRIDE;
+    virtual void recreatePlugin(WebCore::Widget*) OVERRIDE;
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) OVERRIDE;
     
     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL,

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (130976 => 130977)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1724,6 +1724,10 @@
     return 0;
 }
 
+void WebFrameLoaderClient::recreatePlugin(Widget*)
+{
+}
+
 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
 {
     if (!pluginWidget)

Modified: trunk/Source/WebKit/qt/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/qt/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/FrameLoaderClientQt.h:
+        (WebCore::FrameLoaderClientQt::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  Balazs Kelemen  <kbal...@webkit.org>
 
         [Qt] Test drivers should handle repaint rects

Modified: trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h (130976 => 130977)


--- trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -207,6 +207,7 @@
     virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
                                const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
+    virtual void recreatePlugin(Widget*) { }
     virtual void redirectDataToPlugin(Widget* pluginWidget);
 
     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);

Modified: trunk/Source/WebKit/win/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/win/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/win/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        (WebFrameLoaderClient::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-10  Brady Eidson  <beid...@apple.com>
 
         Switch CachedResource over from SharedBuffer to a new ResourceBuffer

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h (130976 => 130977)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -115,6 +115,7 @@
     virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
                                const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
     virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WTF::String>&, const Vector<WTF::String>&, const WTF::String&, bool loadManually);
+    virtual void recreatePlugin(WebCore::Widget*) { }
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
 
     virtual bool shouldUsePluginDocument(const WTF::String& mimeType) const;

Modified: trunk/Source/WebKit/wince/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit/wince/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/wince/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,14 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/FrameLoaderClientWinCE.h:
+        (WebKit::FrameLoaderClientWinCE::recreatePlugin): Stub implementation of recreatePlugin().
+
 2012-10-07  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
 
         Rename first/second to key/value in HashMap iterators

Modified: trunk/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h (130976 => 130977)


--- trunk/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -108,6 +108,7 @@
     virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
                                const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
     virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const WTF::Vector<WTF::String>&, const WTF::Vector<WTF::String>&, const WTF::String&, bool);
+    virtual void recreatePlugin(WebCore::Widget*) { }
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const WTF::Vector<WTF::String>& paramNames, const WTF::Vector<WTF::String>& paramValues);
     virtual WTF::String overrideMediaType() const;

Modified: trunk/Source/WebKit2/ChangeLog (130976 => 130977)


--- trunk/Source/WebKit2/ChangeLog	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,3 +1,34 @@
+2012-10-10  Jon Lee  <jon...@apple.com>
+
+        [WK2] Activate plugins when user clicks on snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=98328
+        <rdar://problem/12426681>
+
+        Reviewed by Brady Eidson.
+
+        Implement the recreation of the plugin.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::recreateAndInitialize): We can run into a situation where the user
+        decided to run the plugin before the snapshot was ready to be taken. In this case, the
+        plugin member variable is non-null, and the timer is still active. Turn off the timer, and
+        destroy that instance of the plugin. We set the plugin to the instance provided in the
+        first parameter to this function, and reset the member variables so that the PluginView is
+        in a state similar to when it was first created. We also immediately initialize the plugin,
+        which may happen synchronously or asynchronously.
+
+        * WebProcess/Plugins/PluginView.h:
+        (WebKit::PluginView::initialParameters): Expose the initial parameters. Used to recreate
+        the plugin.
+        (WebKit::PluginView::pluginElement): Expose the element associated with the widget. Used to
+        recreate the plugin.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::recreatePlugin): Create a new Plugin instance using the same
+        parameters used to create the plugin for snapshotting. Forward that instance to the widget.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        (WebFrameLoaderClient): Implement recreatePlugin().
+
 2012-10-10  Sam Weinig  <s...@webkit.org>
 
         Fix 32-bit build.

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (130976 => 130977)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2012-10-10 23:23:13 UTC (rev 130977)
@@ -316,6 +316,26 @@
     cancelAllStreams();
 }
 
+void PluginView::recreateAndInitialize(PassRefPtr<Plugin> plugin)
+{
+    if (m_plugin) {
+        if (m_pluginSnapshotTimer.isActive())
+            m_pluginSnapshotTimer.stop();
+        destroyPluginAndReset();
+    }
+
+    // Reset member variables to initial values.
+    m_plugin = plugin;
+    m_isInitialized = false;
+    m_isWaitingForSynchronousInitialization = false;
+    m_isWaitingUntilMediaCanStart = false;
+    m_isBeingDestroyed = false;
+    m_manualStreamState = StreamStateInitial;
+    m_transientPaintingSnapshot = nullptr;
+
+    initializePlugin();
+}
+
 Frame* PluginView::frame() const
 {
     return m_pluginElement->document()->frame();

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (130976 => 130977)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -53,6 +53,8 @@
 public:
     static PassRefPtr<PluginView> create(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters&);
 
+    void recreateAndInitialize(PassRefPtr<Plugin>);
+
     WebCore::Frame* frame() const;
 
     bool isBeingDestroyed() const { return m_isBeingDestroyed; }
@@ -72,6 +74,9 @@
     RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); }
 #endif
 
+    WebCore::HTMLPlugInElement* pluginElement() const { return m_pluginElement.get(); }
+    const Plugin::Parameters& initialParameters() const { return m_parameters; }
+
     // 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;
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (130976 => 130977)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1353,6 +1353,16 @@
     return PluginView::create(pluginElement, plugin.release(), parameters);
 }
 
+void WebFrameLoaderClient::recreatePlugin(Widget* widget)
+{
+    ASSERT(widget && widget->isPluginViewBase());
+    ASSERT(m_frame->page());
+
+    PluginView* pluginView = static_cast<PluginView*>(widget);
+    RefPtr<Plugin> plugin = m_frame->page()->createPlugin(m_frame, pluginView->pluginElement(), pluginView->initialParameters());
+    pluginView->recreateAndInitialize(plugin.release());
+}
+
 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
 {
     m_pluginView = static_cast<PluginView*>(pluginWidget);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (130976 => 130977)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:09:36 UTC (rev 130976)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2012-10-10 23:23:13 UTC (rev 130977)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -188,6 +188,7 @@
                                           const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) OVERRIDE;
     
     virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) OVERRIDE;
+    virtual void recreatePlugin(WebCore::Widget*) OVERRIDE;
     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) OVERRIDE;
     
     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) OVERRIDE;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to