diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-09-17 17:07:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-09-19 16:29:10 +0200 |
commit | d84668b5124b2dd973644da18dad281953414242 (patch) | |
tree | 8785fd44202bde8f08e2dd93cb59de86268f0813 | |
parent | 55f814fc556631b390f0c5764bb4ee3ceeea1d45 (diff) |
Need to check if some HTML child elements are HTMLUnknownElement
Based on upstream fix http://trac.webkit.org/changeset/156953
The check for whether an element is an HTMLAudioElement or not was
incomplete. An element can have the 'audio' tag-name but still be
another element if media elements have been disabled. In this
case it will be an HTMLUnknownElement.
Task-number: QTBUG-41360
Change-Id: I6a3e366b9dc268b0dbebe5880ba68945bcb42a27
Reviewed-by: Michael Bruning <michael.bruning@digia.com>
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rwxr-xr-x | Source/WebCore/dom/make_names.pl | 9 | ||||
-rw-r--r-- | Source/WebCore/html/HTMLAudioElement.h | 11 | ||||
-rw-r--r-- | Source/WebCore/html/HTMLMediaElement.cpp | 7 |
3 files changed, 20 insertions, 7 deletions
diff --git a/Source/WebCore/dom/make_names.pl b/Source/WebCore/dom/make_names.pl index 049763ab7..0eb05491e 100755 --- a/Source/WebCore/dom/make_names.pl +++ b/Source/WebCore/dom/make_names.pl @@ -390,6 +390,10 @@ sub printConstructorInterior my ($F, $tagName, $interfaceName, $constructorTagName) = @_; # Handle media elements. + # Note that wrapperOnlyIfMediaIsAvailable is a misnomer, because media availability + # does not just control the wrapper; it controls the element object that is created. + # FIXME: Could we instead do this entirely in the wrapper, and use custom wrappers + # instead of having all the support for this here in this script? if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { print F <<END Settings* settings = document->settings(); @@ -1042,14 +1046,11 @@ sub printWrapperFunctions print F "#if ${conditionalString}\n\n"; } - # Hack for the media tags - # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file. if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { print F <<END static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) { - Settings* settings = element->document()->settings(); - if (!MediaPlayer::isAvailable() || (settings && !settings->mediaEnabled())) + if (element->isHTMLUnknownElement()) return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{namespace}Element, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get()); } diff --git a/Source/WebCore/html/HTMLAudioElement.h b/Source/WebCore/html/HTMLAudioElement.h index 07ca48dd4..0d2483668 100644 --- a/Source/WebCore/html/HTMLAudioElement.h +++ b/Source/WebCore/html/HTMLAudioElement.h @@ -43,14 +43,19 @@ private: HTMLAudioElement(const QualifiedName&, Document*, bool); }; -inline bool isHTMLAudioElement(Node* node) +inline bool isHTMLAudioElement(HTMLElement* element) { - return node->hasTagName(HTMLNames::audioTag); + return !element->isHTMLUnknownElement() && element->hasTagName(HTMLNames::audioTag); } inline bool isHTMLAudioElement(Element* element) { - return element->hasTagName(HTMLNames::audioTag); + return element->isHTMLElement() && isHTMLAudioElement(toHTMLElement(element)); +} + +inline bool isHTMLAudioElement(Node* node) +{ + return node->isHTMLElement() && isHTMLAudioElement(toHTMLElement(node)); } inline HTMLAudioElement* toHTMLAudioElement(Node* node) diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 8ef0348ab..fc8578e57 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -2379,6 +2379,13 @@ double HTMLMediaElement::duration() const bool HTMLMediaElement::paused() const { + // As of this writing, JavaScript garbage collection calls this function directly. In the past + // we had problems where this was called on an object after a bad cast. The assertion below + // made our regression test detect the problem, so we should keep it because of that. But note + // that the value of the assertion relies on the compiler not being smart enough to know that + // isHTMLUnknownElement is guaranteed to return false for an HTMLMediaElement. + ASSERT(!isHTMLUnknownElement()); + return m_paused; } |