| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 const Vector<OwnPtr<MediaQuery> >& queries = querySet->queryVector(); | 125 const Vector<OwnPtr<MediaQuery> >& queries = querySet->queryVector(); |
| 126 if (!queries.size()) | 126 if (!queries.size()) |
| 127 return true; // empty query list evaluates to true | 127 return true; // empty query list evaluates to true |
| 128 | 128 |
| 129 // iterate over queries, stop if any of them eval to true (OR semantics) | 129 // iterate over queries, stop if any of them eval to true (OR semantics) |
| 130 bool result = false; | 130 bool result = false; |
| 131 for (size_t i = 0; i < queries.size() && !result; ++i) { | 131 for (size_t i = 0; i < queries.size() && !result; ++i) { |
| 132 MediaQuery* query = queries[i].get(); | 132 MediaQuery* query = queries[i].get(); |
| 133 | 133 |
| 134 if (query->ignored()) | |
| 135 continue; | |
| 136 | |
| 137 if (mediaTypeMatch(query->mediaType())) { | 134 if (mediaTypeMatch(query->mediaType())) { |
| 138 const Vector<OwnPtr<MediaQueryExp> >* exps = query->expressions(); | 135 const Vector<OwnPtr<MediaQueryExp> >* exps = query->expressions(); |
| 139 // iterate through expressions, stop if any of them eval to false | 136 // iterate through expressions, stop if any of them eval to false |
| 140 // (AND semantics) | 137 // (AND semantics) |
| 141 size_t j = 0; | 138 size_t j = 0; |
| 142 for (; j < exps->size(); ++j) { | 139 for (; j < exps->size(); ++j) { |
| 143 bool exprResult = eval(exps->at(j).get()); | 140 bool exprResult = eval(exps->at(j).get()); |
| 144 if (styleResolver && exps->at(j)->isViewportDependent()) | 141 if (styleResolver && exps->at(j)->isViewportDependent()) |
| 145 styleResolver->addViewportDependentMediaQueryResult(exps->at
(j).get(), exprResult); | 142 styleResolver->addViewportDependentMediaQueryResult(exps->at
(j).get(), exprResult); |
| 146 if (!exprResult) | 143 if (!exprResult) |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 671 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
| 675 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 672 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
| 676 #undef ADD_TO_FUNCTIONMAP | 673 #undef ADD_TO_FUNCTIONMAP |
| 677 } | 674 } |
| 678 | 675 |
| 679 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const | 676 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const |
| 680 { | 677 { |
| 681 if (!m_frame || !m_style) | 678 if (!m_frame || !m_style) |
| 682 return m_expResult; | 679 return m_expResult; |
| 683 | 680 |
| 684 if (!expr->isValid()) | |
| 685 return false; | |
| 686 | |
| 687 if (!gFunctionMap) | 681 if (!gFunctionMap) |
| 688 createFunctionMap(); | 682 createFunctionMap(); |
| 689 | 683 |
| 690 // call the media feature evaluation function. Assume no prefix | 684 // call the media feature evaluation function. Assume no prefix |
| 691 // and let trampoline functions override the prefix if prefix is | 685 // and let trampoline functions override the prefix if prefix is |
| 692 // used | 686 // used |
| 693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 687 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
| 694 if (func) | 688 if (func) |
| 695 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 689 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
| 696 | 690 |
| 697 return false; | 691 return false; |
| 698 } | 692 } |
| 699 | 693 |
| 700 } // namespace | 694 } // namespace |
| OLD | NEW |