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 13 matching lines...) Expand all Loading... | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/resolver/ViewportStyleResolver.h" | 31 #include "core/css/resolver/ViewportStyleResolver.h" |
32 | 32 |
33 #include "CSSValueKeywords.h" | 33 #include "CSSValueKeywords.h" |
34 #include "core/css/CSSPrimitiveValueMappings.h" | |
34 #include "core/css/CSSToLengthConversionData.h" | 35 #include "core/css/CSSToLengthConversionData.h" |
35 #include "core/css/StylePropertySet.h" | 36 #include "core/css/StylePropertySet.h" |
36 #include "core/css/StyleRule.h" | 37 #include "core/css/StyleRule.h" |
37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
38 #include "core/dom/NodeRenderStyle.h" | 39 #include "core/dom/NodeRenderStyle.h" |
39 #include "core/dom/ViewportDescription.h" | 40 #include "core/dom/ViewportDescription.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 ViewportStyleResolver::ViewportStyleResolver(Document* document) | 44 ViewportStyleResolver::ViewportStyleResolver(Document* document) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 || id == CSSPropertyMinHeight | 177 || id == CSSPropertyMinHeight |
177 || id == CSSPropertyMaxWidth | 178 || id == CSSPropertyMaxWidth |
178 || id == CSSPropertyMinWidth); | 179 || id == CSSPropertyMinWidth); |
179 | 180 |
180 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); | 181 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); |
181 if (!value || !value->isPrimitiveValue()) | 182 if (!value || !value->isPrimitiveValue()) |
182 return Length(); // auto | 183 return Length(); // auto |
183 | 184 |
184 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | 185 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); |
185 | 186 |
186 if (primitiveValue->isLength()) | 187 if (primitiveValue->getValueID() == CSSValueInternalExtendToZoom) |
187 return primitiveValue->computeLength<Length>(CSSToLengthConversionData(m _document->renderStyle(), m_document->renderStyle(), 1.0f)); | 188 return Length(ExtendToZoom); |
188 | 189 |
189 if (primitiveValue->isViewportPercentageLength()) | 190 RenderStyle* documentStyle = m_document->renderStyle(); |
kenneth.r.christiansen
2013/12/18 07:16:19
Are we still supporting @viewport { width: 50%; }
Timothy Loh
2013/12/18 07:18:27
This gets converted in primitiveValue->convertToLe
| |
190 return primitiveValue->viewportPercentageLength(); | |
191 | 191 |
192 if (primitiveValue->isPercentage()) | 192 // If we have viewport units the conversion will mark the document style as having viewport units. |
193 return Length(primitiveValue->getFloatValue(), Percent); | 193 bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits(); |
194 documentStyle->setHasViewportUnits(false); | |
195 Length result = primitiveValue->convertToLength<AnyConversion>(CSSToLengthCo nversionData(documentStyle, documentStyle, m_document->renderView(), 1.0f)); | |
196 if (documentStyle->hasViewportUnits()) | |
197 m_document->setHasViewportUnits(); | |
198 documentStyle->setHasViewportUnits(documentStyleHasViewportUnits); | |
194 | 199 |
195 switch (primitiveValue->getValueID()) { | 200 ASSERT(!result.isUndefined()); |
196 case CSSValueInternalExtendToZoom: | 201 return result; |
197 return Length(ExtendToZoom); | |
198 case CSSValueAuto: | |
199 return Length(); | |
200 default: | |
201 // Unrecognized keyword. | |
202 ASSERT_NOT_REACHED(); | |
203 return Length(0, Fixed); | |
204 } | |
205 } | 202 } |
206 | 203 |
207 } // namespace WebCore | 204 } // namespace WebCore |
OLD | NEW |