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 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/html/HTMLSourceElement.h" | 27 #include "core/html/HTMLSourceElement.h" |
28 | 28 |
29 #include "HTMLNames.h" | 29 #include "HTMLNames.h" |
30 #include "core/events/EventSender.h" | 30 #include "core/events/EventSender.h" |
31 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
| 32 #include "core/html/HTMLPictureElement.h" |
32 #include "platform/Logging.h" | 33 #include "platform/Logging.h" |
33 | 34 |
34 using namespace std; | 35 using namespace std; |
35 | 36 |
36 namespace WebCore { | 37 namespace WebCore { |
37 | 38 |
38 using namespace HTMLNames; | 39 using namespace HTMLNames; |
39 | 40 |
40 static SourceEventSender& sourceErrorEventSender() | 41 static SourceEventSender& sourceErrorEventSender() |
41 { | 42 { |
(...skipping 17 matching lines...) Expand all Loading... |
59 { | 60 { |
60 sourceErrorEventSender().cancelEvent(this); | 61 sourceErrorEventSender().cancelEvent(this); |
61 } | 62 } |
62 | 63 |
63 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) | 64 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) |
64 { | 65 { |
65 HTMLElement::insertedInto(insertionPoint); | 66 HTMLElement::insertedInto(insertionPoint); |
66 Element* parent = parentElement(); | 67 Element* parent = parentElement(); |
67 if (isHTMLMediaElement(parent)) | 68 if (isHTMLMediaElement(parent)) |
68 toHTMLMediaElement(parent)->sourceWasAdded(this); | 69 toHTMLMediaElement(parent)->sourceWasAdded(this); |
| 70 if (isHTMLPictureElement(parent)) |
| 71 toHTMLPictureElement(parent)->sourceOrMediaChanged(); |
69 return InsertionDone; | 72 return InsertionDone; |
70 } | 73 } |
71 | 74 |
72 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) | 75 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) |
73 { | 76 { |
74 Element* parent = parentElement(); | 77 Element* parent = parentElement(); |
75 if (!parent && removalRoot->isElementNode()) | 78 if (!parent && removalRoot->isElementNode()) |
76 parent = toElement(removalRoot); | 79 parent = toElement(removalRoot); |
77 if (isHTMLMediaElement(parent)) | 80 if (isHTMLMediaElement(parent)) |
78 toHTMLMediaElement(parent)->sourceWasRemoved(this); | 81 toHTMLMediaElement(parent)->sourceWasRemoved(this); |
| 82 if (isHTMLPictureElement(parent)) |
| 83 toHTMLPictureElement(parent)->sourceOrMediaChanged(); |
79 HTMLElement::removedFrom(removalRoot); | 84 HTMLElement::removedFrom(removalRoot); |
80 } | 85 } |
81 | 86 |
82 void HTMLSourceElement::setSrc(const String& url) | 87 void HTMLSourceElement::setSrc(const String& url) |
83 { | 88 { |
84 setAttribute(srcAttr, AtomicString(url)); | 89 setAttribute(srcAttr, AtomicString(url)); |
85 } | 90 } |
86 | 91 |
87 const AtomicString& HTMLSourceElement::type() const | 92 const AtomicString& HTMLSourceElement::type() const |
88 { | 93 { |
(...skipping 22 matching lines...) Expand all Loading... |
111 ASSERT_UNUSED(eventSender, eventSender == &sourceErrorEventSender()); | 116 ASSERT_UNUSED(eventSender, eventSender == &sourceErrorEventSender()); |
112 WTF_LOG(Media, "HTMLSourceElement::dispatchPendingEvent - %p", this); | 117 WTF_LOG(Media, "HTMLSourceElement::dispatchPendingEvent - %p", this); |
113 dispatchEvent(Event::createCancelable(EventTypeNames::error)); | 118 dispatchEvent(Event::createCancelable(EventTypeNames::error)); |
114 } | 119 } |
115 | 120 |
116 bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const | 121 bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const |
117 { | 122 { |
118 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; | 123 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; |
119 } | 124 } |
120 | 125 |
| 126 void HTMLSourceElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| 127 { |
| 128 HTMLElement::parseAttribute(name, value); |
| 129 if (name == srcsetAttr || name == sizesAttr || name == mediaAttr || name ==
typeAttr) { |
| 130 Element* parent = parentElement(); |
| 131 if (isHTMLPictureElement(parent)) |
| 132 toHTMLPictureElement(parent)->sourceOrMediaChanged(); |
| 133 } |
121 } | 134 } |
| 135 |
| 136 } |
OLD | NEW |