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 |
+ }); |
+}); |