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

Unified Diff: third_party/WebKit/Source/modules/geometry/DOMPoint.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/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
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698