Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. |
| 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
| 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 10 * | 10 * |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 switch (int(resultMaxHeight)) { | 133 switch (int(resultMaxHeight)) { |
| 134 case ViewportArguments::ValueDeviceWidth: | 134 case ViewportArguments::ValueDeviceWidth: |
| 135 resultMaxHeight = deviceSize.width(); | 135 resultMaxHeight = deviceSize.width(); |
| 136 break; | 136 break; |
| 137 case ViewportArguments::ValueDeviceHeight: | 137 case ViewportArguments::ValueDeviceHeight: |
| 138 resultMaxHeight = deviceSize.height(); | 138 resultMaxHeight = deviceSize.height(); |
| 139 break; | 139 break; |
| 140 } | 140 } |
| 141 | 141 |
| 142 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto) | 142 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto) |
| 143 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut o(resultMaxWidth, deviceSize.width(), min), max); | 143 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut o(resultMaxWidth, initialViewportSize.width(), min), max); |
| 144 | 144 |
| 145 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight ! = ViewportArguments::ValueAuto) | 145 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight ! = ViewportArguments::ValueAuto) |
| 146 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA uto(resultMaxHeight, deviceSize.height(), min), max); | 146 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA uto(resultMaxHeight, initialViewportSize.height(), min), max); |
| 147 | 147 |
| 148 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi ewportArguments::ValueAuto) | 148 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi ewportArguments::ValueAuto) |
| 149 resultMaxZoom = max(resultMinZoom, resultMaxZoom); | 149 resultMaxZoom = max(resultMinZoom, resultMaxZoom); |
| 150 | 150 |
| 151 if (resultZoom != ViewportArguments::ValueAuto) | 151 if (resultZoom != ViewportArguments::ValueAuto) |
| 152 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto( resultMaxZoom, resultZoom, min), max); | 152 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto( resultMaxZoom, resultZoom, min), max); |
| 153 | 153 |
| 154 if (resultWidth == ViewportArguments::ValueAuto && resultZoom == Viewpor tArguments::ValueAuto) | 154 if (resultWidth == ViewportArguments::ValueAuto && (resultHeight == View portArguments::ValueAuto || !initialViewportSize.height())) |
| 155 resultWidth = deviceSize.width(); | 155 resultWidth = initialViewportSize.width(); |
| 156 | |
| 157 if (resultWidth == ViewportArguments::ValueAuto && resultHeight == Viewp ortArguments::ValueAuto) | |
| 158 resultWidth = deviceSize.width() / resultZoom; | |
| 159 | 156 |
| 160 if (resultWidth == ViewportArguments::ValueAuto) | 157 if (resultWidth == ViewportArguments::ValueAuto) |
| 161 resultWidth = resultHeight * deviceSize.width() / deviceSize.height( ); | 158 resultWidth = resultHeight * initialViewportSize.width() / initialVi ewportSize.height(); |
|
kenneth.r.christiansen
2013/06/13 13:46:42
I am a bit afraid that this might break Android,
Peter Beverloo
2013/06/28 01:13:51
Can you please add an ASSERT() to ensure that init
rune
2013/07/03 08:01:52
Added.
| |
| 162 | 159 |
| 163 if (resultHeight == ViewportArguments::ValueAuto) | 160 if (resultHeight == ViewportArguments::ValueAuto) { |
| 164 resultHeight = resultWidth * deviceSize.height() / deviceSize.width( ); | 161 if (!initialViewportSize.width()) |
| 165 | 162 resultHeight = initialViewportSize.height(); |
| 166 if (resultZoom != ViewportArguments::ValueAuto || resultMaxZoom != Viewp ortArguments::ValueAuto) { | 163 else |
| 167 resultWidth = compareIgnoringAuto(resultWidth, deviceSize.width() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max); | 164 resultHeight = resultWidth * initialViewportSize.height() / init ialViewportSize.width(); |
| 168 resultHeight = compareIgnoringAuto(resultHeight, deviceSize.height() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max); | |
| 169 } | 165 } |
| 170 | |
| 171 resultWidth = max<float>(1, resultWidth); | |
| 172 resultHeight = max<float>(1, resultHeight); | |
| 173 } | 166 } |
| 174 | 167 |
| 175 if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArgume nts::Implicit) { | 168 if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArgume nts::Implicit) { |
| 176 // Clamp values to a valid range, but not for @viewport since is | 169 // Clamp values to a valid range, but not for @viewport since is |
| 177 // not mandated by the specification. | 170 // not mandated by the specification. |
| 178 resultWidth = clampLengthValue(resultWidth); | 171 resultWidth = clampLengthValue(resultWidth); |
| 179 resultHeight = clampLengthValue(resultHeight); | 172 resultHeight = clampLengthValue(resultHeight); |
| 180 resultZoom = clampScaleValue(resultZoom); | 173 resultZoom = clampScaleValue(resultZoom); |
| 181 resultMinZoom = clampScaleValue(resultMinZoom); | 174 resultMinZoom = clampScaleValue(resultMinZoom); |
| 182 resultMaxZoom = clampScaleValue(resultMaxZoom); | 175 resultMaxZoom = clampScaleValue(resultMaxZoom); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 194 result.maximumScale = float(5.0); | 187 result.maximumScale = float(5.0); |
| 195 result.minimumScale = min(float(5.0), result.minimumScale); | 188 result.minimumScale = min(float(5.0), result.minimumScale); |
| 196 } else | 189 } else |
| 197 result.maximumScale = resultMaxZoom; | 190 result.maximumScale = resultMaxZoom; |
| 198 result.maximumScale = max(result.minimumScale, result.maximumScale); | 191 result.maximumScale = max(result.minimumScale, result.maximumScale); |
| 199 | 192 |
| 200 // Resolve initial-scale value. | 193 // Resolve initial-scale value. |
| 201 result.initialScale = resultZoom; | 194 result.initialScale = resultZoom; |
| 202 if (resultZoom == ViewportArguments::ValueAuto) { | 195 if (resultZoom == ViewportArguments::ValueAuto) { |
| 203 result.initialScale = initialViewportSize.width() / defaultWidth; | 196 result.initialScale = initialViewportSize.width() / defaultWidth; |
| 204 if (resultWidth != ViewportArguments::ValueAuto) | 197 if (resultWidth != ViewportArguments::ValueAuto && resultWidth > 0) |
| 205 result.initialScale = initialViewportSize.width() / resultWidth; | 198 result.initialScale = initialViewportSize.width() / resultWidth; |
| 206 if (resultHeight != ViewportArguments::ValueAuto) { | 199 if (resultHeight != ViewportArguments::ValueAuto && resultHeight > 0) { |
| 207 // if 'auto', the initial-scale will be negative here and thus ignor ed. | 200 // if 'auto', the initial-scale will be negative here and thus ignor ed. |
| 208 result.initialScale = max<float>(result.initialScale, initialViewpor tSize.height() / resultHeight); | 201 result.initialScale = max<float>(result.initialScale, initialViewpor tSize.height() / resultHeight); |
| 209 } | 202 } |
| 210 } | 203 } |
| 211 | 204 |
| 212 // Constrain initial-scale value to minimum-scale/maximum-scale range. | 205 // Constrain initial-scale value to minimum-scale/maximum-scale range. |
| 213 result.initialScale = min(result.maximumScale, max(result.minimumScale, resu lt.initialScale)); | 206 result.initialScale = min(result.maximumScale, max(result.minimumScale, resu lt.initialScale)); |
| 214 | 207 |
| 215 // Resolve width value. | 208 // Resolve width value. |
| 216 if (resultWidth == ViewportArguments::ValueAuto) { | 209 if (resultWidth == ViewportArguments::ValueAuto) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 message.replace("%replacement2", replacement2); | 416 message.replace("%replacement2", replacement2); |
| 424 | 417 |
| 425 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) | 418 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) |
| 426 message.append(" Note that ';' is not a separator in viewport values. Th e list should be comma-separated."); | 419 message.append(" Note that ';' is not a separator in viewport values. Th e list should be comma-separated."); |
| 427 | 420 |
| 428 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 421 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 429 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message); | 422 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message); |
| 430 } | 423 } |
| 431 | 424 |
| 432 } // namespace WebCore | 425 } // namespace WebCore |
| OLD | NEW |