| 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 #include "platform/CrossThreadCopier.h" | 10 #include "platform/CrossThreadCopier.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class CORE_EXPORT MediaValuesCached final : public MediaValues { | 14 class CORE_EXPORT MediaValuesCached final : public MediaValues { |
| 15 public: | 15 public: |
| 16 struct MediaValuesCachedData final { | 16 struct CORE_EXPORT MediaValuesCachedData final { |
| 17 DISALLOW_NEW(); | 17 DISALLOW_NEW(); |
| 18 // Members variables must be thread safe, since they're copied to the parser | 18 // Members variables must be thread safe, since they're copied to the parser |
| 19 // thread | 19 // thread |
| 20 double viewportWidth; | 20 double viewportWidth; |
| 21 double viewportHeight; | 21 double viewportHeight; |
| 22 int deviceWidth; | 22 int deviceWidth; |
| 23 int deviceHeight; | 23 int deviceHeight; |
| 24 float devicePixelRatio; | 24 float devicePixelRatio; |
| 25 int colorBitsPerComponent; | 25 int colorBitsPerComponent; |
| 26 int monochromeBitsPerComponent; | 26 int monochromeBitsPerComponent; |
| 27 PointerType primaryPointerType; | 27 PointerType primaryPointerType; |
| 28 int availablePointerTypes; | 28 int availablePointerTypes; |
| 29 HoverType primaryHoverType; | 29 HoverType primaryHoverType; |
| 30 int availableHoverTypes; | 30 int availableHoverTypes; |
| 31 int defaultFontSize; | 31 int defaultFontSize; |
| 32 bool threeDEnabled; | 32 bool threeDEnabled; |
| 33 bool strictMode; | 33 bool strictMode; |
| 34 String mediaType; | 34 String mediaType; |
| 35 WebDisplayMode displayMode; | 35 WebDisplayMode displayMode; |
| 36 DisplayShape displayShape; | 36 DisplayShape displayShape; |
| 37 ColorSpaceGamut colorGamut; |
| 37 | 38 |
| 38 MediaValuesCachedData() | 39 MediaValuesCachedData(); |
| 39 : viewportWidth(0), | |
| 40 viewportHeight(0), | |
| 41 deviceWidth(0), | |
| 42 deviceHeight(0), | |
| 43 devicePixelRatio(1.0), | |
| 44 colorBitsPerComponent(24), | |
| 45 monochromeBitsPerComponent(0), | |
| 46 primaryPointerType(PointerTypeNone), | |
| 47 availablePointerTypes(PointerTypeNone), | |
| 48 primaryHoverType(HoverTypeNone), | |
| 49 availableHoverTypes(HoverTypeNone), | |
| 50 defaultFontSize(16), | |
| 51 threeDEnabled(false), | |
| 52 strictMode(true), | |
| 53 displayMode(WebDisplayModeBrowser), | |
| 54 displayShape(DisplayShapeRect) {} | |
| 55 | |
| 56 explicit MediaValuesCachedData(Document&); | 40 explicit MediaValuesCachedData(Document&); |
| 57 | 41 |
| 58 MediaValuesCachedData deepCopy() const { | 42 MediaValuesCachedData deepCopy() const { |
| 59 MediaValuesCachedData data; | 43 MediaValuesCachedData data; |
| 60 data.viewportWidth = viewportWidth; | 44 data.viewportWidth = viewportWidth; |
| 61 data.viewportHeight = viewportHeight; | 45 data.viewportHeight = viewportHeight; |
| 62 data.deviceWidth = deviceWidth; | 46 data.deviceWidth = deviceWidth; |
| 63 data.deviceHeight = deviceHeight; | 47 data.deviceHeight = deviceHeight; |
| 64 data.devicePixelRatio = devicePixelRatio; | 48 data.devicePixelRatio = devicePixelRatio; |
| 65 data.colorBitsPerComponent = colorBitsPerComponent; | 49 data.colorBitsPerComponent = colorBitsPerComponent; |
| 66 data.monochromeBitsPerComponent = monochromeBitsPerComponent; | 50 data.monochromeBitsPerComponent = monochromeBitsPerComponent; |
| 67 data.primaryPointerType = primaryPointerType; | 51 data.primaryPointerType = primaryPointerType; |
| 68 data.availablePointerTypes = availablePointerTypes; | 52 data.availablePointerTypes = availablePointerTypes; |
| 69 data.primaryHoverType = primaryHoverType; | 53 data.primaryHoverType = primaryHoverType; |
| 70 data.availableHoverTypes = availableHoverTypes; | 54 data.availableHoverTypes = availableHoverTypes; |
| 71 data.defaultFontSize = defaultFontSize; | 55 data.defaultFontSize = defaultFontSize; |
| 72 data.threeDEnabled = threeDEnabled; | 56 data.threeDEnabled = threeDEnabled; |
| 73 data.strictMode = strictMode; | 57 data.strictMode = strictMode; |
| 74 data.mediaType = mediaType.isolatedCopy(); | 58 data.mediaType = mediaType.isolatedCopy(); |
| 75 data.displayMode = displayMode; | 59 data.displayMode = displayMode; |
| 76 data.displayShape = displayShape; | 60 data.displayShape = displayShape; |
| 61 data.colorGamut = colorGamut; |
| 77 return data; | 62 return data; |
| 78 } | 63 } |
| 79 }; | 64 }; |
| 80 | 65 |
| 81 static MediaValuesCached* create(); | 66 static MediaValuesCached* create(); |
| 82 static MediaValuesCached* create(const MediaValuesCachedData&); | 67 static MediaValuesCached* create(const MediaValuesCachedData&); |
| 83 MediaValues* copy() const override; | 68 MediaValues* copy() const override; |
| 84 bool computeLength(double value, | 69 bool computeLength(double value, |
| 85 CSSPrimitiveValue::UnitType, | 70 CSSPrimitiveValue::UnitType, |
| 86 int& result) const override; | 71 int& result) const override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 int availablePointerTypes() const override; | 84 int availablePointerTypes() const override; |
| 100 HoverType primaryHoverType() const override; | 85 HoverType primaryHoverType() const override; |
| 101 int availableHoverTypes() const override; | 86 int availableHoverTypes() const override; |
| 102 bool threeDEnabled() const override; | 87 bool threeDEnabled() const override; |
| 103 bool strictMode() const override; | 88 bool strictMode() const override; |
| 104 Document* document() const override; | 89 Document* document() const override; |
| 105 bool hasValues() const override; | 90 bool hasValues() const override; |
| 106 const String mediaType() const override; | 91 const String mediaType() const override; |
| 107 WebDisplayMode displayMode() const override; | 92 WebDisplayMode displayMode() const override; |
| 108 DisplayShape displayShape() const override; | 93 DisplayShape displayShape() const override; |
| 94 ColorSpaceGamut colorGamut() const override; |
| 109 | 95 |
| 110 void overrideViewportDimensions(double width, double height) override; | 96 void overrideViewportDimensions(double width, double height) override; |
| 111 | 97 |
| 112 protected: | 98 protected: |
| 113 MediaValuesCached(); | 99 MediaValuesCached(); |
| 114 MediaValuesCached(LocalFrame*); | 100 MediaValuesCached(LocalFrame*); |
| 115 MediaValuesCached(const MediaValuesCachedData&); | 101 MediaValuesCached(const MediaValuesCachedData&); |
| 116 | 102 |
| 117 MediaValuesCachedData m_data; | 103 MediaValuesCachedData m_data; |
| 118 }; | 104 }; |
| 119 | 105 |
| 120 template <> | 106 template <> |
| 121 struct CrossThreadCopier<MediaValuesCached::MediaValuesCachedData> { | 107 struct CrossThreadCopier<MediaValuesCached::MediaValuesCachedData> { |
| 122 typedef MediaValuesCached::MediaValuesCachedData Type; | 108 typedef MediaValuesCached::MediaValuesCachedData Type; |
| 123 static Type copy(const MediaValuesCached::MediaValuesCachedData& data) { | 109 static Type copy(const MediaValuesCached::MediaValuesCachedData& data) { |
| 124 return data.deepCopy(); | 110 return data.deepCopy(); |
| 125 } | 111 } |
| 126 }; | 112 }; |
| 127 | 113 |
| 128 } // namespace blink | 114 } // namespace blink |
| 129 | 115 |
| 130 #endif // MediaValuesCached_h | 116 #endif // MediaValuesCached_h |
| OLD | NEW |