| 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 20 matching lines...) Expand all Loading... |
| 31 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 MediaQueryMatcher* MediaQueryMatcher::create(Document& document) { | 35 MediaQueryMatcher* MediaQueryMatcher::create(Document& document) { |
| 36 return new MediaQueryMatcher(document); | 36 return new MediaQueryMatcher(document); |
| 37 } | 37 } |
| 38 | 38 |
| 39 MediaQueryMatcher::MediaQueryMatcher(Document& document) | 39 MediaQueryMatcher::MediaQueryMatcher(Document& document) |
| 40 : m_document(&document) { | 40 : m_document(&document) { |
| 41 ASSERT(m_document); | 41 DCHECK(m_document); |
| 42 } | 42 } |
| 43 | 43 |
| 44 MediaQueryMatcher::~MediaQueryMatcher() {} | 44 MediaQueryMatcher::~MediaQueryMatcher() {} |
| 45 | 45 |
| 46 void MediaQueryMatcher::documentDetached() { | 46 void MediaQueryMatcher::documentDetached() { |
| 47 m_document = nullptr; | 47 m_document = nullptr; |
| 48 m_evaluator = nullptr; | 48 m_evaluator = nullptr; |
| 49 } | 49 } |
| 50 | 50 |
| 51 MediaQueryEvaluator* MediaQueryMatcher::createEvaluator() const { | 51 MediaQueryEvaluator* MediaQueryMatcher::createEvaluator() const { |
| 52 if (!m_document || !m_document->frame()) | 52 if (!m_document || !m_document->frame()) |
| 53 return nullptr; | 53 return nullptr; |
| 54 | 54 |
| 55 return new MediaQueryEvaluator(m_document->frame()); | 55 return new MediaQueryEvaluator(m_document->frame()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) { | 58 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) { |
| 59 ASSERT(!m_document || m_document->frame() || !m_evaluator); | 59 DCHECK(!m_document || m_document->frame() || !m_evaluator); |
| 60 | 60 |
| 61 if (!media) | 61 if (!media) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 // Cache the evaluator to avoid allocating one per evaluation. | 64 // Cache the evaluator to avoid allocating one per evaluation. |
| 65 if (!m_evaluator) | 65 if (!m_evaluator) |
| 66 m_evaluator = createEvaluator(); | 66 m_evaluator = createEvaluator(); |
| 67 | 67 |
| 68 if (m_evaluator) | 68 if (m_evaluator) |
| 69 return m_evaluator->eval(media); | 69 return m_evaluator->eval(media); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 DEFINE_TRACE(MediaQueryMatcher) { | 133 DEFINE_TRACE(MediaQueryMatcher) { |
| 134 visitor->trace(m_document); | 134 visitor->trace(m_document); |
| 135 visitor->trace(m_evaluator); | 135 visitor->trace(m_evaluator); |
| 136 visitor->trace(m_mediaLists); | 136 visitor->trace(m_mediaLists); |
| 137 visitor->trace(m_viewportListeners); | 137 visitor->trace(m_viewportListeners); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |