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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 m_callback.setWeak(this, &setWeakCallback); | 45 m_callback.setWeak(this, &setWeakCallback); |
46 } | 46 } |
47 | 47 |
48 void V8MutationCallback::call(const WillBeHeapVector<RefPtrWillBeMember<Mutation
Record> >& mutations, MutationObserver* observer) | 48 void V8MutationCallback::call(const WillBeHeapVector<RefPtrWillBeMember<Mutation
Record> >& mutations, MutationObserver* observer) |
49 { | 49 { |
50 if (!canInvokeCallback()) | 50 if (!canInvokeCallback()) |
51 return; | 51 return; |
52 | 52 |
53 v8::Isolate* isolate = m_scriptState->isolate(); | 53 v8::Isolate* isolate = m_scriptState->isolate(); |
54 | 54 |
55 if (m_scriptState->contextIsValid()) | 55 if (!m_scriptState->contextIsValid()) |
56 return; | 56 return; |
57 ScriptState::Scope scope(m_scriptState.get()); | 57 ScriptState::Scope scope(m_scriptState.get()); |
58 | 58 |
59 if (m_callback.isEmpty()) | 59 if (m_callback.isEmpty()) |
60 return; | 60 return; |
61 v8::Handle<v8::Value> observerHandle = toV8(observer, m_scriptState->context
()->Global(), isolate); | 61 v8::Handle<v8::Value> observerHandle = toV8(observer, m_scriptState->context
()->Global(), isolate); |
62 if (observerHandle.IsEmpty()) { | 62 if (observerHandle.IsEmpty()) { |
63 if (!isScriptControllerTerminating()) | 63 if (!isScriptControllerTerminating()) |
64 CRASH(); | 64 CRASH(); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 if (!observerHandle->IsObject()) | 68 if (!observerHandle->IsObject()) |
69 return; | 69 return; |
70 | 70 |
71 v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(observerHan
dle); | 71 v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(observerHan
dle); |
72 v8::Handle<v8::Value> argv[] = { v8Array(mutations, m_scriptState->context()
->Global(), isolate), observerHandle }; | 72 v8::Handle<v8::Value> argv[] = { v8Array(mutations, m_scriptState->context()
->Global(), isolate), observerHandle }; |
73 | 73 |
74 v8::TryCatch exceptionCatcher; | 74 v8::TryCatch exceptionCatcher; |
75 exceptionCatcher.SetVerbose(true); | 75 exceptionCatcher.SetVerbose(true); |
76 ScriptController::callFunction(executionContext(), m_callback.newLocal(isola
te), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate); | 76 ScriptController::callFunction(executionContext(), m_callback.newLocal(isola
te), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate); |
77 } | 77 } |
78 | 78 |
79 void V8MutationCallback::setWeakCallback(const v8::WeakCallbackData<v8::Function
, V8MutationCallback>& data) | 79 void V8MutationCallback::setWeakCallback(const v8::WeakCallbackData<v8::Function
, V8MutationCallback>& data) |
80 { | 80 { |
81 data.GetParameter()->m_callback.clear(); | 81 data.GetParameter()->m_callback.clear(); |
82 } | 82 } |
83 | 83 |
84 } // namespace blink | 84 } // namespace blink |
OLD | NEW |