Skip to content

Commit 9467a91

Browse files
committed
[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(). Canonical link: https://commits.webkit.org/116949@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 184d59e commit 9467a91

28 files changed

Lines changed: 244 additions & 10 deletions

Source/WebCore/ChangeLog

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
2012-10-10 Jon Lee <jonlee@apple.com>
2+
3+
[WK2] Activate plugins when user clicks on snapshot
4+
https://bugs.webkit.org/show_bug.cgi?id=98328
5+
<rdar://problem/12426681>
6+
7+
Reviewed by Brady Eidson.
8+
9+
Extend the default event handler to deal with plugins with snapshots.
10+
When the user clicks on the placeholder, the plugin is recreated and displayed.
11+
12+
* loader/FrameLoaderClient.h: Add new client function recreatePlugin(), which is
13+
expected to re-create the plugin with the same parameters as when it was run to
14+
obtain the plugin's snapshot placeholder.
15+
16+
* loader/EmptyClients.cpp: Stub implementation of recreatePlugin().
17+
* loader/EmptyClients.h:
18+
* WebCore.exp.in: Expose HTMLPlugInElement::pluginWidget().
19+
20+
* html/HTMLPlugInElement.cpp:
21+
(WebCore::HTMLPlugInElement::defaultEventHandler): Update to look for
22+
RenderSnapshottedPlugIn. If the plugin is not playing, have the renderer handle the
23+
event.
24+
25+
* rendering/RenderSnapshottedPlugIn.cpp:
26+
(WebCore::RenderSnapshottedPlugin::getCursor): Set to hand cursor when the plugin is not
27+
playing.
28+
(WebCore::RenderSnapshottedPlugIn::handleEvent): If the user clicked on the plugin using the
29+
left button, update the state of the element to playing. Recreate the plugin if the widget exists
30+
to begin with. The cached snapshot image will be saved for possible reuse on back/forward navigation.
31+
* rendering/RenderSnapshottedPlugIn.h:
32+
(RenderSnapshottedPlugIn):
33+
134
2012-10-10 Kenichi Ishibashi <bashi@chromium.org>
235

336
FontVerticalDataCache should allow zero as a key value

Source/WebCore/WebCore.exp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ __ZNK7WebCore16VisibleSelection17toNormalizedRangeEv
12331233
__ZNK7WebCore16VisibleSelection19rootEditableElementEv
12341234
__ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
12351235
__ZNK7WebCore16VisibleSelection5isAllENS_27EditingBoundaryCrossingRuleE
1236+
__ZNK7WebCore17HTMLPlugInElement12pluginWidgetEv
12361237
__ZNK7WebCore17JSDOMGlobalObject22scriptExecutionContextEv
12371238
__ZNK7WebCore17RegularExpression13matchedLengthEv
12381239
__ZNK7WebCore17RegularExpression5matchERKN3WTF6StringEiPi

Source/WebCore/html/HTMLPlugInElement.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "Page.h"
3636
#include "PluginViewBase.h"
3737
#include "RenderEmbeddedObject.h"
38+
#include "RenderSnapshottedPlugIn.h"
3839
#include "RenderWidget.h"
3940
#include "Settings.h"
4041
#include "Widget.h"
@@ -177,9 +178,15 @@ void HTMLPlugInElement::defaultEventHandler(Event* event)
177178
// FIXME: Mouse down and scroll events are passed down to plug-in via custom code in EventHandler; these code paths should be united.
178179

179180
RenderObject* r = renderer();
180-
if (r && r->isEmbeddedObject() && toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) {
181-
toRenderEmbeddedObject(r)->handleUnavailablePluginIndicatorEvent(event);
182-
return;
181+
if (r && r->isEmbeddedObject()) {
182+
if (toRenderEmbeddedObject(r)->showsUnavailablePluginIndicator()) {
183+
toRenderEmbeddedObject(r)->handleUnavailablePluginIndicatorEvent(event);
184+
return;
185+
}
186+
if (r->isSnapshottedPlugIn() && displayState() < Playing) {
187+
toRenderSnapshottedPlugIn(r)->handleEvent(event);
188+
return;
189+
}
183190
}
184191

185192
if (!r || !r->isWidget())

Source/WebCore/loader/EmptyClients.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3-
* Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
3+
* Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved.
44
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
55
*
66
* Redistribution and use in source and binary forms, with or without
@@ -146,6 +146,10 @@ PassRefPtr<Widget> EmptyFrameLoaderClient::createPlugin(const IntSize&, HTMLPlug
146146
return 0;
147147
}
148148

149+
void EmptyFrameLoaderClient::recreatePlugin(Widget*)
150+
{
151+
}
152+
149153
PassRefPtr<Widget> EmptyFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&)
150154
{
151155
return 0;

Source/WebCore/loader/EmptyClients.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (C) 2006 Eric Seidel (eric@webkit.org)
3-
* Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3+
* Copyright (C) 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
44
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
55
* Copyright (C) 2012 Samsung Electronics. All rights reserved.
66
*
@@ -344,6 +344,7 @@ class EmptyFrameLoaderClient : public FrameLoaderClient {
344344
virtual void didDetectXSS(const KURL&, bool) { }
345345
virtual PassRefPtr<Frame> createFrame(const KURL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int) OVERRIDE;
346346
virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) OVERRIDE;
347+
virtual void recreatePlugin(Widget*) OVERRIDE;
347348
virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE;
348349
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
349350
virtual PassRefPtr<Widget> createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&) OVERRIDE;

Source/WebCore/loader/FrameLoaderClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
2+
* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
33
* Copyright (C) 2012 Google Inc. All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -262,6 +262,7 @@ namespace WebCore {
262262

263263
virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
264264
virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
265+
virtual void recreatePlugin(Widget*) = 0;
265266
virtual void redirectDataToPlugin(Widget* pluginWidget) = 0;
266267

267268
virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;

Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
#include "RenderSnapshottedPlugIn.h"
2828

2929
#include "Cursor.h"
30+
#include "FrameLoaderClient.h"
3031
#include "FrameView.h"
3132
#include "Gradient.h"
3233
#include "HTMLPlugInImageElement.h"
34+
#include "MouseEvent.h"
3335
#include "PaintInfo.h"
3436
#include "Path.h"
3537

@@ -115,4 +117,30 @@ void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const
115117
context->drawImage(image.get(), style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
116118
}
117119

120+
CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cursor& overrideCursor) const
121+
{
122+
if (plugInImageElement()->displayState() < HTMLPlugInElement::Playing) {
123+
overrideCursor = handCursor();
124+
return SetCursor;
125+
}
126+
return RenderEmbeddedObject::getCursor(point, overrideCursor);
127+
}
128+
129+
void RenderSnapshottedPlugIn::handleEvent(Event* event)
130+
{
131+
if (!event->isMouseEvent())
132+
return;
133+
134+
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
135+
if (event->type() == eventNames().clickEvent && mouseEvent->button() == LeftButton) {
136+
plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
137+
if (widget()) {
138+
if (Frame* frame = document()->frame())
139+
frame->loader()->client()->recreatePlugin(widget());
140+
repaint();
141+
}
142+
event->setDefaultHandled();
143+
}
144+
}
145+
118146
} // namespace WebCore

