| 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 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // the device characteristics are not known. This can be used to prune the | 54 // the device characteristics are not known. This can be used to prune the |
| 55 // loading of stylesheets to only those which are probable to match. | 55 // loading of stylesheets to only those which are probable to match. |
| 56 | 56 |
| 57 class CORE_EXPORT MediaQueryEvaluator final | 57 class CORE_EXPORT MediaQueryEvaluator final |
| 58 : public GarbageCollectedFinalized<MediaQueryEvaluator> { | 58 : public GarbageCollectedFinalized<MediaQueryEvaluator> { |
| 59 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); | 59 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); |
| 60 | 60 |
| 61 public: | 61 public: |
| 62 static void init(); | 62 static void init(); |
| 63 | 63 |
| 64 // Creates evaluator which evaluates only simple media queries | 64 // Creates evaluator which evaluates to true for all media queries. |
| 65 // Evaluator returns true for "all", and returns value of \mediaFeatureResult | 65 MediaQueryEvaluator() {} |
| 66 // for any media features. | |
| 67 | |
| 68 explicit MediaQueryEvaluator(bool mediaFeatureResult = false); | |
| 69 | 66 |
| 70 // Creates evaluator which evaluates only simple media queries | 67 // Creates evaluator which evaluates only simple media queries |
| 71 // Evaluator returns true for acceptedMediaType and returns value of | 68 // Evaluator returns true for acceptedMediaType and returns true for any media |
| 72 // \mediafeatureResult for any media features. | 69 // features. |
| 73 | 70 MediaQueryEvaluator(const char* acceptedMediaType); |
| 74 MediaQueryEvaluator(const char* acceptedMediaType, | |
| 75 bool mediaFeatureResult = false); | |
| 76 | 71 |
| 77 // Creates evaluator which evaluates full media queries. | 72 // Creates evaluator which evaluates full media queries. |
| 78 explicit MediaQueryEvaluator(LocalFrame*); | 73 explicit MediaQueryEvaluator(LocalFrame*); |
| 79 | 74 |
| 80 // Creates evaluator which evaluates in a thread-safe manner a subset of media | 75 // Creates evaluator which evaluates in a thread-safe manner a subset of media |
| 81 // values. | 76 // values. |
| 82 explicit MediaQueryEvaluator(const MediaValues&); | 77 explicit MediaQueryEvaluator(const MediaValues&); |
| 83 | 78 |
| 84 explicit MediaQueryEvaluator(MediaValuesInitialViewport*); | 79 explicit MediaQueryEvaluator(MediaValuesInitialViewport*); |
| 85 | 80 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 | 94 |
| 100 // Evaluates media query subexpression, ie "and (media-feature: value)" part. | 95 // Evaluates media query subexpression, ie "and (media-feature: value)" part. |
| 101 bool eval(const MediaQueryExp*) const; | 96 bool eval(const MediaQueryExp*) const; |
| 102 | 97 |
| 103 DECLARE_TRACE(); | 98 DECLARE_TRACE(); |
| 104 | 99 |
| 105 private: | 100 private: |
| 106 const String mediaType() const; | 101 const String mediaType() const; |
| 107 | 102 |
| 108 String m_mediaType; | 103 String m_mediaType; |
| 109 bool m_expectedResult = false; | |
| 110 Member<MediaValues> m_mediaValues; | 104 Member<MediaValues> m_mediaValues; |
| 111 }; | 105 }; |
| 112 | 106 |
| 113 } // namespace blink | 107 } // namespace blink |
| 114 #endif | 108 #endif |
| OLD | NEW |