Skip to content
Permalink
Browse files
2011-06-16 Adam Barth <abarth@webkit.org>
        Reviewed by Eric Seidel.

        Remove HTMLVideoElement::processingUserGesture
        https://bugs.webkit.org/show_bug.cgi?id=62784

        HTMLMediaElement shouldn't have its own notion of the user gesture
        state.  It should just use the normal user gesture state.  Also,
        there's no point in having the bindings send the user gesture state in
        a boolean parameter.

        * WebCore.exp.in:
        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::removedFromDocument):
        (WebCore::HTMLMediaElement::load):
        (WebCore::HTMLMediaElement::play):
        (WebCore::HTMLMediaElement::pause):
        (WebCore::HTMLMediaElement::beginScrubbing):
        (WebCore::HTMLMediaElement::resume):
        * html/HTMLMediaElement.h:
        * html/HTMLMediaElement.idl:
        * html/HTMLVideoElement.cpp:
        (WebCore::HTMLVideoElement::webkitEnterFullscreen):
        * html/HTMLVideoElement.h:
        (WebCore::HTMLVideoElement::webkitEnterFullScreen):
        * html/HTMLVideoElement.idl:
        * html/MediaDocument.cpp:
        (WebCore::MediaDocument::defaultEventHandler):
        * html/shadow/MediaControlElements.cpp:
        (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
2011-06-16  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Remove HTMLVideoElement::processingUserGesture
        https://bugs.webkit.org/show_bug.cgi?id=62784

        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::performMediaPlayerAction):
2011-06-16  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Remove HTMLVideoElement::processingUserGesture
        https://bugs.webkit.org/show_bug.cgi?id=62784

        * WebCoreSupport/FullscreenVideoController.cpp:
        (FullscreenVideoController::play):
        (FullscreenVideoController::pause):
2011-06-16  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Remove HTMLVideoElement::processingUserGesture
        https://bugs.webkit.org/show_bug.cgi?id=62784

        * WebView/WebVideoFullscreenHUDWindowController.mm:
        (-[WebVideoFullscreenHUDWindowController setPlaying:]):
2011-06-16  Adam Barth  <abarth@webkit.org>

        Reviewed by Eric Seidel.

        Remove HTMLVideoElement::processingUserGesture
        https://bugs.webkit.org/show_bug.cgi?id=62784

        * FullscreenVideoController.cpp:
        (FullscreenVideoController::play):
        (FullscreenVideoController::pause):

Canonical link: https://commits.webkit.org/78361@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@89018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Adam Barth committed Jun 16, 2011
1 parent 486edc9 commit 7f5df9fd9346e11543ce8e92d2ac23a46a439608
Showing 18 changed files with 120 additions and 60 deletions.
@@ -1,3 +1,35 @@
2011-06-16 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove HTMLVideoElement::processingUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62784

HTMLMediaElement shouldn't have its own notion of the user gesture
state. It should just use the normal user gesture state. Also,
there's no point in having the bindings send the user gesture state in
a boolean parameter.

* WebCore.exp.in:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::removedFromDocument):
(WebCore::HTMLMediaElement::load):
(WebCore::HTMLMediaElement::play):
(WebCore::HTMLMediaElement::pause):
(WebCore::HTMLMediaElement::beginScrubbing):
(WebCore::HTMLMediaElement::resume):
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitEnterFullscreen):
* html/HTMLVideoElement.h:
(WebCore::HTMLVideoElement::webkitEnterFullScreen):
* html/HTMLVideoElement.idl:
* html/MediaDocument.cpp:
(WebCore::MediaDocument::defaultEventHandler):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlSeekButtonElement::defaultEventHandler):

