Title: [148537] trunk/Source/WebCore
Revision
148537
Author
[email protected]
Date
2013-04-16 13:05:38 -0700 (Tue, 16 Apr 2013)

Log Message

Begin chipping away at ScriptState
https://bugs.webkit.org/show_bug.cgi?id=114695

Reviewed by Geoffrey Garen.

Remove ScriptStateProtectedPtr as well as evalEnabled and setEvalEnabled.

* bindings/js/ScriptState.cpp:
* bindings/js/ScriptState.h:
* inspector/InjectedScriptBase.cpp:
(WebCore::InjectedScriptBase::callFunctionWithEvalEnabled):
* inspector/ScriptArguments.cpp:
(WebCore::ScriptArguments::ScriptArguments):
(WebCore::ScriptArguments::globalState):
* inspector/ScriptArguments.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148536 => 148537)


--- trunk/Source/WebCore/ChangeLog	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/ChangeLog	2013-04-16 20:05:38 UTC (rev 148537)
@@ -1,3 +1,21 @@
+2013-04-16  Anders Carlsson  <[email protected]>
+
+        Begin chipping away at ScriptState
+        https://bugs.webkit.org/show_bug.cgi?id=114695
+
+        Reviewed by Geoffrey Garen.
+
+        Remove ScriptStateProtectedPtr as well as evalEnabled and setEvalEnabled.
+
+        * bindings/js/ScriptState.cpp:
+        * bindings/js/ScriptState.h:
+        * inspector/InjectedScriptBase.cpp:
+        (WebCore::InjectedScriptBase::callFunctionWithEvalEnabled):
+        * inspector/ScriptArguments.cpp:
+        (WebCore::ScriptArguments::ScriptArguments):
+        (WebCore::ScriptArguments::globalState):
+        * inspector/ScriptArguments.h:
+
 2013-04-15  Anders Carlsson  <[email protected]>
 
         Remove unneeded headers from ScriptExecutionContext.h

Modified: trunk/Source/WebCore/bindings/js/ScriptState.cpp (148536 => 148537)


--- trunk/Source/WebCore/bindings/js/ScriptState.cpp	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/bindings/js/ScriptState.cpp	2013-04-16 20:05:38 UTC (rev 148537)
@@ -48,22 +48,6 @@
 
 namespace WebCore {
 
-ScriptStateProtectedPtr::~ScriptStateProtectedPtr()
-{
-}
-
-ScriptStateProtectedPtr::ScriptStateProtectedPtr(ScriptState* scriptState)
-    : m_globalObject(scriptState->globalData(), scriptState->lexicalGlobalObject())
-{
-}
-
-ScriptState* ScriptStateProtectedPtr::get() const
-{
-    if (m_globalObject)
-        return const_cast<JSC::JSGlobalObject*>(m_globalObject.get())->globalExec();
-    return 0;
-}
-
 DOMWindow* domWindowFromScriptState(ScriptState* scriptState)
 {
     JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
@@ -80,18 +64,6 @@
     return JSC::jsCast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext();
 }
 
-bool evalEnabled(ScriptState* scriptState)
-{
-    JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
-    return globalObject->evalEnabled();
-}
-
-void setEvalEnabled(ScriptState* scriptState, bool enabled)
-{
-    JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
-    return globalObject->setEvalEnabled(enabled);
-}
-
 ScriptState* mainWorldScriptState(Frame* frame)
 {
     if (!frame)

Modified: trunk/Source/WebCore/bindings/js/ScriptState.h (148536 => 148537)


--- trunk/Source/WebCore/bindings/js/ScriptState.h	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/bindings/js/ScriptState.h	2013-04-16 20:05:38 UTC (rev 148537)
@@ -32,9 +32,6 @@
 #ifndef ScriptState_h
 #define ScriptState_h
 
-#include <heap/Strong.h>
-#include <wtf/Noncopyable.h>
-
 namespace JSC {
 class ExecState;
 class JSGlobalObject;
@@ -55,22 +52,9 @@
 // For now, the separation is purely by convention.
 typedef JSC::ExecState ScriptState;
 
-class ScriptStateProtectedPtr {
-    WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr);
-public:
-    explicit ScriptStateProtectedPtr(ScriptState*);
-    ~ScriptStateProtectedPtr();
-    ScriptState* get() const;
-private:
-    JSC::Strong<JSC::JSGlobalObject> m_globalObject;
-};
-
 DOMWindow* domWindowFromScriptState(ScriptState*);
 ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState*);
 
-bool evalEnabled(ScriptState*);
-void setEvalEnabled(ScriptState*, bool);
-
 ScriptState* mainWorldScriptState(Frame*);
 
 ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node*);

