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

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

Issue 1555993002: Reduce risk of MediaQueryEvaluator-induced leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 MediaQueryMatcher::~MediaQueryMatcher() 46 MediaQueryMatcher::~MediaQueryMatcher()
47 { 47 {
48 } 48 }
49 49
50 void MediaQueryMatcher::documentDetached() 50 void MediaQueryMatcher::documentDetached()
51 { 51 {
52 m_document = nullptr; 52 m_document = nullptr;
53 m_evaluator = nullptr; 53 m_evaluator = nullptr;
54 } 54 }
55 55
56 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::createEvaluator() const 56 PassOwnPtrWillBeRawPtr<MediaQueryEvaluator> MediaQueryMatcher::createEvaluator() const
57 { 57 {
58 if (!m_document || !m_document->frame()) 58 if (!m_document || !m_document->frame())
59 return nullptr; 59 return nullptr;
60 60
61 return adoptPtr(new MediaQueryEvaluator(m_document->frame())); 61 return adoptPtrWillBeNoop(new MediaQueryEvaluator(m_document->frame()));
62 } 62 }
63 63
64 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) 64 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media)
65 { 65 {
66 ASSERT(!m_document || m_document->frame() || !m_evaluator); 66 ASSERT(!m_document || m_document->frame() || !m_evaluator);
67 67
68 if (!media) 68 if (!media)
69 return false; 69 return false;
70 70
71 // Cache the evaluator to avoid allocating one per evaluation. 71 // Cache the evaluator to avoid allocating one per evaluation.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 for (const auto& listener : m_viewportListeners) 140 for (const auto& listener : m_viewportListeners)
141 listenersToNotify.append(listener); 141 listenersToNotify.append(listener);
142 142
143 m_document->enqueueMediaQueryChangeListeners(listenersToNotify); 143 m_document->enqueueMediaQueryChangeListeners(listenersToNotify);
144 } 144 }
145 145
146 DEFINE_TRACE(MediaQueryMatcher) 146 DEFINE_TRACE(MediaQueryMatcher)
147 { 147 {
148 #if ENABLE(OILPAN) 148 #if ENABLE(OILPAN)
149 visitor->trace(m_document); 149 visitor->trace(m_document);
150 visitor->trace(m_evaluator);
150 visitor->trace(m_mediaLists); 151 visitor->trace(m_mediaLists);
151 visitor->trace(m_viewportListeners); 152 visitor->trace(m_viewportListeners);
152 #endif 153 #endif
153 } 154 }
154 155
155 } 156 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryMatcher.h ('k') | third_party/WebKit/Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698