2011-06-16 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r89011.
@@ -1808,14 +1808,13 @@ __ZN7WebCore16HTMLMediaElement14setCurrentTimeEfRi
__ZN7WebCore16HTMLMediaElement15clearMediaCacheEv
__ZN7WebCore16HTMLMediaElement20getSitesInMediaCacheERN3WTF6VectorINS1_6StringELm0EEE
__ZN7WebCore16HTMLMediaElement22clearMediaCacheForSiteERKN3WTF6StringE
__ZN7WebCore16HTMLMediaElement4playEb
__ZN7WebCore16HTMLMediaElement5pauseEb
__ZN7WebCore16HTMLMediaElement4playEv
__ZN7WebCore16HTMLMediaElement5pauseEv
__ZN7WebCore16HTMLMediaElement6rewindEf
__ZN7WebCore16HTMLMediaElement8setMutedEb
__ZN7WebCore16HTMLMediaElement9setVolumeEfRi
__ZNK7WebCore16HTMLMediaElement11currentTimeEv
__ZNK7WebCore16HTMLMediaElement13platformMediaEv
__ZNK7WebCore16HTMLMediaElement21processingUserGestureEv
__ZNK7WebCore16HTMLMediaElement5mutedEv
__ZNK7WebCore16HTMLMediaElement6volumeEv
__ZNK7WebCore16HTMLMediaElement7canPlayEv
@@ -359,7 +359,7 @@ void HTMLMediaElement::removedFromDocument()
{
LOG(Media, "HTMLMediaElement::removedFromDocument");
if (m_networkState > NETWORK_EMPTY)
pause(processingUserGesture());
pause();
if (m_isFullscreen)
exitFullscreen();
HTMLElement::removedFromDocument();
@@ -489,14 +489,14 @@ String HTMLMediaElement::canPlayType(const String& mimeType) const
return canPlay;
}

void HTMLMediaElement::load(bool isUserGesture, ExceptionCode& ec)
void HTMLMediaElement::load(ExceptionCode& ec)
{
LOG(Media, "HTMLMediaElement::load(isUserGesture : %s)", boolString(isUserGesture));
LOG(Media, "HTMLMediaElement::load()");

if (m_restrictions & RequireUserGestureForLoadRestriction && !isUserGesture)
if (m_restrictions & RequireUserGestureForLoadRestriction && !ScriptController::processingUserGesture())
ec = INVALID_STATE_ERR;
else {
m_loadInitiatedByUserGesture = isUserGesture;
m_loadInitiatedByUserGesture = ScriptController::processingUserGesture();
prepareForLoad();
loadInternal();
}
@@ -1454,24 +1454,23 @@ void HTMLMediaElement::setPreload(const String& preload)
setAttribute(preloadAttr, preload);
}

void HTMLMediaElement::play(bool isUserGesture)
void HTMLMediaElement::play()
{
LOG(Media, "HTMLMediaElement::play(isUserGesture : %s)", boolString(isUserGesture));
LOG(Media, "HTMLMediaElement::play()");

if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
if (m_restrictions & RequireUserGestureForRateChangeRestriction && !ScriptController::processingUserGesture())
return;

Document* doc = document();
Settings* settings = doc->settings();
Settings* settings = document()->settings();
if (settings && settings->needsSiteSpecificQuirks() && m_dispatchingCanPlayEvent && !m_loadInitiatedByUserGesture) {
// It should be impossible to be processing the canplay event while handling a user gesture
// since it is dispatched asynchronously.
ASSERT(!isUserGesture);
String host = doc->baseURL().host();
ASSERT(!ScriptController::processingUserGesture());
String host = document()->baseURL().host();
if (host.endsWith(".npr.org", false) || equalIgnoringCase(host, "npr.org"))
return;
}

playInternal();
}

@@ -1503,11 +1502,11 @@ void HTMLMediaElement::playInternal()
updatePlayState();
}

void HTMLMediaElement::pause(bool isUserGesture)
void HTMLMediaElement::pause()
{
LOG(Media, "HTMLMediaElement::pause(isUserGesture : %s)", boolString(isUserGesture));
LOG(Media, "HTMLMediaElement::pause()");

if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
if (m_restrictions & RequireUserGestureForRateChangeRestriction && !ScriptController::processingUserGesture())
return;

pauseInternal();
@@ -1635,7 +1634,7 @@ void HTMLMediaElement::beginScrubbing()
// Because a media element stays in non-paused state when it reaches end, playback resumes
// when the slider is dragged from the end to another position unless we pause first. Do
// a "hard pause" so an event is generated, since we want to stay paused after scrubbing finishes.
pause(processingUserGesture());
pause();
} else {
// Not at the end but we still want to pause playback so the media engine doesn't try to
// continue playing during scrubbing. Pause without generating an event as we will
@@ -2386,7 +2385,7 @@ void HTMLMediaElement::resume()
// MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
// This behavior is not specified but it seems like a sensible thing to do.
ExceptionCode ec;
load(processingUserGesture(), ec);
load(ec);
}

