| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 HTMLSourceElement::~HTMLSourceElement() | 78 HTMLSourceElement::~HTMLSourceElement() |
| 79 { | 79 { |
| 80 } | 80 } |
| 81 | 81 |
| 82 void HTMLSourceElement::createMediaQueryList(const AtomicString& media) | 82 void HTMLSourceElement::createMediaQueryList(const AtomicString& media) |
| 83 { | 83 { |
| 84 if (media.isEmpty()) | 84 if (media.isEmpty()) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 if (m_mediaQueryList) | 87 removeMediaQueryListListener(); |
| 88 m_mediaQueryList->removeListener(m_listener); | |
| 89 MediaQuerySet* set = MediaQuerySet::create(media); | 88 MediaQuerySet* set = MediaQuerySet::create(media); |
| 90 m_mediaQueryList = MediaQueryList::create(&document(), &document().mediaQuer
yMatcher(), set); | 89 m_mediaQueryList = MediaQueryList::create(&document(), &document().mediaQuer
yMatcher(), set); |
| 91 m_mediaQueryList->addListener(m_listener); | 90 addMediaQueryListListener(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void HTMLSourceElement::didMoveToNewDocument(Document& oldDocument) | 93 void HTMLSourceElement::didMoveToNewDocument(Document& oldDocument) |
| 95 { | 94 { |
| 96 createMediaQueryList(fastGetAttribute(mediaAttr)); | 95 createMediaQueryList(fastGetAttribute(mediaAttr)); |
| 97 HTMLElement::didMoveToNewDocument(oldDocument); | 96 HTMLElement::didMoveToNewDocument(oldDocument); |
| 98 } | 97 } |
| 99 | 98 |
| 100 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) | 99 Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
* insertionPoint) |
| 101 { | 100 { |
| 102 HTMLElement::insertedInto(insertionPoint); | 101 HTMLElement::insertedInto(insertionPoint); |
| 103 Element* parent = parentElement(); | 102 Element* parent = parentElement(); |
| 104 if (isHTMLMediaElement(parent)) | 103 if (isHTMLMediaElement(parent)) |
| 105 toHTMLMediaElement(parent)->sourceWasAdded(this); | 104 toHTMLMediaElement(parent)->sourceWasAdded(this); |
| 106 if (isHTMLPictureElement(parent)) | 105 if (isHTMLPictureElement(parent)) |
| 107 toHTMLPictureElement(parent)->sourceOrMediaChanged(); | 106 toHTMLPictureElement(parent)->sourceOrMediaChanged(); |
| 108 return InsertionDone; | 107 return InsertionDone; |
| 109 } | 108 } |
| 110 | 109 |
| 111 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) | 110 void HTMLSourceElement::removedFrom(ContainerNode* removalRoot) |
| 112 { | 111 { |
| 113 Element* parent = parentElement(); | 112 Element* parent = parentElement(); |
| 114 if (!parent && removalRoot->isElementNode()) | 113 if (!parent && removalRoot->isElementNode()) |
| 115 parent = toElement(removalRoot); | 114 parent = toElement(removalRoot); |
| 116 if (isHTMLMediaElement(parent)) | 115 if (isHTMLMediaElement(parent)) |
| 117 toHTMLMediaElement(parent)->sourceWasRemoved(this); | 116 toHTMLMediaElement(parent)->sourceWasRemoved(this); |
| 118 if (isHTMLPictureElement(parent)) | 117 if (isHTMLPictureElement(parent)) { |
| 118 removeMediaQueryListListener(); |
| 119 toHTMLPictureElement(parent)->sourceOrMediaChanged(); | 119 toHTMLPictureElement(parent)->sourceOrMediaChanged(); |
| 120 } |
| 120 HTMLElement::removedFrom(removalRoot); | 121 HTMLElement::removedFrom(removalRoot); |
| 121 } | 122 } |
| 122 | 123 |
| 124 void HTMLSourceElement::removeMediaQueryListListener() |
| 125 { |
| 126 if (m_mediaQueryList) |
| 127 m_mediaQueryList->removeListener(m_listener); |
| 128 } |
| 129 |
| 130 void HTMLSourceElement::addMediaQueryListListener() |
| 131 { |
| 132 if (m_mediaQueryList) |
| 133 m_mediaQueryList->addListener(m_listener); |
| 134 } |
| 135 |
| 123 void HTMLSourceElement::setSrc(const String& url) | 136 void HTMLSourceElement::setSrc(const String& url) |
| 124 { | 137 { |
| 125 setAttribute(srcAttr, AtomicString(url)); | 138 setAttribute(srcAttr, AtomicString(url)); |
| 126 } | 139 } |
| 127 | 140 |
| 128 const AtomicString& HTMLSourceElement::type() const | 141 const AtomicString& HTMLSourceElement::type() const |
| 129 { | 142 { |
| 130 return getAttribute(typeAttr); | 143 return getAttribute(typeAttr); |
| 131 } | 144 } |
| 132 | 145 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 200 } |
| 188 | 201 |
| 189 DEFINE_TRACE(HTMLSourceElement) | 202 DEFINE_TRACE(HTMLSourceElement) |
| 190 { | 203 { |
| 191 visitor->trace(m_mediaQueryList); | 204 visitor->trace(m_mediaQueryList); |
| 192 visitor->trace(m_listener); | 205 visitor->trace(m_listener); |
| 193 HTMLElement::trace(visitor); | 206 HTMLElement::trace(visitor); |
| 194 } | 207 } |
| 195 | 208 |
| 196 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |