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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const | 77 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const |
78 { | 78 { |
79 if (!m_document || !m_document->frame()) | 79 if (!m_document || !m_document->frame()) |
80 return nullptr; | 80 return nullptr; |
81 | 81 |
82 Element* documentElement = m_document->documentElement(); | 82 Element* documentElement = m_document->documentElement(); |
83 if (!documentElement) | 83 if (!documentElement) |
84 return nullptr; | 84 return nullptr; |
85 | 85 |
86 StyleResolver* styleResolver = m_document->styleResolver(); | 86 StyleResolver* styleResolver = m_document->styleResolver(); |
87 if (!styleResolver) | 87 ASSERT(styleResolver); |
88 return nullptr; | 88 appendPendingStyleSheetsIfNeeded(styleResolver); |
89 | 89 |
90 RefPtr<RenderStyle> rootStyle = styleResolver->styleForElement(documentEleme
nt, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules); | 90 RefPtr<RenderStyle> rootStyle = styleResolver->styleForElement(documentEleme
nt, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules); |
91 | 91 |
92 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), ro
otStyle.get())); | 92 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), ro
otStyle.get())); |
93 } | 93 } |
94 | 94 |
95 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) | 95 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) |
96 { | 96 { |
97 if (!media) | 97 if (!media) |
98 return false; | 98 return false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 ++m_evaluationRound; | 150 ++m_evaluationRound; |
151 OwnPtr<MediaQueryEvaluator> evaluator = prepareEvaluator(); | 151 OwnPtr<MediaQueryEvaluator> evaluator = prepareEvaluator(); |
152 if (!evaluator) | 152 if (!evaluator) |
153 return; | 153 return; |
154 | 154 |
155 for (size_t i = 0; i < m_listeners.size(); ++i) | 155 for (size_t i = 0; i < m_listeners.size(); ++i) |
156 m_listeners[i]->evaluate(scriptState, evaluator.get()); | 156 m_listeners[i]->evaluate(scriptState, evaluator.get()); |
157 } | 157 } |
158 | 158 |
159 } | 159 } |
OLD | NEW |