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

Unified Diff: Source/bindings/v8/custom/V8WindowCustom.cpp

Issue 146003002: Bindings for CSSOM View smooth scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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: Source/bindings/v8/custom/V8WindowCustom.cpp
diff --git a/Source/bindings/v8/custom/V8WindowCustom.cpp b/Source/bindings/v8/custom/V8WindowCustom.cpp
index c48591da29c0d977207b8e5c135c7e3115fd4161..006a1398f5660eef5514813d1e28cf28bf3479d3 100644
--- a/Source/bindings/v8/custom/V8WindowCustom.cpp
+++ b/Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "V8Window.h"
+#include "RuntimeEnabledFeatures.h"
#include "V8HTMLCollection.h"
#include "V8Node.h"
#include "bindings/v8/BindingSecurity.h"
@@ -386,6 +387,81 @@ void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
v8SetReturnValueFast(info, openedWindow.release(), impl);
}
+void V8Window::scrollByMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
haraken 2014/01/27 01:44:13 Ditto. Can't you avoid writing custom bindings by
ajuma 2014/01/27 02:07:00 The problem is that specifying that a particular a
haraken 2014/01/27 02:30:48 Probably we want to improve code_generator_v8.pm s
Nils Barth (inactive) 2014/01/27 05:23:45 Ow! (>.<) That's in principle possible, but would
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "scrollBy", "Window", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ DOMWindow* impl = V8Window::toNative(info.Holder());
+ if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptionState);
+ V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptionState);
+
+ if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled()) {
+ V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetIsolate()));
+ impl->scrollBy(x, y, scrollOptions, exceptionState);
+ } else {
+ impl->scrollBy(x, y, Dictionary(), exceptionState);
+ }
+ exceptionState.throwIfNeeded();
+}
+
+void V8Window::scrollToMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "scrollTo", "Window", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ DOMWindow* impl = V8Window::toNative(info.Holder());
+ if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptionState);
+ V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptionState);
+
+ if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled()) {
+ V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetIsolate()));
+ impl->scrollTo(x, y, scrollOptions, exceptionState);
+ } else {
+ impl->scrollTo(x, y, Dictionary(), exceptionState);
+ }
+ exceptionState.throwIfNeeded();
+}
+
+void V8Window::scrollMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "scroll", "Window", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ DOMWindow* impl = V8Window::toNative(info.Holder());
+ if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ V8TRYCATCH_EXCEPTION_VOID(int, x, toInt32(info[0], exceptionState), exceptionState);
+ V8TRYCATCH_EXCEPTION_VOID(int, y, toInt32(info[1], exceptionState), exceptionState);
+
+ if (info.Length() >= 3 && RuntimeEnabledFeatures::cssomSmoothScrollEnabled()) {
+ V8TRYCATCH_VOID(Dictionary, scrollOptions, Dictionary(info[2], info.GetIsolate()));
+ impl->scroll(x, y, scrollOptions, exceptionState);
+ } else {
+ impl->scroll(x, y, Dictionary(), exceptionState);
+ }
+ exceptionState.throwIfNeeded();
+}
+
void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{

Powered by Google App Engine
This is Rietveld 408576698