Bug 84291 - [BlackBerry] MediaPlayerPrivate should not reference HTMLMediaElement directly
Summary: [BlackBerry] MediaPlayerPrivate should not reference HTMLMediaElement directly
Status: CLOSED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit BlackBerry (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Other
: P2 Normal
Assignee: John Griggs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-18 15:42 PDT by Max Feil
Modified: 2012-11-02 12:38 PDT (History)
7 users (show)

See Also:


Attachments
Patch (11.44 KB, patch)
2012-08-21 06:44 PDT, John Griggs
no flags Details | Formatted Diff | Diff
Patch (11.43 KB, patch)
2012-08-21 08:08 PDT, John Griggs
no flags Details | Formatted Diff | Diff
Patch (11.43 KB, patch)
2012-08-21 08:56 PDT, John Griggs
no flags Details | Formatted Diff | Diff
Patch (16.98 KB, patch)
2012-08-22 08:38 PDT, John Griggs
no flags Details | Formatted Diff | Diff
Patch (16.98 KB, patch)
2012-08-23 07:06 PDT, John Griggs
no flags Details | Formatted Diff | Diff
Patch - fixed style issue from previous patch (16.97 KB, patch)
2012-08-23 07:32 PDT, John Griggs
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Max Feil 2012-04-18 15:42:31 PDT
It has been raised in https://bugs.webkit.org/show_bug.cgi?id=82930 that the BlackBerry version of MediaPlayerPrivate should not be referencing HTMLMediaElement directly. This should be done via MediaPlayer. I am creating this bug to address this concern. Here is was Eric Carlson wrote:

"Particularly unfortunate, IMO, is the code that casts MediaPlayer::mediaPlayerClient() to HTMLMediaElement to make calls on the media element directly. The engine constructor is passed a MediaPlayer* so it has an opaque interface to make calls to WebCore without having to do this. The MediaPlayerClient interface can be extended if you need something from the media element or something it knows about. Adding the necessary plumbing isn't a lot of work, and once it is there other ports can use it too. For example, to allow the AVFoundation based media engine to pass the correct UA string (https://bugs.webkit.org/show_bug.cgi?id=46241) we added mediaPlayerUserAgent to MediaPlayerClient so the engine can get the media element to fetch the UA string from the loader. MediaPlayerBlackBerry apparently needed the same functionality as well, but instead casts to an HTMLMediaElement so it can get a pointer to the frame loader to call userAgent() directly. Bug 46241 would have been much easier to fix if the MediaPlayerClient plumbing had already been there"
Comment 1 John Griggs 2012-08-21 06:44:08 PDT
Created attachment 159679 [details]
Patch
Comment 2 Build Bot 2012-08-21 07:14:22 PDT
Comment on attachment 159679 [details]
Patch

Attachment 159679 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13545528
Comment 3 John Griggs 2012-08-21 08:08:10 PDT
Created attachment 159692 [details]
Patch
Comment 4 WebKit Review Bot 2012-08-21 08:10:37 PDT
Attachment 159692 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/platform/graphics/MediaPlayer.h:195:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 John Griggs 2012-08-21 08:56:32 PDT
Created attachment 159698 [details]
Patch
Comment 6 Eric Carlson 2012-08-21 10:45:25 PDT
Comment on attachment 159698 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=159698&action=review

Thank you for working on this! r- for now because of the relatively minor issues noted, but this is close.

> Source/WebCore/html/HTMLMediaElement.cpp:4398
> +    sprintf(attrString, "%d", width);
> +    setAttribute(widthAttr, attrString);

sprintf is unsafe so you should always use snprintf instead, but in this case you can use String::number :

    setAttribute(widthAttr, String::number(width));

> Source/WebCore/platform/graphics/MediaPlayer.h:195
> +    virtual void mediaPlayerSetSize(int , int) { }

mediaPlayerContentBoxRect returns a LayoutRect, why not have this take a LayoutSize?

> Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:775
> +    return m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->view();

Accessing Document and FrameView from platform is also a layering violation. I see that you only use it to get to the HostWindow and the ClipRect, so why don't you add accessors for those instead?
Comment 7 John Griggs 2012-08-22 08:38:28 PDT
Created attachment 159946 [details]
Patch
Comment 8 John Griggs 2012-08-22 08:41:43 PDT
Eric - implemented all of your notes except for replacing the int arguments to mediaPlayerSetSize with a LayoutSize - there did not seem to be any point in constructing the object only to access it's individual parts (and have to cast them for type for String::number()) at the other end of the function call...
Comment 9 John Griggs 2012-08-22 08:45:41 PDT
Eric - implemented all of your notes except for replacing the int arguments to mediaPlayerSetSize with a LayoutSize - there did not seem to be any point in constructing the object only to access it's individual parts (and have to cast them for type for String::number()) at the other end of the function call...
Comment 10 Eric Carlson 2012-08-22 10:06:11 PDT
Comment on attachment 159946 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=159946&action=review

Marking r+, but I would like to see the size methods change noted.

> Source/WebCore/platform/graphics/MediaPlayer.h:196
> +    virtual void mediaPlayerSetSize(int, int) { }

Every spatial "setSize" in WebCore (except one) takes a size class rather than a pair of unit values. Using ints is fine, but you should really pass the value as an IntSize:

    virtual void mediaPlayerSetSize(const IntSize&) { }
Comment 11 John Griggs 2012-08-22 13:14:52 PDT
Comment on attachment 159946 [details]
Patch

Adding commit-queue ?
Comment 12 Eric Carlson 2012-08-22 13:53:02 PDT
(In reply to comment #11)
> (From update of attachment 159946 [details])
> Adding commit-queue ?

Are you planning to address, or at least comment on, my request to change setSize?
Comment 13 John Griggs 2012-08-22 14:09:31 PDT
Sorry - I'm new at this.  I assumed that the review+ meant that that would have to be handled in a separate bug.  If you want to do whatever is necessary to hold this bug, I will update the patch tomorrow.  Otherwise, feel free to open a new bug and assign to me.  Thanks.
Comment 14 Eric Carlson 2012-08-22 14:19:24 PDT
(In reply to comment #13)
> Sorry - I'm new at this.  I assumed that the review+ meant that that would have to be handled in a separate bug.  If you want to do whatever is necessary to hold this bug, I will update the patch tomorrow.  Otherwise, feel free to open a new bug and assign to me.  Thanks.

Because you didn't mark the patch cq? when you put it up for review I assumed that you would have someone commit it manually (if you mark a patch r? and cq? the reviewer will typically change both when reviewing). I marked it r+ with a comment to indicate that I think the rest of the patch is OK modulo the changes noted, assuming that you would make those changes before committing. 

I think it makes sense to fix this one minor issue in this patch. If you update the patch and mark r? and cq? I will change both at the same time.
Comment 15 John Griggs 2012-08-23 07:06:56 PDT
Created attachment 160154 [details]
Patch
Comment 16 John Griggs 2012-08-23 07:09:19 PDT
Eric - Thanks for your patience.  I am still learning the ropes for both WebKit and RIM procedures.
Comment 17 WebKit Review Bot 2012-08-23 07:10:45 PDT
Attachment 160154 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/html/HTMLMediaElement.h:428:  The parameter name "size" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 John Griggs 2012-08-23 07:32:10 PDT
Created attachment 160157 [details]
Patch - fixed style issue from previous patch
Comment 19 Eric Carlson 2012-08-23 09:20:17 PDT
Comment on attachment 160157 [details]
Patch - fixed style issue from previous patch

Thank you John!
Comment 20 John Griggs 2012-08-23 09:35:36 PDT
My pleasure!  Thank you for your patience and assistance with the proper procedures.
Comment 21 WebKit Review Bot 2012-08-23 09:51:58 PDT
Comment on attachment 160157 [details]
Patch - fixed style issue from previous patch

Clearing flags on attachment: 160157

Committed r126441: <http://trac.webkit.org/changeset/126441>
Comment 22 WebKit Review Bot 2012-08-23 09:52:03 PDT
All reviewed patches have been landed.  Closing bug.
Comment 23 Max Feil 2012-11-02 12:38:39 PDT
Closing bug for patch that landed a long time ago. Thanks John!