| Index: Source/core/html/HTMLSourceElement.cpp
|
| diff --git a/Source/core/html/HTMLSourceElement.cpp b/Source/core/html/HTMLSourceElement.cpp
|
| index 6364f84b11dedffe5d31e7bb8772eb897f7bb789..3a631b423b264316b3b9dd087827af4b81d78480 100644
|
| --- a/Source/core/html/HTMLSourceElement.cpp
|
| +++ b/Source/core/html/HTMLSourceElement.cpp
|
| @@ -27,6 +27,10 @@
|
| #include "core/html/HTMLSourceElement.h"
|
|
|
| #include "core/HTMLNames.h"
|
| +#include "core/css/MediaList.h"
|
| +#include "core/css/MediaQueryList.h"
|
| +#include "core/css/MediaQueryMatcher.h"
|
| +#include "core/dom/Document.h"
|
| #include "core/events/Event.h"
|
| #include "core/events/EventSender.h"
|
| #include "core/html/HTMLMediaElement.h"
|
| @@ -45,6 +49,7 @@ static SourceEventSender& sourceErrorEventSender()
|
|
|
| inline HTMLSourceElement::HTMLSourceElement(Document& document)
|
| : HTMLElement(sourceTag, document)
|
| + , m_listener(adoptRefWillBeNoop(new Listener(this)))
|
| {
|
| WTF_LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this);
|
| ScriptWrappable::init(this);
|
| @@ -55,6 +60,7 @@ DEFINE_NODE_FACTORY(HTMLSourceElement)
|
| HTMLSourceElement::~HTMLSourceElement()
|
| {
|
| sourceErrorEventSender().cancelEvent(this);
|
| + m_listener->clearElement();
|
| }
|
|
|
| Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode* insertionPoint)
|
| @@ -114,6 +120,14 @@ void HTMLSourceElement::dispatchPendingEvent(SourceEventSender* eventSender)
|
| dispatchEvent(Event::createCancelable(EventTypeNames::error));
|
| }
|
|
|
| +bool HTMLSourceElement::mediaQueryMatches() const
|
| +{
|
| + if (!m_mediaQueryList)
|
| + return true;
|
| +
|
| + return m_mediaQueryList->matches();
|
| +}
|
| +
|
| bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const
|
| {
|
| return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute);
|
| @@ -122,6 +136,13 @@ bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const
|
| void HTMLSourceElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
|
| {
|
| HTMLElement::parseAttribute(name, value);
|
| + if (name == mediaAttr) {
|
| + if (m_mediaQueryList)
|
| + m_mediaQueryList->removeListener(m_listener);
|
| + RefPtrWillBeRawPtr<MediaQuerySet> set = MediaQuerySet::create(value);
|
| + m_mediaQueryList = MediaQueryList::create(&document().mediaQueryMatcher(), set.release());
|
| + m_mediaQueryList->addListener(m_listener);
|
| + }
|
| if (name == srcsetAttr || name == sizesAttr || name == mediaAttr || name == typeAttr) {
|
| Element* parent = parentElement();
|
| if (isHTMLPictureElement(parent))
|
| @@ -129,4 +150,11 @@ void HTMLSourceElement::parseAttribute(const QualifiedName& name, const AtomicSt
|
| }
|
| }
|
|
|
| +void HTMLSourceElement::notifyMediaQueryChanged()
|
| +{
|
| + Element* parent = parentElement();
|
| + if (isHTMLPictureElement(parent))
|
| + toHTMLPictureElement(parent)->sourceOrMediaChanged();
|
| +}
|
| +
|
| }
|
|
|