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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/css/MediaValuesDynamic.h"
7
8 #include "core/css/CSSHelper.h"
9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSToLengthConversionData.h"
11 #include "core/dom/Document.h"
12 #include "core/frame/LocalFrame.h"
13
14 namespace WebCore {
15
create(LocalFrame * frame)16 PassRefPtr<MediaValues> MediaValuesDynamic::create(LocalFrame* frame)
17 {
18 return adoptRef(new MediaValuesDynamic(frame));
19 }
20
MediaValuesDynamic(LocalFrame * frame)21 MediaValuesDynamic::MediaValuesDynamic(LocalFrame* frame)
22 : m_frame(frame)
23 {
24 ASSERT(m_frame);
25 }
26
copy() const27 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const
28 {
29 return adoptRef(new MediaValuesDynamic(m_frame));
30 }
31
computeLength(double value,CSSPrimitiveValue::UnitType type,int & result) const32 bool MediaValuesDynamic::computeLength(double value, CSSPrimitiveValue::UnitType type, int& result) const
33 {
34 return MediaValues::computeLength(value,
35 type,
36 calculateDefaultFontSize(m_frame),
37 calculateViewportWidth(m_frame),
38 calculateViewportHeight(m_frame),
39 result);
40 }
41
computeLength(double value,CSSPrimitiveValue::UnitType type,double & result) const42 bool MediaValuesDynamic::computeLength(double value, CSSPrimitiveValue::UnitType type, double& result) const
43 {
44 return MediaValues::computeLength(value,
45 type,
46 calculateDefaultFontSize(m_frame),
47 calculateViewportWidth(m_frame),
48 calculateViewportHeight(m_frame),
49 result);
50 }
51
isSafeToSendToAnotherThread() const52 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const
53 {
54 return false;
55 }
56
viewportWidth() const57 int MediaValuesDynamic::viewportWidth() const
58 {
59 return calculateViewportWidth(m_frame);
60 }
61
viewportHeight() const62 int MediaValuesDynamic::viewportHeight() const
63 {
64 return calculateViewportHeight(m_frame);
65 }
66
deviceWidth() const67 int MediaValuesDynamic::deviceWidth() const
68 {
69 return calculateDeviceWidth(m_frame);
70 }
71
deviceHeight() const72 int MediaValuesDynamic::deviceHeight() const
73 {
74 return calculateDeviceHeight(m_frame);
75 }
76
devicePixelRatio() const77 float MediaValuesDynamic::devicePixelRatio() const
78 {
79 return calculateDevicePixelRatio(m_frame);
80 }
81
colorBitsPerComponent() const82 int MediaValuesDynamic::colorBitsPerComponent() const
83 {
84 return calculateColorBitsPerComponent(m_frame);
85 }
86
monochromeBitsPerComponent() const87 int MediaValuesDynamic::monochromeBitsPerComponent() const
88 {
89 return calculateMonochromeBitsPerComponent(m_frame);
90 }
91
pointer() const92 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const
93 {
94 return calculateLeastCapablePrimaryPointerDeviceType(m_frame);
95 }
96
threeDEnabled() const97 bool MediaValuesDynamic::threeDEnabled() const
98 {
99 return calculateThreeDEnabled(m_frame);
100 }
101
scanMediaType() const102 bool MediaValuesDynamic::scanMediaType() const
103 {
104 return calculateScanMediaType(m_frame);
105 }
106
screenMediaType() const107 bool MediaValuesDynamic::screenMediaType() const
108 {
109 return calculateScreenMediaType(m_frame);
110 }
111
printMediaType() const112 bool MediaValuesDynamic::printMediaType() const
113 {
114 return calculatePrintMediaType(m_frame);
115 }
116
strictMode() const117 bool MediaValuesDynamic::strictMode() const
118 {
119 return calculateStrictMode(m_frame);
120 }
121
document() const122 Document* MediaValuesDynamic::document() const
123 {
124 return m_frame->document();
125 }
126
hasValues() const127 bool MediaValuesDynamic::hasValues() const
128 {
129 return m_frame;
130 }
131
132 } // namespace
133