OLD | NEW |
1 /* | 1 /* |
2 * CSS Media Query Evaluator | 2 * CSS Media Query Evaluator |
3 * | 3 * |
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
5 * Copyright (C) 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2013 Apple Inc. All rights reserved. |
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 bool MediaQueryEvaluator::Eval( | 145 bool MediaQueryEvaluator::Eval( |
146 const MediaQuerySet& query_set, | 146 const MediaQuerySet& query_set, |
147 MediaQueryResultList* viewport_dependent_media_query_results, | 147 MediaQueryResultList* viewport_dependent_media_query_results, |
148 MediaQueryResultList* device_dependent_media_query_results) const { | 148 MediaQueryResultList* device_dependent_media_query_results) const { |
149 const Vector<std::unique_ptr<MediaQuery>>& queries = query_set.QueryVector(); | 149 const Vector<std::unique_ptr<MediaQuery>>& queries = query_set.QueryVector(); |
150 if (!queries.size()) | 150 if (!queries.size()) |
151 return true; // Empty query list evaluates to true. | 151 return true; // Empty query list evaluates to true. |
152 | 152 |
153 // Iterate over queries, stop if any of them eval to true (OR semantics). | 153 // Iterate over queries, stop if any of them eval to true (OR semantics). |
154 bool result = false; | 154 bool result = false; |
155 for (size_t i = 0; i < queries.size() && !result; ++i) { | 155 for (size_t i = 0; i < queries.size() && !result; ++i) |
156 // TODO(sof): CHECK() added for crbug.com/699269 diagnosis, remove sooner. | |
157 CHECK_EQ(queries.data(), query_set.QueryVector().data()); | |
158 result = Eval(*queries[i], viewport_dependent_media_query_results, | 156 result = Eval(*queries[i], viewport_dependent_media_query_results, |
159 device_dependent_media_query_results); | 157 device_dependent_media_query_results); |
160 } | |
161 | 158 |
162 return result; | 159 return result; |
163 } | 160 } |
164 | 161 |
165 template <typename T> | 162 template <typename T> |
166 bool CompareValue(T a, T b, MediaFeaturePrefix op) { | 163 bool CompareValue(T a, T b, MediaFeaturePrefix op) { |
167 switch (op) { | 164 switch (op) { |
168 case kMinPrefix: | 165 case kMinPrefix: |
169 return a >= b; | 166 return a >= b; |
170 case kMaxPrefix: | 167 case kMaxPrefix: |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 // Call the media feature evaluation function. Assume no prefix and let | 814 // Call the media feature evaluation function. Assume no prefix and let |
818 // trampoline functions override the prefix if prefix is used. | 815 // trampoline functions override the prefix if prefix is used. |
819 EvalFunc func = g_function_map->at(expr.MediaFeature().Impl()); | 816 EvalFunc func = g_function_map->at(expr.MediaFeature().Impl()); |
820 if (func) | 817 if (func) |
821 return func(expr.ExpValue(), kNoPrefix, *media_values_); | 818 return func(expr.ExpValue(), kNoPrefix, *media_values_); |
822 | 819 |
823 return false; | 820 return false; |
824 } | 821 } |
825 | 822 |
826 } // namespace blink | 823 } // namespace blink |
OLD | NEW |