OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaValues_h | 5 #ifndef MediaValues_h |
6 #define MediaValues_h | 6 #define MediaValues_h |
7 | 7 |
8 #include "core/css/MediaQueryEvaluator.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/css/resolver/StyleResolverState.h" | |
10 #include "core/rendering/style/RenderStyle.h" | |
11 #include "wtf/RefCounted.h" | 9 #include "wtf/RefCounted.h" |
12 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
13 #include "wtf/text/WTFString.h" | |
14 | 11 |
15 namespace WebCore { | 12 namespace WebCore { |
16 | 13 |
17 class Document; | 14 class Document; |
| 15 class RenderStyle; |
| 16 class CSSPrimitiveValue; |
18 | 17 |
19 class MediaValues : public RefCounted<MediaValues> { | 18 class MediaValues : public RefCounted<MediaValues> { |
20 public: | 19 public: |
21 enum MediaValuesMode { CachingMode, | |
22 DynamicMode }; | |
23 | 20 |
24 enum PointerDeviceType { TouchPointer, | 21 enum MediaValuesMode { |
| 22 CachingMode, |
| 23 DynamicMode |
| 24 }; |
| 25 |
| 26 enum PointerDeviceType { |
| 27 TouchPointer, |
25 MousePointer, | 28 MousePointer, |
26 NoPointer, | 29 NoPointer, |
27 UnknownPointer }; | 30 UnknownPointer |
| 31 }; |
28 | 32 |
| 33 virtual ~MediaValues() { } |
29 | 34 |
30 static PassRefPtr<MediaValues> create(Document*, MediaValuesMode); | 35 virtual PassRefPtr<MediaValues> copy() const = 0; |
31 static PassRefPtr<MediaValues> create(LocalFrame*, RenderStyle*, MediaValues
Mode); | 36 virtual bool isSafeToSendToAnotherThread() const = 0; |
32 static PassRefPtr<MediaValues> create(MediaValuesMode, | 37 virtual bool computeLength(double value, unsigned short type, int& result) c
onst = 0; |
33 int viewportWidth, | |
34 int viewportHeight, | |
35 int deviceWidth, | |
36 int deviceHeight, | |
37 float devicePixelRatio, | |
38 int colorBitsPerComponent, | |
39 int monochromeBitsPerComponent, | |
40 PointerDeviceType, | |
41 int defaultFontSize, | |
42 bool threeDEnabled, | |
43 bool scanMediaType, | |
44 bool screenMediaType, | |
45 bool printMediaType, | |
46 bool strictMode); | |
47 PassRefPtr<MediaValues> copy() const; | |
48 bool isSafeToSendToAnotherThread() const; | |
49 | 38 |
50 int viewportWidth() const; | 39 virtual int viewportWidth() const = 0; |
51 int viewportHeight() const; | 40 virtual int viewportHeight() const = 0; |
52 int deviceWidth() const; | 41 virtual int deviceWidth() const = 0; |
53 int deviceHeight() const; | 42 virtual int deviceHeight() const = 0; |
54 float devicePixelRatio() const; | 43 virtual float devicePixelRatio() const = 0; |
55 int colorBitsPerComponent() const; | 44 virtual int colorBitsPerComponent() const = 0; |
56 int monochromeBitsPerComponent() const; | 45 virtual int monochromeBitsPerComponent() const = 0; |
57 PointerDeviceType pointer() const; | 46 virtual PointerDeviceType pointer() const = 0; |
58 int defaultFontSize() const; | 47 virtual bool threeDEnabled() const = 0; |
59 bool threeDEnabled() const; | 48 virtual bool scanMediaType() const = 0; |
60 bool scanMediaType() const; | 49 virtual bool screenMediaType() const = 0; |
61 bool screenMediaType() const; | 50 virtual bool printMediaType() const = 0; |
62 bool printMediaType() const; | 51 virtual bool strictMode() const = 0; |
63 bool strictMode() const; | 52 virtual Document* document() const = 0; |
64 RenderStyle* style() const { return m_style.get(); } | 53 virtual bool hasValues() const = 0; |
65 Document* document() const; | |
66 | 54 |
67 private: | 55 protected: |
68 MediaValues(LocalFrame* frame, PassRefPtr<RenderStyle> style, MediaValuesMod
e mode) | 56 static Document* getExecutingDocument(Document&); |
69 : m_style(style) | |
70 , m_frame(frame) | |
71 , m_mode(mode) | |
72 , m_viewportWidth(0) | |
73 , m_viewportHeight(0) | |
74 , m_deviceWidth(0) | |
75 , m_deviceHeight(0) | |
76 , m_devicePixelRatio(0) | |
77 , m_colorBitsPerComponent(0) | |
78 , m_monochromeBitsPerComponent(0) | |
79 , m_pointer(UnknownPointer) | |
80 , m_defaultFontSize(0) | |
81 , m_threeDEnabled(false) | |
82 , m_scanMediaType(false) | |
83 , m_screenMediaType(false) | |
84 , m_printMediaType(false) | |
85 , m_strictMode(false) | |
86 { | |
87 } | |
88 | 57 |
89 RefPtr<RenderStyle> m_style; | 58 int calculateViewportWidth(LocalFrame*) const; |
90 LocalFrame* m_frame; | 59 int calculateViewportHeight(LocalFrame*) const; |
91 MediaValuesMode m_mode; | 60 int calculateDeviceWidth(LocalFrame*) const; |
| 61 int calculateDeviceHeight(LocalFrame*) const; |
| 62 bool calculateStrictMode(LocalFrame*) const; |
| 63 float calculateDevicePixelRatio(LocalFrame*) const; |
| 64 int calculateColorBitsPerComponent(LocalFrame*) const; |
| 65 int calculateMonochromeBitsPerComponent(LocalFrame*) const; |
| 66 int calculateDefaultFontSize(RenderStyle*) const; |
| 67 int calculateComputedFontSize(RenderStyle*) const; |
| 68 bool calculateHasXHeight(RenderStyle*) const; |
| 69 double calculateXHeight(RenderStyle*) const; |
| 70 double calculateZeroWidth(RenderStyle*) const; |
| 71 bool calculateScanMediaType(LocalFrame*) const; |
| 72 bool calculateScreenMediaType(LocalFrame*) const; |
| 73 bool calculatePrintMediaType(LocalFrame*) const; |
| 74 bool calculateThreeDEnabled(LocalFrame*) const; |
| 75 float calculateEffectiveZoom(RenderStyle*) const; |
| 76 MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType
(LocalFrame*) const; |
92 | 77 |
93 // Members variables beyond this point must be thread safe, since they're co
pied to the parser thread | |
94 int m_viewportWidth; | |
95 int m_viewportHeight; | |
96 int m_deviceWidth; | |
97 int m_deviceHeight; | |
98 float m_devicePixelRatio; | |
99 int m_colorBitsPerComponent; | |
100 int m_monochromeBitsPerComponent; | |
101 PointerDeviceType m_pointer; | |
102 int m_defaultFontSize; | |
103 bool m_threeDEnabled; | |
104 bool m_scanMediaType; | |
105 bool m_screenMediaType; | |
106 bool m_printMediaType; | |
107 bool m_strictMode; | |
108 }; | 78 }; |
109 | 79 |
110 } // namespace | 80 } // namespace |
111 #endif | 81 |
| 82 #endif // MediaValues_h |
OLD | NEW |