| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ScriptState_h | 31 #ifndef ScriptState_h |
| 32 #define ScriptState_h | 32 #define ScriptState_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScopedPersistent.h" | 34 #include "bindings/v8/ScopedPersistent.h" |
| 35 #include "bindings/v8/V8Utilities.h" | 35 #include "bindings/v8/V8Utilities.h" |
| 36 #include <v8.h> | 36 #include <v8.h> |
| 37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 38 #include "wtf/text/WTFString.h" |
| 38 | 39 |
| 39 namespace WebCore { | 40 namespace WebCore { |
| 40 | 41 |
| 41 class DOMWindow; | 42 class DOMWindow; |
| 42 class DOMWrapperWorld; | 43 class DOMWrapperWorld; |
| 43 class Frame; | 44 class Frame; |
| 44 class ScriptExecutionContext; | 45 class ScriptExecutionContext; |
| 45 class WorkerGlobalScope; | 46 class WorkerGlobalScope; |
| 46 | 47 |
| 47 class ScriptState { | 48 class ScriptState { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 v8::Isolate* isolate() | 64 v8::Isolate* isolate() |
| 64 { | 65 { |
| 65 return m_isolate; | 66 return m_isolate; |
| 66 } | 67 } |
| 67 | 68 |
| 68 DOMWindow* domWindow() const; | 69 DOMWindow* domWindow() const; |
| 69 ScriptExecutionContext* scriptExecutionContext() const; | 70 ScriptExecutionContext* scriptExecutionContext() const; |
| 70 bool evalEnabled() const; | 71 bool evalEnabled() const; |
| 71 void setEvalEnabled(bool); | 72 void setEvalEnabled(bool); |
| 72 | 73 |
| 74 virtual const String* name() { return 0; } |
| 75 // FIXME: determine a better name and use an enum of supported languages, et
c. |
| 76 virtual bool isJavaScript() { return true; } |
| 77 |
| 73 static ScriptState* forContext(v8::Handle<v8::Context>); | 78 static ScriptState* forContext(v8::Handle<v8::Context>); |
| 74 static ScriptState* current(); | 79 static ScriptState* current(); |
| 75 | 80 |
| 76 protected: | 81 protected: |
| 77 ScriptState() | 82 ScriptState() |
| 78 : m_isolate(v8::Isolate::GetCurrent()) | 83 : m_isolate(v8::Isolate::GetCurrent()) |
| 79 { | 84 { |
| 80 } | 85 } |
| 81 | 86 |
| 82 ~ScriptState(); | 87 explicit ScriptState(v8::Handle<v8::Context>); |
| 88 |
| 89 virtual ~ScriptState(); |
| 83 | 90 |
| 84 private: | 91 private: |
| 85 friend ScriptState* mainWorldScriptState(Frame*); | 92 friend ScriptState* mainWorldScriptState(Frame*); |
| 86 explicit ScriptState(v8::Handle<v8::Context>); | |
| 87 | 93 |
| 88 static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Context>*, Scr
iptState*); | 94 static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Context>*, Scr
iptState*); |
| 89 | 95 |
| 90 ScopedPersistent<v8::Value> m_exception; | 96 ScopedPersistent<v8::Value> m_exception; |
| 91 ScopedPersistent<v8::Context> m_context; | 97 ScopedPersistent<v8::Context> m_context; |
| 92 v8::Isolate* m_isolate; | 98 v8::Isolate* m_isolate; |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 class EmptyScriptState : public ScriptState { | 101 class EmptyScriptState : public ScriptState { |
| 96 public: | 102 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 ScopedPersistent<v8::Context> m_context; | 127 ScopedPersistent<v8::Context> m_context; |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 ScriptState* mainWorldScriptState(Frame*); | 130 ScriptState* mainWorldScriptState(Frame*); |
| 125 | 131 |
| 126 ScriptState* scriptStateFromWorkerGlobalScope(WorkerGlobalScope*); | 132 ScriptState* scriptStateFromWorkerGlobalScope(WorkerGlobalScope*); |
| 127 | 133 |
| 128 } | 134 } |
| 129 | 135 |
| 130 #endif // ScriptState_h | 136 #endif // ScriptState_h |
| OLD | NEW |