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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add missing break, rebaseline, no config.h Created 4 years, 12 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 "bindings/core/v8/V8IntersectionObserver.h"
6
7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/V8DOMWrapper.h"
11 #include "bindings/core/v8/V8GCController.h"
12 #include "bindings/core/v8/V8IntersectionObserverCallback.h"
13 #include "bindings/core/v8/V8IntersectionObserverInit.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 if (!info[0]->IsFunction()) {
27 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::f ailedToExecute("createIntersectionObserver", "Intersection", "The callback provi ded as parameter 1 is not a function."));
28 return;
29 }
30
31 if (info.Length() > 1 && !isUndefinedOrNull(info[1]) && !info[1]->IsObject() ) {
32 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::f ailedToExecute("createIntersectionObserver", "Intersection", "IntersectionObserv erInit (parameter 2) is not an object."));
33 return;
34 }
35
36 IntersectionObserverInit intersectionObserverInit;
37 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Intersec tion", info.Holder(), info.GetIsolate());
38 V8IntersectionObserverInit::toImpl(info.GetIsolate(), info[1], intersectionO bserverInit, exceptionState);
39 if (exceptionState.hadException()) {
40 V8ThrowException::throwGeneralError(info.GetIsolate(), exceptionState.me ssage());
41 return;
42 }
43
44 IntersectionObserverCallback* callback = new V8IntersectionObserverCallback( v8::Local<v8::Function>::Cast(info[0]), wrapper, ScriptState::current(info.GetIs olate()));
45 IntersectionObserver* observer = IntersectionObserver::create(intersectionOb serverInit, *callback, exceptionState);
haraken 2015/12/22 01:13:29 I think you can just pass callback instead of *cal
esprehn 2015/12/22 07:50:32 *callback signifies that it's not null to the ::cr
szager1 2015/12/22 07:53:40 Previous comment from esprehn@ suggested this para
46 if (!observer || exceptionState.hadException()) {
47 V8ThrowException::throwGeneralError(info.GetIsolate(), exceptionState.me ssage());
haraken 2015/12/22 01:13:29 Why do you need this GeneralError? When writing c
szager1 2015/12/22 07:53:40 IntersectionObserver::create will return NULL and
48 return;
49 }
50
51 v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsol ate(), observer, &wrapperTypeInfo, wrapper));
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698