| Index: Source/bindings/core/v8/custom/V8IntersectionObserverCustom.cpp
|
| diff --git a/Source/bindings/core/v8/custom/V8IntersectionObserverCustom.cpp b/Source/bindings/core/v8/custom/V8IntersectionObserverCustom.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a1a120336d6b674f2b95c880f02a6fb9b57a4ccd
|
| --- /dev/null
|
| +++ b/Source/bindings/core/v8/custom/V8IntersectionObserverCustom.cpp
|
| @@ -0,0 +1,42 @@
|
| +// Copyright 2015 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 "config.h"
|
| +#include "bindings/core/v8/V8IntersectionObserver.h"
|
| +
|
| +#include "bindings/core/v8/ExceptionMessages.h"
|
| +#include "bindings/core/v8/ExceptionState.h"
|
| +#include "bindings/core/v8/V8Binding.h"
|
| +#include "bindings/core/v8/V8DOMWrapper.h"
|
| +#include "bindings/core/v8/V8GCController.h"
|
| +#include "bindings/core/v8/V8IntersectionObserverCallback.h"
|
| +
|
| +namespace blink {
|
| +
|
| +void V8IntersectionObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +{
|
| + if (UNLIKELY(info.Length() < 1)) {
|
| + V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "createIntersectionObserver", "Intersection", 1, info.Length()), info.GetIsolate());
|
| + return;
|
| + }
|
| +
|
| + v8::Local<v8::Object> wrapper = info.Holder();
|
| +
|
| + Document* document = nullptr;
|
| + DOMWindow* window = toDOMWindow(wrapper->CreationContext());
|
| + if (window)
|
| + document = window->document();
|
| +
|
| + if (info.Length() <= 0 || !info[0]->IsFunction()) {
|
| + V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("createIntersectionObserver", "Intersection", "The callback provided as parameter 1 is not a function."));
|
| + return;
|
| + }
|
| +
|
| + OwnPtrWillBeRawPtr<IntersectionObserverCallback> callback = V8IntersectionObserverCallback::create(v8::Local<v8::Function>::Cast(info[0]), wrapper, ScriptState::current(info.GetIsolate()));
|
| + RefPtrWillBeRawPtr<IntersectionObserver> observer = IntersectionObserver::create(document, callback.release());
|
| +
|
| + v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), observer.get(), &wrapperTypeInfo, wrapper));
|
| +}
|
| +
|
| +} // namespace blink
|
|
|