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 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 class LocalFrame; | 35 class LocalFrame; |
36 class MediaQueryExp; | 36 class MediaQueryExp; |
37 class MediaQueryResult; | 37 class MediaQueryResult; |
38 class MediaQuerySet; | 38 class MediaQuerySet; |
39 class RenderStyle; | 39 class RenderStyle; |
40 | 40 |
41 typedef WillBeHeapVector<RefPtrWillBeMember<MediaQueryResult> > MediaQueryResult List; | 41 typedef WillBeHeapVector<RefPtrWillBeMember<MediaQueryResult> > MediaQueryResult List; |
42 typedef WillBePersistentHeapVector<RefPtrWillBeMember<MediaQueryResult> > WillBe PersistentMediaQueryResultList; | 42 typedef WillBePersistentHeapVector<RefPtrWillBeMember<MediaQueryResult> > WillBe PersistentMediaQueryResultList; |
43 class Document; | |
44 | |
45 class MediaValues : public RefCountedWillBeGarbageCollected<MediaValues> { | |
46 public: | |
47 // Should return a pointer that auto destructs when copied | |
48 static PassRefPtr<MediaValues> create(Document*); | |
49 static PassRefPtr<MediaValues> copy(const MediaValues*); | |
50 | |
51 int getViewportWidth() { return m_viewportWidth; } | |
52 int getViewportHeight() { return m_viewportHeight; } | |
53 int getDeviceWidth() { return m_deviceWidth; } | |
54 int getDeviceHeight() { return m_deviceHeight; } | |
55 float getPixelRatio() { return m_pixelRatio; } | |
56 int getColorBitsPerComponent() { return m_colorBitsPerComponent; } | |
57 int getMonochromeBitsPerComponent() { return m_monochromeBitsPerComponent; } | |
58 int getPointer() { return m_pointer; } | |
59 int getDefaultFontSize() { return m_defaultFontSize; } | |
60 bool getThreeDEnabled() { return m_threeDEnabled; } | |
61 String getMediaType() { return m_mediaType; } | |
62 | |
63 private: | |
64 MediaValues(int viewportWidth, | |
65 int viewportHeight, | |
66 int deviceWidth, | |
67 int deviceHeight, | |
68 float pixelRatio, | |
69 int colorBitsPerComponent, | |
70 int monochromeBitsPerComponent, | |
71 int pointer, | |
72 int defaultFontSize, | |
73 int threeDEnabled, | |
74 String mediaType) | |
75 : m_viewportWidth(viewportWidth) | |
76 , m_viewportHeight(viewportHeight) | |
77 , m_deviceWidth(deviceWidth) | |
78 , m_deviceHeight(deviceHeight) | |
79 , m_pixelRatio(pixelRatio) | |
80 , m_colorBitsPerComponent(colorBitsPerComponent) | |
81 , m_monochromeBitsPerComponent(monochromeBitsPerComponent) | |
82 , m_pointer(pointer) | |
83 , m_defaultFontSize(defaultFontSize) | |
84 , m_threeDEnabled(threeDEnabled) | |
85 , m_mediaType(mediaType.isolatedCopy()) | |
abarth-chromium
2014/03/17 19:00:01
These should be indented four more spaces
| |
86 { | |
87 } | |
88 | |
89 int m_viewportWidth; | |
90 int m_viewportHeight; | |
91 int m_deviceWidth; | |
92 int m_deviceHeight; | |
93 float m_pixelRatio; | |
94 int m_colorBitsPerComponent; | |
95 int m_monochromeBitsPerComponent; | |
96 int m_pointer; | |
97 int m_defaultFontSize; | |
98 bool m_threeDEnabled; | |
99 String m_mediaType; | |
100 }; | |
43 | 101 |
44 /** | 102 /** |
45 * Class that evaluates css media queries as defined in | 103 * Class that evaluates css media queries as defined in |
46 * CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) | 104 * CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) |
47 * Special constructors are needed, if simple media queries are to be | 105 * Special constructors are needed, if simple media queries are to be |
48 * evaluated without knowledge of the medium features. This can happen | 106 * evaluated without knowledge of the medium features. This can happen |
49 * for example when parsing UA stylesheets, if evaluation is done | 107 * for example when parsing UA stylesheets, if evaluation is done |
50 * right after parsing. | 108 * right after parsing. |
51 * | 109 * |
52 * the boolean parameter is used to approximate results of evaluation, if | 110 * the boolean parameter is used to approximate results of evaluation, if |
(...skipping 12 matching lines...) Expand all Loading... | |
65 /** Creates evaluator which evaluates only simple media queries | 123 /** Creates evaluator which evaluates only simple media queries |
66 * Evaluator returns true for acceptedMediaType and returns value of \medi afeatureResult | 124 * Evaluator returns true for acceptedMediaType and returns value of \medi afeatureResult |
67 * for any media features | 125 * for any media features |
68 */ | 126 */ |
69 MediaQueryEvaluator(const String& acceptedMediaType, bool mediaFeatureResult = false); | 127 MediaQueryEvaluator(const String& acceptedMediaType, bool mediaFeatureResult = false); |
70 MediaQueryEvaluator(const char* acceptedMediaType, bool mediaFeatureResult = false); | 128 MediaQueryEvaluator(const char* acceptedMediaType, bool mediaFeatureResult = false); |
71 | 129 |
72 /** Creates evaluator which evaluates full media queries */ | 130 /** Creates evaluator which evaluates full media queries */ |
73 MediaQueryEvaluator(const String& acceptedMediaType, LocalFrame*, RenderStyl e*); | 131 MediaQueryEvaluator(const String& acceptedMediaType, LocalFrame*, RenderStyl e*); |
74 | 132 |
133 /** Creates evaluator which evaluates in a thread-safe manner a subset of me dia values | |
134 */ | |
135 MediaQueryEvaluator(const String& acceptedMediaType, const MediaValues* , bo ol mediaFeatureResult); | |
136 | |
75 ~MediaQueryEvaluator(); | 137 ~MediaQueryEvaluator(); |
76 | 138 |
77 bool mediaTypeMatch(const String& mediaTypeToMatch) const; | 139 bool mediaTypeMatch(const String& mediaTypeToMatch) const; |
78 bool mediaTypeMatchSpecific(const char* mediaTypeToMatch) const; | 140 bool mediaTypeMatchSpecific(const char* mediaTypeToMatch) const; |
79 | 141 |
80 /** Evaluates a list of media queries */ | 142 /** Evaluates a list of media queries */ |
81 bool eval(const MediaQuerySet*, MediaQueryResultList* = 0) const; | 143 bool eval(const MediaQuerySet*, MediaQueryResultList* = 0) const; |
82 | 144 |
83 /** Evaluates media query subexpression, ie "and (media-feature: value)" par t */ | 145 /** Evaluates media query subexpression, ie "and (media-feature: value)" par t */ |
84 bool eval(const MediaQueryExp*) const; | 146 bool eval(const MediaQueryExp*) const; |
85 | 147 |
86 private: | 148 private: |
87 String m_mediaType; | 149 String m_mediaType; |
88 LocalFrame* m_frame; // Not owned. | 150 LocalFrame* m_frame; // Not owned. |
89 RefPtr<RenderStyle> m_style; | 151 RefPtrWillBeMember<RenderStyle> m_style; |
abarth-chromium
2014/03/17 19:00:01
Why did this type change?
| |
90 bool m_expResult; | 152 bool m_expResult; |
153 RefPtrWillBeMember<MediaValues> m_mediaValues; | |
91 }; | 154 }; |
92 | 155 |
93 } // namespace | 156 } // namespace |
94 #endif | 157 #endif |
OLD | NEW |