| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "config.h" | 20 #include "config.h" |
| 21 #include "core/css/MediaQueryList.h" | 21 #include "core/css/MediaQueryList.h" |
| 22 | 22 |
| 23 #include "core/css/MediaList.h" | 23 #include "core/css/MediaList.h" |
| 24 #include "core/css/MediaQueryEvaluator.h" | 24 #include "core/css/MediaQueryEvaluator.h" |
| 25 #include "core/css/MediaQueryListListener.h" | 25 #include "core/css/MediaQueryListListener.h" |
| 26 #include "core/css/MediaQueryMatcher.h" | 26 #include "core/css/MediaQueryMatcher.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryList::create(PassRefPtrWillBeRa
wPtr<MediaQueryMatcher> matcher, PassRefPtrWillBeRawPtr<MediaQuerySet> media) | 30 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryList::create(ExecutionContext*
context, PassRefPtrWillBeRawPtr<MediaQueryMatcher> matcher, PassRefPtrWillBeRawP
tr<MediaQuerySet> media) |
| 31 { | 31 { |
| 32 return adoptRefWillBeNoop(new MediaQueryList(matcher, media)); | 32 RefPtrWillBeRawPtr<MediaQueryList> list = adoptRefWillBeNoop(new MediaQueryL
ist(context, matcher, media)); |
| 33 list->suspendIfNeeded(); |
| 34 return list.release(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 MediaQueryList::MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher> matcher
, PassRefPtrWillBeRawPtr<MediaQuerySet> media) | 37 MediaQueryList::MediaQueryList(ExecutionContext* context, PassRefPtrWillBeRawPtr
<MediaQueryMatcher> matcher, PassRefPtrWillBeRawPtr<MediaQuerySet> media) |
| 36 : m_matcher(matcher) | 38 : ActiveDOMObject(context) |
| 39 , m_matcher(matcher) |
| 37 , m_media(media) | 40 , m_media(media) |
| 38 , m_matchesDirty(true) | 41 , m_matchesDirty(true) |
| 39 , m_matches(false) | 42 , m_matches(false) |
| 40 { | 43 { |
| 41 m_matcher->addMediaQueryList(this); | 44 m_matcher->addMediaQueryList(this); |
| 42 updateMatches(); | 45 updateMatches(); |
| 43 } | 46 } |
| 44 | 47 |
| 45 MediaQueryList::~MediaQueryList() | 48 MediaQueryList::~MediaQueryList() |
| 46 { | 49 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 74 for (ListenerList::iterator it = m_listeners.begin(), end = m_listeners.end(
); it != end; ++it) { | 77 for (ListenerList::iterator it = m_listeners.begin(), end = m_listeners.end(
); it != end; ++it) { |
| 75 // We can't just use m_listeners.remove() here, because we get a new wra
pper for the | 78 // We can't just use m_listeners.remove() here, because we get a new wra
pper for the |
| 76 // listener callback every time. We have to use MediaQueryListListener::
operator==. | 79 // listener callback every time. We have to use MediaQueryListListener::
operator==. |
| 77 if (**it == *listener.get()) { | 80 if (**it == *listener.get()) { |
| 78 m_listeners.remove(it); | 81 m_listeners.remove(it); |
| 79 break; | 82 break; |
| 80 } | 83 } |
| 81 } | 84 } |
| 82 } | 85 } |
| 83 | 86 |
| 84 void MediaQueryList::documentDetached() | 87 bool MediaQueryList::hasPendingActivity() const |
| 88 { |
| 89 return m_listeners.size(); |
| 90 } |
| 91 |
| 92 void MediaQueryList::stop() |
| 85 { | 93 { |
| 86 m_listeners.clear(); | 94 m_listeners.clear(); |
| 87 } | 95 } |
| 88 | 96 |
| 89 void MediaQueryList::mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<Me
diaQueryListListener> >* listenersToNotify) | 97 void MediaQueryList::mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<Me
diaQueryListListener> >* listenersToNotify) |
| 90 { | 98 { |
| 91 m_matchesDirty = true; | 99 m_matchesDirty = true; |
| 92 if (!updateMatches()) | 100 if (!updateMatches()) |
| 93 return; | 101 return; |
| 94 for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listener
s.end(); it != end; ++it) { | 102 for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listener
s.end(); it != end; ++it) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 115 void MediaQueryList::trace(Visitor* visitor) | 123 void MediaQueryList::trace(Visitor* visitor) |
| 116 { | 124 { |
| 117 #if ENABLE(OILPAN) | 125 #if ENABLE(OILPAN) |
| 118 visitor->trace(m_matcher); | 126 visitor->trace(m_matcher); |
| 119 visitor->trace(m_media); | 127 visitor->trace(m_media); |
| 120 visitor->trace(m_listeners); | 128 visitor->trace(m_listeners); |
| 121 #endif | 129 #endif |
| 122 } | 130 } |
| 123 | 131 |
| 124 } | 132 } |
| OLD | NEW |