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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceWidth); | 107 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceWidth); |
108 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceHeight); | 108 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceHeight); |
109 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceWidth); | 109 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceWidth); |
110 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceHeight); | 110 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceHeight); |
111 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceWidth); | 111 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceWidth); |
112 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceHeight); | 112 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceHeight); |
113 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceWidth); | 113 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceWidth); |
114 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight); | 114 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight); |
115 | 115 |
116 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth !=
ViewportArguments::ValueAuto) | 116 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth !=
ViewportArguments::ValueAuto) |
117 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut
o(resultMaxWidth, deviceSize.width(), min), max); | 117 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut
o(resultMaxWidth, initialViewportSize.width(), min), max); |
118 | 118 |
119 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight !
= ViewportArguments::ValueAuto) | 119 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight !
= ViewportArguments::ValueAuto) |
120 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA
uto(resultMaxHeight, deviceSize.height(), min), max); | 120 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA
uto(resultMaxHeight, initialViewportSize.height(), min), max); |
121 | 121 |
122 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi
ewportArguments::ValueAuto) | 122 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi
ewportArguments::ValueAuto) |
123 resultMaxZoom = max(resultMinZoom, resultMaxZoom); | 123 resultMaxZoom = max(resultMinZoom, resultMaxZoom); |
124 | 124 |
125 if (resultZoom != ViewportArguments::ValueAuto) | 125 if (resultZoom != ViewportArguments::ValueAuto) |
126 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(
resultMaxZoom, resultZoom, min), max); | 126 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(
resultMaxZoom, resultZoom, min), max); |
127 | 127 |
128 if (resultWidth == ViewportArguments::ValueAuto && resultZoom == Viewpor
tArguments::ValueAuto) | 128 if (resultWidth == ViewportArguments::ValueAuto && (resultHeight == View
portArguments::ValueAuto || !initialViewportSize.height())) |
129 resultWidth = deviceSize.width(); | 129 resultWidth = initialViewportSize.width(); |
130 | 130 |
131 if (resultWidth == ViewportArguments::ValueAuto && resultHeight == Viewp
ortArguments::ValueAuto) | 131 if (resultWidth == ViewportArguments::ValueAuto) { |
132 resultWidth = deviceSize.width() / resultZoom; | 132 ASSERT(initialViewportSize.height()); // If height is 0, resultWidth
should be resolved above. |
133 | 133 resultWidth = resultHeight * initialViewportSize.width() / initialVi
ewportSize.height(); |
134 if (resultWidth == ViewportArguments::ValueAuto) | |
135 resultWidth = resultHeight * deviceSize.width() / deviceSize.height(
); | |
136 | |
137 if (resultHeight == ViewportArguments::ValueAuto) | |
138 resultHeight = resultWidth * deviceSize.height() / deviceSize.width(
); | |
139 | |
140 if (resultZoom != ViewportArguments::ValueAuto || resultMaxZoom != Viewp
ortArguments::ValueAuto) { | |
141 resultWidth = compareIgnoringAuto(resultWidth, deviceSize.width() /
compareIgnoringAuto(resultZoom, resultMaxZoom, min), max); | |
142 resultHeight = compareIgnoringAuto(resultHeight, deviceSize.height()
/ compareIgnoringAuto(resultZoom, resultMaxZoom, min), max); | |
143 } | 134 } |
144 | 135 |
145 resultWidth = max<float>(1, resultWidth); | 136 if (resultHeight == ViewportArguments::ValueAuto) { |
146 resultHeight = max<float>(1, resultHeight); | 137 if (!initialViewportSize.width()) |
| 138 resultHeight = initialViewportSize.height(); |
| 139 else |
| 140 resultHeight = resultWidth * initialViewportSize.height() / init
ialViewportSize.width(); |
| 141 } |
147 } | 142 } |
148 | 143 |
149 if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArgume
nts::Implicit) { | 144 if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArgume
nts::Implicit) { |
150 // Clamp values to a valid range, but not for @viewport since is | 145 // Clamp values to a valid range, but not for @viewport since is |
151 // not mandated by the specification. | 146 // not mandated by the specification. |
152 resultWidth = clampLengthValue(resultWidth); | 147 resultWidth = clampLengthValue(resultWidth); |
153 resultHeight = clampLengthValue(resultHeight); | 148 resultHeight = clampLengthValue(resultHeight); |
154 resultZoom = clampScaleValue(resultZoom); | 149 resultZoom = clampScaleValue(resultZoom); |
155 resultMinZoom = clampScaleValue(resultMinZoom); | 150 resultMinZoom = clampScaleValue(resultMinZoom); |
156 resultMaxZoom = clampScaleValue(resultMaxZoom); | 151 resultMaxZoom = clampScaleValue(resultMaxZoom); |
(...skipping 11 matching lines...) Expand all Loading... |
168 result.maximumScale = float(5.0); | 163 result.maximumScale = float(5.0); |
169 result.minimumScale = min(float(5.0), result.minimumScale); | 164 result.minimumScale = min(float(5.0), result.minimumScale); |
170 } else | 165 } else |
171 result.maximumScale = resultMaxZoom; | 166 result.maximumScale = resultMaxZoom; |
172 result.maximumScale = max(result.minimumScale, result.maximumScale); | 167 result.maximumScale = max(result.minimumScale, result.maximumScale); |
173 | 168 |
174 // Resolve initial-scale value. | 169 // Resolve initial-scale value. |
175 result.initialScale = resultZoom; | 170 result.initialScale = resultZoom; |
176 if (resultZoom == ViewportArguments::ValueAuto) { | 171 if (resultZoom == ViewportArguments::ValueAuto) { |
177 result.initialScale = initialViewportSize.width() / defaultWidth; | 172 result.initialScale = initialViewportSize.width() / defaultWidth; |
178 if (resultWidth != ViewportArguments::ValueAuto) | 173 if (resultWidth != ViewportArguments::ValueAuto && resultWidth > 0) |
179 result.initialScale = initialViewportSize.width() / resultWidth; | 174 result.initialScale = initialViewportSize.width() / resultWidth; |
180 if (resultHeight != ViewportArguments::ValueAuto) { | 175 if (resultHeight != ViewportArguments::ValueAuto && resultHeight > 0) { |
181 // if 'auto', the initial-scale will be negative here and thus ignor
ed. | 176 // if 'auto', the initial-scale will be negative here and thus ignor
ed. |
182 result.initialScale = max<float>(result.initialScale, initialViewpor
tSize.height() / resultHeight); | 177 result.initialScale = max<float>(result.initialScale, initialViewpor
tSize.height() / resultHeight); |
183 } | 178 } |
184 } | 179 } |
185 | 180 |
186 // Constrain initial-scale value to minimum-scale/maximum-scale range. | 181 // Constrain initial-scale value to minimum-scale/maximum-scale range. |
187 result.initialScale = min(result.maximumScale, max(result.minimumScale, resu
lt.initialScale)); | 182 result.initialScale = min(result.maximumScale, max(result.minimumScale, resu
lt.initialScale)); |
188 | 183 |
189 // Resolve width value. | 184 // Resolve width value. |
190 if (resultWidth == ViewportArguments::ValueAuto) { | 185 if (resultWidth == ViewportArguments::ValueAuto) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 message.replace("%replacement2", replacement2); | 392 message.replace("%replacement2", replacement2); |
398 | 393 |
399 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru
ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) | 394 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru
ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) |
400 message.append(" Note that ';' is not a separator in viewport values. Th
e list should be comma-separated."); | 395 message.append(" Note that ';' is not a separator in viewport values. Th
e list should be comma-separated."); |
401 | 396 |
402 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 397 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
403 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); | 398 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); |
404 } | 399 } |
405 | 400 |
406 } // namespace WebCore | 401 } // namespace WebCore |
OLD | NEW |