if (renderer())
@@ -2423,16 +2422,6 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
#endif
}

// FIXME: We should remove this function in favor of just calling ScriptController::processingUserGesture().
bool HTMLMediaElement::processingUserGesture() const
{
// FIXME: We should remove this check, but it seems to be needed to stop
// some media tests from crashing.
if (!document()->frame())
return true;
return ScriptController::processingUserGesture();
}

#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)

void HTMLMediaElement::ensureMediaPlayer()
@@ -95,7 +95,7 @@ class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, private M
void setPreload(const String&);

PassRefPtr<TimeRanges> buffered() const;
void load(bool isUserGesture, ExceptionCode&);
void load(ExceptionCode&);
String canPlayType(const String& mimeType) const;

// ready state
@@ -122,8 +122,8 @@ class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, private M
void setAutoplay(bool b);
bool loop() const;
void setLoop(bool b);
void play(bool isUserGesture);
void pause(bool isUserGesture);
void play();
void pause();

// captions
bool webkitHasClosedCaptions() const;
@@ -174,8 +174,6 @@ class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, private M

MediaControls* mediaControls();

bool processingUserGesture() const;

void sourceWillBeRemoved(HTMLSourceElement*);
void sourceWasAdded(HTMLSourceElement*);

@@ -41,7 +41,7 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement {
attribute DOMString preload;

readonly attribute TimeRanges buffered;
[NeedsUserGestureCheck] void load()
void load()
raises (DOMException);
DOMString canPlayType(in DOMString type);

@@ -67,8 +67,8 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement {
readonly attribute boolean ended;
attribute [Reflect] boolean autoplay;
attribute [Reflect] boolean loop;
[NeedsUserGestureCheck] void play();
[NeedsUserGestureCheck] void pause();
void play();
void pause();

// controls
attribute boolean controls;
@@ -39,6 +39,7 @@
#include "Page.h"
#include "RenderImage.h"
#include "RenderVideo.h"
#include "ScriptController.h"

namespace WebCore {

@@ -230,14 +231,14 @@ bool HTMLVideoElement::hasAvailableVideoFrame() const
return player()->hasAvailableVideoFrame();
}

void HTMLVideoElement::webkitEnterFullscreen(bool isUserGesture, ExceptionCode& ec)
void HTMLVideoElement::webkitEnterFullscreen(ExceptionCode& ec)
{
if (isFullscreen())
return;

// Generate an exception if this isn't called in response to a user gesture, or if the
// element does not support fullscreen.
if ((requireUserGestureForFullScreen() && !isUserGesture) || !supportsFullscreen()) {
if ((requireUserGestureForFullScreen() && !ScriptController::processingUserGesture()) || !supportsFullscreen()) {
ec = INVALID_STATE_ERR;
return;
}
@@ -45,14 +45,14 @@ class HTMLVideoElement : public HTMLMediaElement {
unsigned videoHeight() const;

// Fullscreen
void webkitEnterFullscreen(bool isUserGesture, ExceptionCode&);
void webkitEnterFullscreen(ExceptionCode&);
void webkitExitFullscreen();
bool webkitSupportsFullscreen();
bool webkitDisplayingFullscreen();

// FIXME: Maintain "FullScreen" capitalization scheme for backwards compatibility.
// https://bugs.webkit.org/show_bug.cgi?id=36081
void webkitEnterFullScreen(bool isUserGesture, ExceptionCode& ec) { webkitEnterFullscreen(isUserGesture, ec); }
void webkitEnterFullScreen(ExceptionCode& ec) { webkitEnterFullscreen(ec); }
void webkitExitFullScreen() { webkitExitFullscreen(); }

#if ENABLE(MEDIA_STATISTICS)
@@ -37,11 +37,11 @@ module html {
readonly attribute boolean webkitSupportsFullscreen;
readonly attribute boolean webkitDisplayingFullscreen;

[NeedsUserGestureCheck] void webkitEnterFullscreen() raises (DOMException);
void webkitEnterFullscreen() raises (DOMException);
void webkitExitFullscreen();

// Note the different capitalization of the "S" in FullScreen.
[NeedsUserGestureCheck] void webkitEnterFullScreen() raises (DOMException);
void webkitEnterFullScreen() raises (DOMException);
void webkitExitFullScreen();

#if defined(ENABLE_MEDIA_STATISTICS) && ENABLE_MEDIA_STATISTICS
@@ -165,12 +165,12 @@ void MediaDocument::defaultEventHandler(Event* event)
if (HTMLVideoElement* video = ancestorVideoElement(targetNode)) {
if (event->type() == eventNames().clickEvent) {
if (!video->canPlay()) {
video->pause(ScriptController::processingUserGesture());
video->pause();
event->setDefaultHandled();
}
} else if (event->type() == eventNames().dblclickEvent) {
if (video->canPlay()) {
video->play(ScriptController::processingUserGesture());
video->play();
event->setDefaultHandled();
}
}
@@ -185,9 +185,9 @@ void MediaDocument::defaultEventHandler(Event* event)
if (keyboardEvent->keyIdentifier() == "U+0020") { // space
if (video->paused()) {
if (video->canPlay())
video->play(ScriptController::processingUserGesture());
video->play();
} else
video->pause(ScriptController::processingUserGesture());
video->pause();
event->setDefaultHandled();
}
}
@@ -548,7 +548,7 @@ void MediaControlSeekButtonElement::defaultEventHandler(Event* event)
m_capturing = true;
frame->eventHandler()->setCapturingMouseEventsNode(this);
}
mediaElement()->pause(ScriptController::processingUserGesture());
mediaElement()->pause();
m_seekTimer.startRepeating(cSeekRepeatDelay);
event->setDefaultHandled();
} else if (event->type() == eventNames().mouseupEvent) {
@@ -1,3 +1,13 @@
2011-06-16 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove HTMLVideoElement::processingUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62784

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::performMediaPlayerAction):

2011-06-15 Mikhail Naganov <mnaganov@chromium.org>

Reviewed by Pavel Feldman.
@@ -1797,8 +1797,7 @@ double WebView::zoomFactorToZoomLevel(double factor)
void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
const WebPoint& location)
{
HitTestResult result =
hitTestResultForWindowPos(location);
HitTestResult result = hitTestResultForWindowPos(location);
RefPtr<Node> node = result.innerNonSharedNode();
if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))
return;
@@ -1808,9 +1807,9 @@ void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
switch (action.type) {
case WebMediaPlayerAction::Play:
if (action.enable)
mediaElement->play(mediaElement->processingUserGesture());
mediaElement->play();
else
mediaElement->pause(mediaElement->processingUserGesture());
mediaElement->pause();
break;
case WebMediaPlayerAction::Mute:
mediaElement->setMuted(action.enable);
@@ -1,3 +1,14 @@
2011-06-16 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove HTMLVideoElement::processingUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62784

* WebCoreSupport/FullscreenVideoController.cpp:
(FullscreenVideoController::play):
(FullscreenVideoController::pause):

2011-06-15 Claudio Saavedra <csaavedra@igalia.com>

Reviewed by Xan Lopez.
@@ -368,7 +368,7 @@ bool FullscreenVideoController::canPlay() const
void FullscreenVideoController::play()
{
if (m_mediaElement)
m_mediaElement->play(m_mediaElement->processingUserGesture());
m_mediaElement->play();

playStateChanged();
showHud(true);
@@ -377,7 +377,7 @@ void FullscreenVideoController::play()
void FullscreenVideoController::pause()
{
if (m_mediaElement)
m_mediaElement->pause(m_mediaElement->processingUserGesture());
m_mediaElement->pause();

playStateChanged();
showHud(false);
@@ -1,3 +1,13 @@
2011-06-16 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove HTMLVideoElement::processingUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62784

* WebView/WebVideoFullscreenHUDWindowController.mm:
(-[WebVideoFullscreenHUDWindowController setPlaying:]):

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.
@@ -563,9 +563,9 @@ - (void)setPlaying:(BOOL)playing
return;

if (playing)
mediaElement->play(mediaElement->processingUserGesture());
mediaElement->play();
else
mediaElement->pause(mediaElement->processingUserGesture());
mediaElement->pause();
}

static NSString *timeToString(double time)

0 comments on commit 7f5df9f

Please sign in to comment.