summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp62
1 files changed, 35 insertions, 27 deletions
diff --git a/chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp b/chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
index 75daceb07a4..6364f84b11d 100644
--- a/chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
+++ b/chromium/third_party/WebKit/Source/core/html/HTMLSourceElement.cpp
@@ -26,37 +26,45 @@
#include "config.h"
#include "core/html/HTMLSourceElement.h"
-#include "HTMLNames.h"
+#include "core/HTMLNames.h"
#include "core/events/Event.h"
-#include "core/events/ThreadLocalEventNames.h"
+#include "core/events/EventSender.h"
#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLPictureElement.h"
#include "platform/Logging.h"
-using namespace std;
-
namespace WebCore {
using namespace HTMLNames;
+static SourceEventSender& sourceErrorEventSender()
+{
+ DEFINE_STATIC_LOCAL(SourceEventSender, sharedErrorEventSender, (EventTypeNames::error));
+ return sharedErrorEventSender;
+}
+
inline HTMLSourceElement::HTMLSourceElement(Document& document)
: HTMLElement(sourceTag, document)
- , m_errorEventTimer(this, &HTMLSourceElement::errorEventTimerFired)
{
WTF_LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this);
ScriptWrappable::init(this);
}
-PassRefPtr<HTMLSourceElement> HTMLSourceElement::create(Document& document)
+DEFINE_NODE_FACTORY(HTMLSourceElement)
+
+HTMLSourceElement::~HTMLSourceElement()
{
- return adoptRef(new HTMLSourceElement(document));
+ sourceErrorEventSender().cancelEvent(this);
}
Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
Element* parent = parentElement();
- if (parent && parent->isMediaElement())
- toHTMLMediaElement(parentNode())->sourceWasAdded(this);
+ if (isHTMLMediaElement(parent))
+ toHTMLMediaElement(parent)->sourceWasAdded(this);
+ if (isHTMLPictureElement(parent))
+ toHTMLPictureElement(parent)->sourceOrMediaChanged();
return InsertionDone;
}
@@ -65,8 +73,10 @@ void HTMLSourceElement::removedFrom(ContainerNode* removalRoot)
Element* parent = parentElement();
if (!parent && removalRoot->isElementNode())
parent = toElement(removalRoot);
- if (parent && parent->isMediaElement())
+ if (isHTMLMediaElement(parent))
toHTMLMediaElement(parent)->sourceWasRemoved(this);
+ if (isHTMLPictureElement(parent))
+ toHTMLPictureElement(parent)->sourceOrMediaChanged();
HTMLElement::removedFrom(removalRoot);
}
@@ -75,16 +85,6 @@ void HTMLSourceElement::setSrc(const String& url)
setAttribute(srcAttr, AtomicString(url));
}
-const AtomicString& HTMLSourceElement::media() const
-{
- return getAttribute(mediaAttr);
-}
-
-void HTMLSourceElement::setMedia(const AtomicString& media)
-{
- setAttribute(mediaAttr, media);
-}
-
const AtomicString& HTMLSourceElement::type() const
{
return getAttribute(typeAttr);
@@ -98,21 +98,19 @@ void HTMLSourceElement::setType(const AtomicString& type)
void HTMLSourceElement::scheduleErrorEvent()
{
WTF_LOG(Media, "HTMLSourceElement::scheduleErrorEvent - %p", this);
- if (m_errorEventTimer.isActive())
- return;
-
- m_errorEventTimer.startOneShot(0);
+ sourceErrorEventSender().dispatchEventSoon(this);
}
void HTMLSourceElement::cancelPendingErrorEvent()
{
WTF_LOG(Media, "HTMLSourceElement::cancelPendingErrorEvent - %p", this);
- m_errorEventTimer.stop();
+ sourceErrorEventSender().cancelEvent(this);
}
-void HTMLSourceElement::errorEventTimerFired(Timer<HTMLSourceElement>*)
+void HTMLSourceElement::dispatchPendingEvent(SourceEventSender* eventSender)
{
- WTF_LOG(Media, "HTMLSourceElement::errorEventTimerFired - %p", this);
+ ASSERT_UNUSED(eventSender, eventSender == &sourceErrorEventSender());
+ WTF_LOG(Media, "HTMLSourceElement::dispatchPendingEvent - %p", this);
dispatchEvent(Event::createCancelable(EventTypeNames::error));
}
@@ -121,4 +119,14 @@ bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const
return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute);
}
+void HTMLSourceElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+ HTMLElement::parseAttribute(name, value);
+ if (name == srcsetAttr || name == sizesAttr || name == mediaAttr || name == typeAttr) {
+ Element* parent = parentElement();
+ if (isHTMLPictureElement(parent))
+ toHTMLPictureElement(parent)->sourceOrMediaChanged();
+ }
+}
+
}