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 MediaValuesCached_h | 5 #ifndef MediaValuesCached_h |
6 #define MediaValuesCached_h | 6 #define MediaValuesCached_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/css/MediaValues.h" | 9 #include "core/css/MediaValues.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class CORE_EXPORT MediaValuesCached final : public MediaValues { | 13 class CORE_EXPORT MediaValuesCached final : public MediaValues { |
14 public: | 14 public: |
15 struct MediaValuesCachedData { | 15 struct MediaValuesCachedData final { |
16 DISALLOW_NEW(); | 16 DISALLOW_NEW(); |
17 // Members variables must be thread safe, since they're copied to the pa
rser thread | 17 // Members variables must be thread safe, since they're copied to the pa
rser thread |
18 double viewportWidth; | 18 double viewportWidth; |
19 double viewportHeight; | 19 double viewportHeight; |
20 int deviceWidth; | 20 int deviceWidth; |
21 int deviceHeight; | 21 int deviceHeight; |
22 float devicePixelRatio; | 22 float devicePixelRatio; |
23 int colorBitsPerComponent; | 23 int colorBitsPerComponent; |
24 int monochromeBitsPerComponent; | 24 int monochromeBitsPerComponent; |
25 PointerType primaryPointerType; | 25 PointerType primaryPointerType; |
(...skipping 17 matching lines...) Expand all Loading... |
43 , primaryPointerType(PointerTypeNone) | 43 , primaryPointerType(PointerTypeNone) |
44 , availablePointerTypes(PointerTypeNone) | 44 , availablePointerTypes(PointerTypeNone) |
45 , primaryHoverType(HoverTypeNone) | 45 , primaryHoverType(HoverTypeNone) |
46 , availableHoverTypes(HoverTypeNone) | 46 , availableHoverTypes(HoverTypeNone) |
47 , defaultFontSize(16) | 47 , defaultFontSize(16) |
48 , threeDEnabled(false) | 48 , threeDEnabled(false) |
49 , strictMode(true) | 49 , strictMode(true) |
50 , displayMode(WebDisplayModeBrowser) | 50 , displayMode(WebDisplayModeBrowser) |
51 { | 51 { |
52 } | 52 } |
| 53 |
| 54 explicit MediaValuesCachedData(Document&); |
| 55 |
| 56 MediaValuesCachedData deepCopy() const |
| 57 { |
| 58 MediaValuesCachedData data; |
| 59 data.viewportWidth = viewportWidth; |
| 60 data.viewportHeight = viewportHeight; |
| 61 data.deviceWidth = deviceWidth; |
| 62 data.deviceHeight = deviceHeight; |
| 63 data.devicePixelRatio = devicePixelRatio; |
| 64 data.colorBitsPerComponent = colorBitsPerComponent; |
| 65 data.monochromeBitsPerComponent = monochromeBitsPerComponent; |
| 66 data.primaryPointerType = primaryPointerType; |
| 67 data.availablePointerTypes = availablePointerTypes; |
| 68 data.primaryHoverType = primaryHoverType; |
| 69 data.availableHoverTypes = availableHoverTypes; |
| 70 data.defaultFontSize = defaultFontSize; |
| 71 data.threeDEnabled = threeDEnabled; |
| 72 data.strictMode = strictMode; |
| 73 data.mediaType = mediaType.isolatedCopy(); |
| 74 data.displayMode = displayMode; |
| 75 return data; |
| 76 } |
53 }; | 77 }; |
54 | 78 |
55 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(); | 79 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(); |
56 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(Document&); | 80 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(const MediaValuesCac
hedData&); |
57 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(LocalFrame*); | |
58 static PassRefPtrWillBeRawPtr<MediaValuesCached> create(MediaValuesCachedDat
a&); | |
59 PassRefPtrWillBeRawPtr<MediaValues> copy() const override; | 81 PassRefPtrWillBeRawPtr<MediaValues> copy() const override; |
60 bool isSafeToSendToAnotherThread() const; | |
61 bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) c
onst override; | 82 bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) c
onst override; |
62 bool computeLength(double value, CSSPrimitiveValue::UnitType, double& result
) const override; | 83 bool computeLength(double value, CSSPrimitiveValue::UnitType, double& result
) const override; |
63 | 84 |
64 double viewportWidth() const override; | 85 double viewportWidth() const override; |
65 double viewportHeight() const override; | 86 double viewportHeight() const override; |
66 int deviceWidth() const override; | 87 int deviceWidth() const override; |
67 int deviceHeight() const override; | 88 int deviceHeight() const override; |
68 float devicePixelRatio() const override; | 89 float devicePixelRatio() const override; |
69 int colorBitsPerComponent() const override; | 90 int colorBitsPerComponent() const override; |
70 int monochromeBitsPerComponent() const override; | 91 int monochromeBitsPerComponent() const override; |
(...skipping 12 matching lines...) Expand all Loading... |
83 void setViewportHeight(double); | 104 void setViewportHeight(double); |
84 | 105 |
85 protected: | 106 protected: |
86 MediaValuesCached(); | 107 MediaValuesCached(); |
87 MediaValuesCached(LocalFrame*); | 108 MediaValuesCached(LocalFrame*); |
88 MediaValuesCached(const MediaValuesCachedData&); | 109 MediaValuesCached(const MediaValuesCachedData&); |
89 | 110 |
90 MediaValuesCachedData m_data; | 111 MediaValuesCachedData m_data; |
91 }; | 112 }; |
92 | 113 |
| 114 template<> struct CrossThreadCopierBase<false, false, false, MediaValuesCached::
MediaValuesCachedData> { |
| 115 typedef MediaValuesCached::MediaValuesCachedData Type; |
| 116 static Type copy(const MediaValuesCached::MediaValuesCachedData& data) { ret
urn data.deepCopy(); } |
| 117 }; |
| 118 |
93 } // namespace blink | 119 } // namespace blink |
94 | 120 |
95 #endif // MediaValuesCached_h | 121 #endif // MediaValuesCached_h |
OLD | NEW |