Changeset 126441 in webkit


Ignore:
Timestamp:
Aug 23, 2012 9:52:20 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Replace access ot HTMLMediaElement from MediaPlayerPrivateBlackBerry with methods in MediaPlayerClient - updated with notes from initial reviews. https://bugs.webkit.org/show_bug.cgi?id=84291

Reviewed by Eric Carlson.

Code standard compliance - no functional change, so no new tests required.

  • html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::mediaPlayerExitFullscreen): (WebCore): (WebCore::HTMLMediaElement::mediaPlayerIsVideo): (WebCore::HTMLMediaElement::mediaPlayerContentBoxRect): (WebCore::HTMLMediaElement::mediaPlayerSetSize): (WebCore::HTMLMediaElement::mediaPlayerPause): (WebCore::HTMLMediaElement::mediaPlayerPlay): (WebCore::HTMLMediaElement::mediaPlayerIsPaused): (WebCore::HTMLMediaElement::mediaPlayerHostWindow): (WebCore::HTMLMediaElement::mediaPlayerWindowClipRect):
  • html/HTMLMediaElement.h: (HTMLMediaElement):
  • platform/graphics/MediaPlayer.h: (WebCore): (WebCore::MediaPlayerClient::mediaPlayerExitFullscreen): (WebCore::MediaPlayerClient::mediaPlayerIsVideo): (WebCore::MediaPlayerClient::mediaPlayerContentBoxRect): (WebCore::MediaPlayerClient::mediaPlayerSetSize): (WebCore::MediaPlayerClient::mediaPlayerPause): (WebCore::MediaPlayerClient::mediaPlayerPlay): (WebCore::MediaPlayerClient::mediaPlayerIsPaused): (WebCore::MediaPlayerClient::mediaPlayerHostWindow): (WebCore::MediaPlayerClient::mediaPlayerWindowClipRect):
  • platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp: (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): (WebCore::MediaPlayerPrivate::load): (WebCore::MediaPlayerPrivate::paint): (WebCore::MediaPlayerPrivate::resizeSourceDimensions): (WebCore::MediaPlayerPrivate::updateStates): (WebCore::MediaPlayerPrivate::onPauseStateChanged): (WebCore::MediaPlayerPrivate::onPlayNotified): (WebCore::MediaPlayerPrivate::onPauseNotified): (WebCore::MediaPlayerPrivate::onAuthenticationNeeded): (WebCore::MediaPlayerPrivate::showErrorDialog): (WebCore::MediaPlayerPrivate::platformWindow): (WebCore::MediaPlayerPrivate::isElementPaused): (WebCore::MediaPlayerPrivate::isTabVisible):
  • platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h: (MediaPlayerPrivate):

