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 struct MediaValuesInitializer { | |
34 int viewportWidth; | |
35 int viewportHeight; | |
36 int deviceWidth; | |
37 int deviceHeight; | |
38 float devicePixelRatio; | |
39 int colorBitsPerComponent; | |
40 int monochromeBitsPerComponent; | |
41 PointerDeviceType pointer; | |
42 int defaultFontSize; | |
43 int computedFontSize; | |
44 bool hasXHeight; | |
45 double xHeight; | |
46 double zeroWidth; | |
47 bool threeDEnabled; | |
48 bool scanMediaType; | |
49 bool screenMediaType; | |
50 bool printMediaType; | |
51 bool strictMode; | |
52 }; | |
29 | 53 |
30 static PassRefPtr<MediaValues> create(Document*, MediaValuesMode); | 54 static PassRefPtr<MediaValues> create(Document&, MediaValuesMode); |
31 static PassRefPtr<MediaValues> create(LocalFrame*, RenderStyle*, MediaValues Mode); | 55 static PassRefPtr<MediaValues> create(PassRefPtr<LocalFrame>, PassRefPtr<Ren derStyle>, MediaValuesMode); |
eseidel
2014/04/14 23:10:13
Should this be on the base class or the subclass?
| |
32 static PassRefPtr<MediaValues> create(MediaValuesMode, | 56 static PassRefPtr<MediaValues> createCached(MediaValuesInitializer&); |
eseidel
2014/04/14 23:10:13
Maybe this should move to MediaValuesCached::creat
| |
33 int viewportWidth, | 57 virtual ~MediaValues() { } |
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 | 58 |
50 int viewportWidth() const; | 59 virtual PassRefPtr<MediaValues> copy() const = 0; |
eseidel
2014/04/14 23:10:13
Does this create a cached copy or a dynamic one?
| |
51 int viewportHeight() const; | 60 virtual bool isSafeToSendToAnotherThread() const = 0; |
eseidel
2014/04/14 23:10:13
This is always false for MediaValuesDynamic, no?
| |
52 int deviceWidth() const; | 61 virtual bool computeLength(CSSPrimitiveValue&, int& result) const = 0; |
53 int deviceHeight() const; | |
54 float devicePixelRatio() const; | |
55 int colorBitsPerComponent() const; | |
56 int monochromeBitsPerComponent() const; | |
57 PointerDeviceType pointer() const; | |
58 int defaultFontSize() const; | |
59 bool threeDEnabled() const; | |
60 bool scanMediaType() const; | |
61 bool screenMediaType() const; | |
62 bool printMediaType() const; | |
63 bool strictMode() const; | |
64 RenderStyle* style() const { return m_style.get(); } | |
65 Document* document() const; | |
66 | 62 |
67 private: | 63 virtual int viewportWidth() const = 0; |
68 MediaValues(LocalFrame* frame, PassRefPtr<RenderStyle> style, MediaValuesMod e mode) | 64 virtual int viewportHeight() const = 0; |
69 : m_style(style) | 65 virtual int deviceWidth() const = 0; |
70 , m_frame(frame) | 66 virtual int deviceHeight() const = 0; |
71 , m_mode(mode) | 67 virtual float devicePixelRatio() const = 0; |
72 , m_viewportWidth(0) | 68 virtual int colorBitsPerComponent() const = 0; |
73 , m_viewportHeight(0) | 69 virtual int monochromeBitsPerComponent() const = 0; |
74 , m_deviceWidth(0) | 70 virtual PointerDeviceType pointer() const = 0; |
75 , m_deviceHeight(0) | 71 virtual bool threeDEnabled() const = 0; |
76 , m_devicePixelRatio(0) | 72 virtual bool scanMediaType() const = 0; |
77 , m_colorBitsPerComponent(0) | 73 virtual bool screenMediaType() const = 0; |
78 , m_monochromeBitsPerComponent(0) | 74 virtual bool printMediaType() const = 0; |
79 , m_pointer(UnknownPointer) | 75 virtual bool strictMode() const = 0; |
80 , m_defaultFontSize(0) | 76 virtual Document* document() const = 0; |
81 , m_threeDEnabled(false) | 77 virtual bool hasValues() const = 0; |
82 , m_scanMediaType(false) | |
83 , m_screenMediaType(false) | |
84 , m_printMediaType(false) | |
85 , m_strictMode(false) | |
86 { | |
87 } | |
88 | 78 |
89 RefPtr<RenderStyle> m_style; | 79 protected: |
90 LocalFrame* m_frame; | 80 int calculateViewportWidth(LocalFrame*, RenderStyle*) const; |
91 MediaValuesMode m_mode; | 81 int calculateViewportHeight(LocalFrame*, RenderStyle*) const; |
82 int calculateDeviceWidth(LocalFrame*) const; | |
83 int calculateDeviceHeight(LocalFrame*) const; | |
84 bool calculateStrictMode(LocalFrame*) const; | |
85 float calculateDevicePixelRatio(LocalFrame*) const; | |
86 int calculateColorBitsPerComponent(LocalFrame*) const; | |
87 int calculateMonochromeBitsPerComponent(LocalFrame*) const; | |
88 int calculateDefaultFontSize(RenderStyle*) const; | |
89 int calculateComputedFontSize(RenderStyle*) const; | |
90 bool calculateHasXHeight(RenderStyle*) const; | |
91 double calculateXHeight(RenderStyle*) const; | |
92 double calculateZeroWidth(RenderStyle*) const; | |
93 bool calculateScanMediaType(LocalFrame*) const; | |
94 bool calculateScreenMediaType(LocalFrame*) const; | |
95 bool calculatePrintMediaType(LocalFrame*) const; | |
96 bool calculateThreeDEnabled(LocalFrame*) const; | |
97 float calculateEffectiveZoom(RenderStyle*) const; | |
98 MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType (LocalFrame*) const; | |
92 | 99 |
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 }; | 100 }; |
109 | 101 |
110 } // namespace | 102 } // namespace |
111 #endif | 103 |
104 #endif // MediaValues_h | |
OLD | NEW |