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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 namespace WebCore { | 60 namespace WebCore { |
61 | 61 |
62 using namespace MediaFeatureNames; | 62 using namespace MediaFeatureNames; |
63 | 63 |
64 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; | 64 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; |
65 | 65 |
66 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix); | 66 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix); |
67 typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap; | 67 typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap; |
68 static FunctionMap* gFunctionMap; | 68 static FunctionMap* gFunctionMap; |
69 | 69 |
70 /* | |
71 * FIXME: following media features are not implemented: scan | |
72 * | |
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 */ | |
77 | |
78 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) | 70 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) |
79 : m_frame(0) | 71 : m_frame(0) |
80 , m_style(0) | 72 , m_style(0) |
81 , m_expResult(mediaFeatureResult) | 73 , m_expResult(mediaFeatureResult) |
82 { | 74 { |
83 } | 75 } |
84 | 76 |
85 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m
ediaFeatureResult) | 77 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m
ediaFeatureResult) |
86 : m_mediaType(acceptedMediaType) | 78 : m_mediaType(acceptedMediaType) |
87 , m_frame(0) | 79 , m_frame(0) |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 | 645 |
654 if (!value->isPrimitiveValue()) | 646 if (!value->isPrimitiveValue()) |
655 return false; | 647 return false; |
656 | 648 |
657 const int id = toCSSPrimitiveValue(value)->getIdent(); | 649 const int id = toCSSPrimitiveValue(value)->getIdent(); |
658 return (pointer == NoPointer && id == CSSValueNone) | 650 return (pointer == NoPointer && id == CSSValueNone) |
659 || (pointer == TouchPointer && id == CSSValueCoarse) | 651 || (pointer == TouchPointer && id == CSSValueCoarse) |
660 || (pointer == MousePointer && id == CSSValueFine); | 652 || (pointer == MousePointer && id == CSSValueFine); |
661 } | 653 } |
662 | 654 |
| 655 static bool scanMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, Me
diaFeaturePrefix) |
| 656 { |
| 657 // Scan only applies to tv media. |
| 658 if (!equalIgnoringCase(frame->view()->mediaType(), "tv")) |
| 659 return false; |
| 660 |
| 661 if (!value) |
| 662 return true; |
| 663 |
| 664 if (!value->isPrimitiveValue()) |
| 665 return false; |
| 666 |
| 667 // If a platform interface supplies progressive/interlace info for TVs in th
e |
| 668 // future, it needs to be handled here. For now, assume a modern TV with |
| 669 // progressive display. |
| 670 const int id = toCSSPrimitiveValue(value)->getIdent(); |
| 671 return id == CSSValueProgressive; |
| 672 } |
| 673 |
663 static void createFunctionMap() | 674 static void createFunctionMap() |
664 { | 675 { |
665 // Create the table. | 676 // Create the table. |
666 gFunctionMap = new FunctionMap; | 677 gFunctionMap = new FunctionMap; |
667 #define ADD_TO_FUNCTIONMAP(name, str) \ | 678 #define ADD_TO_FUNCTIONMAP(name, str) \ |
668 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); | 679 gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval); |
669 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); | 680 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP); |
670 #undef ADD_TO_FUNCTIONMAP | 681 #undef ADD_TO_FUNCTIONMAP |
671 } | 682 } |
672 | 683 |
(...skipping 12 matching lines...) Expand all Loading... |
685 // and let trampoline functions override the prefix if prefix is | 696 // and let trampoline functions override the prefix if prefix is |
686 // used | 697 // used |
687 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 698 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
688 if (func) | 699 if (func) |
689 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 700 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
690 | 701 |
691 return false; | 702 return false; |
692 } | 703 } |
693 | 704 |
694 } // namespace | 705 } // namespace |
OLD | NEW |