Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: Source/core/css/MediaValues.h

Issue 224733011: A sizes attribute parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed "final" syntax Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 virtual ~MediaValues() { }
31 static PassRefPtr<MediaValues> create(LocalFrame*, RenderStyle*, MediaValues Mode);
32 static PassRefPtr<MediaValues> create(MediaValuesMode,
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 55
50 int viewportWidth() const; 56 virtual PassRefPtr<MediaValues> copy() const = 0;
51 int viewportHeight() const; 57 virtual bool isSafeToSendToAnotherThread() const = 0;
52 int deviceWidth() const; 58 virtual bool computeLength(double value, unsigned short type, int& result) c onst = 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 59
67 private: 60 virtual int viewportWidth() const = 0;
68 MediaValues(LocalFrame* frame, PassRefPtr<RenderStyle> style, MediaValuesMod e mode) 61 virtual int viewportHeight() const = 0;
69 : m_style(style) 62 virtual int deviceWidth() const = 0;
70 , m_frame(frame) 63 virtual int deviceHeight() const = 0;
71 , m_mode(mode) 64 virtual float devicePixelRatio() const = 0;
72 , m_viewportWidth(0) 65 virtual int colorBitsPerComponent() const = 0;
73 , m_viewportHeight(0) 66 virtual int monochromeBitsPerComponent() const = 0;
74 , m_deviceWidth(0) 67 virtual PointerDeviceType pointer() const = 0;
75 , m_deviceHeight(0) 68 virtual bool threeDEnabled() const = 0;
76 , m_devicePixelRatio(0) 69 virtual bool scanMediaType() const = 0;
77 , m_colorBitsPerComponent(0) 70 virtual bool screenMediaType() const = 0;
78 , m_monochromeBitsPerComponent(0) 71 virtual bool printMediaType() const = 0;
79 , m_pointer(UnknownPointer) 72 virtual bool strictMode() const = 0;
80 , m_defaultFontSize(0) 73 virtual Document* document() const = 0;
81 , m_threeDEnabled(false) 74 virtual bool hasValues() const = 0;
82 , m_scanMediaType(false)
83 , m_screenMediaType(false)
84 , m_printMediaType(false)
85 , m_strictMode(false)
86 {
87 }
88 75
89 RefPtr<RenderStyle> m_style; 76 protected:
90 LocalFrame* m_frame; 77 static Document* getExecutingDocument(Document&);
91 MediaValuesMode m_mode;
92 78
93 // Members variables beyond this point must be thread safe, since they're co pied to the parser thread 79 int calculateViewportWidth(LocalFrame*, RenderStyle*) const;
94 int m_viewportWidth; 80 int calculateViewportHeight(LocalFrame*, RenderStyle*) const;
95 int m_viewportHeight; 81 int calculateDeviceWidth(LocalFrame*) const;
96 int m_deviceWidth; 82 int calculateDeviceHeight(LocalFrame*) const;
97 int m_deviceHeight; 83 bool calculateStrictMode(LocalFrame*) const;
98 float m_devicePixelRatio; 84 float calculateDevicePixelRatio(LocalFrame*) const;
99 int m_colorBitsPerComponent; 85 int calculateColorBitsPerComponent(LocalFrame*) const;
100 int m_monochromeBitsPerComponent; 86 int calculateMonochromeBitsPerComponent(LocalFrame*) const;
101 PointerDeviceType m_pointer; 87 int calculateDefaultFontSize(RenderStyle*) const;
102 int m_defaultFontSize; 88 int calculateComputedFontSize(RenderStyle*) const;
103 bool m_threeDEnabled; 89 bool calculateHasXHeight(RenderStyle*) const;
104 bool m_scanMediaType; 90 double calculateXHeight(RenderStyle*) const;
105 bool m_screenMediaType; 91 double calculateZeroWidth(RenderStyle*) const;
106 bool m_printMediaType; 92 bool calculateScanMediaType(LocalFrame*) const;
107 bool m_strictMode; 93 bool calculateScreenMediaType(LocalFrame*) const;
94 bool calculatePrintMediaType(LocalFrame*) const;
95 bool calculateThreeDEnabled(LocalFrame*) const;
96 float calculateEffectiveZoom(RenderStyle*) const;
97 MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType (LocalFrame*) const;
98
108 }; 99 };
109 100
110 } // namespace 101 } // namespace
111 #endif 102
103 #endif // MediaValues_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698