W3C home > Mailing lists > Public > www-style@w3.org > March 2015

[geometry] Dictionary argument for DOMQuad constructor

From: Simon Pieters <simonp@opera.com>
Date: Tue, 24 Mar 2015 21:35:19 +0100
To: "www-style@w3.org" <www-style@w3.org>
Message-ID: <op.xv0rg5e9idj3kv@simons-mbp>
The constructor for DOMQuad is currently:


[Constructor(optional DOMPointInit p1, optional DOMPointInit p2,
              optional DOMPointInit p3, optional DOMPointInit p4),
  Constructor(optional DOMRectInit rect),
interface DOMQuad {
     [SameObject] readonly attribute DOMPoint p1;
     [SameObject] readonly attribute DOMPoint p2;
     [SameObject] readonly attribute DOMPoint p3;
     [SameObject] readonly attribute DOMPoint p4;
     [SameObject] readonly attribute DOMRectReadOnly bounds;

I think there are a few issues here.

* All arguments are optional. This is invalid WebIDL since it's not  
possible to distinguish which constructor to use. For other constructors  
I've let the dictionary be optional and have the other constructor have  
two required arguments. We can do that here as well.

* If one does `new DOMQuad(other_domquad)`, it will convert the object to  
a DOMRectInit and result in the same thing as `new DOMQuad({})` which is  
probably not what was intended. Supporting two kinds of dictionaries is  
not straightforward, though, since I think WebIDL doesn't distinguish  
between different dictionaries. My proposal to fix this is to have a  
dictionary type that can have rect members or quad members; see  

Any opinions?
Simon Pieters
Opera Software
Received on Tuesday, 24 March 2015 20:35:50 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:49 UTC