OLD | NEW |
(Empty) | |
| 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/rendering/style/RenderStyle.h" |
| 12 #include "core/rendering/style/StyleInheritedData.h" |
| 13 |
| 14 namespace WebCore { |
| 15 |
| 16 PassRefPtr<MediaValues> MediaValuesDynamic::create(PassRefPtr<LocalFrame> frame,
PassRefPtr<RenderStyle> style) |
| 17 { |
| 18 return adoptRef(new MediaValuesDynamic(frame, style)); |
| 19 } |
| 20 |
| 21 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame, PassRefPtr<
RenderStyle> style) |
| 22 : m_style(style) |
| 23 , m_frame(frame) |
| 24 { |
| 25 } |
| 26 |
| 27 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const |
| 28 { |
| 29 return adoptRef(new MediaValuesDynamic(m_frame, m_style)); |
| 30 } |
| 31 |
| 32 bool MediaValuesDynamic::computeLength(CSSPrimitiveValue& primitiveValue, int& r
esult) const |
| 33 { |
| 34 ASSERT(m_style.get()); |
| 35 result = primitiveValue.computeLength<int>(CSSToLengthConversionData(m_style
.get(), m_style.get(), 0, 1.0 /* zoom */, true /* computingFontSize */)); |
| 36 return true; |
| 37 } |
| 38 |
| 39 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const |
| 40 { |
| 41 return false; |
| 42 } |
| 43 |
| 44 int MediaValuesDynamic::viewportWidth() const |
| 45 { |
| 46 ASSERT(m_style.get()); |
| 47 ASSERT(m_frame.get()); |
| 48 return calculateViewportWidth(m_frame.get(), m_style.get()); |
| 49 } |
| 50 |
| 51 int MediaValuesDynamic::viewportHeight() const |
| 52 { |
| 53 ASSERT(m_style.get()); |
| 54 ASSERT(m_frame.get()); |
| 55 return calculateViewportHeight(m_frame.get(), m_style.get()); |
| 56 } |
| 57 |
| 58 int MediaValuesDynamic::deviceWidth() const |
| 59 { |
| 60 ASSERT(m_frame.get()); |
| 61 return calculateDeviceWidth(m_frame.get()); |
| 62 } |
| 63 |
| 64 int MediaValuesDynamic::deviceHeight() const |
| 65 { |
| 66 ASSERT(m_frame.get()); |
| 67 return calculateDeviceHeight(m_frame.get()); |
| 68 } |
| 69 |
| 70 float MediaValuesDynamic::devicePixelRatio() const |
| 71 { |
| 72 ASSERT(m_frame.get()); |
| 73 return calculateDevicePixelRatio(m_frame.get()); |
| 74 } |
| 75 |
| 76 int MediaValuesDynamic::colorBitsPerComponent() const |
| 77 { |
| 78 ASSERT(m_frame.get()); |
| 79 return calculateColorBitsPerComponent(m_frame.get()); |
| 80 } |
| 81 |
| 82 int MediaValuesDynamic::monochromeBitsPerComponent() const |
| 83 { |
| 84 ASSERT(m_frame.get()); |
| 85 return calculateMonochromeBitsPerComponent(m_frame.get()); |
| 86 } |
| 87 |
| 88 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const |
| 89 { |
| 90 ASSERT(m_frame.get()); |
| 91 return calculateLeastCapablePrimaryPointerDeviceType(m_frame.get()); |
| 92 } |
| 93 |
| 94 bool MediaValuesDynamic::threeDEnabled() const |
| 95 { |
| 96 ASSERT(m_frame.get()); |
| 97 return calculateThreeDEnabled(m_frame.get()); |
| 98 } |
| 99 |
| 100 bool MediaValuesDynamic::scanMediaType() const |
| 101 { |
| 102 ASSERT(m_frame.get()); |
| 103 return calculateScanMediaType(m_frame.get()); |
| 104 } |
| 105 |
| 106 bool MediaValuesDynamic::screenMediaType() const |
| 107 { |
| 108 ASSERT(m_frame.get()); |
| 109 return calculateScreenMediaType(m_frame.get()); |
| 110 } |
| 111 |
| 112 bool MediaValuesDynamic::printMediaType() const |
| 113 { |
| 114 ASSERT(m_frame.get()); |
| 115 return calculatePrintMediaType(m_frame.get()); |
| 116 } |
| 117 |
| 118 bool MediaValuesDynamic::strictMode() const |
| 119 { |
| 120 ASSERT(m_frame.get()); |
| 121 return calculateStrictMode(m_frame.get()); |
| 122 } |
| 123 |
| 124 Document* MediaValuesDynamic::document() const |
| 125 { |
| 126 ASSERT(m_frame.get()); |
| 127 return m_frame->document(); |
| 128 } |
| 129 |
| 130 bool MediaValuesDynamic::hasValues() const |
| 131 { |
| 132 return(m_style.get() && m_frame.get()); |
| 133 } |
| 134 |
| 135 } // namespace |
OLD | NEW |