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

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

Issue 2135083003: Initialize gFunctionMap from CoreInitializer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryEvaluator.h ('k') | no next file » | 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 650
651 if (!value.isID) 651 if (!value.isID)
652 return false; 652 return false;
653 653
654 // If a platform interface supplies progressive/interlace info for TVs in th e 654 // If a platform interface supplies progressive/interlace info for TVs in th e
655 // future, it needs to be handled here. For now, assume a modern TV with 655 // future, it needs to be handled here. For now, assume a modern TV with
656 // progressive display. 656 // progressive display.
657 return (value.id == CSSValueProgressive); 657 return (value.id == CSSValueProgressive);
658 } 658 }
659 659
660 static void createFunctionMap() 660 void MediaQueryEvaluator::init()
661 { 661 {
662 // Create the table. 662 // Create the table.
663 gFunctionMap = new FunctionMap; 663 gFunctionMap = new FunctionMap;
664 #define ADD_TO_FUNCTIONMAP(name) \ 664 #define ADD_TO_FUNCTIONMAP(name) \
665 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); 665 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval);
666 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); 666 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP);
667 #undef ADD_TO_FUNCTIONMAP 667 #undef ADD_TO_FUNCTIONMAP
668 } 668 }
669 669
670 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const 670 bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const
671 { 671 {
672 if (!m_mediaValues || !m_mediaValues->hasValues()) 672 if (!m_mediaValues || !m_mediaValues->hasValues())
673 return m_expectedResult; 673 return m_expectedResult;
674 674
675 if (!gFunctionMap) 675 DCHECK(gFunctionMap);
676 createFunctionMap();
677 676
678 // Call the media feature evaluation function. Assume no prefix and let 677 // Call the media feature evaluation function. Assume no prefix and let
679 // trampoline functions override the prefix if prefix is used. 678 // trampoline functions override the prefix if prefix is used.
680 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); 679 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
681 if (func) 680 if (func)
682 return func(expr->expValue(), NoPrefix, *m_mediaValues); 681 return func(expr->expValue(), NoPrefix, *m_mediaValues);
683 682
684 return false; 683 return false;
685 } 684 }
686 685
687 } // namespace blink 686 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryEvaluator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698