Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: Source/core/css/MediaValuesDynamic.cpp

Issue 240063003: Revert "A sizes attribute parser" (https://codereview.chromium.org/224733011) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/MediaValuesDynamic.h ('k') | Source/core/css/parser/MediaConditionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/dom/Document.h"
12 #include "core/rendering/RenderObject.h"
13 #include "core/rendering/style/RenderStyle.h"
14 #include "core/rendering/style/StyleInheritedData.h"
15
16 namespace WebCore {
17
18 PassRefPtr<MediaValues> MediaValuesDynamic::create(PassRefPtr<LocalFrame> frame, PassRefPtr<RenderStyle> style)
19 {
20 return adoptRef(new MediaValuesDynamic(frame, style));
21 }
22
23 PassRefPtr<MediaValues> MediaValuesDynamic::create(Document& document)
24 {
25 Document* executingDocument = getExecutingDocument(document);
26 return MediaValuesDynamic::create(executingDocument->frame(), executingDocum ent->renderer()->style());
27 }
28
29 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame, PassRefPtr< RenderStyle> style)
30 : m_style(style)
31 , m_frame(frame)
32 {
33 }
34
35 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const
36 {
37 return adoptRef(new MediaValuesDynamic(m_frame, m_style));
38 }
39
40 bool MediaValuesDynamic::computeLength(double value, unsigned short type, int& r esult) const
41 {
42 ASSERT(m_style.get());
43 RefPtr<CSSPrimitiveValue> primitiveValue = CSSPrimitiveValue::create(value, (CSSPrimitiveValue::UnitTypes)type);
44 result = primitiveValue->computeLength<int>(CSSToLengthConversionData(m_styl e.get(), m_style.get(), 0, 1.0 /* zoom */, true /* computingFontSize */));
45 return true;
46 }
47
48 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const
49 {
50 return false;
51 }
52
53 int MediaValuesDynamic::viewportWidth() const
54 {
55 ASSERT(m_style.get());
56 ASSERT(m_frame.get());
57 return calculateViewportWidth(m_frame.get(), m_style.get());
58 }
59
60 int MediaValuesDynamic::viewportHeight() const
61 {
62 ASSERT(m_style.get());
63 ASSERT(m_frame.get());
64 return calculateViewportHeight(m_frame.get(), m_style.get());
65 }
66
67 int MediaValuesDynamic::deviceWidth() const
68 {
69 ASSERT(m_frame.get());
70 return calculateDeviceWidth(m_frame.get());
71 }
72
73 int MediaValuesDynamic::deviceHeight() const
74 {
75 ASSERT(m_frame.get());
76 return calculateDeviceHeight(m_frame.get());
77 }
78
79 float MediaValuesDynamic::devicePixelRatio() const
80 {
81 ASSERT(m_frame.get());
82 return calculateDevicePixelRatio(m_frame.get());
83 }
84
85 int MediaValuesDynamic::colorBitsPerComponent() const
86 {
87 ASSERT(m_frame.get());
88 return calculateColorBitsPerComponent(m_frame.get());
89 }
90
91 int MediaValuesDynamic::monochromeBitsPerComponent() const
92 {
93 ASSERT(m_frame.get());
94 return calculateMonochromeBitsPerComponent(m_frame.get());
95 }
96
97 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const
98 {
99 ASSERT(m_frame.get());
100 return calculateLeastCapablePrimaryPointerDeviceType(m_frame.get());
101 }
102
103 bool MediaValuesDynamic::threeDEnabled() const
104 {
105 ASSERT(m_frame.get());
106 return calculateThreeDEnabled(m_frame.get());
107 }
108
109 bool MediaValuesDynamic::scanMediaType() const
110 {
111 ASSERT(m_frame.get());
112 return calculateScanMediaType(m_frame.get());
113 }
114
115 bool MediaValuesDynamic::screenMediaType() const
116 {
117 ASSERT(m_frame.get());
118 return calculateScreenMediaType(m_frame.get());
119 }
120
121 bool MediaValuesDynamic::printMediaType() const
122 {
123 ASSERT(m_frame.get());
124 return calculatePrintMediaType(m_frame.get());
125 }
126
127 bool MediaValuesDynamic::strictMode() const
128 {
129 ASSERT(m_frame.get());
130 return calculateStrictMode(m_frame.get());
131 }
132
133 Document* MediaValuesDynamic::document() const
134 {
135 ASSERT(m_frame.get());
136 return m_frame->document();
137 }
138
139 bool MediaValuesDynamic::hasValues() const
140 {
141 return(m_style.get() && m_frame.get());
142 }
143
144 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/MediaValuesDynamic.h ('k') | Source/core/css/parser/MediaConditionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698