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

Side by Side Diff: Source/bindings/core/v8/custom/V8IntersectionObserverCustom.cpp

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix segfault on null input. Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "bindings/core/v8/V8IntersectionObserver.h"
7
8 #include "bindings/core/v8/ExceptionMessages.h"
9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/V8Binding.h"
11 #include "bindings/core/v8/V8DOMWrapper.h"
12 #include "bindings/core/v8/V8GCController.h"
13 #include "bindings/core/v8/V8IntersectionObserverCallback.h"
14
15 namespace blink {
16
17 void V8IntersectionObserver::constructorCustom(const v8::FunctionCallbackInfo<v8 ::Value>& info)
18 {
19 if (UNLIKELY(info.Length() < 1)) {
20 V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(in fo.GetIsolate(), "createIntersectionObserver", "Intersection", 1, info.Length()) , info.GetIsolate());
21 return;
22 }
23
24 v8::Local<v8::Object> wrapper = info.Holder();
25
26 Document* document = nullptr;
27 DOMWindow* window = toDOMWindow(wrapper->CreationContext());
28 if (window)
29 document = window->document();
30
31 if (info.Length() <= 0 || !info[0]->IsFunction()) {
32 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::f ailedToExecute("createIntersectionObserver", "Intersection", "The callback provi ded as parameter 1 is not a function."));
33 return;
34 }
35
36 OwnPtrWillBeRawPtr<IntersectionObserverCallback> callback = V8IntersectionOb serverCallback::create(v8::Local<v8::Function>::Cast(info[0]), wrapper, ScriptSt ate::current(info.GetIsolate()));
37 RefPtrWillBeRawPtr<IntersectionObserver> observer = IntersectionObserver::cr eate(document, callback.release());
38
39 v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsol ate(), observer.get(), &wrapperTypeInfo, wrapper));
40 }
41
42 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698