| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/text/WTFString.h" | 33 #include "wtf/text/WTFString.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 class LocalFrame; | 36 class LocalFrame; |
| 37 class MediaQuery; | 37 class MediaQuery; |
| 38 class MediaQueryExp; | 38 class MediaQueryExp; |
| 39 class MediaQueryResult; | 39 class MediaQueryResult; |
| 40 class MediaQuerySet; | 40 class MediaQuerySet; |
| 41 class MediaValues; | 41 class MediaValues; |
| 42 | 42 |
| 43 using MediaQueryResultList = WillBeHeapVector<RefPtrWillBeMember<MediaQueryResul
t>>; | 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 loadi
ng |
| 54 // of stylesheets to only those which are probable to match. | 54 // of stylesheets to only those which are probable to match. |
| 55 | 55 |
| 56 class CORE_EXPORT MediaQueryEvaluator final : public NoBaseWillBeGarbageCollecte
dFinalized<MediaQueryEvaluator> { | 56 class CORE_EXPORT MediaQueryEvaluator final : public GarbageCollectedFinalized<M
ediaQueryEvaluator> { |
| 57 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); | 57 WTF_MAKE_NONCOPYABLE(MediaQueryEvaluator); |
| 58 USING_FAST_MALLOC_WILL_BE_REMOVED(MediaQueryEvaluator); | |
| 59 public: | 58 public: |
| 60 // Creates evaluator which evaluates only simple media queries | 59 // Creates evaluator which evaluates only simple media queries |
| 61 // Evaluator returns true for "all", and returns value of \mediaFeatureResul
t | 60 // Evaluator returns true for "all", and returns value of \mediaFeatureResul
t |
| 62 // for any media features. | 61 // for any media features. |
| 63 | 62 |
| 64 explicit MediaQueryEvaluator(bool mediaFeatureResult = false); | 63 explicit MediaQueryEvaluator(bool mediaFeatureResult = false); |
| 65 | 64 |
| 66 // Creates evaluator which evaluates only simple media queries | 65 // Creates evaluator which evaluates only simple media queries |
| 67 // Evaluator returns true for acceptedMediaType and returns value of \media
featureResult | 66 // Evaluator returns true for acceptedMediaType and returns value of \media
featureResult |
| 68 // for any media features. | 67 // for any media features. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 // Evaluates media query subexpression, ie "and (media-feature: value)" part
. | 87 // Evaluates media query subexpression, ie "and (media-feature: value)" part
. |
| 89 bool eval(const MediaQueryExp*) const; | 88 bool eval(const MediaQueryExp*) const; |
| 90 | 89 |
| 91 DECLARE_TRACE(); | 90 DECLARE_TRACE(); |
| 92 | 91 |
| 93 private: | 92 private: |
| 94 const String mediaType() const; | 93 const String mediaType() const; |
| 95 | 94 |
| 96 String m_mediaType; | 95 String m_mediaType; |
| 97 bool m_expectedResult; | 96 bool m_expectedResult; |
| 98 RefPtrWillBeMember<MediaValues> m_mediaValues; | 97 Member<MediaValues> m_mediaValues; |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace blink | 100 } // namespace blink |
| 102 #endif | 101 #endif |
| OLD | NEW |