Index: third_party/WebKit/Source/modules/geometry/DOMPoint.js |
diff --git a/third_party/WebKit/Source/modules/geometry/DOMPoint.js b/third_party/WebKit/Source/modules/geometry/DOMPoint.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1b01fef69107a3b1c440c96563dc6de95193537d |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/geometry/DOMPoint.js |
@@ -0,0 +1,84 @@ |
+// 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 { |
+ domPointX: _x, |
+ domPointY: _y, |
+ domPointZ: _z, |
+ domPointW: _w, |
+ ensureDOMPoint: ensureDOMPoint |
+ } = binding; |
+ |
+ class DOMPoint extends DOMPointReadOnly { |
+ constructor(x = 0, y = 0, z = 0, w = 1) { |
+ super(x, y, z, w); |
+ } |
+ |
+ get x() { |
+ ensureDOMPoint(this); |
+ return this[_x]; |
+ } |
+ |
+ set x(x) { |
+ ensureDOMPoint(this); |
+ this[_x] = +x; |
+ } |
+ |
+ get y() { |
+ ensureDOMPoint(this); |
+ return this[_y]; |
+ } |
+ |
+ set y(y) { |
+ ensureDOMPoint(this); |
+ this[_y] = +y; |
+ } |
+ |
+ get z() { |
+ ensureDOMPoint(this); |
+ return this[_z]; |
+ } |
+ |
+ set z(z) { |
+ ensureDOMPoint(this); |
+ this[_z] = +z; |
+ } |
+ |
+ get w() { |
+ ensureDOMPoint(this); |
+ return this[_w]; |
+ } |
+ |
+ set w(w) { |
+ ensureDOMPoint(this); |
+ this[_w] = +w; |
+ } |
+ |
+ static fromPoint(init) { |
+ return new DOMPoint(init.x, init.y, init.z, init.w); |
+ } |
+ } |
+ |
+ binding.createDOMPoint = (x, y, z, w) => new DOMPoint(x, y, z, w); |
+ binding.updateDOMPoint = function(obj, x, y, z, w) { |
+ if (_x in obj) { |
+ obj[_x] = +x; |
+ obj[_y] = +y; |
+ obj[_z] = +z; |
+ obj[_w] = +w; |
+ } |
+ }; |
+ |
+ defineProperty(global, 'DOMPoint', { |
+ value: DOMPoint, |
+ configurable: true, |
+ enumerable: false, |
+ writable: true |
+ }); |
+}); |