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

Unified Diff: Source/bindings/v8/custom/V8ElementCustom.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/V8ElementCustom.cpp
diff --git a/Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp b/Source/bindings/v8/custom/V8ElementCustom.cpp
similarity index 53%
copy from Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp
copy to Source/bindings/v8/custom/V8ElementCustom.cpp
index 65074da2ef8beeb3bffdbb8812d18701b0026918..3e1517830cb7c785858a6290bca423175d5146c6 100644
--- a/Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8ElementCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,31 +29,47 @@
*/
#include "config.h"
-#include "V8HTMLFrameElement.h"
+#include "V8Element.h"
-#include "HTMLNames.h"
-#include "bindings/v8/BindingSecurity.h"
+#include "RuntimeEnabledFeatures.h"
+#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
-#include "core/html/HTMLFrameElement.h"
-#include "core/html/parser/HTMLParserIdioms.h"
+#include "bindings/v8/V8BindingMacros.h"
+#include "core/dom/Element.h"
namespace WebCore {
-using namespace HTMLNames;
+void V8Element::scrollLeftAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
haraken 2014/01/27 01:44:13 Why do you need to write these methods in custom b
ajuma 2014/01/27 02:07:00 These setters need to be able to take either an in
haraken 2014/01/27 02:30:48 Won't overloading IDL methods work? void scrollLe
Nils Barth (inactive) 2014/01/27 02:38:24 Conveniently, long vs. Dictionary overloading is p
+{
+ ExceptionState exceptionState(ExceptionState::SetterContext, "scrollLeft", "Element", info.Holder(), info.GetIsolate());
+ Element* imp = V8Element::toNative(info.Holder());
+
+ if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject()) {
+ V8TRYCATCH_VOID(Dictionary, scrollOptionsHorizontal, Dictionary(value, info.GetIsolate()));
+ imp->setScrollLeft(scrollOptionsHorizontal, exceptionState);
+ exceptionState.throwIfNeeded();
+ return;
+ }
+
+ V8TRYCATCH_EXCEPTION_VOID(int, position, toInt32(value, exceptionState), exceptionState);
+ imp->setScrollLeft(position);
+}
-void V8HTMLFrameElement::locationAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
+void V8Element::scrollTopAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
- HTMLFrameElement* frame = V8HTMLFrameElement::toNative(info.Holder());
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, locationValue, value);
+ ExceptionState exceptionState(ExceptionState::SetterContext, "scrollTop", "Element", info.Holder(), info.GetIsolate());
+ Element* imp = V8Element::toNative(info.Holder());
- ExceptionState exceptionState(ExceptionState::SetterContext, "location", "HTMLFrameElement", info.Holder(), info.GetIsolate());
- if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(locationValue)) && !BindingSecurity::shouldAllowAccessToFrame(frame->contentFrame(), exceptionState)) {
+ if (RuntimeEnabledFeatures::cssomSmoothScrollEnabled() && value->IsObject()) {
+ V8TRYCATCH_VOID(Dictionary, scrollOptionsVertical, Dictionary(value, info.GetIsolate()));
+ imp->setScrollTop(scrollOptionsVertical, exceptionState);
exceptionState.throwIfNeeded();
return;
}
- frame->setLocation(locationValue);
+ V8TRYCATCH_EXCEPTION_VOID(int, position, toInt32(value, exceptionState), exceptionState);
+ imp->setScrollTop(position);
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698