| 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" |
| 41 #include "core/frame/FrameView.h" |
| 40 | 42 |
| 41 namespace WebCore { | 43 namespace WebCore { |
| 42 | 44 |
| 43 ViewportStyleResolver::ViewportStyleResolver(Document* document) | 45 ViewportStyleResolver::ViewportStyleResolver(Document* document) |
| 44 : m_document(document), | 46 : m_document(document), |
| 45 m_hasAuthorStyle(false) | 47 m_hasAuthorStyle(false) |
| 46 { | 48 { |
| 47 ASSERT(m_document); | 49 ASSERT(m_document); |
| 48 } | 50 } |
| 49 | 51 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 || id == CSSPropertyMinHeight | 178 || id == CSSPropertyMinHeight |
| 177 || id == CSSPropertyMaxWidth | 179 || id == CSSPropertyMaxWidth |
| 178 || id == CSSPropertyMinWidth); | 180 || id == CSSPropertyMinWidth); |
| 179 | 181 |
| 180 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); | 182 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); |
| 181 if (!value || !value->isPrimitiveValue()) | 183 if (!value || !value->isPrimitiveValue()) |
| 182 return Length(); // auto | 184 return Length(); // auto |
| 183 | 185 |
| 184 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | 186 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); |
| 185 | 187 |
| 186 if (primitiveValue->isLength()) | 188 if (primitiveValue->getValueID() == CSSValueInternalExtendToZoom) |
| 187 return primitiveValue->computeLength<Length>(CSSToLengthConversionData(m
_document->renderStyle(), m_document->renderStyle(), 1.0f)); | 189 return Length(ExtendToZoom); |
| 188 | 190 |
| 189 if (primitiveValue->isViewportPercentageLength()) | 191 RenderStyle* documentStyle = m_document->renderStyle(); |
| 190 return primitiveValue->viewportPercentageLength(); | |
| 191 | 192 |
| 192 if (primitiveValue->isPercentage()) | 193 // If we have viewport units the conversion will mark the document style as
having viewport units. |
| 193 return Length(primitiveValue->getFloatValue(), Percent); | 194 bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits(); |
| 195 documentStyle->setHasViewportUnits(false); |
| 194 | 196 |
| 195 switch (primitiveValue->getValueID()) { | 197 FrameView* view = m_document->view(); |
| 196 case CSSValueInternalExtendToZoom: | 198 float width = view ? view->width() : 0; |
| 197 return Length(ExtendToZoom); | 199 float height = view ? view->height() : 0; |
| 198 case CSSValueAuto: | 200 |
| 199 return Length(); | 201 Length result = primitiveValue->convertToLength<AnyConversion>(CSSToLengthCo
nversionData(documentStyle, documentStyle, width, height, 1.0f)); |
| 200 default: | 202 if (documentStyle->hasViewportUnits()) |
| 201 // Unrecognized keyword. | 203 m_document->setHasViewportUnits(); |
| 202 ASSERT_NOT_REACHED(); | 204 documentStyle->setHasViewportUnits(documentStyleHasViewportUnits); |
| 203 return Length(0, Fixed); | 205 |
| 204 } | 206 return result; |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // namespace WebCore | 209 } // namespace WebCore |
| OLD | NEW |