|
14 | 14 | */ |
15 | 15 | package org.htmlunit.javascript.host; |
16 | 16 |
|
| 17 | +import org.htmlunit.corejs.javascript.Context; |
| 18 | +import org.htmlunit.corejs.javascript.Function; |
| 19 | +import org.htmlunit.corejs.javascript.Scriptable; |
17 | 20 | import org.htmlunit.javascript.configuration.JsxClass; |
18 | 21 | import org.htmlunit.javascript.configuration.JsxConstructor; |
| 22 | +import org.htmlunit.javascript.configuration.JsxConstructorAlias; |
19 | 23 | import org.htmlunit.javascript.configuration.JsxGetter; |
20 | 24 | import org.htmlunit.javascript.configuration.JsxSetter; |
21 | 25 | import org.htmlunit.javascript.host.dom.DOMRectReadOnly; |
|
30 | 34 | @JsxClass |
31 | 35 | public class DOMRect extends DOMRectReadOnly { |
32 | 36 |
|
33 | | - private int bottom_; |
34 | | - private int left_; |
35 | | - private int right_; |
36 | | - private int top_; |
37 | | - |
38 | 37 | /** |
39 | | - * Creates an instance. |
| 38 | + * JavaScript constructor. |
| 39 | + * @param cx the current context |
| 40 | + * @param scope the scope |
| 41 | + * @param args the arguments to the WebSocket constructor |
| 42 | + * @param ctorObj the function object |
| 43 | + * @param inNewExpr Is new or not |
| 44 | + * @return the java object to allow JavaScript to access |
40 | 45 | */ |
41 | | - public DOMRect() { |
42 | | - super(); |
| 46 | + @JsxConstructor |
| 47 | + @JsxConstructorAlias(alias = "WebKitCSSMatrix") |
| 48 | + public static DOMRect jsConstructor(final Context cx, final Scriptable scope, |
| 49 | + final Object[] args, final Function ctorObj, final boolean inNewExpr) { |
| 50 | + |
| 51 | + final DOMRect rect = new DOMRect(); |
| 52 | + rect.init(args, ctorObj); |
| 53 | + return rect; |
43 | 54 | } |
44 | 55 |
|
45 | 56 | /** |
46 | | - * JavaScript constructor. |
| 57 | + * Creates an instance. |
47 | 58 | */ |
48 | | - @JsxConstructor |
49 | | - @Override |
50 | | - public void jsConstructor() { |
51 | | - super.jsConstructor(); |
| 59 | + public DOMRect() { |
| 60 | + super(); |
52 | 61 | } |
53 | 62 |
|
54 | 63 | /** |
55 | 64 | * Creates an instance, with the given coordinates. |
56 | 65 | * |
57 | | - * @param bottom the bottom coordinate of the rectangle surrounding the object content |
58 | | - * @param left the left coordinate of the rectangle surrounding the object content |
59 | | - * @param right the right coordinate of the rectangle surrounding the object content |
60 | | - * @param top the top coordinate of the rectangle surrounding the object content |
| 66 | + * @param x the x coordinate of the rectangle surrounding the object content |
| 67 | + * @param y the y coordinate of the rectangle surrounding the object content |
| 68 | + * @param width the width coordinate of the rectangle surrounding the object content |
| 69 | + * @param height the height of the rectangle surrounding the object content |
61 | 70 | */ |
62 | | - public DOMRect(final int bottom, final int left, final int right, final int top) { |
63 | | - this(); |
64 | | - bottom_ = bottom; |
65 | | - left_ = left; |
66 | | - right_ = right; |
67 | | - top_ = top; |
| 71 | + public DOMRect(final int x, final int y, final int width, final int height) { |
| 72 | + super(x, y, width, height); |
68 | 73 | } |
69 | 74 |
|
70 | 75 | /** |
71 | | - * Sets the bottom coordinate of the rectangle surrounding the object content. |
72 | | - * @param bottom the bottom coordinate of the rectangle surrounding the object content |
73 | | - */ |
74 | | - @JsxSetter |
75 | | - public void setBottom(final int bottom) { |
76 | | - bottom_ = bottom; |
77 | | - } |
78 | | - |
79 | | - /** |
80 | | - * Returns the bottom coordinate of the rectangle surrounding the object content. |
81 | | - * @return the bottom coordinate of the rectangle surrounding the object content |
| 76 | + * {@inheritDoc} |
82 | 77 | */ |
| 78 | + @Override |
83 | 79 | @JsxGetter |
84 | | - public int getBottom() { |
85 | | - return bottom_; |
| 80 | + public double getX() { |
| 81 | + return super.getX(); |
86 | 82 | } |
87 | 83 |
|
88 | 84 | /** |
89 | | - * Sets the left coordinate of the rectangle surrounding the object content. |
90 | | - * @param left the left coordinate of the rectangle surrounding the object content |
| 85 | + * {@inheritDoc} |
91 | 86 | */ |
| 87 | + @Override |
92 | 88 | @JsxSetter |
93 | | - public void setLeft(final int left) { |
94 | | - left_ = left; |
| 89 | + public void setX(final double x) { |
| 90 | + super.setX(x); |
95 | 91 | } |
96 | 92 |
|
97 | 93 | /** |
98 | | - * Returns the left coordinate of the rectangle surrounding the object content. |
99 | | - * @return the left coordinate of the rectangle surrounding the object content |
| 94 | + * {@inheritDoc} |
100 | 95 | */ |
| 96 | + @Override |
101 | 97 | @JsxGetter |
102 | | - public int getLeft() { |
103 | | - return left_; |
| 98 | + public double getY() { |
| 99 | + return super.getY(); |
104 | 100 | } |
105 | 101 |
|
106 | 102 | /** |
107 | | - * Sets the right coordinate of the rectangle surrounding the object content. |
108 | | - * @param right the right coordinate of the rectangle surrounding the object content |
| 103 | + * {@inheritDoc} |
109 | 104 | */ |
| 105 | + @Override |
110 | 106 | @JsxSetter |
111 | | - public void setRight(final int right) { |
112 | | - right_ = right; |
| 107 | + public void setY(final double y) { |
| 108 | + super.setY(y); |
113 | 109 | } |
114 | 110 |
|
115 | 111 | /** |
116 | | - * Returns the right coordinate of the rectangle surrounding the object content. |
117 | | - * @return the right coordinate of the rectangle surrounding the object content |
| 112 | + * {@inheritDoc} |
118 | 113 | */ |
| 114 | + @Override |
119 | 115 | @JsxGetter |
120 | | - public int getRight() { |
121 | | - return right_; |
| 116 | + public double getWidth() { |
| 117 | + return super.getWidth(); |
122 | 118 | } |
123 | 119 |
|
124 | 120 | /** |
125 | | - * Sets the top coordinate of the rectangle surrounding the object content. |
126 | | - * @param top the top coordinate of the rectangle surrounding the object content |
| 121 | + * {@inheritDoc} |
127 | 122 | */ |
| 123 | + @Override |
128 | 124 | @JsxSetter |
129 | | - public void setTop(final int top) { |
130 | | - top_ = top; |
131 | | - } |
132 | | - |
133 | | - /** |
134 | | - * Returns the top coordinate of the rectangle surrounding the object content. |
135 | | - * @return the top coordinate of the rectangle surrounding the object content |
136 | | - */ |
137 | | - @JsxGetter |
138 | | - public int getTop() { |
139 | | - return top_; |
| 125 | + public void setWidth(final double width) { |
| 126 | + super.setWidth(width); |
140 | 127 | } |
141 | 128 |
|
142 | 129 | /** |
143 | | - * Returns the {@code width} property. |
144 | | - * @return the {@code width} property |
| 130 | + * {@inheritDoc} |
145 | 131 | */ |
| 132 | + @Override |
146 | 133 | @JsxGetter |
147 | | - public int getWidth() { |
148 | | - return getRight() - getLeft(); |
| 134 | + public double getHeight() { |
| 135 | + return super.getHeight(); |
149 | 136 | } |
150 | 137 |
|
151 | 138 | /** |
152 | | - * Returns the {@code height} property. |
153 | | - * @return the {@code height} property |
| 139 | + * {@inheritDoc} |
154 | 140 | */ |
155 | | - @JsxGetter |
156 | | - public int getHeight() { |
157 | | - return getBottom() - getTop(); |
| 141 | + @Override |
| 142 | + @JsxSetter |
| 143 | + public void setHeight(final double height) { |
| 144 | + super.setHeight(height); |
158 | 145 | } |
159 | 146 | } |
0 commit comments