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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function(global, binding, v8) {
6 'use strict';
7
8 const defineProperty = global.Object.defineProperty;
9
10 const {
11 domPointX: _x,
12 domPointY: _y,
13 domPointZ: _z,
14 domPointW: _w,
15 ensureDOMPoint: ensureDOMPoint
16 } = binding;
17
18 class DOMPoint extends DOMPointReadOnly {
19 constructor(x = 0, y = 0, z = 0, w = 1) {
20 super(x, y, z, w);
21 }
22
23 get x() {
24 ensureDOMPoint(this);
25 return this[_x];
26 }
27
28 set x(x) {
29 ensureDOMPoint(this);
30 this[_x] = +x;
31 }
32
33 get y() {
34 ensureDOMPoint(this);
35 return this[_y];
36 }
37
38 set y(y) {
39 ensureDOMPoint(this);
40 this[_y] = +y;
41 }
42
43 get z() {
44 ensureDOMPoint(this);
45 return this[_z];
46 }
47
48 set z(z) {
49 ensureDOMPoint(this);
50 this[_z] = +z;
51 }
52
53 get w() {
54 ensureDOMPoint(this);
55 return this[_w];
56 }
57
58 set w(w) {
59 ensureDOMPoint(this);
60 this[_w] = +w;
61 }
62
63 static fromPoint(init) {
64 return new DOMPoint(init.x, init.y, init.z, init.w);
65 }
66 }
67
68 binding.createDOMPoint = (x, y, z, w) => new DOMPoint(x, y, z, w);
69 binding.updateDOMPoint = function(obj, x, y, z, w) {
70 if (_x in obj) {
71 obj[_x] = +x;
72 obj[_y] = +y;
73 obj[_z] = +z;
74 obj[_w] = +w;
75 }
76 };
77
78 defineProperty(global, 'DOMPoint', {
79 value: DOMPoint,
80 configurable: true,
81 enumerable: false,
82 writable: true
83 });
84 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698