[Constructor(DOMQuadInit quad)]
[Constructor(unrestricted optional double x = 0, unrestricted optional double y = 0,
unrestricted optional double width = 0, unrestricted optional double height = 0)]
interface DOMRectReadOnly {
readonly attribute unrestricted double x;
readonly attribute unrestricted double y;
readonly attribute unrestricted double width;
readonly attribute unrestricted double height;
readonly attribute unrestricted double right;
readonly attribute unrestricted double bottom;
readonly attribute unrestricted double left;
}
DOMRectReadOnly
instances have six internal slots: [[type]]
, [[quad]]
, [[x]]
, [[y]]
, [[width]]
, and [[height]]
.
The new DOMRectReadOnly(quad)
constructor must:
- Set the
[[type]]
internal slot ofthis
to"quadbounds"
. - Set the
[[quad]]
internal slot ofthis
toquad
.
The new DOMRectReadOnly(x, y, width, height)
constructor must:
- Set the
[[type]]
internal slot ofthis
to"rect"
. - Set the
[[x]]
internal slot ofthis
tox
. - Set the
[[y]]
internal slot ofthis
toy
. - Set the
[[width]]
internal slot ofthis
towidth
. - Set the
[[height]]
internal slot ofthis
toheight
.
In the following algorithms, let t
be the value of the [[type]]
internal slot of this
, and q
be the value of the [[quad]]
internal slot of this
. Then:
The x
getter must:
- If
t
is"quadbounds"
, return the minimum ofq.p1.x
,q.p2.x
,q.p3.x
, andq.p4.x
. - If
t
is"rect"
, return the value of the[[x]]
internal slot.
The y
getter must:
- If
t
is"quad"
, return the minimum ofq.p1.y
,q.p2.y
,q.p3.y
, andq.p4.y
. - If
t
is"rect"
, return the value of the[[y]]
internal slot.
The width
getter must:
- If
t
is"quadbounds"
, return (the maximum ofq.p1.x
,q.p2.x
,q.p3.x
, andq.p4.x
) minusthis.x
. - If
t
is"rect"
, return the value of the[[width]]
internal slot.
The height
getter must:
- If
t
is"quadbounds"
, return (the maximum ofq.p1.y
,q.p2.y
,q.p3.y
, andq.p4.y
) minusthis.y
. - If
t
is"rect"
, return the value of the[[height]]
internal slot.
The top
getter must return min(this.y
, this.y
+ this.height
).
The right
getter must return max(this.x
, this.x
+ this.width
).
The bottom
getter must return max(this.y
, this.y
+ this.height
).
The left
getter must return min(this.x
, this.x
+ this.width
).
[Constructor(unrestricted optional double x = 0, unrestricted optional double y = 0,
unrestricted optional double width = 0, unrestricted optional double height = 0)]
interface DOMRect : DOMRectReadOnly {
attribute unrestricted double x;
attribute unrestricted double y;
attribute unrestricted double width;
attribute unrestricted double height;
};
NOTE: DOMRectReadOnly
instances have the same internal slots as DOMRectReadOnly
instances; they are instantiated by inheriting the @@create
behavior via class-side inheritnace.
The DOMRect(x, y, width, height)
constructor must call super(x, y, width, height)
.
The x
, y
, width
, and height
accessors must reflect the [[x]]
, [[y]]
, [[width]]
, and [[height]]
internal slots, respectively.
Should
class DOMRect
beclass DOMRect extends DOMRectReadOnly
?