| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 using MediaQueryResultList = HeapVector<Member<MediaQueryResult>>; | 43 using MediaQueryResultList = HeapVector<Member<MediaQueryResult>>; |
| 44 | 44 |
| 45 // Class that evaluates css media queries as defined in | 45 // Class that evaluates css media queries as defined in |
| 46 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) | 46 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) |
| 47 // Special constructors are needed, if simple media queries are to be | 47 // Special constructors are needed, if simple media queries are to be |
| 48 // evaluated without knowledge of the medium features. This can happen | 48 // evaluated without knowledge of the medium features. This can happen |
| 49 // for example when parsing UA stylesheets, if evaluation is done | 49 // for example when parsing UA stylesheets, if evaluation is done |
| 50 // right after parsing. | 50 // right after parsing. |
| 51 // | 51 // |
| 52 // the boolean parameter is used to approximate results of evaluation, if | 52 // the boolean parameter is used to approximate results of evaluation, if |
| 53 // the device characteristics are not known. This can be used to prune the loadi
ng | 53 // the device characteristics are not known. This can be used to prune the |
| 54 // of stylesheets to only those which are probable to match. | 54 // loading of stylesheets to only those which are probable to match. |
| 55 | 55 |
| 56 class CORE_EXPORT MediaQueryEvaluator final | 56 class CORE_EXPORT MediaQueryEvaluator final |
| 57 : public GarbageCollectedFinalized<MediaQueryEvaluator> { | 57 : public GarbageCollectedFinalized<MediaQueryEvaluator> { |
| 58 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); | 58 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); |
| 59 | 59 |
| 60 public: | 60 public: |
| 61 static void init(); | 61 static void init(); |
| 62 | 62 |
| 63 // Creates evaluator which evaluates only simple media queries | 63 // Creates evaluator which evaluates only simple media queries |
| 64 // Evaluator returns true for "all", and returns value of \mediaFeatureResult | 64 // Evaluator returns true for "all", and returns value of \mediaFeatureResult |
| 65 // for any media features. | 65 // for any media features. |
| 66 | 66 |
| 67 explicit MediaQueryEvaluator(bool mediaFeatureResult = false); | 67 explicit MediaQueryEvaluator(bool mediaFeatureResult = false); |
| 68 | 68 |
| 69 // Creates evaluator which evaluates only simple media queries | 69 // Creates evaluator which evaluates only simple media queries |
| 70 // Evaluator returns true for acceptedMediaType and returns value of \mediafe
atureResult | 70 // Evaluator returns true for acceptedMediaType and returns value of |
| 71 // for any media features. | 71 // \mediafeatureResult for any media features. |
| 72 | 72 |
| 73 MediaQueryEvaluator(const char* acceptedMediaType, | 73 MediaQueryEvaluator(const char* acceptedMediaType, |
| 74 bool mediaFeatureResult = false); | 74 bool mediaFeatureResult = false); |
| 75 | 75 |
| 76 // Creates evaluator which evaluates full media queries. | 76 // Creates evaluator which evaluates full media queries. |
| 77 explicit MediaQueryEvaluator(LocalFrame*); | 77 explicit MediaQueryEvaluator(LocalFrame*); |
| 78 | 78 |
| 79 // Creates evaluator which evaluates in a thread-safe manner a subset of media
values. | 79 // Creates evaluator which evaluates in a thread-safe manner a subset of media |
| 80 // values. |
| 80 explicit MediaQueryEvaluator(const MediaValues&); | 81 explicit MediaQueryEvaluator(const MediaValues&); |
| 81 | 82 |
| 82 ~MediaQueryEvaluator(); | 83 ~MediaQueryEvaluator(); |
| 83 | 84 |
| 84 bool mediaTypeMatch(const String& mediaTypeToMatch) const; | 85 bool mediaTypeMatch(const String& mediaTypeToMatch) const; |
| 85 | 86 |
| 86 // Evaluates a list of media queries. | 87 // Evaluates a list of media queries. |
| 87 bool eval(const MediaQuerySet*, | 88 bool eval(const MediaQuerySet*, |
| 88 MediaQueryResultList* viewportDependent = 0, | 89 MediaQueryResultList* viewportDependent = 0, |
| 89 MediaQueryResultList* deviceDependent = 0) const; | 90 MediaQueryResultList* deviceDependent = 0) const; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 101 private: | 102 private: |
| 102 const String mediaType() const; | 103 const String mediaType() const; |
| 103 | 104 |
| 104 String m_mediaType; | 105 String m_mediaType; |
| 105 bool m_expectedResult; | 106 bool m_expectedResult; |
| 106 Member<MediaValues> m_mediaValues; | 107 Member<MediaValues> m_mediaValues; |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 } // namespace blink | 110 } // namespace blink |
| 110 #endif | 111 #endif |
| OLD | NEW |