Re: [css-regions] Possible change to the Region interface

On 10/3/13 3:45 PM, Mihnea-Vlad Ovidenie wrote:
> Are you saying that Gecko has support for the above scenario without
> multiple inheritance in the C++ layer? Would you mind pointing me to where
> I should take a look and what are the interfaces involved?

Sure.

Consider this WebIDL [1]:

   attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle;

There's clearly no sane way to do this with multiple inheritance (esp. 
the DOMString bit!).

The C++ implementation of this is at 
http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/CanvasRenderingContext2D.h?rev=37535faf57f9#102 
which then lands you at 
http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/CanvasRenderingContext2D.cpp?rev=37535faf57f9#1347 
which then does dispatch based on what the actual type in the union is. 
  The "StringOrCanvasGradientOrCanvasPattern" struct is auto-generated 
from the IDL.

See also the (still somewhat bare-bones) documentation at 
https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Union_types

-Boris

[1] From 
http://mxr.mozilla.org/mozilla-central/source/dom/webidl/CanvasRenderingContext2D.webidl?rev=37535faf57f9#49

Received on Thursday, 3 October 2013 21:22:06 UTC