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

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

Issue 335313003: MediaQueryEvaluator getting mediaType from MediaValues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a bug and added tests Created 6 years, 5 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher) 59 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher)
60 60
61 void MediaQueryMatcher::documentDestroyed() 61 void MediaQueryMatcher::documentDestroyed()
62 { 62 {
63 m_listeners.clear(); 63 m_listeners.clear();
64 m_document = nullptr; 64 m_document = nullptr;
65 } 65 }
66 66
67 AtomicString MediaQueryMatcher::mediaType() const
68 {
69 if (!m_document || !m_document->frame() || !m_document->frame()->view())
70 return nullAtom;
71
72 return m_document->frame()->view()->mediaType();
73 }
74
75 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const 67 PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const
76 { 68 {
77 if (!m_document || !m_document->frame()) 69 if (!m_document || !m_document->frame())
78 return nullptr; 70 return nullptr;
79 71
80 return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame())); 72 return adoptPtr(new MediaQueryEvaluator(m_document->frame()));
81 } 73 }
82 74
83 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media) 75 bool MediaQueryMatcher::evaluate(const MediaQuerySet* media)
84 { 76 {
85 if (!media) 77 if (!media)
86 return false; 78 return false;
87 79
88 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator()); 80 OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator());
89 return evaluator && evaluator->eval(media); 81 return evaluator && evaluator->eval(media);
90 } 82 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 { 136 {
145 visitor->trace(m_document); 137 visitor->trace(m_document);
146 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >). 138 // We don't support tracing of vectors of OwnPtrs (ie. Vector<OwnPtr<Listene r> >).
147 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled. 139 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled.
148 #if ENABLE(OILPAN) 140 #if ENABLE(OILPAN)
149 visitor->trace(m_listeners); 141 visitor->trace(m_listeners);
150 #endif 142 #endif
151 } 143 }
152 144
153 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698