Chromium Code Reviews| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 { | 77 { |
| 78 if (!m_document || !m_propertySet) | 78 if (!m_document || !m_propertySet) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); | 81 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); |
| 82 | 82 |
| 83 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom); | 83 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom); |
| 84 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom); | 84 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom); |
| 85 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom); | 85 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom); |
| 86 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom); | 86 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom); |
| 87 arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth); | 87 arguments.minWidth = getViewportLengthValue(CSSPropertyMinWidth); |
| 88 arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth); | 88 arguments.maxWidth = getViewportLengthValue(CSSPropertyMaxWidth); |
| 89 arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight); | 89 arguments.minHeight = getViewportLengthValue(CSSPropertyMinHeight); |
| 90 arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight); | 90 arguments.maxHeight = getViewportLengthValue(CSSPropertyMaxHeight); |
| 91 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation); | 91 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation); |
| 92 | 92 |
| 93 m_document->setViewportArguments(arguments); | 93 m_document->setViewportArguments(arguments); |
| 94 m_document->updateViewportArguments(); | 94 m_document->updateViewportArguments(); |
| 95 | 95 |
| 96 m_propertySet = 0; | 96 m_propertySet = 0; |
| 97 } | 97 } |
| 98 | 98 |
| 99 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const | 99 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const |
| 100 { | 100 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 114 | 114 |
| 115 if (primitiveValue->isNumber() || primitiveValue->isPx()) | 115 if (primitiveValue->isNumber() || primitiveValue->isPx()) |
| 116 return primitiveValue->getFloatValue(); | 116 return primitiveValue->getFloatValue(); |
| 117 | 117 |
| 118 if (primitiveValue->isFontRelativeLength()) | 118 if (primitiveValue->isFontRelativeLength()) |
| 119 return primitiveValue->getFloatValue() * m_document->renderStyle()->font Description().computedSize(); | 119 return primitiveValue->getFloatValue() * m_document->renderStyle()->font Description().computedSize(); |
| 120 | 120 |
| 121 if (primitiveValue->isPercentage()) { | 121 if (primitiveValue->isPercentage()) { |
| 122 float percentValue = primitiveValue->getFloatValue() / 100.0f; | 122 float percentValue = primitiveValue->getFloatValue() / 100.0f; |
| 123 switch (id) { | 123 switch (id) { |
| 124 case CSSPropertyMaxHeight: | |
| 125 case CSSPropertyMinHeight: | |
| 126 return percentValue * m_document->initialViewportSize().height(); | |
| 127 case CSSPropertyMaxWidth: | |
| 128 case CSSPropertyMinWidth: | |
| 129 return percentValue * m_document->initialViewportSize().width(); | |
| 130 case CSSPropertyMaxZoom: | 124 case CSSPropertyMaxZoom: |
| 131 case CSSPropertyMinZoom: | 125 case CSSPropertyMinZoom: |
| 132 case CSSPropertyZoom: | 126 case CSSPropertyZoom: |
| 133 return percentValue; | 127 return percentValue; |
| 134 default: | 128 default: |
| 135 ASSERT_NOT_REACHED(); | 129 ASSERT_NOT_REACHED(); |
| 136 break; | 130 break; |
| 137 } | 131 } |
| 138 } | 132 } |
| 139 | 133 |
| 140 switch (primitiveValue->getValueID()) { | 134 switch (primitiveValue->getValueID()) { |
| 141 case CSSValueAuto: | 135 case CSSValueAuto: |
| 142 return defaultValue; | 136 return defaultValue; |
| 143 case CSSValueLandscape: | 137 case CSSValueLandscape: |
| 144 return ViewportArguments::ValueLandscape; | 138 return ViewportArguments::ValueLandscape; |
| 145 case CSSValuePortrait: | 139 case CSSValuePortrait: |
| 146 return ViewportArguments::ValuePortrait; | 140 return ViewportArguments::ValuePortrait; |
| 147 case CSSValueZoom: | 141 case CSSValueZoom: |
| 148 return defaultValue; | 142 return defaultValue; |
| 149 case CSSValueInternalExtendToZoom: | 143 case CSSValueInternalExtendToZoom: |
| 150 return ViewportArguments::ValueExtendToZoom; | 144 return ViewportArguments::ValueExtendToZoom; |
| 151 case CSSValueFixed: | 145 case CSSValueFixed: |
| 152 return 0; | 146 return 0; |
| 153 default: | 147 default: |
| 154 return defaultValue; | 148 return defaultValue; |
| 155 } | 149 } |
| 156 } | 150 } |
| 157 | 151 |
| 152 Length ViewportStyleResolver::getViewportLengthValue(CSSPropertyID id) const | |
| 153 { | |
| 154 ASSERT(id == CSSPropertyMaxHeight | |
| 155 || id == CSSPropertyMinHeight | |
| 156 || id == CSSPropertyMaxWidth | |
| 157 || id == CSSPropertyMinWidth); | |
| 158 | |
| 159 RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); | |
| 160 if (!value) | |
| 161 return Length(); // auto | |
| 162 | |
| 163 ASSERT(value->isPrimitiveValue()); | |
| 164 | |
| 165 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | |
| 166 | |
| 167 if (primitiveValue->isLength()) | |
| 168 return primitiveValue->computeLength<Length>(m_document->renderStyle(), m_document->renderStyle()); | |
| 169 | |
| 170 if (primitiveValue->isViewportPercentageLength()) | |
| 171 return primitiveValue->viewportPercentageLength(); | |
| 172 | |
| 173 if (primitiveValue->isPercentage()) | |
| 174 return Length(primitiveValue->getFloatValue(), Percent); | |
| 175 | |
| 176 switch (primitiveValue->getValueID()) { | |
| 177 case CSSValueInternalExtendToZoom: | |
| 178 return Length(ExtendToZoom); | |
| 179 default: | |
|
apavlov
2013/08/07 09:25:54
Is there any particular idea behind putting "defau
rune
2013/08/07 10:06:15
Just to avoid an extra "return Length();" statemen
apavlov
2013/08/07 10:12:10
Well, this doesn't look like code where two cases
rune
2013/08/07 11:30:04
Chose 0px in patch set 3.
| |
| 180 ASSERT_NOT_REACHED(); | |
| 181 case CSSValueAuto: | |
| 182 return Length(); | |
| 183 } | |
| 184 } | |
| 185 | |
| 158 } // namespace WebCore | 186 } // namespace WebCore |
| OLD | NEW |