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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8ResizeObserverCallbackCustom.cpp

Issue 2303893003: Pass ResizeObserver as 'this' to callback (Closed)
Patch Set: CR fix, merge master Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8ResizeObserverCallbackCustom.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ResizeObserverCallbackCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ResizeObserverCallbackCustom.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d331bdc4bcd01879ceb071454ea743b82e5d427e
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ResizeObserverCallbackCustom.cpp
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "bindings/core/v8/V8ResizeObserverCallback.h"
+
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8ResizeObserver.h"
+#include "bindings/core/v8/V8ResizeObserverEntry.h"
+#include "core/dom/ExecutionContext.h"
+
+namespace blink {
+
+void V8ResizeObserverCallback::handleEvent(const HeapVector<Member<ResizeObserverEntry>>& entries, ResizeObserver* observer)
+{
+ if (!canInvokeCallback())
+ return;
+
+ v8::Isolate* isolate = m_scriptState->isolate();
+
+ if (!m_scriptState->contextIsValid())
+ return;
+ ScriptState::Scope scope(m_scriptState.get());
+
+ if (m_callback.isEmpty())
+ return;
+
+ v8::Local<v8::Value> observerHandle = toV8(observer, m_scriptState->context()->Global(), m_scriptState->isolate());
+ if (!observerHandle->IsObject())
+ return;
+
+ v8::Local<v8::Object> thisObject = v8::Local<v8::Object>::Cast(observerHandle);
+ v8::Local<v8::Value> entriesHandle = toV8(entries, m_scriptState->context()->Global(), m_scriptState->isolate());
+ if (entriesHandle.IsEmpty())
+ return;
+ v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle };
+
+ v8::TryCatch exceptionCatcher(m_scriptState->isolate());
+ exceptionCatcher.SetVerbose(true);
+ V8ScriptRunner::callFunction(m_callback.newLocal(isolate), getExecutionContext(), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate);
+}
+
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/bindings.gni ('k') | third_party/WebKit/Source/core/observer/ResizeObserverCallback.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698