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 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 | 59 |
60 using namespace MediaFeatureNames; | 60 using namespace MediaFeatureNames; |
61 | 61 |
62 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; | 62 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; |
63 | 63 |
64 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix); | 64 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix); |
65 typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap; | 65 typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap; |
66 static FunctionMap* gFunctionMap; | 66 static FunctionMap* gFunctionMap; |
67 | 67 |
68 /* | 68 /* |
69 * FIXME: following media features are not implemented: color_index, scan | 69 * FIXME: following media features are not implemented: color_index |
70 * | 70 * |
71 * color_index, min-color-index, max_color_index: It's unknown how to retrieve | 71 * color_index, min-color-index, max_color_index: It's unknown how to retrieve |
72 * the information if the display mode is indexed | 72 * the information if the display mode is indexed |
73 * scan: The "scan" media feature describes the scanning process of | |
74 * tv output devices. It's unknown how to retrieve this information from | |
75 * the platform | |
76 */ | 73 */ |
77 | 74 |
78 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) | 75 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) |
79 : m_frame(0) | 76 : m_frame(0) |
80 , m_style(0) | 77 , m_style(0) |
81 , m_expResult(mediaFeatureResult) | 78 , m_expResult(mediaFeatureResult) |
82 { | 79 { |
83 } | 80 } |
84 | 81 |
85 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m ediaFeatureResult) | 82 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m ediaFeatureResult) |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 | 734 |
738 if (!value->isPrimitiveValue()) | 735 if (!value->isPrimitiveValue()) |
739 return false; | 736 return false; |
740 | 737 |
741 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent(); | 738 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent(); |
742 return (pointer == NoPointer && id == CSSValueNone) | 739 return (pointer == NoPointer && id == CSSValueNone) |
743 || (pointer == TouchPointer && id == CSSValueCoarse) | 740 || (pointer == TouchPointer && id == CSSValueCoarse) |
744 || (pointer == MousePointer && id == CSSValueFine); | 741 || (pointer == MousePointer && id == CSSValueFine); |
745 } | 742 } |
746 | 743 |
744 static bool scanMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, Me diaFeaturePrefix) | |
745 { | |
746 String mediaType = frame->view()->mediaType(); | |
747 | |
748 // scan only applies to tv media. | |
apavlov
2013/05/15 11:29:41
Blink mostly inherits the comment style from WebKi
| |
749 if (equalIgnoringCase(mediaType, "tv")) { | |
apavlov
2013/05/15 11:29:41
Early returns are preferred, as they reduce code i
| |
750 | |
apavlov
2013/05/15 11:29:41
extra blank line
| |
751 if (!value) | |
752 return true; | |
753 | |
754 if (!value->isPrimitiveValue()) | |
755 return false; | |
756 | |
757 // If a platform interface supply progressive/interlace info for TVs in the | |
apavlov
2013/05/15 11:29:41
supply -> supplies
| |
758 // future, it needs to be handled here. For now, assume a modern TV with | |
759 // progressive display. | |
760 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent(); | |
761 return id == CSSValueProgressive; | |
762 } | |
763 | |
764 return false; | |
765 } | |
766 | |
747 static void createFunctionMap() | 767 static void createFunctionMap() |
748 { | 768 { |
749 // Create the table. | 769 // Create the table. |
750 gFunctionMap = new FunctionMap; | 770 gFunctionMap = new FunctionMap; |
751 #define ADD_TO_FUNCTIONMAP(name, str) \ | 771 #define ADD_TO_FUNCTIONMAP(name, str) \ |
752 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 772 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
753 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 773 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
754 #undef ADD_TO_FUNCTIONMAP | 774 #undef ADD_TO_FUNCTIONMAP |
755 } | 775 } |
756 | 776 |
(...skipping 12 matching lines...) Expand all Loading... | |
769 // and let trampoline functions override the prefix if prefix is | 789 // and let trampoline functions override the prefix if prefix is |
770 // used | 790 // used |
771 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 791 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
772 if (func) | 792 if (func) |
773 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 793 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
774 | 794 |
775 return false; | 795 return false; |
776 } | 796 } |
777 | 797 |
778 } // namespace | 798 } // namespace |
OLD | NEW |