Modified: trunk/Source/WebCore/inspector/InjectedScriptBase.cpp (148536 => 148537)


--- trunk/Source/WebCore/inspector/InjectedScriptBase.cpp	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/inspector/InjectedScriptBase.cpp	2013-04-16 20:05:38 UTC (rev 148537)
@@ -37,6 +37,7 @@
 #include "InspectorInstrumentation.h"
 #include "InspectorValues.h"
 #include "ScriptFunctionCall.h"
+#include <runtime/JSGlobalObject.h>
 #include <wtf/text/WTFString.h>
 
 using WebCore::TypeBuilder::Runtime::RemoteObject;
@@ -80,16 +81,16 @@
     ScriptState* scriptState = m_injectedScriptObject.scriptState();
     bool evalIsDisabled = false;
     if (scriptState) {
-        evalIsDisabled = !evalEnabled(scriptState);
+        evalIsDisabled = !scriptState->lexicalGlobalObject()->evalEnabled();
         // Temporarily enable allow evals for inspector.
         if (evalIsDisabled)
-            setEvalEnabled(scriptState, true);
+            scriptState->lexicalGlobalObject()->setEvalEnabled(true);
     }
 
     ScriptValue resultValue = function.call(hadException);
 
     if (evalIsDisabled)
-        setEvalEnabled(scriptState, false);
+        scriptState->lexicalGlobalObject()->setEvalEnabled(false);
 
     InspectorInstrumentation::didCallFunction(cookie);
     return resultValue;

Modified: trunk/Source/WebCore/inspector/ScriptArguments.cpp (148536 => 148537)


--- trunk/Source/WebCore/inspector/ScriptArguments.cpp	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/inspector/ScriptArguments.cpp	2013-04-16 20:05:38 UTC (rev 148537)
@@ -41,7 +41,7 @@
 }
 
 ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
-    : m_scriptState(scriptState)
+    : m_globalObject(scriptState->globalData(), scriptState->lexicalGlobalObject())
 {
     m_arguments.swap(arguments);
 }
@@ -58,7 +58,9 @@
 
 ScriptState* ScriptArguments::globalState() const
 {
-    return m_scriptState.get();
+    if (m_globalObject)
+        return const_cast<JSC::JSGlobalObject*>(m_globalObject.get())->globalExec();
+    return 0;
 }
 
 bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined)

Modified: trunk/Source/WebCore/inspector/ScriptArguments.h (148536 => 148537)


--- trunk/Source/WebCore/inspector/ScriptArguments.h	2013-04-16 19:57:36 UTC (rev 148536)
+++ trunk/Source/WebCore/inspector/ScriptArguments.h	2013-04-16 20:05:38 UTC (rev 148537)
@@ -31,14 +31,20 @@
 #ifndef ScriptArguments_h
 #define ScriptArguments_h
 
-#include "ScriptState.h"
+#include <heap/Strong.h>
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
+namespace JSC {
+class ExecState;
+class JSGlobalObject;
+}
+
 namespace WebCore {
 
+typedef JSC::ExecState ScriptState;
 class ScriptValue;
 
 class ScriptArguments : public RefCounted<ScriptArguments> {
@@ -58,7 +64,7 @@
 private:
     ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments);
 
-    ScriptStateProtectedPtr m_scriptState;
+    JSC::Strong<JSC::JSGlobalObject> m_globalObject;
     Vector<ScriptValue> m_arguments;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to