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

Side by Side 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, 9 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 _x = binding.domPointX = v8.createPrivateSymbol('[[x]]');
11 const _y = binding.domPointY = v8.createPrivateSymbol('[[y]]');
12 const _z = binding.domPointZ = v8.createPrivateSymbol('[[z]]');
13 const _w = binding.domPointW = v8.createPrivateSymbol('[[w]]');
14
15 function ensureDOMPoint(obj) {
16 if (!(_x in obj))
17 throw new TypeError('Illegal invocation');
18 }
19
20 class DOMPointReadOnly {
21 constructor(x = 0, y = 0, z = 0, w = 1) {
22 this[_x] = +x;
23 this[_y] = +y;
24 this[_z] = +z;
25 this[_w] = +w;
26 }
27
28 get x() {
29 ensureDOMPoint(this);
30 return this[_x];
31 }
32
33 get y() {
34 ensureDOMPoint(this);
35 return this[_y];
36 }
37
38 get z() {
39 ensureDOMPoint(this);
40 return this[_z];
41 }
42
43 get w() {
44 ensureDOMPoint(this);
45 return this[_w];
46 }
47
48 static fromPoint(init) {
49 return new DOMPointReadOnly(init.x, init.y, init.z, init.w);
50 }
51 }
52
53 binding.createDOMPointReadOnly = (x, y, z, w) =>
54 new DOMPointReadOnly(x, y, z, w);
55 binding.ensureDOMPoint = ensureDOMPoint;
56
57 defineProperty(global, 'DOMPointReadOnly', {
58 value: DOMPointReadOnly,
59 configurable: true,
60 enumerable: false,
61 writable: true
62 });
63 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698