| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #if ENABLE(VIDEO) | 27 #if ENABLE(VIDEO) |
| 28 #include "HTMLSourceElement.h" | 28 #include "HTMLSourceElement.h" |
| 29 | 29 |
| 30 #include "Event.h" | 30 #include "Event.h" |
| 31 #include "EventNames.h" | 31 #include "EventNames.h" |
| 32 #include "HTMLDocument.h" | 32 #include "HTMLDocument.h" |
| 33 #include "HTMLMediaElement.h" | 33 #include "HTMLMediaElement.h" |
| 34 #if ENABLE(PICTURE) |
| 35 #include "HTMLPictureElement.h" |
| 36 #endif |
| 34 #include "HTMLNames.h" | 37 #include "HTMLNames.h" |
| 35 #include "Logging.h" | 38 #include "Logging.h" |
| 36 | 39 |
| 37 using namespace std; | 40 using namespace std; |
| 38 | 41 |
| 39 namespace WebCore { | 42 namespace WebCore { |
| 40 | 43 |
| 41 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 42 | 45 |
| 43 inline HTMLSourceElement::HTMLSourceElement(const QualifiedName& tagName, Docume
nt* document) | 46 inline HTMLSourceElement::HTMLSourceElement(const QualifiedName& tagName, Docume
nt* document) |
| 44 : HTMLElement(tagName, document) | 47 : HTMLElement(tagName, document) |
| 45 , m_errorEventTimer(this, &HTMLSourceElement::errorEventTimerFired) | 48 , m_errorEventTimer(this, &HTMLSourceElement::errorEventTimerFired) |
| 46 { | 49 { |
| 47 LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this); | 50 LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this); |
| 48 ASSERT(hasTagName(sourceTag)); | 51 ASSERT(hasTagName(sourceTag)); |
| 49 ScriptWrappable::init(this); | 52 ScriptWrappable::init(this); |
| 50 } | 53 } |
| 51 | 54 |
| 52 PassRefPtr<HTMLSourceElement> HTMLSourceElement::create(const QualifiedName& tag
Name, Document* document) | 55 PassRefPtr<HTMLSourceElement> HTMLSourceElement::create(const QualifiedName& tag
Name, Document* document) |
| 53 { | 56 { |
| 54 return adoptRef(new HTMLSourceElement(tagName, document)); | 57 return adoptRef(new HTMLSourceElement(tagName, document)); |
| 55 } | 58 } |
| 56 | 59 |
| 57 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) | 60 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) |
| 58 { | 61 { |
| 59 HTMLElement::insertedInto(insertionPoint); | 62 HTMLElement::insertedInto(insertionPoint); |
| 60 Element* parent = parentElement(); | 63 Element* parent = parentElement(); |
| 61 if (parent && parent->isMediaElement()) | 64 if (parent && parent->isMediaElement()) |
| 62 static_cast<HTMLMediaElement*>(parentNode())->sourceWasAdded(this); | 65 static_cast<HTMLMediaElement*>(parentNode())->sourceWasAdded(this); |
| 66 #if ENABLE(PICTURE) |
| 67 if (parent && parent->isPictureElement()) |
| 68 static_cast<HTMLPictureElement*>(parentNode())->sourceWasAdded(); |
| 69 #endif |
| 63 return InsertionDone; | 70 return InsertionDone; |
| 64 } | 71 } |
| 65 | 72 |
| 66 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) | 73 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) |
| 67 { | 74 { |
| 68 Element* parent = parentElement(); | 75 Element* parent = parentElement(); |
| 69 if (!parent && removalRoot->isElementNode()) | 76 if (!parent && removalRoot->isElementNode()) |
| 70 parent = toElement(removalRoot); | 77 parent = toElement(removalRoot); |
| 71 if (parent && parent->isMediaElement()) | 78 if (parent && parent->isMediaElement()) |
| 72 toMediaElement(parent)->sourceWasRemoved(this); | 79 toMediaElement(parent)->sourceWasRemoved(this); |
| 73 HTMLElement::removedFrom(removalRoot); | 80 HTMLElement::removedFrom(removalRoot); |
| 74 } | 81 } |
| 75 | 82 |
| 76 void HTMLSourceElement::setSrc(const String& url) | 83 void HTMLSourceElement::setSrc(const String& url) |
| 77 { | 84 { |
| 78 setAttribute(srcAttr, url); | 85 setAttribute(srcAttr, url); |
| 79 } | 86 } |
| 80 | 87 |
| 88 String HTMLSourceElement::src() const |
| 89 { |
| 90 return getAttribute(srcAttr); |
| 91 } |
| 92 |
| 81 String HTMLSourceElement::media() const | 93 String HTMLSourceElement::media() const |
| 82 { | 94 { |
| 83 return getAttribute(mediaAttr); | 95 return getAttribute(mediaAttr); |
| 84 } | 96 } |
| 85 | 97 |
| 86 void HTMLSourceElement::setMedia(const String& media) | 98 void HTMLSourceElement::setMedia(const String& media) |
| 87 { | 99 { |
| 88 setAttribute(mediaAttr, media); | 100 setAttribute(mediaAttr, media); |
| 89 } | 101 } |
| 90 | 102 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 } | 132 } |
| 121 | 133 |
| 122 bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const | 134 bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const |
| 123 { | 135 { |
| 124 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; | 136 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; |
| 125 } | 137 } |
| 126 | 138 |
| 127 } | 139 } |
| 128 | 140 |
| 129 #endif | 141 #endif |
| OLD | NEW |