diff options
Diffstat (limited to 'WebCore/bindings/js/ScriptState.h')
-rw-r--r-- | WebCore/bindings/js/ScriptState.h | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/WebCore/bindings/js/ScriptState.h b/WebCore/bindings/js/ScriptState.h index 0c7c575..6bef4f7 100644 --- a/WebCore/bindings/js/ScriptState.h +++ b/WebCore/bindings/js/ScriptState.h @@ -33,23 +33,39 @@ #define ScriptState_h #include "JSDOMBinding.h" +#include <runtime/Protect.h> +#include <wtf/Noncopyable.h> namespace WebCore { - class DOMWrapperWorld; - class Frame; - class Node; - class Page; +class DOMWrapperWorld; +class Frame; +class Node; +class Page; - // The idea is to expose "state-like" methods (hadException, and any other - // methods where ExecState just dips into globalData) of JSC::ExecState as a - // separate abstraction. - // For now, the separation is purely by convention. - typedef JSC::ExecState ScriptState; +// The idea is to expose "state-like" methods (hadException, and any other +// methods where ExecState just dips into globalData) of JSC::ExecState as a +// separate abstraction. +// For now, the separation is purely by convention. +typedef JSC::ExecState ScriptState; - ScriptState* mainWorldScriptState(Frame*); +class ScriptStateProtectedPtr : public Noncopyable { +public: + ScriptStateProtectedPtr() { } + ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { } + ScriptState* get() + { + if (m_globalObject) + return m_globalObject->globalExec(); + return 0; + } +private: + JSC::ProtectedPtr<JSC::JSGlobalObject> m_globalObject; +}; - ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node*); - ScriptState* scriptStateFromPage(DOMWrapperWorld*, Page*); +ScriptState* mainWorldScriptState(Frame*); + +ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node*); +ScriptState* scriptStateFromPage(DOMWrapperWorld*, Page*); } // namespace WebCore |