Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8MutationCallback.cpp

Issue 2023213002: binding: Makes XxxObserverCallback use V8PrivateProperty instead of V8HiddenValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
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 #include "bindings/core/v8/V8MutationCallback.h" 26 #include "bindings/core/v8/V8MutationCallback.h"
27 27
28 #include "bindings/core/v8/ScriptController.h" 28 #include "bindings/core/v8/ScriptController.h"
29 #include "bindings/core/v8/ScriptState.h"
29 #include "bindings/core/v8/V8Binding.h" 30 #include "bindings/core/v8/V8Binding.h"
30 #include "bindings/core/v8/V8HiddenValue.h"
31 #include "bindings/core/v8/V8MutationObserver.h" 31 #include "bindings/core/v8/V8MutationObserver.h"
32 #include "bindings/core/v8/V8MutationRecord.h" 32 #include "bindings/core/v8/V8MutationRecord.h"
33 #include "bindings/core/v8/V8PrivateProperty.h"
33 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
34 #include "wtf/Assertions.h" 35 #include "wtf/Assertions.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 V8MutationCallback::V8MutationCallback(v8::Local<v8::Function> callback, v8::Loc al<v8::Object> owner, ScriptState* scriptState) 39 V8MutationCallback::V8MutationCallback(v8::Local<v8::Function> callback, v8::Loc al<v8::Object> owner, ScriptState* scriptState)
39 : ActiveDOMCallback(scriptState->getExecutionContext()) 40 : ActiveDOMCallback(scriptState->getExecutionContext())
40 , m_callback(scriptState->isolate(), callback) 41 , m_callback(scriptState->isolate(), callback)
41 , m_scriptState(scriptState) 42 , m_scriptState(scriptState)
42 { 43 {
43 V8HiddenValue::setHiddenValue(scriptState, owner, V8HiddenValue::callback(sc riptState->isolate()), callback); 44 V8PrivateProperty::getMutationObserverCallback(scriptState->isolate()).set(s criptState->context(), owner, callback);
44 m_callback.setWeak(this, &setWeakCallback); 45 m_callback.setPhantom();
45 } 46 }
46 47
47 V8MutationCallback::~V8MutationCallback() 48 V8MutationCallback::~V8MutationCallback()
48 { 49 {
49 } 50 }
50 51
51 void V8MutationCallback::call(const HeapVector<Member<MutationRecord>>& mutation s, MutationObserver* observer) 52 void V8MutationCallback::call(const HeapVector<Member<MutationRecord>>& mutation s, MutationObserver* observer)
52 { 53 {
53 if (!canInvokeCallback()) 54 if (!canInvokeCallback())
54 return; 55 return;
(...skipping 20 matching lines...) Expand all
75 v8::Local<v8::Value> v8Mutations = toV8(mutations, m_scriptState->context()- >Global(), isolate); 76 v8::Local<v8::Value> v8Mutations = toV8(mutations, m_scriptState->context()- >Global(), isolate);
76 if (v8Mutations.IsEmpty()) 77 if (v8Mutations.IsEmpty())
77 return; 78 return;
78 v8::Local<v8::Value> argv[] = { v8Mutations, observerHandle }; 79 v8::Local<v8::Value> argv[] = { v8Mutations, observerHandle };
79 80
80 v8::TryCatch exceptionCatcher(isolate); 81 v8::TryCatch exceptionCatcher(isolate);
81 exceptionCatcher.SetVerbose(true); 82 exceptionCatcher.SetVerbose(true);
82 ScriptController::callFunction(getExecutionContext(), m_callback.newLocal(is olate), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate); 83 ScriptController::callFunction(getExecutionContext(), m_callback.newLocal(is olate), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate);
83 } 84 }
84 85
85 void V8MutationCallback::setWeakCallback(const v8::WeakCallbackInfo<V8MutationCa llback>& data)
86 {
87 data.GetParameter()->m_callback.clear();
88 }
89
90 DEFINE_TRACE(V8MutationCallback) 86 DEFINE_TRACE(V8MutationCallback)
91 { 87 {
92 MutationCallback::trace(visitor); 88 MutationCallback::trace(visitor);
93 ActiveDOMCallback::trace(visitor); 89 ActiveDOMCallback::trace(visitor);
94 } 90 }
95 91
96 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698