| 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 11 matching lines...) Expand all Loading... |
| 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/ScopedPersistent.h" | 29 #include "bindings/core/v8/ScopedPersistent.h" |
| 30 #include "bindings/core/v8/ScriptState.h" | 30 #include "bindings/core/v8/ScriptState.h" |
| 31 #include "bindings/core/v8/TraceWrapperV8Reference.h" | 31 #include "bindings/core/v8/TraceWrapperV8Reference.h" |
| 32 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/dom/MutationCallback.h" | 33 #include "core/dom/MutationCallback.h" |
| 33 #include "platform/wtf/RefPtr.h" | 34 #include "platform/wtf/RefPtr.h" |
| 34 #include "v8/include/v8.h" | 35 #include "v8/include/v8.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 class ExecutionContext; | 39 class ExecutionContext; |
| 39 | 40 |
| 40 class V8MutationCallback final : public MutationCallback { | 41 class V8MutationCallback final : public MutationCallback { |
| 41 public: | 42 public: |
| 42 static V8MutationCallback* Create(v8::Local<v8::Function> callback, | 43 static V8MutationCallback* Create(v8::Local<v8::Function> callback, |
| 43 v8::Local<v8::Object> owner, | 44 v8::Local<v8::Object> owner, |
| 44 ScriptState* script_state) { | 45 ScriptState* script_state) { |
| 45 return new V8MutationCallback(callback, owner, script_state); | 46 return new V8MutationCallback(callback, owner, script_state); |
| 46 } | 47 } |
| 47 ~V8MutationCallback() override; | 48 ~V8MutationCallback() override; |
| 48 | 49 |
| 49 void Call(const HeapVector<Member<MutationRecord>>&, | 50 void Call(const HeapVector<Member<MutationRecord>>&, |
| 50 MutationObserver*) override; | 51 MutationObserver*) override; |
| 51 | 52 |
| 52 ExecutionContext* GetExecutionContext() const override { | 53 ExecutionContext* GetExecutionContext() const override { |
| 53 return script_state_->GetExecutionContext(); | 54 return ExecutionContext::From(script_state_.Get()); |
| 54 } | 55 } |
| 55 | 56 |
| 56 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
| 57 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 58 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 V8MutationCallback(v8::Local<v8::Function>, | 61 V8MutationCallback(v8::Local<v8::Function>, |
| 61 v8::Local<v8::Object>, | 62 v8::Local<v8::Object>, |
| 62 ScriptState*); | 63 ScriptState*); |
| 63 | 64 |
| 64 TraceWrapperV8Reference<v8::Function> callback_; | 65 TraceWrapperV8Reference<v8::Function> callback_; |
| 65 RefPtr<ScriptState> script_state_; | 66 RefPtr<ScriptState> script_state_; |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 } // namespace blink | 69 } // namespace blink |
| 69 | 70 |
| 70 #endif // V8MutationCallback_h | 71 #endif // V8MutationCallback_h |
| OLD | NEW |