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 23 matching lines...) Expand all Loading... |
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 class MediaValuesInitialViewport; | 42 class MediaValuesInitialViewport; |
43 | 43 |
44 using MediaQueryResultList = HeapVector<Member<MediaQueryResult>>; | 44 using MediaQueryResultList = Vector<MediaQueryResult>; |
45 | 45 |
46 // Class that evaluates css media queries as defined in | 46 // Class that evaluates css media queries as defined in |
47 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) | 47 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) |
48 // Special constructors are needed, if simple media queries are to be | 48 // Special constructors are needed, if simple media queries are to be |
49 // evaluated without knowledge of the medium features. This can happen | 49 // evaluated without knowledge of the medium features. This can happen |
50 // for example when parsing UA stylesheets, if evaluation is done | 50 // for example when parsing UA stylesheets, if evaluation is done |
51 // right after parsing. | 51 // right after parsing. |
52 // | 52 // |
53 // the boolean parameter is used to approximate results of evaluation, if | 53 // the boolean parameter is used to approximate results of evaluation, if |
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 |
(...skipping 21 matching lines...) Expand all Loading... |
76 // values. | 76 // values. |
77 explicit MediaQueryEvaluator(const MediaValues&); | 77 explicit MediaQueryEvaluator(const MediaValues&); |
78 | 78 |
79 explicit MediaQueryEvaluator(MediaValuesInitialViewport*); | 79 explicit MediaQueryEvaluator(MediaValuesInitialViewport*); |
80 | 80 |
81 ~MediaQueryEvaluator(); | 81 ~MediaQueryEvaluator(); |
82 | 82 |
83 bool MediaTypeMatch(const String& media_type_to_match) const; | 83 bool MediaTypeMatch(const String& media_type_to_match) const; |
84 | 84 |
85 // Evaluates a list of media queries. | 85 // Evaluates a list of media queries. |
86 bool Eval(const MediaQuerySet*, | 86 bool Eval(const MediaQuerySet&, |
87 MediaQueryResultList* viewport_dependent = nullptr, | 87 MediaQueryResultList* viewport_dependent = nullptr, |
88 MediaQueryResultList* device_dependent = nullptr) const; | 88 MediaQueryResultList* device_dependent = nullptr) const; |
89 | 89 |
90 // Evaluates media query. | 90 // Evaluates media query. |
91 bool Eval(const MediaQuery*, | 91 bool Eval(const MediaQuery&, |
92 MediaQueryResultList* viewport_dependent = nullptr, | 92 MediaQueryResultList* viewport_dependent = nullptr, |
93 MediaQueryResultList* device_dependent = nullptr) const; | 93 MediaQueryResultList* device_dependent = nullptr) const; |
94 | 94 |
95 // Evaluates media query subexpression, ie "and (media-feature: value)" part. | 95 // Evaluates media query subexpression, ie "and (media-feature: value)" part. |
96 bool Eval(const MediaQueryExp*) const; | 96 bool Eval(const MediaQueryExp&) const; |
97 | 97 |
98 DECLARE_TRACE(); | 98 DECLARE_TRACE(); |
99 | 99 |
100 private: | 100 private: |
101 const String MediaType() const; | 101 const String MediaType() const; |
102 | 102 |
103 String media_type_; | 103 String media_type_; |
104 Member<MediaValues> media_values_; | 104 Member<MediaValues> media_values_; |
105 }; | 105 }; |
106 | 106 |
107 } // namespace blink | 107 } // namespace blink |
108 #endif | 108 #endif |
OLD | NEW |