From d84668b5124b2dd973644da18dad281953414242 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 17 Sep 2014 17:07:48 +0200 Subject: 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 Reviewed-by: Jocelyn Turcotte --- Source/WebCore/dom/make_names.pl | 9 +++++---- Source/WebCore/html/HTMLAudioElement.h | 11 ++++++++--- 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 <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 < 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; } -- cgit v1.2.3