Source/WebCore/rendering/RenderSnapshottedPlugIn.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
4242

4343
void updateSnapshot(PassRefPtr<Image>);
4444

45+
void handleEvent(Event*);
46+
4547
private:
4648
HTMLPlugInImageElement* plugInImageElement() const;
4749
virtual const char* renderName() const { return "RenderSnapshottedPlugIn"; }
4850

51+
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const OVERRIDE;
4952
virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
5053
virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
5154
virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;

Source/WebKit/chromium/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2012-10-10 Jon Lee <jonlee@apple.com>
2+
3+
[WK2] Activate plugins when user clicks on snapshot
4+
https://bugs.webkit.org/show_bug.cgi?id=98328
5+
<rdar://problem/12426681>
6+
7+
Reviewed by Brady Eidson.
8+
9+
* src/FrameLoaderClientImpl.h:
10+
(WebKit::FrameLoaderClientImpl::recreatePlugin): Stub implementation of recreatePlugin().
11+
112
2012-10-10 David Barton <dbarton@mathscribe.com>
213

314
Turn on ENABLE_MATHML for Chromium

Source/WebKit/chromium/src/FrameLoaderClientImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class FrameLoaderClientImpl : public WebCore::FrameLoaderClient {
182182
const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&,
183183
const Vector<WTF::String>&, const Vector<WTF::String>&,
184184
const WTF::String&, bool loadManually);
185+
virtual void recreatePlugin(WebCore::Widget*) { }
185186
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
186187
virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
187188
const WebCore::IntSize&,

0 commit comments

Comments
 (0)