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

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

Issue 16208004: No need to store invalid media queries. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « Source/core/css/MediaQuery.cpp ('k') | Source/core/css/MediaQueryExp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/css/MediaQuery.cpp ('k') | Source/core/css/MediaQueryExp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698