Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 return nullAtom; | 70 return nullAtom; |
| 71 | 71 |
| 72 return m_document->frame()->view()->mediaType(); | 72 return m_document->frame()->view()->mediaType(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const | 75 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const |
| 76 { | 76 { |
| 77 if (!m_document || !m_document->frame()) | 77 if (!m_document || !m_document->frame()) |
| 78 return nullptr; | 78 return nullptr; |
| 79 | 79 |
| 80 Element* documentElement = m_document->documentElement(); | 80 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame())); |
| 81 if (!documentElement) | |
| 82 return nullptr; | |
| 83 | |
| 84 StyleResolver& styleResolver = m_document->ensureStyleResolver(); | |
| 85 RefPtr<RenderStyle> rootStyle = styleResolver.styleForElement(documentElemen t, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules); | |
|
eseidel
2014/04/19 00:42:15
Yes, you're removing this recalc, so it's not surp
| |
| 86 | |
| 87 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), ro otStyle.get())); | |
| 88 } | 81 } |
| 89 | 82 |
| 90 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) | 83 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) |
| 91 { | 84 { |
| 92 if (!media) | 85 if (!media) |
| 93 return false; | 86 return false; |
| 94 | 87 |
| 95 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator()); | 88 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator()); |
| 96 return evaluator && evaluator->eval(media); | 89 return evaluator && evaluator->eval(media); |
| 97 } | 90 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 void MediaQueryMatcher::trace(Visitor* visitor) | 147 void MediaQueryMatcher::trace(Visitor* visitor) |
| 155 { | 148 { |
| 156 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >). | 149 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >). |
| 157 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled. | 150 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled. |
| 158 #if ENABLE(OILPAN) | 151 #if ENABLE(OILPAN) |
| 159 visitor->trace(m_listeners); | 152 visitor->trace(m_listeners); |
| 160 #endif | 153 #endif |
| 161 } | 154 } |
| 162 | 155 |
| 163 } | 156 } |
| OLD | NEW |