Title: [88731] trunk/Source/WebCore
Revision
88731
Author
[email protected]
Date
2011-06-13 16:28:23 -0700 (Mon, 13 Jun 2011)

Log Message

2011-06-13  Adam Barth  <[email protected]>

        Reviewed by Darin Adler.

        anyPageIsProcessingUserGesture is not longer needed because user gesture state is static
        https://bugs.webkit.org/show_bug.cgi?id=62601

        Previously, our user-gesture state was per-frame.  Code needed to check
        the "global" user gesture state called anyPageIsProcessingUserGesture()
        to iterate through all the frames and look for one that was processing
        a user gesture.  Since we changed the user gesture state to be static,
        iterating over every frame in existence isn't needed.

        This patch also cleans up a couple other user-gesture callsites I saw
        while I was in this code.  Code should just call
        ScriptController::processingUserGesture directly instead of
        trampolining through other functions.

        * bindings/ScriptControllerBase.cpp:
        (WebCore::ScriptController::executeScript):
        * bindings/generic/BindingSecurity.h:
        (WebCore::::allowPopUp):
        * bindings/js/JSDOMBinding.cpp:
        * bindings/js/JSDOMBinding.h:
        * bindings/js/JSDocumentCustom.cpp:
        (WebCore::JSDocument::setLocation):
        * bindings/js/ScriptController.cpp:
        * bindings/js/ScriptController.h:
        * bindings/scripts/CodeGeneratorJS.pm:
        * bindings/scripts/CodeGeneratorV8.pm:
        * bindings/v8/ScriptController.cpp:
        * bindings/v8/ScriptController.h:
        (WebCore::ScriptController::setProcessingTimerCallback):
        * bindings/v8/V8Utilities.cpp:
        * bindings/v8/V8Utilities.h:
        * bindings/v8/specialization/V8BindingState.cpp:
        * bindings/v8/specialization/V8BindingState.h:
        * html/HTMLFormElement.cpp:
        (WebCore::HTMLFormElement::submitFromJavaScript):
        (WebCore::HTMLFormElement::submit):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::setLocation):
        (WebCore::DOMWindow::createWindow):
        (WebCore::DOMWindow::open):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88730 => 88731)


--- trunk/Source/WebCore/ChangeLog	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/ChangeLog	2011-06-13 23:28:23 UTC (rev 88731)
@@ -1,3 +1,48 @@
+2011-06-13  Adam Barth  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        anyPageIsProcessingUserGesture is not longer needed because user gesture state is static
+        https://bugs.webkit.org/show_bug.cgi?id=62601
+
+        Previously, our user-gesture state was per-frame.  Code needed to check
+        the "global" user gesture state called anyPageIsProcessingUserGesture()
+        to iterate through all the frames and look for one that was processing
+        a user gesture.  Since we changed the user gesture state to be static,
+        iterating over every frame in existence isn't needed.
+
+        This patch also cleans up a couple other user-gesture callsites I saw
+        while I was in this code.  Code should just call
+        ScriptController::processingUserGesture directly instead of
+        trampolining through other functions.
+
+        * bindings/ScriptControllerBase.cpp:
+        (WebCore::ScriptController::executeScript):
+        * bindings/generic/BindingSecurity.h:
+        (WebCore::::allowPopUp):
+        * bindings/js/JSDOMBinding.cpp:
+        * bindings/js/JSDOMBinding.h:
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::setLocation):
+        * bindings/js/ScriptController.cpp:
+        * bindings/js/ScriptController.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/ScriptController.cpp:
+        * bindings/v8/ScriptController.h:
+        (WebCore::ScriptController::setProcessingTimerCallback):
+        * bindings/v8/V8Utilities.cpp:
+        * bindings/v8/V8Utilities.h:
+        * bindings/v8/specialization/V8BindingState.cpp:
+        * bindings/v8/specialization/V8BindingState.h:
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::submitFromJavaScript):
+        (WebCore::HTMLFormElement::submit):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::setLocation):
+        (WebCore::DOMWindow::createWindow):
+        (WebCore::DOMWindow::open):
+
 2011-06-13  Jeffrey Pfau  <[email protected]>
 
         Reviewed by Darin Adler.

Modified: trunk/Source/WebCore/bindings/ScriptControllerBase.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -54,6 +54,8 @@
 
 ScriptValue ScriptController::executeScript(const String& script, bool forceUserGesture)
 {
+    // FIXME: Why does the URL of the script depend on forceUserGesture?
+    // This looks suspiciously like an old user-gesture back-channel.
     return executeScript(ScriptSourceCode(script, forceUserGesture ? KURL() : m_frame->document()->url()));
 }
 

