Bug 35374

Summary: MediaPlayer has no reliable method of accessing it's owning document
Product: WebKit Reporter: Nick Young <nicholas.young>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric.carlson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 35328    
Attachments:
Description Flags
Initial Patch none

Description Nick Young 2010-02-24 18:13:47 PST
It is sometimes desirable for the MediaPlayer to access information about its owning document.

Currently there is a method MediaPlayer::frameView(), which returns the FrameView which renders the MediaPlayer.
However, there are some situations where a renderer is not created for a Media element, and as such there is no way for the MediaPlayer to access its owning document.

An example of one of these situations can be seen here: http://people.freedesktop.org/~company/stuff/video-demo.html
(Credit goes to Bug 30679 for this link)

In this demonstration, the video elements are never added to the DOM, so a renderer is never created.

As discussed in Bug 35328, the proposed solution is to add a MediaPlayerClient::mediaPlayerOwningDocument().

A patch is coming.
Comment 1 Nick Young 2010-02-24 18:19:02 PST
Created attachment 49458 [details]
Initial Patch
Comment 2 WebKit Commit Bot 2010-02-24 23:14:14 PST
Comment on attachment 49458 [details]
Initial Patch

Clearing flags on attachment: 49458

Committed r55225: <http://trac.webkit.org/changeset/55225>
Comment 3 WebKit Commit Bot 2010-02-24 23:14:18 PST
All reviewed patches have been landed.  Closing bug.
Comment 4 Darin Adler 2010-02-25 07:44:31 PST
Comment on attachment 49458 [details]
Initial Patch

> +Document* HTMLMediaElement::mediaPlayerOwningDocument()
> +{
> +    Document* d = document();
> +    
> +    if (!d)
> +        d = ownerDocument();
> +    
> +    return d;
> +}

The implementation of this function is needlessly complex. The Node::document() function never returns 0 for an element, and ownerDocument() always returns the same thing as document() except when ownerDocument() returns 0.