[whatwg] <object> behavior

Boris Zbarsky bzbarsky at MIT.EDU
Fri Sep 18 11:43:39 PDT 2009


On 9/18/09 10:21 AM, Michael A. Puls II wrote:
> Attaching a test.

Thanks for doing that!

> In Opera:
>
> If you switch the display to none, it destroys the plug-in instance.
> Setting the display to something else again doesn't restore the previous
> plug-in instance. It creates a new one that starts playing from the
> beginning.
>
> However, switching between inline, inline-block, block and table just
> changes the display and the plug-in keeps playing the file.

Gotcha.  Note that due to the way style changes tend to be processed in 
browsers this leads to bizarre behavior where exactly how you do your 
switching matters.  For example, in your testcase in Opera if I do this:

    document.getElementsByTagName('object')[0].style.display="none";
    document.getElementsByTagName('object')[0].style.display="block";

while the video is running, the video doesn't restart.  However if I do:

    document.getElementsByTagName('object')[0].style.display="none";
    document.body.offsetWidth;
    document.getElementsByTagName('object')[0].style.display="block";

then the video does restart.

Note that Gecko and Webkit suffer from a similar inconsistency as long 
as the display value was "block" before the two lines above; if it was 
something else the video restarts no matter what, as you noted.

> Once the <object> is shown for the first time, you can set its display
> to none, inline, inline-block, block and table and it will just change
> the display while letting the plug-in keep playing. This means that
> setting the display to none won't destroy the plug-in instance like it
> does in other browsers.

In other words, there's hysteresis.  The DOM state doesn't uniquely 
describe the document state...

> So, is it IE's behavior we want here, or Opera's?

In my opinion, neither.  We don't want to have plug-in instantiation 
depending on the CSS box model at all (and want to instantiate even if 
display is "none").  If that's not feasible, then IE's model is imo 
preferable to Opera's "sometimes it'll restart sometimes not" model....

> Or, are you saying that the <object> should also load the plug-in even
> when its display is set to none by default?

That seems like the most self-consistent approach to me.

-Boris



More information about the whatwg mailing list