Re: [svgwg] Revert change from SVGRect/SVGPoint/SVGMatrix to DOM equivalents (#706)

> > But I had to change the IDL a little and the C++ class does not match the IDL anymore.
> 
> What specific mismatches were there, BTW? Could the IDL be fixed?

1. C++ DOMPoint has to inherit from DOMPointReadOnly and a new class which I named it DOMLiveProperty in WebKit. This makes DOMPoint owns a virtual table while DOMPointReadOnly does not. It also makes the sizeof(DOMPoint) != sizeof(DOMPointReadOnly). So casting DOMPointReadOnly to DOMPoint is not an option anymore.
2. DOMPoint can actually be read only. For example 'ployLineElement.animatedPoints[0].x = 10' has throw an exception. This is a little bit awkward since the DOMPoint is supposed to provide a modifiable point object but because its SVGElement decides it can't be modified, this DOMPoint behaves as if it were a DOMPointReadOnly.
3. The C++ DOMPoint needs to provide two sets of functions for setting its members. For example for setting the 'x' member we still need the function 

```
void setX(double x) { m_x = x; }
```
This function is used only internally. But for the DOM binding we need something like this:
```
ExceptionOr<void> setXForBindings(double x)
{
    if (isReadOnly())
        return Exception { NoModificationAllowedError };

    m_x = x;
    commitChange();
    return { };
}
```
This function throws an exception if the SVGElement says it is readonly. Otherwise it tells the SVGElement to update the attribute.

Two problems I see with the current IDL:
1. DOMPoint.IDL has to mention somehow it can be a live object
2. There is a discrepancy between SVGPoint and DOMPoint/DOMPointReadOnly specification. The SVGPoint can be modifiable or read-only. It throws exception if it being modified and is readonly. But DOMPoint/DOMPointReadOnly tries to solve the readonly issue this by having two separate classes which can be casted to each other. In my patch I made casting DOMPointReadOnly to DOMPoint is not an option anymore and I made DOMPoint throws exception when it's "ReadOnly" which I think should not happen.

-- 
GitHub Notification of comment by shallawa
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/706#issuecomment-542777394 using your GitHub account

Received on Wednesday, 16 October 2019 16:11:09 UTC