Changeset 89001 in webkit
- Timestamp:
- Jun 15, 2011 9:10:36 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88998 r89001 1 2011-06-15 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Remove ScriptController::setAllowPopupsFromPlugin 6 https://bugs.webkit.org/show_bug.cgi?id=62706 7 8 This API is just a poor man's UserGestureIndicator. We should use the 9 real deal. 10 11 * bindings/js/ScriptController.cpp: 12 (WebCore::ScriptController::ScriptController): 13 (WebCore::ScriptController::processingUserGesture): 14 * bindings/js/ScriptController.h: 15 * bindings/v8/NPV8Object.cpp: 16 (_NPN_EvaluateHelper): 17 * bindings/v8/ScriptController.cpp: 18 (WebCore::ScriptController::ScriptController): 19 (WebCore::ScriptController::processingUserGesture): 20 * bindings/v8/ScriptController.h: 21 1 22 2011-06-15 Adam Barth <abarth@webkit.org> 2 23 -
trunk/Source/WebCore/bindings/js/ScriptController.cpp
r88998 r89001 66 66 , m_processingTimerCallback(false) 67 67 , m_paused(false) 68 , m_allowPopupsFromPlugin(false)69 68 #if ENABLE(NETSCAPE_PLUGIN_API) 70 69 , m_windowScriptNPObject(0) … … 253 252 return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; 254 253 255 // FIXME: We check the plugin popup flag and javascript anchor navigation 256 // from the dynamic frame becuase they should only be initiated on the 257 // dynamic frame in which execution began if they do happen. 258 ScriptController* scriptController = frame->script(); 259 ASSERT(scriptController); 260 if (scriptController->allowPopupsFromPlugin() || scriptController->isJavaScriptAnchorNavigation()) 254 // FIXME: Remove the isJavaScriptAnchorNavigation check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed. 255 if (frame->script()->isJavaScriptAnchorNavigation()) 261 256 return true; 262 257 263 258 // If a DOM event is being processed, check that it was initiated by the user 264 259 // and that it is in the whitelist of event types allowed to generate pop-ups. 265 if (JSDOMWindowShell* shell = scriptController->existingWindowShell(currentWorld(exec)))260 if (JSDOMWindowShell* shell = frame->script()->existingWindowShell(currentWorld(exec))) 266 261 if (Event* event = shell->window()->currentEvent()) 267 262 return event->fromUserGesture(); -
trunk/Source/WebCore/bindings/js/ScriptController.h
r88731 r89001 122 122 bool isPaused() const { return m_paused; } 123 123 124 void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }125 bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }126 127 124 const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script 128 125 … … 183 180 bool m_processingTimerCallback; 184 181 bool m_paused; 185 bool m_allowPopupsFromPlugin;186 182 187 183 // The root object used for objects bound outside the context of a plugin, such -
trunk/Source/WebCore/bindings/v8/NPV8Object.cpp
r88679 r89001 35 35 #include "PlatformString.h" 36 36 #include "ScriptSourceCode.h" 37 #include "UserGestureIndicator.h" 37 38 #include "V8GCController.h" 38 39 #include "V8Helpers.h" … … 303 304 ExceptionCatcher exceptionCatcher; 304 305 306 // FIXME: Is this branch still needed after switching to using UserGestureIndicator? 305 307 String filename; 306 308 if (!popupsAllowed) 307 309 filename = "npscript"; 308 310 309 // Set popupsAllowed flag to the current execution frame, so WebKit can get310 // right gesture status for popups initiated from plugins.311 Frame* frame = proxy->frame();312 ASSERT(frame);313 bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();314 frame->script()->setAllowPopupsFromPlugin(popupsAllowed);315 316 311 String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length); 312 313 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 317 314 v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0); 318 // Restore the old flag.319 frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);320 315 321 316 if (v8result.IsEmpty()) -
trunk/Source/WebCore/bindings/v8/ScriptController.cpp
r88731 r89001 112 112 , m_processingTimerCallback(false) 113 113 , m_paused(false) 114 , m_allowPopupsFromPlugin(false)115 114 , m_proxy(adoptPtr(new V8Proxy(frame))) 116 115 #if ENABLE(NETSCAPE_PLUGIN_API) … … 156 155 bool ScriptController::processingUserGesture() 157 156 { 158 Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext(); 159 // No script is running, so it is user-initiated unless the gesture stack 160 // explicitly says it is not. 161 if (!activeFrame) 157 Frame* firstFrame = V8Proxy::retrieveFrameForEnteredContext(); 158 if (!firstFrame) 162 159 return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; 163 160 164 V8Proxy* activeProxy = activeFrame->script()->proxy(); 165 166 v8::HandleScope handleScope; 167 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame); 168 // FIXME: find all cases context can be empty: 169 // 1) JS is disabled; 170 // 2) page is NULL; 161 v8::HandleScope handleScope; 162 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(firstFrame); 171 163 if (v8Context.IsEmpty()) 172 164 return true; 173 174 165 v8::Context::Scope scope(v8Context); 175 176 166 v8::Handle<v8::Object> global = v8Context->Global(); 177 167 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(); 178 168 v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol); 179 169 Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0; 180 181 // Based on code from JSC's ScriptController::processingUserGesture. 182 // Note: This is more liberal than Firefox's implementation. 183 if (event) { 184 // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false. 170 if (event) 185 171 return event->fromUserGesture(); 186 } 187 // FIXME: We check the javascript anchor navigation from the last entered 188 // frame becuase it should only be initiated on the last entered frame in 189 // which execution began if it does happen. 190 const String* sourceURL = activeFrame->script()->sourceURL(); 191 if (sourceURL && sourceURL->isNull() && !activeProxy->timerCallback()) { 192 // This is the <a href="javascript:window.open('...')> case -> we let it through. 172 173 // FIXME: Remove this check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed. 174 const String* sourceURL = firstFrame->script()->sourceURL(); 175 if (sourceURL && sourceURL->isNull() && !firstFrame->script()->proxy()->timerCallback()) 193 176 return true; 194 } 195 if (activeFrame->script()->allowPopupsFromPlugin()) 196 return true; 197 // This is the <script>window.open(...)</script> case or a timer callback -> block it. 198 // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations. 177 199 178 return UserGestureIndicator::processingUserGesture(); 200 179 } -
trunk/Source/WebCore/bindings/v8/ScriptController.h
r88731 r89001 190 190 static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); 191 191 192 void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }193 bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }194 195 192 private: 196 193 Frame* m_frame; … … 201 198 bool m_processingTimerCallback; 202 199 bool m_paused; 203 bool m_allowPopupsFromPlugin;204 200 205 201 OwnPtr<V8Proxy> m_proxy; -
trunk/Source/WebKit/mac/ChangeLog
r88968 r89001 1 2011-06-15 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Remove ScriptController::setAllowPopupsFromPlugin 6 https://bugs.webkit.org/show_bug.cgi?id=62706 7 8 * Plugins/Hosted/NetscapePluginInstanceProxy.mm: 9 (WebKit::NetscapePluginInstanceProxy::evaluate): 10 * Plugins/WebNetscapePluginView.mm: 11 (-[WebNetscapePluginView sendEvent:isDrawRect:]): 12 1 13 2011-06-15 David Kilzer <ddkilzer@apple.com> 2 14 -
trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
r83385 r89001 56 56 #import <WebCore/ScriptValue.h> 57 57 #import <WebCore/StringSourceProvider.h> 58 #import <WebCore/UserGestureIndicator.h> 58 59 #import <WebCore/npruntime_impl.h> 59 60 #import <WebCore/runtime_object.h> … … 870 871 ExecState* exec = globalObject->globalExec(); 871 872 872 bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();873 frame->script()->setAllowPopupsFromPlugin(allowPopups);874 875 873 globalObject->globalData().timeoutChecker.start(); 874 875 UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 876 876 Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script)); 877 877 878 globalObject->globalData().timeoutChecker.stop(); 878 879 ComplType type = completion.complType(); 879 880 880 frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);881 882 881 JSValue result; 883 882 if (type == Normal) -
trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm
r85036 r89001 71 71 #import <WebCore/SecurityOrigin.h> 72 72 #import <WebCore/SoftLinking.h> 73 #import <WebCore/UserGestureIndicator.h> 73 74 #import <WebCore/WebCoreObjCExtras.h> 74 75 #import <WebCore/WebCoreURLResponse.h> … … 666 667 // Set the pluginAllowPopup flag. 667 668 ASSERT(_eventHandler); 668 bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();669 frame->script()->setAllowPopupsFromPlugin(_eventHandler->currentEventIsUserGesture());670 669 { 671 670 JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); 671 UserGestureIndicator gestureIndicator(_eventHandler->currentEventIsUserGesture() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 672 672 acceptedEvent = [_pluginPackage.get() pluginFuncs]->event(plugin, event); 673 673 } 674 // Restore the old pluginAllowPopup flag.675 frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);676 674 [self didCallPlugInFunction]; 677 675 678 676 if (portState) { 679 677 if ([self currentWindow]) -
trunk/Source/WebKit2/ChangeLog
r88991 r89001 1 2011-06-15 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Remove ScriptController::setAllowPopupsFromPlugin 6 https://bugs.webkit.org/show_bug.cgi?id=62706 7 8 * WebProcess/Plugins/PluginView.cpp: 9 (WebKit::PluginView::performJavaScriptURLRequest): 10 (WebKit::PluginView::evaluate): 11 1 12 2011-06-15 Ryuan Choi <ryuan.choi@samsung.com> 2 13 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
r87806 r89001 59 59 #include <WebCore/ScrollView.h> 60 60 #include <WebCore/Settings.h> 61 #include <WebCore/UserGestureIndicator.h> 61 62 62 63 using namespace JSC; … … 779 780 // grab references to the plug-in here. 780 781 RefPtr<Plugin> plugin = m_plugin; 781 782 bool oldAllowPopups = frame->script()->allowPopupsFromPlugin(); 783 frame->script()->setAllowPopupsFromPlugin(request->allowPopups()); 784 785 ScriptValue result = frame->script()->executeScript(jsString); 786 787 frame->script()->setAllowPopupsFromPlugin(oldAllowPopups); 782 ScriptValue result = frame->script()->executeScript(jsString, request->allowPopups()); 788 783 789 784 // Check if evaluating the JavaScript destroyed the plug-in. … … 980 975 bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups) 981 976 { 982 RefPtr<Frame> frame = m_pluginElement->document()->frame();983 if (! frame)977 // FIXME: Is this check necessary? 978 if (!m_pluginElement->document()->frame()) 984 979 return false; 985 986 bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();987 frame->script()->setAllowPopupsFromPlugin(allowPopups);988 980 989 981 // Calling evaluate will run JavaScript that can potentially remove the plug-in element, so we need to … … 991 983 NPRuntimeObjectMap::PluginProtector pluginProtector(&m_npRuntimeObjectMap); 992 984 993 bool returnValue = m_npRuntimeObjectMap.evaluate(npObject, scriptString, result); 994 995 frame->script()->setAllowPopupsFromPlugin(oldAllowPopups); 996 997 return returnValue; 985 UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 986 return m_npRuntimeObjectMap.evaluate(npObject, scriptString, result); 998 987 } 999 988
Note: See TracChangeset
for help on using the changeset viewer.