Modified: trunk/Source/WebCore/bindings/generic/BindingSecurity.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/generic/BindingSecurity.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/generic/BindingSecurity.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -38,6 +38,7 @@
 #include "HTMLFrameElementBase.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "ScriptController.h"
 #include "Settings.h"
 
 namespace WebCore {
@@ -116,7 +117,7 @@
 template <class Binding>
 bool BindingSecurity<Binding>::allowPopUp(State<Binding>* state)
 {
-    if (state->processingUserGesture())
+    if (ScriptController::processingUserGesture())
         return true;
 
     Frame* frame = state->firstFrame();

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -303,12 +303,6 @@
     return firstDOMWindow(exec)->frame();
 }
 
-// FIXME: We should remove this function. Callers can use ScriptController directly.
-bool processingUserGesture()
-{
-    return ScriptController::processingUserGesture();
-}
-
 JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
 {
     return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, objectProtoFuncToString);

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -251,8 +251,7 @@
     JSC::JSValue objectToStringFunctionGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier& propertyName);
 
     Frame* toDynamicFrame(JSC::ExecState*);
-    bool processingUserGesture();
-    
+
     inline JSC::JSValue jsString(JSC::ExecState* exec, const String& s)
     {
         StringImpl* stringImpl = s.impl();

Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -78,8 +78,9 @@
     Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();
     str = activeFrame->document()->completeURL(str).string();
 
+    bool lockHistory = !ScriptController::processingUserGesture();
     frame->navigationScheduler()->scheduleLocationChange(lexicalFrame->document()->securityOrigin(),
-        str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
+        str, activeFrame->loader()->outgoingReferrer(), lockHistory, false);
 }
 
 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* document)

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -280,37 +280,6 @@
     return false;
 }
 
-bool ScriptController::anyPageIsProcessingUserGesture() const
-{
-    Page* page = m_frame->page();
-    if (!page)
-        return false;
-
-    const HashSet<Page*>& pages = page->group().pages();
-    HashSet<Page*>::const_iterator end = pages.end();
-    for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
-        for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-            ScriptController* script = frame->script();
-
-            if (script->m_allowPopupsFromPlugin)
-                return true;
-
-            const ShellMap::const_iterator iterEnd = m_windowShells.end();
-            for (ShellMap::const_iterator iter = m_windowShells.begin(); iter != iterEnd; ++iter) {
-                JSDOMWindowShell* shell = iter->second.get();
-                Event* event = shell->window()->currentEvent();
-                if (event && event->fromUserGesture())
-                    return true;
-            }
-
-            if (isJavaScriptAnchorNavigation())
-                return true;
-        }
-    }
-
-    return false;
-}
-
 bool ScriptController::canAccessFromCurrentOrigin(Frame *frame)
 {
     ExecState* exec = JSMainThreadExecState::currentState();

Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/js/ScriptController.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -110,7 +110,6 @@
 
     void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
     static bool processingUserGesture();
-    bool anyPageIsProcessingUserGesture() const;
 
     static bool canAccessFromCurrentOrigin(Frame*);
     bool canExecuteScripts(ReasonForCallingCanExecuteScripts);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (88730 => 88731)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-06-13 23:28:23 UTC (rev 88731)
@@ -2099,8 +2099,9 @@
 
                     if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
                         $functionString .= ", " if $paramIndex;
-                        $functionString .= "processingUserGesture()";
+                        $functionString .= "ScriptController::processingUserGesture()";
                         $paramIndex++;
+                        $implIncludes{"ScriptController.h"} = 1;
                     }
 
                     push(@implContent, "\n");

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (88730 => 88731)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-06-13 23:28:23 UTC (rev 88731)
@@ -2752,10 +2752,9 @@
 
     if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
         $functionString .= ", " if $index;
-        # FIXME: We need to pass DOMWrapperWorld as a parameter.
-        # See http://trac.webkit.org/changeset/54182
-        $functionString .= "processingUserGesture()";
+        $functionString .= "ScriptController::processingUserGesture()";
         $index++;
+        $implIncludes{"ScriptController.h"} = 1;
     }
 
     if (@{$function->raisesExceptions}) {

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -199,12 +199,6 @@
     return UserGestureIndicator::processingUserGesture();
 }
 
-bool ScriptController::anyPageIsProcessingUserGesture() const
-{
-    // FIXME: is this right?
-    return ScriptController::processingUserGesture();
-}
-
 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources)
 {
     m_proxy->evaluateInIsolatedWorld(worldID, sources, 0);

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -158,10 +158,7 @@
     TextPosition0 eventHandlerPosition() const;
 
     void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; }
-    // FIXME: Currently we don't use the parameter world at all.
-    // See http://trac.webkit.org/changeset/54182
     static bool processingUserGesture();
