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-2013 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 { | 61 { |
62 ASSERT(value != ViewportArguments::ValueDeviceWidth); | 62 ASSERT(value != ViewportArguments::ValueDeviceWidth); |
63 ASSERT(value != ViewportArguments::ValueDeviceHeight); | 63 ASSERT(value != ViewportArguments::ValueDeviceHeight); |
64 | 64 |
65 // Limits as defined in the css-device-adapt spec. | 65 // Limits as defined in the css-device-adapt spec. |
66 if (value != ViewportArguments::ValueAuto) | 66 if (value != ViewportArguments::ValueAuto) |
67 return min(float(10), max(value, float(0.1))); | 67 return min(float(10), max(value, float(0.1))); |
68 return value; | 68 return value; |
69 } | 69 } |
70 | 70 |
71 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
Size, const FloatSize& deviceSize, int defaultWidth) const | 71 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
Size, int defaultWidth) const |
72 { | 72 { |
73 float resultWidth = width; | 73 float resultWidth = width; |
74 float resultMaxWidth = maxWidth; | 74 float resultMaxWidth = maxWidth; |
75 float resultMinWidth = minWidth; | 75 float resultMinWidth = minWidth; |
76 float resultHeight = height; | 76 float resultHeight = height; |
77 float resultMinHeight = minHeight; | 77 float resultMinHeight = minHeight; |
78 float resultMaxHeight = maxHeight; | 78 float resultMaxHeight = maxHeight; |
79 | 79 |
80 float resultZoom = zoom; | 80 float resultZoom = zoom; |
81 float resultMinZoom = minZoom; | 81 float resultMinZoom = minZoom; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 result.minimumScale = resultMinZoom; | 161 result.minimumScale = resultMinZoom; |
162 result.maximumScale = resultMaxZoom; | 162 result.maximumScale = resultMaxZoom; |
163 result.initialScale = resultZoom; | 163 result.initialScale = resultZoom; |
164 result.layoutSize.setWidth(resultWidth); | 164 result.layoutSize.setWidth(resultWidth); |
165 result.layoutSize.setHeight(resultHeight); | 165 result.layoutSize.setHeight(resultHeight); |
166 return result; | 166 return result; |
167 } | 167 } |
168 | 168 |
169 switch (static_cast<int>(resultWidth)) { | 169 switch (static_cast<int>(resultWidth)) { |
170 case ViewportArguments::ValueDeviceWidth: | 170 case ViewportArguments::ValueDeviceWidth: |
171 resultWidth = deviceSize.width(); | 171 resultWidth = initialViewportSize.width(); |
172 break; | 172 break; |
173 case ViewportArguments::ValueDeviceHeight: | 173 case ViewportArguments::ValueDeviceHeight: |
174 resultWidth = deviceSize.height(); | 174 resultWidth = initialViewportSize.height(); |
175 break; | 175 break; |
176 } | 176 } |
177 | 177 |
178 switch (static_cast<int>(resultHeight)) { | 178 switch (static_cast<int>(resultHeight)) { |
179 case ViewportArguments::ValueDeviceWidth: | 179 case ViewportArguments::ValueDeviceWidth: |
180 resultHeight = deviceSize.width(); | 180 resultHeight = initialViewportSize.width(); |
181 break; | 181 break; |
182 case ViewportArguments::ValueDeviceHeight: | 182 case ViewportArguments::ValueDeviceHeight: |
183 resultHeight = deviceSize.height(); | 183 resultHeight = initialViewportSize.height(); |
184 break; | 184 break; |
185 } | 185 } |
186 | 186 |
187 if (type != ViewportArguments::Implicit) { | 187 if (type != ViewportArguments::Implicit) { |
188 // Clamp values to a valid range, but not for @viewport since is | 188 // Clamp values to a valid range, but not for @viewport since is |
189 // not mandated by the specification. | 189 // not mandated by the specification. |
190 resultWidth = clampLengthValue(resultWidth); | 190 resultWidth = clampLengthValue(resultWidth); |
191 resultHeight = clampLengthValue(resultHeight); | 191 resultHeight = clampLengthValue(resultHeight); |
192 resultZoom = clampScaleValue(resultZoom); | 192 resultZoom = clampScaleValue(resultZoom); |
193 resultMinZoom = clampScaleValue(resultMinZoom); | 193 resultMinZoom = clampScaleValue(resultMinZoom); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 message.replace("%replacement2", replacement2); | 435 message.replace("%replacement2", replacement2); |
436 | 436 |
437 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru
ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) | 437 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru
ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound) |
438 message.append(" Note that ';' is not a separator in viewport values. Th
e list should be comma-separated."); | 438 message.append(" Note that ';' is not a separator in viewport values. Th
e list should be comma-separated."); |
439 | 439 |
440 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 440 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
441 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); | 441 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); |
442 } | 442 } |
443 | 443 |
444 } // namespace WebCore | 444 } // namespace WebCore |
OLD | NEW |