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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 } | 89 } |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); | 93 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); |
94 | 94 |
95 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom); | 95 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom); |
96 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom); | 96 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom); |
97 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom); | 97 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom); |
98 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom); | 98 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom); |
99 arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth); | 99 arguments.minWidth = getViewportLengthValue(CSSPropertyMinWidth); |
100 arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth); | 100 arguments.maxWidth = getViewportLengthValue(CSSPropertyMaxWidth); |
101 arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight); | 101 arguments.minHeight = getViewportLengthValue(CSSPropertyMinHeight); |
102 arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight); | 102 arguments.maxHeight = getViewportLengthValue(CSSPropertyMaxHeight); |
103 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation); | 103 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation); |
104 | 104 |
105 m_document->setViewportArguments(arguments); | 105 m_document->setViewportArguments(arguments); |
106 m_document->updateViewportArguments(); | 106 m_document->updateViewportArguments(); |
107 | 107 |
108 m_propertySet = 0; | 108 m_propertySet = 0; |
109 } | 109 } |
110 | 110 |
111 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const | 111 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const |
112 { | 112 { |
(...skipping 13 matching lines...) Expand all Loading... | |
126 | 126 |
127 if (primitiveValue->isNumber() || primitiveValue->isPx()) | 127 if (primitiveValue->isNumber() || primitiveValue->isPx()) |
128 return primitiveValue->getFloatValue(); | 128 return primitiveValue->getFloatValue(); |
129 | 129 |
130 if (primitiveValue->isFontRelativeLength()) | 130 if (primitiveValue->isFontRelativeLength()) |
131 return primitiveValue->getFloatValue() * m_document->renderStyle()->font Description().computedSize(); | 131 return primitiveValue->getFloatValue() * m_document->renderStyle()->font Description().computedSize(); |
132 | 132 |
133 if (primitiveValue->isPercentage()) { | 133 if (primitiveValue->isPercentage()) { |
134 float percentValue = primitiveValue->getFloatValue() / 100.0f; | 134 float percentValue = primitiveValue->getFloatValue() / 100.0f; |
135 switch (id) { | 135 switch (id) { |
136 case CSSPropertyMaxHeight: | |
137 case CSSPropertyMinHeight: | |
138 return percentValue * m_document->initialViewportSize().height(); | |
139 case CSSPropertyMaxWidth: | |
140 case CSSPropertyMinWidth: | |
141 return percentValue * m_document->initialViewportSize().width(); | |
142 case CSSPropertyMaxZoom: | 136 case CSSPropertyMaxZoom: |
143 case CSSPropertyMinZoom: | 137 case CSSPropertyMinZoom: |
144 case CSSPropertyZoom: | 138 case CSSPropertyZoom: |
145 return percentValue; | 139 return percentValue; |
146 default: | 140 default: |
147 ASSERT_NOT_REACHED(); | 141 ASSERT_NOT_REACHED(); |
148 break; | 142 break; |
149 } | 143 } |
150 } | 144 } |
151 | 145 |
152 switch (primitiveValue->getValueID()) { | 146 switch (primitiveValue->getValueID()) { |
153 case CSSValueAuto: | 147 case CSSValueAuto: |
154 return defaultValue; | 148 return defaultValue; |
155 case CSSValueLandscape: | 149 case CSSValueLandscape: |
156 return ViewportArguments::ValueLandscape; | 150 return ViewportArguments::ValueLandscape; |
157 case CSSValuePortrait: | 151 case CSSValuePortrait: |
158 return ViewportArguments::ValuePortrait; | 152 return ViewportArguments::ValuePortrait; |
159 case CSSValueZoom: | 153 case CSSValueZoom: |
160 return defaultValue; | 154 return defaultValue; |
161 case CSSValueInternalExtendToZoom: | 155 case CSSValueInternalExtendToZoom: |
162 return ViewportArguments::ValueExtendToZoom; | 156 return ViewportArguments::ValueExtendToZoom; |
163 case CSSValueFixed: | 157 case CSSValueFixed: |
164 return 0; | 158 return 0; |
165 default: | 159 default: |
166 return defaultValue; | 160 return defaultValue; |
167 } | 161 } |
168 } | 162 } |
169 | 163 |
164 Length ViewportStyleResolver::getViewportLengthValue(CSSPropertyID id) const | |
esprehn
2013/09/04 11:22:24
This should really be called viewportLengthValue()
rune
2013/09/04 14:53:31
Done.
| |
165 { | |
166 ASSERT(id == CSSPropertyMaxHeight | |
167 || id == CSSPropertyMinHeight | |
168 || id == CSSPropertyMaxWidth | |
169 || id == CSSPropertyMinWidth); | |
170 | |
171 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); | |
172 if (!value || !value->isPrimitiveValue()) | |
173 return Length(); // auto | |
174 | |
175 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | |
176 | |
177 if (primitiveValue->isLength()) | |
178 return primitiveValue->computeLength<Length>(m_document->renderStyle(), m_document->renderStyle()); | |
179 | |
180 if (primitiveValue->isViewportPercentageLength()) | |
181 return primitiveValue->viewportPercentageLength(); | |
182 | |
183 if (primitiveValue->isPercentage()) | |
184 return Length(primitiveValue->getFloatValue(), Percent); | |
185 | |
186 switch (primitiveValue->getValueID()) { | |
187 case CSSValueInternalExtendToZoom: | |
188 return Length(ExtendToZoom); | |
189 case CSSValueAuto: | |
190 return Length(); | |
191 default: | |
192 // Unrecognized keyword. | |
193 ASSERT_NOT_REACHED(); | |
194 return Length(0, Fixed); | |
195 } | |
196 } | |
197 | |
170 } // namespace WebCore | 198 } // namespace WebCore |
OLD | NEW |