Changeset 126441 in webkit
- Timestamp:
- Aug 23, 2012 9:52:20 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126438 r126441 1 2012-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 1 50 2012-08-23 John Mellor <johnme@chromium.org> 2 51 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r126331 r126441 4378 4378 } 4379 4379 4380 void HTMLMediaElement::mediaPlayerExitFullscreen() 4381 { 4382 exitFullscreen(); 4383 } 4384 4385 bool HTMLMediaElement::mediaPlayerIsVideo() const 4386 { 4387 return isVideo(); 4388 } 4389 4390 LayoutRect HTMLMediaElement::mediaPlayerContentBoxRect() const 4391 { 4392 if (renderer()) 4393 return renderer()->enclosingBox()->contentBoxRect(); 4394 return LayoutRect(); 4395 } 4396 4397 void HTMLMediaElement::mediaPlayerSetSize(const IntSize& size) 4398 { 4399 setAttribute(widthAttr, String::number(size.width())); 4400 setAttribute(heightAttr, String::number(size.height())); 4401 } 4402 4403 void HTMLMediaElement::mediaPlayerPause() 4404 { 4405 pause(); 4406 } 4407 4408 void HTMLMediaElement::mediaPlayerPlay() 4409 { 4410 play(); 4411 } 4412 4413 bool HTMLMediaElement::mediaPlayerIsPaused() const 4414 { 4415 return paused(); 4416 } 4417 4418 HostWindow* HTMLMediaElement::mediaPlayerHostWindow() 4419 { 4420 return mediaPlayerOwningDocument()->view()->hostWindow(); 4421 } 4422 4423 IntRect HTMLMediaElement::mediaPlayerWindowClipRect() 4424 { 4425 return mediaPlayerOwningDocument()->view()->windowClipRect(); 4426 } 4427 4380 4428 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture() 4381 4429 { -
trunk/Source/WebCore/html/HTMLMediaElement.h
r125429 r126441 423 423 virtual String mediaPlayerDocumentHost() const OVERRIDE; 424 424 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 425 435 #if PLATFORM(WIN) && USE(AVFOUNDATION) 426 436 virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const OVERRIDE; -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r125682 r126441 99 99 struct MediaPlayerFactory; 100 100 class TimeRanges; 101 class HostWindow; 101 102 102 103 #if PLATFORM(WIN) && USE(AVFOUNDATION) … … 190 191 virtual String mediaPlayerUserAgent() const { return String(); } 191 192 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(); } 192 202 }; 193 203 -
trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
r126412 r126441 28 28 #include "FrameView.h" 29 29 #include "GraphicsContext.h" 30 #include "HTMLMediaElement.h"31 30 #include "HTMLNames.h" 32 31 #include "HostWindow.h" … … 123 122 { 124 123 if (isFullscreen()) { 125 HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient()); 126 element->exitFullscreen(); 124 m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen(); 127 125 } 128 126 #if USE(ACCELERATED_COMPOSITING) … … 152 150 } 153 151 154 void* tabId = 0; 155 if (frameView() && frameView()->hostWindow()) 156 tabId = frameView()->hostWindow()->platformPageClient(); 152 void* tabId = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient(); 157 153 158 154 deleteGuardedObject(m_platformPlayer); … … 371 367 372 368 BlackBerry::Platform::IntRect platformRect(rect.x(), rect.y(), rect.width(), rect.height()); 373 IntRect clippedRect = frameView()->windowClipRect();369 IntRect clippedRect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerWindowClipRect(); 374 370 BlackBerry::Platform::IntRect platformWindowClipRect(clippedRect.x(), clippedRect.y(), clippedRect.width(), clippedRect.height()); 375 371 m_platformPlayer->paint(graphics->canvas(), platformRect, platformWindowClipRect); … … 400 396 return; 401 397 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()) 409 399 return; 410 400 411 401 // If we have an HTMLVideoElement but the source has no video, then we need to resize the media element. 412 402 if (!hasVideo()) { 413 IntRect rect = o->enclosingBox()->contentBoxRect();403 LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect(); 414 404 415 405 static const int playbookMinAudioElementWidth = 300; 416 406 static const int playbookMinAudioElementHeight = 32; 417 407 // 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)); 428 412 } 429 413 … … 431 415 if (m_platformPlayer->sourceWidth() && m_platformPlayer->sourceHeight()) 432 416 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()); 435 419 } 436 420 … … 511 495 512 496 PlatformPlayer::Error currentError = m_platformPlayer->error(); 513 514 HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());515 497 516 498 if (currentError != PlatformPlayer::MediaOK) { … … 550 532 #endif 551 533 if (isFullscreen()) 552 element->exitFullscreen();534 m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen(); 553 535 break; 554 536 case PlatformPlayer::MP_STATE_ACTIVE: … … 609 591 return; 610 592 611 HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());612 593 // Paused state change not due to local controller. 613 594 if (m_platformPlayer->isPaused()) 614 element->pause();595 m_webCorePlayer->mediaPlayerClient()->mediaPlayerPause(); 615 596 else { 616 597 // The HMI fullscreen widget has resumed play. Check if the 617 598 // pause timeout occurred. 618 599 m_platformPlayer->processPauseTimeoutIfNecessary(); 619 element->play();600 m_webCorePlayer->mediaPlayerClient()->mediaPlayerPlay(); 620 601 } 621 602 } … … 645 626 void MediaPlayerPrivate::onPlayNotified() 646 627 { 647 if (HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient())) 648 element->play(); 628 m_webCorePlayer->mediaPlayerClient()->mediaPlayerPlay(); 649 629 } 650 630 651 631 void MediaPlayerPrivate::onPauseNotified() 652 632 { 653 if (HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient())) 654 element->pause(); 633 m_webCorePlayer->mediaPlayerClient()->mediaPlayerPause(); 655 634 } 656 635 … … 727 706 bool isConfirmed = false; 728 707 if (credential.isEmpty()) { 729 i f (frameView() && frameView()->hostWindow())730 isConfirmed = frameView()->hostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential); 708 isConfirmed = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential); 709 731 710 } else 732 711 isConfirmed = true; … … 784 763 return -1; 785 764 } 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); 791 766 } 792 767 … … 818 793 } 819 794 820 FrameView* MediaPlayerPrivate::frameView() const821 {822 // We previously used m_webCorePlayer->frameView(), but this method returns823 // a null frameView until quite late in the media player initialization,824 // and starting quite early in the media player destruction (because825 // it may be set to zero by the destructor in RenderVideo.cpp before826 // our destructor is called, leaving us unable to clean up child windows827 // in mmrDisconnect).828 HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());829 return element->document()->view();830 }831 832 795 BlackBerry::Platform::Graphics::Window* MediaPlayerPrivate::platformWindow() 833 796 { 834 if (frameView() && frameView()->hostWindow()) 835 return frameView()->hostWindow()->platformPageClient()->platformWindow(); 836 return 0; 797 return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->platformWindow(); 837 798 } 838 799 … … 844 805 bool MediaPlayerPrivate::isElementPaused() const 845 806 { 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(); 850 808 } 851 809 852 810 bool MediaPlayerPrivate::isTabVisible() const 853 811 { 854 if (frameView() && frameView()->hostWindow()) 855 return frameView()->hostWindow()->platformPageClient()->isVisible(); 856 return true; 812 return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->isVisible(); 857 813 } 858 814 -
trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h
r126412 r126441 146 146 MediaPlayerPrivate(MediaPlayer*); 147 147 148 FrameView* frameView() const;149 148 void updateStates(); 150 149 String userAgent(const String&) const;
Note: See TracChangeset
for help on using the changeset viewer.