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

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

Issue 240063003: Revert "A sizes attribute parser" (https://codereview.chromium.org/224733011) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/MediaQuerySetTest.cpp ('k') | Source/core/css/MediaValues.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/frame/LocalFrame.h" 8 #include "core/css/MediaQueryEvaluator.h"
9 #include "core/css/resolver/StyleResolverState.h"
10 #include "core/rendering/style/RenderStyle.h"
9 #include "wtf/RefCounted.h" 11 #include "wtf/RefCounted.h"
10 #include "wtf/RefPtr.h" 12 #include "wtf/RefPtr.h"
13 #include "wtf/text/WTFString.h"
11 14
12 namespace WebCore { 15 namespace WebCore {
13 16
14 class Document; 17 class Document;
15 class RenderStyle;
16 class CSSPrimitiveValue;
17 18
18 class MediaValues : public RefCounted<MediaValues> { 19 class MediaValues : public RefCounted<MediaValues> {
19 public: 20 public:
21 enum MediaValuesMode { CachingMode,
22 DynamicMode };
20 23
21 enum MediaValuesMode { 24 enum PointerDeviceType { TouchPointer,
22 CachingMode,
23 DynamicMode
24 };
25
26 enum PointerDeviceType {
27 TouchPointer,
28 MousePointer, 25 MousePointer,
29 NoPointer, 26 NoPointer,
30 UnknownPointer 27 UnknownPointer };
31 };
32 28
33 virtual ~MediaValues() { }
34 29
35 virtual PassRefPtr<MediaValues> copy() const = 0; 30 static PassRefPtr<MediaValues> create(Document*, MediaValuesMode);
36 virtual bool isSafeToSendToAnotherThread() const = 0; 31 static PassRefPtr<MediaValues> create(LocalFrame*, RenderStyle*, MediaValues Mode);
37 virtual bool computeLength(double value, unsigned short type, int& result) c onst = 0; 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;
38 49
39 virtual int viewportWidth() const = 0; 50 int viewportWidth() const;
40 virtual int viewportHeight() const = 0; 51 int viewportHeight() const;
41 virtual int deviceWidth() const = 0; 52 int deviceWidth() const;
42 virtual int deviceHeight() const = 0; 53 int deviceHeight() const;
43 virtual float devicePixelRatio() const = 0; 54 float devicePixelRatio() const;
44 virtual int colorBitsPerComponent() const = 0; 55 int colorBitsPerComponent() const;
45 virtual int monochromeBitsPerComponent() const = 0; 56 int monochromeBitsPerComponent() const;
46 virtual PointerDeviceType pointer() const = 0; 57 PointerDeviceType pointer() const;
47 virtual bool threeDEnabled() const = 0; 58 int defaultFontSize() const;
48 virtual bool scanMediaType() const = 0; 59 bool threeDEnabled() const;
49 virtual bool screenMediaType() const = 0; 60 bool scanMediaType() const;
50 virtual bool printMediaType() const = 0; 61 bool screenMediaType() const;
51 virtual bool strictMode() const = 0; 62 bool printMediaType() const;
52 virtual Document* document() const = 0; 63 bool strictMode() const;
53 virtual bool hasValues() const = 0; 64 RenderStyle* style() const { return m_style.get(); }
65 Document* document() const;
54 66
55 protected: 67 private:
56 static Document* getExecutingDocument(Document&); 68 MediaValues(LocalFrame* frame, PassRefPtr<RenderStyle> style, MediaValuesMod e mode)
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 }
57 88
58 int calculateViewportWidth(LocalFrame*, RenderStyle*) const; 89 RefPtr<RenderStyle> m_style;
59 int calculateViewportHeight(LocalFrame*, RenderStyle*) const; 90 LocalFrame* m_frame;
60 int calculateDeviceWidth(LocalFrame*) const; 91 MediaValuesMode m_mode;
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;
77 92
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;
78 }; 108 };
79 109
80 } // namespace 110 } // namespace
81 111 #endif
82 #endif // MediaValues_h
OLDNEW
« no previous file with comments | « Source/core/css/MediaQuerySetTest.cpp ('k') | Source/core/css/MediaValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698