Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: Source/core/css/MediaQueryMatcher.cpp

Issue 396283004: Make the MediaQueryList listener an EventListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: argh, forgot a --reset-results Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/MediaQueryMatcher.h" 21 #include "core/css/MediaQueryMatcher.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/MediaQueryList.h" 25 #include "core/css/MediaQueryList.h"
26 #include "core/css/MediaQueryListEvent.h"
26 #include "core/css/MediaQueryListListener.h" 27 #include "core/css/MediaQueryListListener.h"
27 #include "core/css/resolver/StyleResolver.h" 28 #include "core/css/resolver/StyleResolver.h"
28 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
29 #include "core/frame/FrameView.h" 30 #include "core/frame/FrameView.h"
30 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
31 32
32 namespace WebCore { 33 namespace WebCore {
33 34
34 PassRefPtrWillBeRawPtr<MediaQueryMatcher> MediaQueryMatcher::create(Document& do cument) 35 PassRefPtrWillBeRawPtr<MediaQueryMatcher> MediaQueryMatcher::create(Document& do cument)
35 { 36 {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 85 }
85 86
86 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryMatcher::matchMedia(const Strin g& query) 87 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryMatcher::matchMedia(const Strin g& query)
87 { 88 {
88 if (!m_document) 89 if (!m_document)
89 return nullptr; 90 return nullptr;
90 91
91 RefPtrWillBeRawPtr<MediaQuerySet> media = MediaQuerySet::create(query); 92 RefPtrWillBeRawPtr<MediaQuerySet> media = MediaQuerySet::create(query);
92 // Add warning message to inspector whenever dpi/dpcm values are used for "s creen" media. 93 // Add warning message to inspector whenever dpi/dpcm values are used for "s creen" media.
93 reportMediaQueryWarningIfNeeded(m_document, media.get()); 94 reportMediaQueryWarningIfNeeded(m_document, media.get());
94 return MediaQueryList::create(this, media); 95 return MediaQueryList::create(this, media, m_document);
95 } 96 }
96 97
97 void MediaQueryMatcher::addMediaQueryList(MediaQueryList* query) 98 void MediaQueryMatcher::addMediaQueryList(MediaQueryList* query)
98 { 99 {
99 if (!m_document) 100 if (!m_document)
100 return; 101 return;
101 m_mediaLists.add(query); 102 m_mediaLists.add(query);
102 } 103 }
103 104
104 void MediaQueryMatcher::removeMediaQueryList(MediaQueryList* query) 105 void MediaQueryMatcher::removeMediaQueryList(MediaQueryList* query)
105 { 106 {
106 if (!m_document) 107 if (!m_document)
107 return; 108 return;
108 m_mediaLists.remove(query); 109 m_mediaLists.remove(query);
109 } 110 }
110 111
111 void MediaQueryMatcher::mediaFeaturesChanged() 112 void MediaQueryMatcher::mediaFeaturesChanged()
112 { 113 {
113 if (!m_document) 114 if (!m_document)
114 return; 115 return;
115 116
116 WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> > listenersToNot ify; 117 WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> > listenersToNot ify;
117 for (MediaQueryListSet::iterator it = m_mediaLists.begin(); it != m_mediaLis ts.end(); ++it) 118 for (MediaQueryListSet::iterator it = m_mediaLists.begin(); it != m_mediaLis ts.end(); ++it) {
118 (*it)->mediaFeaturesChanged(&listenersToNotify); 119 if ((*it)->mediaFeaturesChanged(&listenersToNotify)) {
120 RefPtrWillBeRawPtr<Event> event(MediaQueryListEvent::create((*it)->m edia(), (*it)->matches()));
121 event->setTarget(*it);
122 m_document->enqueuePerFrameEvent(event);
123 }
124 }
119 125
120 m_document->enqueueMediaQueryChangeListeners(listenersToNotify); 126 m_document->enqueueMediaQueryChangeListeners(listenersToNotify);
121 } 127 }
122 128
123 void MediaQueryMatcher::trace(Visitor* visitor) 129 void MediaQueryMatcher::trace(Visitor* visitor)
124 { 130 {
125 #if ENABLE(OILPAN) 131 #if ENABLE(OILPAN)
126 visitor->trace(m_document); 132 visitor->trace(m_document);
127 visitor->trace(m_mediaLists); 133 visitor->trace(m_mediaLists);
128 #endif 134 #endif
129 } 135 }
130 136
131 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698