OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. | 2 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // UserZoom default value is CSSValueZoom, which maps to true, meaning that | 134 // UserZoom default value is CSSValueZoom, which maps to true, meaning that |
135 // yes, it is user scalable. When the value is set to CSSValueFixed, we | 135 // yes, it is user scalable. When the value is set to CSSValueFixed, we |
136 // return false. | 136 // return false. |
137 if (id == CSSPropertyUserZoom) | 137 if (id == CSSPropertyUserZoom) |
138 defaultValue = 1; | 138 defaultValue = 1; |
139 | 139 |
140 NullableCSSValue value = m_propertySet->getPropertyCSSValue(id); | 140 NullableCSSValue value = m_propertySet->getPropertyCSSValue(id); |
141 if (!value || !value->isPrimitiveValue()) | 141 if (!value || !value->isPrimitiveValue()) |
142 return defaultValue; | 142 return defaultValue; |
143 | 143 |
144 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 144 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(*value); |
145 | 145 |
146 if (primitiveValue->isNumber() || primitiveValue->isPx()) | 146 if (primitiveValue.isNumber() || primitiveValue.isPx()) |
147 return primitiveValue->getFloatValue(); | 147 return primitiveValue.getFloatValue(); |
148 | 148 |
149 if (primitiveValue->isFontRelativeLength()) | 149 if (primitiveValue.isFontRelativeLength()) |
150 return primitiveValue->getFloatValue() * m_document->computedStyle()->fo
ntDescription().computedSize(); | 150 return primitiveValue.getFloatValue() * m_document->computedStyle()->fon
tDescription().computedSize(); |
151 | 151 |
152 if (primitiveValue->isPercentage()) { | 152 if (primitiveValue.isPercentage()) { |
153 float percentValue = primitiveValue->getFloatValue() / 100.0f; | 153 float percentValue = primitiveValue.getFloatValue() / 100.0f; |
154 switch (id) { | 154 switch (id) { |
155 case CSSPropertyMaxZoom: | 155 case CSSPropertyMaxZoom: |
156 case CSSPropertyMinZoom: | 156 case CSSPropertyMinZoom: |
157 case CSSPropertyZoom: | 157 case CSSPropertyZoom: |
158 return percentValue; | 158 return percentValue; |
159 default: | 159 default: |
160 ASSERT_NOT_REACHED(); | 160 ASSERT_NOT_REACHED(); |
161 break; | 161 break; |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 switch (primitiveValue->getValueID()) { | 165 switch (primitiveValue.getValueID()) { |
166 case CSSValueAuto: | 166 case CSSValueAuto: |
167 return defaultValue; | 167 return defaultValue; |
168 case CSSValueLandscape: | 168 case CSSValueLandscape: |
169 return ViewportDescription::ValueLandscape; | 169 return ViewportDescription::ValueLandscape; |
170 case CSSValuePortrait: | 170 case CSSValuePortrait: |
171 return ViewportDescription::ValuePortrait; | 171 return ViewportDescription::ValuePortrait; |
172 case CSSValueZoom: | 172 case CSSValueZoom: |
173 return defaultValue; | 173 return defaultValue; |
174 case CSSValueInternalExtendToZoom: | 174 case CSSValueInternalExtendToZoom: |
175 return ViewportDescription::ValueExtendToZoom; | 175 return ViewportDescription::ValueExtendToZoom; |
176 case CSSValueFixed: | 176 case CSSValueFixed: |
177 return 0; | 177 return 0; |
178 default: | 178 default: |
179 return defaultValue; | 179 return defaultValue; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const | 183 Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const |
184 { | 184 { |
185 ASSERT(id == CSSPropertyMaxHeight | 185 ASSERT(id == CSSPropertyMaxHeight |
186 || id == CSSPropertyMinHeight | 186 || id == CSSPropertyMinHeight |
187 || id == CSSPropertyMaxWidth | 187 || id == CSSPropertyMaxWidth |
188 || id == CSSPropertyMinWidth); | 188 || id == CSSPropertyMinWidth); |
189 | 189 |
190 NullableCSSValue value = m_propertySet->getPropertyCSSValue(id); | 190 NullableCSSValue value = m_propertySet->getPropertyCSSValue(id); |
191 if (!value || !value->isPrimitiveValue()) | 191 if (!value || !value->isPrimitiveValue()) |
192 return Length(); // auto | 192 return Length(); // auto |
193 | 193 |
194 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 194 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(*value); |
195 | 195 |
196 if (primitiveValue->getValueID() == CSSValueInternalExtendToZoom) | 196 if (primitiveValue.getValueID() == CSSValueInternalExtendToZoom) |
197 return Length(ExtendToZoom); | 197 return Length(ExtendToZoom); |
198 | 198 |
199 ComputedStyle* documentStyle = m_document->mutableComputedStyle(); | 199 ComputedStyle* documentStyle = m_document->mutableComputedStyle(); |
200 | 200 |
201 // If we have viewport units the conversion will mark the document style as
having viewport units. | 201 // If we have viewport units the conversion will mark the document style as
having viewport units. |
202 bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits(); | 202 bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits(); |
203 documentStyle->setHasViewportUnits(false); | 203 documentStyle->setHasViewportUnits(false); |
204 | 204 |
205 FrameView* view = m_document->view(); | 205 FrameView* view = m_document->view(); |
206 float width = view ? view->width() : 0; | 206 float width = view ? view->width() : 0; |
207 float height = view ? view->height() : 0; | 207 float height = view ? view->height() : 0; |
208 | 208 |
209 CSSToLengthConversionData::FontSizes fontSizes(documentStyle, documentStyle)
; | 209 CSSToLengthConversionData::FontSizes fontSizes(documentStyle, documentStyle)
; |
210 CSSToLengthConversionData::ViewportSize viewportSize(width, height); | 210 CSSToLengthConversionData::ViewportSize viewportSize(width, height); |
211 | 211 |
212 if (primitiveValue->getValueID() == CSSValueAuto) | 212 if (primitiveValue.getValueID() == CSSValueAuto) |
213 return Length(Auto); | 213 return Length(Auto); |
214 | 214 |
215 Length result = primitiveValue->convertToLength(CSSToLengthConversionData(do
cumentStyle, fontSizes, viewportSize, 1.0f)); | 215 Length result = primitiveValue.convertToLength(CSSToLengthConversionData(doc
umentStyle, fontSizes, viewportSize, 1.0f)); |
216 if (documentStyle->hasViewportUnits()) | 216 if (documentStyle->hasViewportUnits()) |
217 m_document->setHasViewportUnits(); | 217 m_document->setHasViewportUnits(); |
218 documentStyle->setHasViewportUnits(documentStyleHasViewportUnits); | 218 documentStyle->setHasViewportUnits(documentStyleHasViewportUnits); |
219 | 219 |
220 return result; | 220 return result; |
221 } | 221 } |
222 | 222 |
223 DEFINE_TRACE(ViewportStyleResolver) | 223 DEFINE_TRACE(ViewportStyleResolver) |
224 { | 224 { |
225 visitor->trace(m_propertySet); | 225 visitor->trace(m_propertySet); |
226 visitor->trace(m_document); | 226 visitor->trace(m_document); |
227 } | 227 } |
228 | 228 |
229 } // namespace blink | 229 } // namespace blink |
OLD | NEW |