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 |
(...skipping 30 matching lines...) Expand all Loading... |
41 { | 41 { |
42 ASSERT(m_document); | 42 ASSERT(m_document); |
43 } | 43 } |
44 | 44 |
45 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher) | 45 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher) |
46 | 46 |
47 void MediaQueryMatcher::documentDetached() | 47 void MediaQueryMatcher::documentDetached() |
48 { | 48 { |
49 m_document = nullptr; | 49 m_document = nullptr; |
50 m_evaluator = nullptr; | 50 m_evaluator = nullptr; |
51 | |
52 // Take a ref to each MediaQueryList as removing the listeners in documentDe
tached | |
53 // could release the last ref and mutate the m_mediaLists. | |
54 WillBeHeapVector<RefPtrWillBeMember<MediaQueryList> > lists; | |
55 copyToVector(m_mediaLists, lists); | |
56 | |
57 for (size_t i = 0; i < lists.size(); ++i) | |
58 lists[i]->documentDetached(); | |
59 } | 51 } |
60 | 52 |
61 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::createEvaluator() const | 53 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::createEvaluator() const |
62 { | 54 { |
63 if (!m_document || !m_document->frame()) | 55 if (!m_document || !m_document->frame()) |
64 return nullptr; | 56 return nullptr; |
65 | 57 |
66 return adoptPtr(new MediaQueryEvaluator(m_document->frame())); | 58 return adoptPtr(new MediaQueryEvaluator(m_document->frame())); |
67 } | 59 } |
68 | 60 |
(...skipping 15 matching lines...) Expand all Loading... |
84 } | 76 } |
85 | 77 |
86 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryMatcher::matchMedia(const Strin
g& query) | 78 PassRefPtrWillBeRawPtr<MediaQueryList> MediaQueryMatcher::matchMedia(const Strin
g& query) |
87 { | 79 { |
88 if (!m_document) | 80 if (!m_document) |
89 return nullptr; | 81 return nullptr; |
90 | 82 |
91 RefPtrWillBeRawPtr<MediaQuerySet> media = MediaQuerySet::create(query); | 83 RefPtrWillBeRawPtr<MediaQuerySet> media = MediaQuerySet::create(query); |
92 // Add warning message to inspector whenever dpi/dpcm values are used for "s
creen" media. | 84 // Add warning message to inspector whenever dpi/dpcm values are used for "s
creen" media. |
93 reportMediaQueryWarningIfNeeded(m_document, media.get()); | 85 reportMediaQueryWarningIfNeeded(m_document, media.get()); |
94 return MediaQueryList::create(this, media); | 86 return MediaQueryList::create(m_document, this, media); |
95 } | 87 } |
96 | 88 |
97 void MediaQueryMatcher::addMediaQueryList(MediaQueryList* query) | 89 void MediaQueryMatcher::addMediaQueryList(MediaQueryList* query) |
98 { | 90 { |
99 if (!m_document) | 91 if (!m_document) |
100 return; | 92 return; |
101 m_mediaLists.add(query); | 93 m_mediaLists.add(query); |
102 } | 94 } |
103 | 95 |
104 void MediaQueryMatcher::removeMediaQueryList(MediaQueryList* query) | 96 void MediaQueryMatcher::removeMediaQueryList(MediaQueryList* query) |
(...skipping 17 matching lines...) Expand all Loading... |
122 | 114 |
123 void MediaQueryMatcher::trace(Visitor* visitor) | 115 void MediaQueryMatcher::trace(Visitor* visitor) |
124 { | 116 { |
125 #if ENABLE(OILPAN) | 117 #if ENABLE(OILPAN) |
126 visitor->trace(m_document); | 118 visitor->trace(m_document); |
127 visitor->trace(m_mediaLists); | 119 visitor->trace(m_mediaLists); |
128 #endif | 120 #endif |
129 } | 121 } |
130 | 122 |
131 } | 123 } |
OLD | NEW |