diff options
Diffstat (limited to 'WebCore/bindings/v8/ScriptState.h')
-rw-r--r-- | WebCore/bindings/v8/ScriptState.h | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/WebCore/bindings/v8/ScriptState.h b/WebCore/bindings/v8/ScriptState.h index 12a1388..e71becb 100644 --- a/WebCore/bindings/v8/ScriptState.h +++ b/WebCore/bindings/v8/ScriptState.h @@ -31,6 +31,7 @@ #ifndef ScriptState_h #define ScriptState_h +#include "DOMWrapperWorld.h" #include <v8.h> #include <wtf/Noncopyable.h> #include <wtf/RefCounted.h> @@ -43,11 +44,6 @@ namespace WebCore { class ScriptState : public Noncopyable { public: - ScriptState() { } - ScriptState(Frame* frame); - ScriptState(Frame* frame, v8::Handle<v8::Context> context); - ~ScriptState(); - bool hadException() { return !m_exception.IsEmpty(); } void setException(v8::Local<v8::Value> exception) { @@ -55,29 +51,42 @@ namespace WebCore { } v8::Local<v8::Value> exception() { return m_exception; } - Frame* frame() const { return m_frame; } v8::Local<v8::Context> context() const { return v8::Local<v8::Context>::New(m_context); } + static ScriptState* forContext(v8::Local<v8::Context>); + static ScriptState* current(); + + protected: + ScriptState() { } + ~ScriptState(); + private: + friend ScriptState* mainWorldScriptState(Frame*); + explicit ScriptState(v8::Handle<v8::Context>); + + static void weakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter); + v8::Local<v8::Value> m_exception; - Frame* m_frame; v8::Persistent<v8::Context> m_context; }; + class EmptyScriptState : public ScriptState { + public: + EmptyScriptState() : ScriptState() { } + ~EmptyScriptState() { } + }; + + ScriptState* mainWorldScriptState(Frame*); + ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node*); ScriptState* scriptStateFromPage(DOMWrapperWorld*, Page*); - DOMWrapperWorld* mainThreadNormalWorld(); inline DOMWrapperWorld* debuggerWorld() { return mainThreadNormalWorld(); } inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); } - // Dummy class to avoid a bunch of ifdef's in WebCore. - class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { - }; - } #endif // ScriptState_h |