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 16 PassRefPtr<MediaValues> MediaValuesDynamic::create(LocalFrame* frame) 17 { 18 return adoptRef(new MediaValuesDynamic(frame)); 19 } 20 21 MediaValuesDynamic::MediaValuesDynamic(LocalFrame* frame) 22 : m_frame(frame) 23 { 24 ASSERT(m_frame); 25 } 26 27 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const 28 { 29 return adoptRef(new MediaValuesDynamic(m_frame)); 30 } 31 32 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 42 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 52 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const 53 { 54 return false; 55 } 56 57 int MediaValuesDynamic::viewportWidth() const 58 { 59 return calculateViewportWidth(m_frame); 60 } 61 62 int MediaValuesDynamic::viewportHeight() const 63 { 64 return calculateViewportHeight(m_frame); 65 } 66 67 int MediaValuesDynamic::deviceWidth() const 68 { 69 return calculateDeviceWidth(m_frame); 70 } 71 72 int MediaValuesDynamic::deviceHeight() const 73 { 74 return calculateDeviceHeight(m_frame); 75 } 76 77 float MediaValuesDynamic::devicePixelRatio() const 78 { 79 return calculateDevicePixelRatio(m_frame); 80 } 81 82 int MediaValuesDynamic::colorBitsPerComponent() const 83 { 84 return calculateColorBitsPerComponent(m_frame); 85 } 86 87 int MediaValuesDynamic::monochromeBitsPerComponent() const 88 { 89 return calculateMonochromeBitsPerComponent(m_frame); 90 } 91 92 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const 93 { 94 return calculateLeastCapablePrimaryPointerDeviceType(m_frame); 95 } 96 97 bool MediaValuesDynamic::threeDEnabled() const 98 { 99 return calculateThreeDEnabled(m_frame); 100 } 101 102 bool MediaValuesDynamic::scanMediaType() const 103 { 104 return calculateScanMediaType(m_frame); 105 } 106 107 bool MediaValuesDynamic::screenMediaType() const 108 { 109 return calculateScreenMediaType(m_frame); 110 } 111 112 bool MediaValuesDynamic::printMediaType() const 113 { 114 return calculatePrintMediaType(m_frame); 115 } 116 117 bool MediaValuesDynamic::strictMode() const 118 { 119 return calculateStrictMode(m_frame); 120 } 121 122 Document* MediaValuesDynamic::document() const 123 { 124 return m_frame->document(); 125 } 126 127 bool MediaValuesDynamic::hasValues() const 128 { 129 return m_frame; 130 } 131 132 } // namespace 133