Diff
Modified: trunk/Source/WebCore/ChangeLog (89000 => 89001)
--- trunk/Source/WebCore/ChangeLog 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/ChangeLog 2011-06-16 04:10:36 UTC (rev 89001)
@@ -2,6 +2,27 @@
Reviewed by Eric Seidel.
+ Remove ScriptController::setAllowPopupsFromPlugin
+ https://bugs.webkit.org/show_bug.cgi?id=62706
+
+ This API is just a poor man's UserGestureIndicator. We should use the
+ real deal.
+
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::ScriptController):
+ (WebCore::ScriptController::processingUserGesture):
+ * bindings/js/ScriptController.h:
+ * bindings/v8/NPV8Object.cpp:
+ (_NPN_EvaluateHelper):
+ * bindings/v8/ScriptController.cpp:
+ (WebCore::ScriptController::ScriptController):
+ (WebCore::ScriptController::processingUserGesture):
+ * bindings/v8/ScriptController.h:
+
+2011-06-15 Adam Barth <[email protected]>
+
+ Reviewed by Eric Seidel.
+
Remove forceUserGesture bool in favor of UserGestureIndicator
https://bugs.webkit.org/show_bug.cgi?id=62702
Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (89000 => 89001)
--- trunk/Source/WebCore/bindings/js/ScriptController.cpp 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp 2011-06-16 04:10:36 UTC (rev 89001)
@@ -65,7 +65,6 @@
, m_inExecuteScript(false)
, m_processingTimerCallback(false)
, m_paused(false)
- , m_allowPopupsFromPlugin(false)
#if ENABLE(NETSCAPE_PLUGIN_API)
, m_windowScriptNPObject(0)
#endif
@@ -252,17 +251,13 @@
if (!frame)
return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
- // FIXME: We check the plugin popup flag and _javascript_ anchor navigation
- // from the dynamic frame becuase they should only be initiated on the
- // dynamic frame in which execution began if they do happen.
- ScriptController* scriptController = frame->script();
- ASSERT(scriptController);
- if (scriptController->allowPopupsFromPlugin() || scriptController->isJavaScriptAnchorNavigation())
+ // FIXME: Remove the isJavaScriptAnchorNavigation check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed.
+ if (frame->script()->isJavaScriptAnchorNavigation())
return true;
// If a DOM event is being processed, check that it was initiated by the user
// and that it is in the whitelist of event types allowed to generate pop-ups.
- if (JSDOMWindowShell* shell = scriptController->existingWindowShell(currentWorld(exec)))
+ if (JSDOMWindowShell* shell = frame->script()->existingWindowShell(currentWorld(exec)))
if (Event* event = shell->window()->currentEvent())
return event->fromUserGesture();
Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (89000 => 89001)
--- trunk/Source/WebCore/bindings/js/ScriptController.h 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h 2011-06-16 04:10:36 UTC (rev 89001)
@@ -121,9 +121,6 @@
void setPaused(bool b) { m_paused = b; }
bool isPaused() const { return m_paused; }
- void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
- bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
-
const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script
void clearWindowShell(bool goingIntoPageCache = false);
@@ -182,7 +179,6 @@
bool m_processingTimerCallback;
bool m_paused;
- bool m_allowPopupsFromPlugin;
// The root object used for objects bound outside the context of a plugin, such
// as NPAPI plugins. The plugins using these objects prevent a page from being cached so they
Modified: trunk/Source/WebCore/bindings/v8/NPV8Object.cpp (89000 => 89001)
--- trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2011-06-16 04:10:36 UTC (rev 89001)
@@ -34,6 +34,7 @@
#include "OwnArrayPtr.h"
#include "PlatformString.h"
#include "ScriptSourceCode.h"
+#include "UserGestureIndicator.h"
#include "V8GCController.h"
#include "V8Helpers.h"
#include "V8NPUtils.h"
@@ -302,21 +303,15 @@
v8::Context::Scope scope(context);
ExceptionCatcher exceptionCatcher;
+ // FIXME: Is this branch still needed after switching to using UserGestureIndicator?
String filename;
if (!popupsAllowed)
filename = "npscript";
- // Set popupsAllowed flag to the current execution frame, so WebKit can get
- // right gesture status for popups initiated from plugins.
- Frame* frame = proxy->frame();
- ASSERT(frame);
- bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
- frame->script()->setAllowPopupsFromPlugin(popupsAllowed);
-
String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
+
+ UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
- // Restore the old flag.
- frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
if (v8result.IsEmpty())
return false;
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (89000 => 89001)
--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2011-06-16 04:10:36 UTC (rev 89001)
@@ -111,7 +111,6 @@
, m_inExecuteScript(false)
, m_processingTimerCallback(false)
, m_paused(false)
- , m_allowPopupsFromPlugin(false)
, m_proxy(adoptPtr(new V8Proxy(frame)))
#if ENABLE(NETSCAPE_PLUGIN_API)
, m_windowScriptNPObject(0)
@@ -155,47 +154,27 @@
bool ScriptController::processingUserGesture()
{
- Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
- // No script is running, so it is user-initiated unless the gesture stack
- // explicitly says it is not.
- if (!activeFrame)
+ Frame* firstFrame = V8Proxy::retrieveFrameForEnteredContext();
+ if (!firstFrame)
return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
- V8Proxy* activeProxy = activeFrame->script()->proxy();
-
v8::HandleScope handleScope;
- v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
- // FIXME: find all cases context can be empty:
- // 1) JS is disabled;
- // 2) page is NULL;
+ v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(firstFrame);
if (v8Context.IsEmpty())
return true;
-
v8::Context::Scope scope(v8Context);
-
v8::Handle<v8::Object> global = v8Context->Global();
v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol);
Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
-
- // Based on code from JSC's ScriptController::processingUserGesture.
- // Note: This is more liberal than Firefox's implementation.
- if (event) {
- // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false.
+ if (event)
return event->fromUserGesture();
- }
- // FIXME: We check the _javascript_ anchor navigation from the last entered
- // frame becuase it should only be initiated on the last entered frame in
- // which execution began if it does happen.
- const String* sourceURL = activeFrame->script()->sourceURL();
- if (sourceURL && sourceURL->isNull() && !activeProxy->timerCallback()) {
- // This is the <a href="" case -> we let it through.
+
+ // FIXME: Remove this check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed.
+ const String* sourceURL = firstFrame->script()->sourceURL();
+ if (sourceURL && sourceURL->isNull() && !firstFrame->script()->proxy()->timerCallback())
return true;
- }
- if (activeFrame->script()->allowPopupsFromPlugin())
- return true;
- // This is the <script>window.open(...)</script> case or a timer callback -> block it.
- // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations.
+
return UserGestureIndicator::processingUserGesture();
}
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (89000 => 89001)
--- trunk/Source/WebCore/bindings/v8/ScriptController.h 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h 2011-06-16 04:10:36 UTC (rev 89001)
@@ -189,9 +189,6 @@
void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
- void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
- bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
-
private:
Frame* m_frame;
const String* m_sourceURL;
@@ -200,7 +197,6 @@
bool m_processingTimerCallback;
bool m_paused;
- bool m_allowPopupsFromPlugin;
OwnPtr<V8Proxy> m_proxy;
typedef HashMap<Widget*, NPObject*> PluginObjectMap;
Modified: trunk/Source/WebKit/mac/ChangeLog (89000 => 89001)
--- trunk/Source/WebKit/mac/ChangeLog 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebKit/mac/ChangeLog 2011-06-16 04:10:36 UTC (rev 89001)
@@ -1,3 +1,15 @@
+2011-06-15 Adam Barth <[email protected]>
+
+ Reviewed by Eric Seidel.
+
+ Remove ScriptController::setAllowPopupsFromPlugin
+ https://bugs.webkit.org/show_bug.cgi?id=62706
+
+ * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+ (WebKit::NetscapePluginInstanceProxy::evaluate):
+ * Plugins/WebNetscapePluginView.mm:
+ (-[WebNetscapePluginView sendEvent:isDrawRect:]):
+
2011-06-15 David Kilzer <[email protected]>
<http://webkit.org/b/62745> Convert WebNSFileManagerExtras.m to Objective-C++
Modified: trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm (89000 => 89001)
--- trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2011-06-16 04:10:36 UTC (rev 89001)
@@ -55,6 +55,7 @@
#import <WebCore/ScriptController.h>
#import <WebCore/ScriptValue.h>
#import <WebCore/StringSourceProvider.h>
+#import <WebCore/UserGestureIndicator.h>
#import <WebCore/npruntime_impl.h>
#import <WebCore/runtime_object.h>
#import <WebKitSystemInterface.h>
@@ -869,16 +870,14 @@
Strong<JSGlobalObject> globalObject(*pluginWorld()->globalData(), frame->script()->globalObject(pluginWorld()));
ExecState* exec = globalObject->globalExec();
- bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
- frame->script()->setAllowPopupsFromPlugin(allowPopups);
-
globalObject->globalData().timeoutChecker.start();
+
+ UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script));
+
globalObject->globalData().timeoutChecker.stop();
ComplType type = completion.complType();
- frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
-
JSValue result;
if (type == Normal)
result = completion.value();
Modified: trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm (89000 => 89001)
--- trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm 2011-06-16 04:10:36 UTC (rev 89001)
@@ -70,6 +70,7 @@
#import <WebCore/ScriptController.h>
#import <WebCore/SecurityOrigin.h>
#import <WebCore/SoftLinking.h>
+#import <WebCore/UserGestureIndicator.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebCore/WebCoreURLResponse.h>
#import <WebCore/npruntime_impl.h>
@@ -665,16 +666,13 @@
[self willCallPlugInFunction];
// Set the pluginAllowPopup flag.
ASSERT(_eventHandler);
- bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
- frame->script()->setAllowPopupsFromPlugin(_eventHandler->currentEventIsUserGesture());
{
JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
+ UserGestureIndicator gestureIndicator(_eventHandler->currentEventIsUserGesture() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
acceptedEvent = [_pluginPackage.get() pluginFuncs]->event(plugin, event);
}
- // Restore the old pluginAllowPopup flag.
- frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
[self didCallPlugInFunction];
-
+
if (portState) {
if ([self currentWindow])
[self restorePortState:portState];
Modified: trunk/Source/WebKit2/ChangeLog (89000 => 89001)
--- trunk/Source/WebKit2/ChangeLog 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-16 04:10:36 UTC (rev 89001)
@@ -1,3 +1,14 @@
+2011-06-15 Adam Barth <[email protected]>
+
+ Reviewed by Eric Seidel.
+
+ Remove ScriptController::setAllowPopupsFromPlugin
+ https://bugs.webkit.org/show_bug.cgi?id=62706
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::performJavaScriptURLRequest):
+ (WebKit::PluginView::evaluate):
+
2011-06-15 Ryuan Choi <[email protected]>
Rubber stamped by Eric Seidel.
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (89000 => 89001)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2011-06-16 04:09:35 UTC (rev 89000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2011-06-16 04:10:36 UTC (rev 89001)
@@ -58,6 +58,7 @@
#include <WebCore/ScriptValue.h>
#include <WebCore/ScrollView.h>
#include <WebCore/Settings.h>
+#include <WebCore/UserGestureIndicator.h>
using namespace JSC;
using namespace WebCore;
@@ -778,14 +779,8 @@
// Evaluate the _javascript_ code. Note that running _javascript_ here could cause the plug-in to be destroyed, so we
// grab references to the plug-in here.
RefPtr<Plugin> plugin = m_plugin;
+ ScriptValue result = frame->script()->executeScript(jsString, request->allowPopups());
- bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
- frame->script()->setAllowPopupsFromPlugin(request->allowPopups());
-
- ScriptValue result = frame->script()->executeScript(jsString);
-
- frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
-
// Check if evaluating the _javascript_ destroyed the plug-in.
if (!plugin->controller())
return;
@@ -979,22 +974,16 @@
bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups)
{
- RefPtr<Frame> frame = m_pluginElement->document()->frame();
- if (!frame)
+ // FIXME: Is this check necessary?
+ if (!m_pluginElement->document()->frame())
return false;
- bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
- frame->script()->setAllowPopupsFromPlugin(allowPopups);
-
// Calling evaluate will run _javascript_ that can potentially remove the plug-in element, so we need to
// protect the plug-in view from destruction.
NPRuntimeObjectMap::PluginProtector pluginProtector(&m_npRuntimeObjectMap);
- bool returnValue = m_npRuntimeObjectMap.evaluate(npObject, scriptString, result);
-
- frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
-
- return returnValue;
+ UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
+ return m_npRuntimeObjectMap.evaluate(npObject, scriptString, result);
}
bool PluginView::tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result)