-    bool anyPageIsProcessingUserGesture() const;
 
     void setPaused(bool paused) { m_paused = paused; }
     bool isPaused() const { return m_paused; }

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -107,11 +107,6 @@
         createHiddenDependency(object, newValue, cacheIndex);
 }
 
-bool processingUserGesture()
-{
-    return V8BindingState::Only()->processingUserGesture();
-}
-
 Frame* callingOrEnteredFrame()
 {
     return V8BindingState::Only()->activeFrame();

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -47,11 +47,10 @@
     // Use an array to hold dependents. It works like a ref-counted scheme. A value can be added more than once to the DOM object.
     void createHiddenDependency(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
     void removeHiddenDependency(v8::Handle<v8::Object>, v8::Local<v8::Value>, int cacheIndex);
-    
+
     // Combo create/remove, for generated event-handler-setter bindings:
     void transferHiddenDependency(v8::Handle<v8::Object>, EventListener* oldValue, v8::Local<v8::Value> newValue, int cacheIndex);
-    
-    bool processingUserGesture();
+
     bool shouldAllowNavigation(Frame*);
     KURL completeURL(const String& relativeURL);
 

Modified: trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -84,11 +84,6 @@
     V8Proxy::reportUnsafeAccessTo(target);
 }
 
-bool State<V8Binding>::processingUserGesture()
-{
-    return ScriptController::processingUserGesture();
-}
-
 bool State<V8Binding>::allowsAccessFromFrame(Frame* frame)
 {
     return ScriptController::isSafeScript(frame);

Modified: trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.h (88730 => 88731)


--- trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.h	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.h	2011-06-13 23:28:23 UTC (rev 88731)
@@ -55,8 +55,6 @@
     Frame* activeFrame();
     Frame* firstFrame();
 
-    bool processingUserGesture();
-
     // FIXME: This should be shared in BindingSecurity
     bool allowsAccessFromFrame(Frame*);
 

Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (88730 => 88731)


--- trunk/Source/WebCore/html/HTMLFormElement.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -295,10 +295,7 @@
 
 void HTMLFormElement::submitFromJavaScript()
 {
-    Frame* frame = document()->frame();
-    if (!frame)
-        return;
-    submit(0, false, frame->script()->anyPageIsProcessingUserGesture(), SubmittedByJavaScript);
+    submit(0, false, ScriptController::processingUserGesture(), SubmittedByJavaScript);
 }
 
 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger formSubmissionTrigger)
@@ -335,7 +332,8 @@
     if (needButtonActivation && firstSuccessfulSubmitButton)
         firstSuccessfulSubmitButton->setActivatedSubmit(true);
 
-    frame->loader()->submitForm(FormSubmission::create(this, m_attributes, event, !processingUserGesture, formSubmissionTrigger));
+    bool lockHistory = !processingUserGesture;
+    frame->loader()->submitForm(FormSubmission::create(this, m_attributes, event, lockHistory, formSubmissionTrigger));
 
     if (needButtonActivation && firstSuccessfulSubmitButton)
         firstSuccessfulSubmitButton->setActivatedSubmit(false);

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (88730 => 88731)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2011-06-13 23:20:47 UTC (rev 88730)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2011-06-13 23:28:23 UTC (rev 88731)
@@ -1677,7 +1677,7 @@
     // We want a new history item if we are processing a user gesture.
     m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
         completedURL, activeFrame->loader()->outgoingReferrer(),
-        locking != LockHistoryBasedOnGestureState || !activeFrame->script()->anyPageIsProcessingUserGesture(),
+        locking != LockHistoryBasedOnGestureState || !ScriptController::processingUserGesture(),
         locking != LockHistoryBasedOnGestureState);
 }
 
@@ -1765,8 +1765,8 @@
     if (created)
         newFrame->loader()->changeLocation(activeWindow->securityOrigin(), completedURL, referrer, false, false);
     else if (!urlString.isEmpty()) {
-        newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->securityOrigin(), completedURL.string(), referrer,
-            !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
+        bool lockHistory = !ScriptController::processingUserGesture();
+        newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->securityOrigin(), completedURL.string(), referrer, lockHistory, false);
     }
 
     return newFrame;
@@ -1814,11 +1814,13 @@
 
         // For whatever reason, Firefox uses the first window rather than the active window to
         // determine the outgoing referrer. We replicate that behavior here.
-        targetFrame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
+        bool lockHistory = !ScriptController::processingUserGesture();
+        targetFrame->navigationScheduler()->scheduleLocationChange(
+            activeFrame->document()->securityOrigin(),
             firstFrame->document()->completeURL(urlString).string(),
             firstFrame->loader()->outgoingReferrer(),
-            !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
-
+            lockHistory,
+            false);
         return targetFrame->domWindow();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to