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.
6 #include "core/css/MediaValuesDynamic.h"
8 #include "core/css/CSSHelper.h"
9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSToLengthConversionData.h"
11 #include "core/css/MediaValuesCached.h"
12 #include "core/dom/Document.h"
13 #include "core/frame/LocalFrame.h"
17 PassRefPtr<MediaValues> MediaValuesDynamic::create(Document& document)
19 return MediaValuesDynamic::create(frameFrom(document));
22 PassRefPtr<MediaValues> MediaValuesDynamic::create(LocalFrame* frame)
24 if (!frame || !frame->view() || !frame->document() || !frame->document()->renderView())
25 return MediaValuesCached::create();
26 return adoptRef(new MediaValuesDynamic(frame));
29 MediaValuesDynamic::MediaValuesDynamic(LocalFrame* frame)
35 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const
37 return adoptRef(new MediaValuesDynamic(m_frame));
40 bool MediaValuesDynamic::computeLength(double value, CSSPrimitiveValue::UnitType type, int& result) const
42 return MediaValues::computeLength(value,
44 calculateDefaultFontSize(m_frame),
45 calculateViewportWidth(m_frame),
46 calculateViewportHeight(m_frame),
50 bool MediaValuesDynamic::computeLength(double value, CSSPrimitiveValue::UnitType type, double& result) const
52 return MediaValues::computeLength(value,
54 calculateDefaultFontSize(m_frame),
55 calculateViewportWidth(m_frame),
56 calculateViewportHeight(m_frame),
60 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const
65 int MediaValuesDynamic::viewportWidth() const
67 return calculateViewportWidth(m_frame);
70 int MediaValuesDynamic::viewportHeight() const
72 return calculateViewportHeight(m_frame);
75 int MediaValuesDynamic::deviceWidth() const
77 return calculateDeviceWidth(m_frame);
80 int MediaValuesDynamic::deviceHeight() const
82 return calculateDeviceHeight(m_frame);
85 float MediaValuesDynamic::devicePixelRatio() const
87 return calculateDevicePixelRatio(m_frame);
90 int MediaValuesDynamic::colorBitsPerComponent() const
92 return calculateColorBitsPerComponent(m_frame);
95 int MediaValuesDynamic::monochromeBitsPerComponent() const
97 return calculateMonochromeBitsPerComponent(m_frame);
100 PointerType MediaValuesDynamic::primaryPointerType() const
102 return calculatePrimaryPointerType(m_frame);
105 int MediaValuesDynamic::availablePointerTypes() const
107 return calculateAvailablePointerTypes(m_frame);
110 HoverType MediaValuesDynamic::primaryHoverType() const
112 return calculatePrimaryHoverType(m_frame);
115 int MediaValuesDynamic::availableHoverTypes() const
117 return calculateAvailableHoverTypes(m_frame);
120 bool MediaValuesDynamic::threeDEnabled() const
122 return calculateThreeDEnabled(m_frame);
125 const String MediaValuesDynamic::mediaType() const
127 return calculateMediaType(m_frame);
130 bool MediaValuesDynamic::strictMode() const
132 return calculateStrictMode(m_frame);
135 Document* MediaValuesDynamic::document() const
137 return m_frame->document();
140 bool MediaValuesDynamic::hasValues() const