| 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 float ViewportArguments::resolveViewportLength(const Length& length, const Float
Size& initialViewportSize, Direction direction) |
| 72 { |
| 73 if (length.isAuto()) |
| 74 return ViewportArguments::ValueAuto; |
| 75 |
| 76 if (length.isFixed()) |
| 77 return length.getFloatValue(); |
| 78 |
| 79 if (length.type() == ExtendToZoom) |
| 80 return ViewportArguments::ValueExtendToZoom; |
| 81 |
| 82 if ((length.type() == Percent && direction == Horizontal) || length.type() =
= ViewportPercentageWidth) |
| 83 return initialViewportSize.width() * length.getFloatValue() / 100.0f; |
| 84 |
| 85 if ((length.type() == Percent && direction == Vertical) || length.type() ==
ViewportPercentageHeight) |
| 86 return initialViewportSize.height() * length.getFloatValue() / 100.0f; |
| 87 |
| 88 if (length.type() == ViewportPercentageMin) |
| 89 return min(initialViewportSize.width(), initialViewportSize.height()) *
length.viewportPercentageLength() / 100.0f; |
| 90 |
| 91 if (length.type() == ViewportPercentageMax) |
| 92 return max(initialViewportSize.width(), initialViewportSize.height()) *
length.viewportPercentageLength() / 100.0f; |
| 93 |
| 94 ASSERT_NOT_REACHED(); |
| 95 return ViewportArguments::ValueAuto; |
| 96 } |
| 97 |
| 71 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
Size, int defaultWidth) const | 98 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
Size, int defaultWidth) const |
| 72 { | 99 { |
| 73 float resultWidth = width; | 100 float resultWidth = width; |
| 74 float resultMaxWidth = maxWidth; | |
| 75 float resultMinWidth = minWidth; | |
| 76 float resultHeight = height; | 101 float resultHeight = height; |
| 77 float resultMinHeight = minHeight; | |
| 78 float resultMaxHeight = maxHeight; | |
| 79 | |
| 80 float resultZoom = zoom; | 102 float resultZoom = zoom; |
| 81 float resultMinZoom = minZoom; | 103 float resultMinZoom = minZoom; |
| 82 float resultMaxZoom = maxZoom; | 104 float resultMaxZoom = maxZoom; |
| 83 float resultUserZoom = userZoom; | 105 float resultUserZoom = userZoom; |
| 84 | 106 |
| 85 if (type == ViewportArguments::CSSDeviceAdaptation) { | 107 if (type == ViewportArguments::CSSDeviceAdaptation) { |
| 86 | 108 |
| 87 // device-width/device-height not supported for @viewport. | 109 float resultMaxWidth = resolveViewportLength(maxWidth, initialViewportSi
ze, Horizontal); |
| 88 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceWidth); | 110 float resultMinWidth = resolveViewportLength(minWidth, initialViewportSi
ze, Horizontal); |
| 89 ASSERT(resultMinWidth != ViewportArguments::ValueDeviceHeight); | 111 float resultMaxHeight = resolveViewportLength(maxHeight, initialViewport
Size, Vertical); |
| 90 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceWidth); | 112 float resultMinHeight = resolveViewportLength(minHeight, initialViewport
Size, Vertical); |
| 91 ASSERT(resultMaxWidth != ViewportArguments::ValueDeviceHeight); | |
| 92 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceWidth); | |
| 93 ASSERT(resultMinHeight != ViewportArguments::ValueDeviceHeight); | |
| 94 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceWidth); | |
| 95 ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight); | |
| 96 | 113 |
| 97 // 1. Resolve min-zoom and max-zoom values. | 114 // 1. Resolve min-zoom and max-zoom values. |
| 98 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi
ewportArguments::ValueAuto) | 115 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi
ewportArguments::ValueAuto) |
| 99 resultMaxZoom = max(resultMinZoom, resultMaxZoom); | 116 resultMaxZoom = max(resultMinZoom, resultMaxZoom); |
| 100 | 117 |
| 101 // 2. Constrain zoom value to the [min-zoom, max-zoom] range. | 118 // 2. Constrain zoom value to the [min-zoom, max-zoom] range. |
| 102 if (resultZoom != ViewportArguments::ValueAuto) | 119 if (resultZoom != ViewportArguments::ValueAuto) |
| 103 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(
resultMaxZoom, resultZoom, min), max); | 120 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(
resultMaxZoom, resultZoom, min), max); |
| 104 | 121 |
| 105 float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min); | 122 float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 136 // 4. Resolve initial width from min/max descriptors. | 153 // 4. Resolve initial width from min/max descriptors. |
| 137 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth !=
ViewportArguments::ValueAuto) | 154 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth !=
ViewportArguments::ValueAuto) |
| 138 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut
o(resultMaxWidth, initialViewportSize.width(), min), max); | 155 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut
o(resultMaxWidth, initialViewportSize.width(), min), max); |
| 139 | 156 |
| 140 // 5. Resolve initial height from min/max descriptors. | 157 // 5. Resolve initial height from min/max descriptors. |
| 141 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight !
= ViewportArguments::ValueAuto) | 158 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight !
= ViewportArguments::ValueAuto) |
| 142 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA
uto(resultMaxHeight, initialViewportSize.height(), min), max); | 159 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA
uto(resultMaxHeight, initialViewportSize.height(), min), max); |
| 143 | 160 |
| 144 // 6-7. Resolve width value. | 161 // 6-7. Resolve width value. |
| 145 if (resultWidth == ViewportArguments::ValueAuto) { | 162 if (resultWidth == ViewportArguments::ValueAuto) { |
| 146 if (resultHeight == ViewportArguments::ValueAuto || !initialViewport
Size .height()) | 163 if (resultHeight == ViewportArguments::ValueAuto || !initialViewport
Size.height()) |
| 147 resultWidth = initialViewportSize.width(); | 164 resultWidth = initialViewportSize.width(); |
| 148 else | 165 else |
| 149 resultWidth = resultHeight * (initialViewportSize.width() / init
ialViewportSize.height()); | 166 resultWidth = resultHeight * (initialViewportSize.width() / init
ialViewportSize.height()); |
| 150 } | 167 } |
| 151 | 168 |
| 152 // 8. Resolve height value. | 169 // 8. Resolve height value. |
| 153 if (resultHeight == ViewportArguments::ValueAuto) { | 170 if (resultHeight == ViewportArguments::ValueAuto) { |
| 154 if (!initialViewportSize.width()) | 171 if (!initialViewportSize.width()) |
| 155 resultHeight = initialViewportSize.height(); | 172 resultHeight = initialViewportSize.height(); |
| 156 else | 173 else |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!replacement1.isNull()) | 451 if (!replacement1.isNull()) |
| 435 message.replace("%replacement1", replacement1); | 452 message.replace("%replacement1", replacement1); |
| 436 if (!replacement2.isNull()) | 453 if (!replacement2.isNull()) |
| 437 message.replace("%replacement2", replacement2); | 454 message.replace("%replacement2", replacement2); |
| 438 | 455 |
| 439 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 456 // 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 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); | 457 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); |
| 441 } | 458 } |
| 442 | 459 |
| 443 } // namespace WebCore | 460 } // namespace WebCore |
| OLD | NEW |