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

Unified Diff: third_party/WebKit/Source/modules/geometry/DOMPointReadOnly.js

Issue 1709003002: Geometry: Reimplement DOMPoint using V8 extras. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/modules/geometry/DOMPointReadOnly.js
diff --git a/third_party/WebKit/Source/modules/geometry/DOMPointReadOnly.js b/third_party/WebKit/Source/modules/geometry/DOMPointReadOnly.js
new file mode 100644
index 0000000000000000000000000000000000000000..c4de665c0a2823a51e94b1da4a44c68e322ed9e9
--- /dev/null
+++ b/third_party/WebKit/Source/modules/geometry/DOMPointReadOnly.js
@@ -0,0 +1,63 @@
+// Copyright 2016 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.
+
+(function(global, binding, v8) {
+ 'use strict';
+
+ const defineProperty = global.Object.defineProperty;
+
+ const _x = binding.domPointX = v8.createPrivateSymbol('[[x]]');
+ const _y = binding.domPointY = v8.createPrivateSymbol('[[y]]');
+ const _z = binding.domPointZ = v8.createPrivateSymbol('[[z]]');
+ const _w = binding.domPointW = v8.createPrivateSymbol('[[w]]');
+
+ function ensureDOMPoint(obj) {
+ if (!(_x in obj))
+ throw new TypeError('Illegal invocation');
+ }
+
+ class DOMPointReadOnly {
+ constructor(x = 0, y = 0, z = 0, w = 1) {
+ this[_x] = +x;
+ this[_y] = +y;
+ this[_z] = +z;
+ this[_w] = +w;
+ }
+
+ get x() {
+ ensureDOMPoint(this);
+ return this[_x];
+ }
+
+ get y() {
+ ensureDOMPoint(this);
+ return this[_y];
+ }
+
+ get z() {
+ ensureDOMPoint(this);
+ return this[_z];
+ }
+
+ get w() {
+ ensureDOMPoint(this);
+ return this[_w];
+ }
+
+ static fromPoint(init) {
+ return new DOMPointReadOnly(init.x, init.y, init.z, init.w);
+ }
+ }
+
+ binding.createDOMPointReadOnly = (x, y, z, w) =>
+ new DOMPointReadOnly(x, y, z, w);
+ binding.ensureDOMPoint = ensureDOMPoint;
+
+ defineProperty(global, 'DOMPointReadOnly', {
+ value: DOMPointReadOnly,
+ configurable: true,
+ enumerable: false,
+ writable: true
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698