Commit 3ff921d3 authored by beidson@apple.com's avatar beidson@apple.com
Browse files

<rdar://problem/7902467> - Audio plays upon loading of npr.org but shouldn't

Reviewed by Eric Carlson.

No new tests. (Currently no way to test such site specific hack behavior)

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::asyncEventTimerFired): If the event to be dispatched is the canplay
  event, wrap the dispatch with m_dispatchingCanPlayEvent set.
(WebCore::HTMLMediaElement::play): If m_dispatchingCanPlayEvent is true and the site is npr.org, 
  don't perform the play().
* html/HTMLMediaElement.h: Add m_dispatchingCanPlayEvent member.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9cd3ea41
2010-04-30 Brady Eidson <beidson@apple.com>
Reviewed by Eric Carlson.
<rdar://problem/7902467> - Audio plays upon loading of npr.org but shouldn't
No new tests. (Currently no way to test such site specific hack behavior)
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::asyncEventTimerFired): If the event to be dispatched is the canplay
event, wrap the dispatch with m_dispatchingCanPlayEvent set.
(WebCore::HTMLMediaElement::play): If m_dispatchingCanPlayEvent is true and the site is npr.org,
don't perform the play().
* html/HTMLMediaElement.h: Add m_dispatchingCanPlayEvent member.
2010-04-30 Dan Bernstein <mitz@apple.com>
 
Reviewed by Adele Peterson.
......@@ -59,6 +59,7 @@
#include "RenderVideo.h"
#include "RenderView.h"
#include "ScriptEventListener.h"
#include "Settings.h"
#include "TimeRanges.h"
#include <limits>
#include <wtf/CurrentTime.h>
......@@ -127,6 +128,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* doc)
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
, m_needWidgetUpdate(false)
#endif
, m_dispatchingCanPlayEvent(false)
{
document()->registerForDocumentActivationCallbacks(this);
document()->registerForMediaVolumeCallbacks(this);
......@@ -359,8 +361,14 @@ void HTMLMediaElement::asyncEventTimerFired(Timer<HTMLMediaElement>*)
m_pendingEvents.swap(pendingEvents);
unsigned count = pendingEvents.size();
for (unsigned ndx = 0; ndx < count; ++ndx)
dispatchEvent(pendingEvents[ndx].release(), ec);
for (unsigned ndx = 0; ndx < count; ++ndx) {
if (pendingEvents[ndx]->type() == eventNames().canplayEvent) {
m_dispatchingCanPlayEvent = true;
dispatchEvent(pendingEvents[ndx].release(), ec);
m_dispatchingCanPlayEvent = false;
} else
dispatchEvent(pendingEvents[ndx].release(), ec);
}
}
void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*)
......@@ -1189,6 +1197,17 @@ void HTMLMediaElement::play(bool isUserGesture)
if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
return;
Document* doc = document();
Settings* settings = doc->settings();
if (settings && settings->needsSiteSpecificQuirks() && m_dispatchingCanPlayEvent) {
// 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();
if (host.endsWith(".npr.org", false) || equalIgnoringCase(host, "npr.org"))
return;
}
playInternal();
}
......
......@@ -362,6 +362,8 @@ private:
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
bool m_needWidgetUpdate : 1;
#endif
bool m_dispatchingCanPlayEvent : 1;
};
} //namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment