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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8DOMMatrixReadOnlyCustom.cpp

Issue 2750763005: WIP: Use v8::Eternal<v8::String> to hold dictionary keys.
Patch Set: Created 3 years, 9 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: third_party/WebKit/Source/bindings/core/v8/custom/V8DOMMatrixReadOnlyCustom.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8DOMMatrixReadOnlyCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8DOMMatrixReadOnlyCustom.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d2038dd11ecfdaa81ee6b2de96322d16090ce537
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8DOMMatrixReadOnlyCustom.cpp
@@ -0,0 +1,427 @@
+// Copyright 2017 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 "bindings/core/v8/V8DOMMatrixReadOnly.h"
+
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
+#include "core/dom/DOMMatrixInit.h"
+
+namespace blink {
+
+void V8DOMMatrixReadOnly::multiplyMethodCustom(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(),
+ ExceptionState::ExecutionContext,
+ "DOMMatrixReadOnly", "multiply");
+
+ DOMMatrixReadOnly* impl = V8DOMMatrixReadOnly::toImpl(info.Holder());
+
+ DOMMatrixInit other;
+ if (!isUndefinedOrNull(info[0]) && !info[0]->IsObject()) {
+ exceptionState.throwTypeError("parameter 1 ('other') is not an object.");
+
+ return;
+ }
+
+ // V8DOMMatrixInit::toImpl(info.GetIsolate(), info[0], other, exceptionState);
+
+ // TODO(jbroman): Use a cache in V8PerIsolateData.
+ v8::Isolate* isolate = info.GetIsolate();
+ static v8::Eternal<v8::String>* s_schema = new v8::Eternal<v8::String>[23];
+ static bool s_schemaInitialized = false;
+ if (!s_schemaInitialized) {
+ static const char* const kKeys[] = {
+ "a", "b", "c", "d", "e", "f", "is2D", "m11",
+ "m12", "m13", "m14", "m21", "m22", "m23", "m24", "m31",
+ "m32", "m33", "m34", "m41", "m42", "m43", "m44",
+ };
+ std::transform(
+ std::begin(kKeys), std::end(kKeys), s_schema, [isolate](const char* k) {
+ return v8::Eternal<v8::String>(isolate, v8AtomicString(isolate, k));
+ });
+ s_schemaInitialized = true;
+ }
+ v8::Eternal<v8::String>* schema = s_schema;
+
+ {
+ v8::TryCatch block(isolate);
+ v8::Local<v8::Object> v8Object = info[0].As<v8::Object>();
+ v8::Local<v8::Value> aValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[0].Get(isolate))
+ .ToLocal(&aValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (aValue.IsEmpty() || aValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double a = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, aValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setA(a);
+ }
+
+ v8::Local<v8::Value> bValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[1].Get(isolate))
+ .ToLocal(&bValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (bValue.IsEmpty() || bValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double b = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, bValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setB(b);
+ }
+
+ v8::Local<v8::Value> cValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[2].Get(isolate))
+ .ToLocal(&cValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (cValue.IsEmpty() || cValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double c = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, cValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setC(c);
+ }
+
+ v8::Local<v8::Value> dValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[3].Get(isolate))
+ .ToLocal(&dValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (dValue.IsEmpty() || dValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double d = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, dValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setD(d);
+ }
+
+ v8::Local<v8::Value> eValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[4].Get(isolate))
+ .ToLocal(&eValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (eValue.IsEmpty() || eValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double e = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, eValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setE(e);
+ }
+
+ v8::Local<v8::Value> fValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[5].Get(isolate))
+ .ToLocal(&fValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (fValue.IsEmpty() || fValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double f = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, fValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setF(f);
+ }
+
+ v8::Local<v8::Value> is2DValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[6].Get(isolate))
+ .ToLocal(&is2DValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (is2DValue.IsEmpty() || is2DValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ bool is2D = NativeValueTraits<IDLBoolean>::nativeValue(isolate, is2DValue,
+ exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setIs2D(is2D);
+ }
+
+ v8::Local<v8::Value> m11Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[7].Get(isolate))
+ .ToLocal(&m11Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m11Value.IsEmpty() || m11Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m11 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m11Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM11(m11);
+ }
+
+ v8::Local<v8::Value> m12Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[8].Get(isolate))
+ .ToLocal(&m12Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m12Value.IsEmpty() || m12Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m12 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m12Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM12(m12);
+ }
+
+ v8::Local<v8::Value> m13Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[9].Get(isolate))
+ .ToLocal(&m13Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m13Value.IsEmpty() || m13Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m13 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m13Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM13(m13);
+ }
+
+ v8::Local<v8::Value> m14Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[10].Get(isolate))
+ .ToLocal(&m14Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m14Value.IsEmpty() || m14Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m14 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m14Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM14(m14);
+ }
+
+ v8::Local<v8::Value> m21Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[11].Get(isolate))
+ .ToLocal(&m21Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m21Value.IsEmpty() || m21Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m21 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m21Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM21(m21);
+ }
+
+ v8::Local<v8::Value> m22Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[12].Get(isolate))
+ .ToLocal(&m22Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m22Value.IsEmpty() || m22Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m22 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m22Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM22(m22);
+ }
+
+ v8::Local<v8::Value> m23Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[13].Get(isolate))
+ .ToLocal(&m23Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m23Value.IsEmpty() || m23Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m23 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m23Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM23(m23);
+ }
+
+ v8::Local<v8::Value> m24Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[14].Get(isolate))
+ .ToLocal(&m24Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m24Value.IsEmpty() || m24Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m24 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m24Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM24(m24);
+ }
+
+ v8::Local<v8::Value> m31Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[15].Get(isolate))
+ .ToLocal(&m31Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m31Value.IsEmpty() || m31Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m31 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m31Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM31(m31);
+ }
+
+ v8::Local<v8::Value> m32Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[16].Get(isolate))
+ .ToLocal(&m32Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m32Value.IsEmpty() || m32Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m32 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m32Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM32(m32);
+ }
+
+ v8::Local<v8::Value> m33Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[17].Get(isolate))
+ .ToLocal(&m33Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m33Value.IsEmpty() || m33Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m33 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m33Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM33(m33);
+ }
+
+ v8::Local<v8::Value> m34Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[18].Get(isolate))
+ .ToLocal(&m34Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m34Value.IsEmpty() || m34Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m34 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m34Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM34(m34);
+ }
+
+ v8::Local<v8::Value> m41Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[19].Get(isolate))
+ .ToLocal(&m41Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m41Value.IsEmpty() || m41Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m41 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m41Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM41(m41);
+ }
+
+ v8::Local<v8::Value> m42Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[20].Get(isolate))
+ .ToLocal(&m42Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m42Value.IsEmpty() || m42Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m42 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m42Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM42(m42);
+ }
+
+ v8::Local<v8::Value> m43Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[21].Get(isolate))
+ .ToLocal(&m43Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m43Value.IsEmpty() || m43Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m43 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m43Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM43(m43);
+ }
+
+ v8::Local<v8::Value> m44Value;
+ if (!v8Object->Get(isolate->GetCurrentContext(), schema[22].Get(isolate))
+ .ToLocal(&m44Value)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (m44Value.IsEmpty() || m44Value->IsUndefined()) {
+ // Do nothing.
+ } else {
+ double m44 = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(
+ isolate, m44Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ other.setM44(m44);
+ }
+ }
+
+ DOMMatrix* result = impl->multiply(other, exceptionState);
+ if (exceptionState.hadException()) {
+ return;
+ }
+ v8SetReturnValue(info, result);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/bindings.gni ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698