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/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
9 #include "wtf/RefCounted.h" | 9 #include "wtf/RefCounted.h" |
10 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 MousePointer, | 28 MousePointer, |
29 NoPointer, | 29 NoPointer, |
30 UnknownPointer | 30 UnknownPointer |
31 }; | 31 }; |
32 | 32 |
33 virtual ~MediaValues() { } | 33 virtual ~MediaValues() { } |
34 | 34 |
35 static PassRefPtr<MediaValues> createDynamicIfFrameExists(LocalFrame*); | 35 static PassRefPtr<MediaValues> createDynamicIfFrameExists(LocalFrame*); |
36 virtual PassRefPtr<MediaValues> copy() const = 0; | 36 virtual PassRefPtr<MediaValues> copy() const = 0; |
37 virtual bool isSafeToSendToAnotherThread() const = 0; | 37 virtual bool isSafeToSendToAnotherThread() const = 0; |
38 static bool computeLength(double value, CSSPrimitiveValue::UnitTypes, unsign
ed defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, int& result
); | 38 |
| 39 static bool computeLengthImpl(double value, CSSPrimitiveValue::UnitTypes, un
signed defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, double&
result); |
| 40 template<typename T> |
| 41 static bool computeLength(double value, CSSPrimitiveValue::UnitTypes type, u
nsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, T& res
ult) |
| 42 { |
| 43 double tempResult; |
| 44 if (!computeLengthImpl(value, type, defaultFontSize, viewportWidth, view
portHeight, tempResult)) |
| 45 return false; |
| 46 result = roundForImpreciseConversion<T>(tempResult); |
| 47 return true; |
| 48 } |
39 virtual bool computeLength(double value, CSSPrimitiveValue::UnitTypes, int&
result) const = 0; | 49 virtual bool computeLength(double value, CSSPrimitiveValue::UnitTypes, int&
result) const = 0; |
| 50 virtual bool computeLength(double value, CSSPrimitiveValue::UnitTypes, doubl
e& result) const = 0; |
40 | 51 |
41 virtual int viewportWidth() const = 0; | 52 virtual int viewportWidth() const = 0; |
42 virtual int viewportHeight() const = 0; | 53 virtual int viewportHeight() const = 0; |
43 virtual int deviceWidth() const = 0; | 54 virtual int deviceWidth() const = 0; |
44 virtual int deviceHeight() const = 0; | 55 virtual int deviceHeight() const = 0; |
45 virtual float devicePixelRatio() const = 0; | 56 virtual float devicePixelRatio() const = 0; |
46 virtual int colorBitsPerComponent() const = 0; | 57 virtual int colorBitsPerComponent() const = 0; |
47 virtual int monochromeBitsPerComponent() const = 0; | 58 virtual int monochromeBitsPerComponent() const = 0; |
48 virtual PointerDeviceType pointer() const = 0; | 59 virtual PointerDeviceType pointer() const = 0; |
49 virtual bool threeDEnabled() const = 0; | 60 virtual bool threeDEnabled() const = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
68 bool calculateScreenMediaType(LocalFrame*) const; | 79 bool calculateScreenMediaType(LocalFrame*) const; |
69 bool calculatePrintMediaType(LocalFrame*) const; | 80 bool calculatePrintMediaType(LocalFrame*) const; |
70 bool calculateThreeDEnabled(LocalFrame*) const; | 81 bool calculateThreeDEnabled(LocalFrame*) const; |
71 MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType
(LocalFrame*) const; | 82 MediaValues::PointerDeviceType calculateLeastCapablePrimaryPointerDeviceType
(LocalFrame*) const; |
72 | 83 |
73 }; | 84 }; |
74 | 85 |
75 } // namespace | 86 } // namespace |
76 | 87 |
77 #endif // MediaValues_h | 88 #endif // MediaValues_h |
OLD | NEW |