| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef V8MutationCallback_h | 26 #ifndef V8MutationCallback_h |
| 27 #define V8MutationCallback_h | 27 #define V8MutationCallback_h |
| 28 | 28 |
| 29 #include "bindings/core/v8/ActiveDOMCallback.h" | 29 #include "bindings/core/v8/ActiveDOMCallback.h" |
| 30 #include "bindings/core/v8/ScopedPersistent.h" | 30 #include "bindings/core/v8/ScopedPersistent.h" |
| 31 #include "bindings/core/v8/ScriptState.h" |
| 31 #include "core/dom/MutationCallback.h" | 32 #include "core/dom/MutationCallback.h" |
| 32 #include "wtf/RefPtr.h" | 33 #include "wtf/RefPtr.h" |
| 33 #include <v8.h> | 34 #include <v8.h> |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 class ExecutionContext; | 38 class ExecutionContext; |
| 38 class ScriptState; | |
| 39 | 39 |
| 40 class V8MutationCallback final : public MutationCallback, | 40 class V8MutationCallback final : public MutationCallback, |
| 41 public ActiveDOMCallback { | 41 public ActiveDOMCallback { |
| 42 USING_GARBAGE_COLLECTED_MIXIN(V8MutationCallback); | 42 USING_GARBAGE_COLLECTED_MIXIN(V8MutationCallback); |
| 43 | 43 |
| 44 public: | 44 public: |
| 45 static V8MutationCallback* create(v8::Local<v8::Function> callback, | 45 static V8MutationCallback* create(v8::Local<v8::Function> callback, |
| 46 v8::Local<v8::Object> owner, | 46 v8::Local<v8::Object> owner, |
| 47 ScriptState* scriptState) { | 47 ScriptState* scriptState) { |
| 48 return new V8MutationCallback(callback, owner, scriptState); | 48 return new V8MutationCallback(callback, owner, scriptState); |
| 49 } | 49 } |
| 50 ~V8MutationCallback() override; | 50 ~V8MutationCallback() override; |
| 51 | 51 |
| 52 void call(const HeapVector<Member<MutationRecord>>&, | 52 void call(const HeapVector<Member<MutationRecord>>&, |
| 53 MutationObserver*) override; | 53 MutationObserver*) override; |
| 54 |
| 54 ExecutionContext* getExecutionContext() const override { | 55 ExecutionContext* getExecutionContext() const override { |
| 55 return ContextLifecycleObserver::getExecutionContext(); | 56 return m_scriptState->getExecutionContext(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 DECLARE_VIRTUAL_TRACE(); | 59 DECLARE_VIRTUAL_TRACE(); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 V8MutationCallback(v8::Local<v8::Function>, | 62 V8MutationCallback(v8::Local<v8::Function>, |
| 62 v8::Local<v8::Object>, | 63 v8::Local<v8::Object>, |
| 63 ScriptState*); | 64 ScriptState*); |
| 64 | 65 |
| 65 ScopedPersistent<v8::Function> m_callback; | 66 ScopedPersistent<v8::Function> m_callback; |
| 66 RefPtr<ScriptState> m_scriptState; | 67 RefPtr<ScriptState> m_scriptState; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 } // namespace blink | 70 } // namespace blink |
| 70 | 71 |
| 71 #endif // V8MutationCallback_h | 72 #endif // V8MutationCallback_h |
| OLD | NEW |