Patch by John Griggs <jgriggs@rim.com> on 2012-08-23

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126438 r126441  
     12012-08-23  John Griggs  <jgriggs@rim.com>
     2
     3                Replace access ot HTMLMediaElement from MediaPlayerPrivateBlackBerry with methods in MediaPlayerClient - updated with notes from initial reviews.  https://bugs.webkit.org/show_bug.cgi?id=84291
     4
     5                Reviewed by Eric Carlson.
     6
     7                Code standard compliance - no functional change, so no new tests required.
     8
     9                * html/HTMLMediaElement.cpp:
     10                (WebCore::HTMLMediaElement::mediaPlayerExitFullscreen):
     11                (WebCore):
     12                (WebCore::HTMLMediaElement::mediaPlayerIsVideo):
     13                (WebCore::HTMLMediaElement::mediaPlayerContentBoxRect):
     14                (WebCore::HTMLMediaElement::mediaPlayerSetSize):
     15                (WebCore::HTMLMediaElement::mediaPlayerPause):
     16                (WebCore::HTMLMediaElement::mediaPlayerPlay):
     17                (WebCore::HTMLMediaElement::mediaPlayerIsPaused):
     18                (WebCore::HTMLMediaElement::mediaPlayerHostWindow):
     19                (WebCore::HTMLMediaElement::mediaPlayerWindowClipRect):
     20                * html/HTMLMediaElement.h:
     21                (HTMLMediaElement):
     22                * platform/graphics/MediaPlayer.h:
     23                (WebCore):
     24                (WebCore::MediaPlayerClient::mediaPlayerExitFullscreen):
     25                (WebCore::MediaPlayerClient::mediaPlayerIsVideo):
     26                (WebCore::MediaPlayerClient::mediaPlayerContentBoxRect):
     27                (WebCore::MediaPlayerClient::mediaPlayerSetSize):
     28                (WebCore::MediaPlayerClient::mediaPlayerPause):
     29                (WebCore::MediaPlayerClient::mediaPlayerPlay):
     30                (WebCore::MediaPlayerClient::mediaPlayerIsPaused):
     31                (WebCore::MediaPlayerClient::mediaPlayerHostWindow):
     32                (WebCore::MediaPlayerClient::mediaPlayerWindowClipRect):
     33                * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
     34                (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate):
     35                (WebCore::MediaPlayerPrivate::load):
     36                (WebCore::MediaPlayerPrivate::paint):
     37                (WebCore::MediaPlayerPrivate::resizeSourceDimensions):
     38                (WebCore::MediaPlayerPrivate::updateStates):
     39                (WebCore::MediaPlayerPrivate::onPauseStateChanged):
     40                (WebCore::MediaPlayerPrivate::onPlayNotified):
     41                (WebCore::MediaPlayerPrivate::onPauseNotified):
     42                (WebCore::MediaPlayerPrivate::onAuthenticationNeeded):
     43                (WebCore::MediaPlayerPrivate::showErrorDialog):
     44                (WebCore::MediaPlayerPrivate::platformWindow):
     45                (WebCore::MediaPlayerPrivate::isElementPaused):
     46                (WebCore::MediaPlayerPrivate::isTabVisible):
     47                * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
     48                (MediaPlayerPrivate):
     49
    1502012-08-23  John Mellor  <johnme@chromium.org>
    251
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r126331 r126441  
    43784378}
    43794379
     4380void HTMLMediaElement::mediaPlayerExitFullscreen()
     4381{
     4382    exitFullscreen();
     4383}
     4384
     4385bool HTMLMediaElement::mediaPlayerIsVideo() const
     4386{
     4387    return isVideo();
     4388}
     4389
     4390LayoutRect HTMLMediaElement::mediaPlayerContentBoxRect() const
     4391{
     4392    if (renderer())
     4393        return renderer()->enclosingBox()->contentBoxRect();
     4394    return LayoutRect();
     4395}
     4396
     4397void HTMLMediaElement::mediaPlayerSetSize(const IntSize& size)
     4398{
     4399    setAttribute(widthAttr, String::number(size.width()));
     4400    setAttribute(heightAttr, String::number(size.height()));
     4401}
     4402
     4403void HTMLMediaElement::mediaPlayerPause()
     4404{
     4405    pause();
     4406}
     4407
     4408void HTMLMediaElement::mediaPlayerPlay()
     4409{
     4410    play();
     4411}
     4412
     4413bool HTMLMediaElement::mediaPlayerIsPaused() const
     4414{
     4415    return paused();
     4416}
     4417
     4418HostWindow* HTMLMediaElement::mediaPlayerHostWindow()
     4419{
     4420    return mediaPlayerOwningDocument()->view()->hostWindow();
     4421}
     4422
     4423IntRect HTMLMediaElement::mediaPlayerWindowClipRect()
     4424{
     4425    return mediaPlayerOwningDocument()->view()->windowClipRect();
     4426}
     4427
    43804428void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
    43814429{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r125429 r126441  
    423423    virtual String mediaPlayerDocumentHost() const OVERRIDE;
    424424
     425    virtual void mediaPlayerExitFullscreen() OVERRIDE;
     426    virtual bool mediaPlayerIsVideo() const OVERRIDE;
     427    virtual LayoutRect mediaPlayerContentBoxRect() const OVERRIDE;
     428    virtual void mediaPlayerSetSize(const IntSize&) OVERRIDE;
     429    virtual void mediaPlayerPause() OVERRIDE;
     430    virtual void mediaPlayerPlay() OVERRIDE;
     431    virtual bool mediaPlayerIsPaused() const OVERRIDE;
     432    virtual HostWindow* mediaPlayerHostWindow() OVERRIDE;
     433    virtual IntRect mediaPlayerWindowClipRect() OVERRIDE;
     434
    425435#if PLATFORM(WIN) && USE(AVFOUNDATION)
    426436    virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const OVERRIDE;
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r125682 r126441  
    9999struct MediaPlayerFactory;
    100100class TimeRanges;
     101class HostWindow;
    101102
    102103#if PLATFORM(WIN) && USE(AVFOUNDATION)
     
    190191    virtual String mediaPlayerUserAgent() const { return String(); }
    191192    virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
     193    virtual void mediaPlayerExitFullscreen() { }
     194    virtual bool mediaPlayerIsVideo() const { return false; }
     195    virtual LayoutRect mediaPlayerContentBoxRect() const { return LayoutRect(); }
     196    virtual void mediaPlayerSetSize(const IntSize&) { }
     197    virtual void mediaPlayerPause() { }
     198    virtual void mediaPlayerPlay() { }
     199    virtual bool mediaPlayerIsPaused() const { return true; }
     200    virtual HostWindow* mediaPlayerHostWindow() { return 0; }
     201    virtual IntRect mediaPlayerWindowClipRect() { return IntRect(); }
    192202};
    193203
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp

    r126412 r126441  
    2828#include "FrameView.h"
    2929#include "GraphicsContext.h"
    30 #include "HTMLMediaElement.h"
    3130#include "HTMLNames.h"
    3231#include "HostWindow.h"
     
    123122{
    124123    if (isFullscreen()) {
    125         HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    126         element->exitFullscreen();
     124        m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen();
    127125    }
    128126#if USE(ACCELERATED_COMPOSITING)
     
    152150    }
    153151
    154     void* tabId = 0;
    155     if (frameView() && frameView()->hostWindow())
    156         tabId = frameView()->hostWindow()->platformPageClient();
     152    void* tabId = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient();
    157153
    158154    deleteGuardedObject(m_platformPlayer);
     
    371367
    372368    BlackBerry::Platform::IntRect platformRect(rect.x(), rect.y(), rect.width(), rect.height());
    373     IntRect clippedRect = frameView()->windowClipRect();
     369    IntRect clippedRect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerWindowClipRect();
    374370    BlackBerry::Platform::IntRect platformWindowClipRect(clippedRect.x(), clippedRect.y(), clippedRect.width(), clippedRect.height());
    375371    m_platformPlayer->paint(graphics->canvas(), platformRect, platformWindowClipRect);
     
    400396        return;
    401397
    402     HTMLMediaElement* client = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    403 
    404     if (!client || !client->isVideo())
    405         return;
    406 
    407     RenderObject* o = client->renderer();
    408     if (!o)
     398    if (!m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsVideo())
    409399        return;
    410400
    411401    // If we have an HTMLVideoElement but the source has no video, then we need to resize the media element.
    412402    if (!hasVideo()) {
    413         IntRect rect = o->enclosingBox()->contentBoxRect();
     403        LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();
    414404
    415405        static const int playbookMinAudioElementWidth = 300;
    416406        static const int playbookMinAudioElementHeight = 32;
    417407        // If the rect dimensions are less than the allowed minimum, use the minimum instead.
    418         int newWidth = max(rect.width(), playbookMinAudioElementWidth);
    419         int newHeight = max(rect.height(), playbookMinAudioElementHeight);
    420 
    421         char attrString[12];
    422 
    423         sprintf(attrString, "%d", newWidth);
    424         client->setAttribute(HTMLNames::widthAttr, attrString);
    425 
    426         sprintf(attrString, "%d", newHeight);
    427         client->setAttribute(HTMLNames::heightAttr, attrString);
     408        int newWidth = max(rect.width().toInt(), playbookMinAudioElementWidth);
     409        int newHeight = max(rect.height().toInt(), playbookMinAudioElementHeight);
     410
     411        m_webCorePlayer->mediaPlayerClient()->mediaPlayerSetSize(IntSize(newWidth, newHeight));
    428412    }
    429413
     
    431415    if (m_platformPlayer->sourceWidth() && m_platformPlayer->sourceHeight())
    432416        return;
    433     IntRect rect = o->enclosingBox()->contentBoxRect();
    434     m_platformPlayer->setSourceDimension(rect.width(), rect.height());
     417    LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();
     418    m_platformPlayer->setSourceDimension(rect.width().toUnsigned(), rect.height().toUnsigned());
    435419}
    436420
     
    511495
    512496    PlatformPlayer::Error currentError = m_platformPlayer->error();
    513 
    514     HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    515497
    516498    if (currentError != PlatformPlayer::MediaOK) {
     
    550532#endif
    551533            if (isFullscreen())
    552                 element->exitFullscreen();
     534                m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen();
    553535            break;
    554536        case PlatformPlayer::MP_STATE_ACTIVE:
     
    609591        return;
    610592
    611     HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    612593    // Paused state change not due to local controller.
    613594    if (m_platformPlayer->isPaused())
    614         element->pause();
     595        m_webCorePlayer->mediaPlayerClient()->mediaPlayerPause();
    615596    else {
    616597        // The HMI fullscreen widget has resumed play. Check if the
    617598        // pause timeout occurred.
    618599        m_platformPlayer->processPauseTimeoutIfNecessary();
    619         element->play();
     600        m_webCorePlayer->mediaPlayerClient()->mediaPlayerPlay();
    620601    }
    621602}
     
    645626void MediaPlayerPrivate::onPlayNotified()
    646627{
    647     if (HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient()))
    648         element->play();
     628    m_webCorePlayer->mediaPlayerClient()->mediaPlayerPlay();
    649629}
    650630
    651631void MediaPlayerPrivate::onPauseNotified()
    652632{
    653     if (HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient()))
    654         element->pause();
     633    m_webCorePlayer->mediaPlayerClient()->mediaPlayerPause();
    655634}
    656635
     
    727706    bool isConfirmed = false;
    728707    if (credential.isEmpty()) {
    729         if (frameView() && frameView()->hostWindow())
    730             isConfirmed = frameView()->hostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential);
     708        isConfirmed = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential);
     709
    731710    } else
    732711        isConfirmed = true;
     
    784763        return -1;
    785764    }
    786 
    787     int rc = 0;
    788     if (frameView() && frameView()->hostWindow())
    789         rc = frameView()->hostWindow()->platformPageClient()->showAlertDialog(atype);
    790     return rc;
     765    return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->showAlertDialog(atype);
    791766}
    792767
     
    818793}
    819794
    820 FrameView* MediaPlayerPrivate::frameView() const
    821 {
    822     // We previously used m_webCorePlayer->frameView(), but this method returns
    823     // a null frameView until quite late in the media player initialization,
    824     // and starting quite early in the media player destruction (because
    825     // it may be set to zero by the destructor in RenderVideo.cpp before
    826     // our destructor is called, leaving us unable to clean up child windows
    827     // in mmrDisconnect).
    828     HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    829     return element->document()->view();
    830 }
    831 
    832795BlackBerry::Platform::Graphics::Window* MediaPlayerPrivate::platformWindow()
    833796{
    834     if (frameView() && frameView()->hostWindow())
    835         return frameView()->hostWindow()->platformPageClient()->platformWindow();
    836     return 0;
     797    return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->platformWindow();
    837798}
    838799
     
    844805bool MediaPlayerPrivate::isElementPaused() const
    845806{
    846     HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
    847     if (!element || element->paused())
    848         return true;
    849     return false;
     807    return m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsPaused();
    850808}
    851809
    852810bool MediaPlayerPrivate::isTabVisible() const
    853811{
    854     if (frameView() && frameView()->hostWindow())
    855         return frameView()->hostWindow()->platformPageClient()->isVisible();
    856     return true;
     812    return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->isVisible();
    857813}
    858814
  • trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h

    r126412 r126441  
    146146    MediaPlayerPrivate(MediaPlayer*);
    147147
    148     FrameView* frameView() const;
    149148    void updateStates();
    150149    String userAgent(const String&) const;
Note: See TracChangeset for help on using the changeset viewer.