| 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 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 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 10 matching lines...) Expand all Loading... |
| 21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
| 22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
| 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
| 25 * | 25 * |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef ViewportArguments_h | 28 #ifndef ViewportArguments_h |
| 29 #define ViewportArguments_h | 29 #define ViewportArguments_h |
| 30 | 30 |
| 31 #include "core/dom/ViewportAttributes.h" |
| 31 #include "core/platform/graphics/FloatSize.h" | 32 #include "core/platform/graphics/FloatSize.h" |
| 32 #include <wtf/Forward.h> | 33 #include <wtf/Forward.h> |
| 33 | 34 |
| 34 namespace WebCore { | 35 namespace WebCore { |
| 35 | 36 |
| 36 class Document; | 37 class Document; |
| 37 | 38 |
| 38 enum ViewportErrorCode { | 39 enum ViewportErrorCode { |
| 39 UnrecognizedViewportArgumentKeyError, | 40 UnrecognizedViewportArgumentKeyError, |
| 40 UnrecognizedViewportArgumentValueError, | 41 UnrecognizedViewportArgumentValueError, |
| 41 TruncatedViewportArgumentValueError, | 42 TruncatedViewportArgumentValueError, |
| 42 MaximumScaleTooLargeError, | 43 MaximumScaleTooLargeError, |
| 43 TargetDensityDpiUnsupported | 44 TargetDensityDpiUnsupported |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 struct ViewportAttributes { | |
| 47 FloatSize layoutSize; | |
| 48 | |
| 49 float initialScale; | |
| 50 float minimumScale; | |
| 51 float maximumScale; | |
| 52 | |
| 53 float userScalable; | |
| 54 float orientation; | |
| 55 }; | |
| 56 | |
| 57 struct ViewportArguments { | 47 struct ViewportArguments { |
| 58 | 48 |
| 59 enum Type { | 49 enum Type { |
| 60 // These are ordered in increasing importance. | 50 // These are ordered in increasing importance. |
| 61 Implicit, | 51 Implicit, |
| 62 XHTMLMobileProfile, | 52 XHTMLMobileProfile, |
| 63 HandheldFriendlyMeta, | 53 HandheldFriendlyMeta, |
| 64 MobileOptimizedMeta, | 54 MobileOptimizedMeta, |
| 65 ViewportMeta, | 55 ViewportMeta, |
| 66 CSSDeviceAdaptation | 56 CSSDeviceAdaptation |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 , width(ValueAuto) | 73 , width(ValueAuto) |
| 84 , minWidth(ValueAuto) | 74 , minWidth(ValueAuto) |
| 85 , maxWidth(ValueAuto) | 75 , maxWidth(ValueAuto) |
| 86 , height(ValueAuto) | 76 , height(ValueAuto) |
| 87 , minHeight(ValueAuto) | 77 , minHeight(ValueAuto) |
| 88 , maxHeight(ValueAuto) | 78 , maxHeight(ValueAuto) |
| 89 , zoom(ValueAuto) | 79 , zoom(ValueAuto) |
| 90 , minZoom(ValueAuto) | 80 , minZoom(ValueAuto) |
| 91 , maxZoom(ValueAuto) | 81 , maxZoom(ValueAuto) |
| 92 , userZoom(ValueAuto) | 82 , userZoom(ValueAuto) |
| 93 , orientation(ValueAuto) | |
| 94 , deprecatedTargetDensityDPI(ValueAuto) | 83 , deprecatedTargetDensityDPI(ValueAuto) |
| 95 { | 84 { |
| 96 } | 85 } |
| 97 | 86 |
| 98 // All arguments are in CSS units. | 87 // All arguments are in CSS units. |
| 99 ViewportAttributes resolve(const FloatSize& initialViewportSize, const Float
Size& deviceSize, int defaultWidth) const; | 88 ViewportAttributes resolve(const FloatSize& initialViewportSize, const Float
Size& deviceSize, int defaultWidth) const; |
| 100 | 89 |
| 101 float width; | 90 float width; |
| 102 float minWidth; | 91 float minWidth; |
| 103 float maxWidth; | 92 float maxWidth; |
| 104 float height; | 93 float height; |
| 105 float minHeight; | 94 float minHeight; |
| 106 float maxHeight; | 95 float maxHeight; |
| 107 float zoom; | 96 float zoom; |
| 108 float minZoom; | 97 float minZoom; |
| 109 float maxZoom; | 98 float maxZoom; |
| 110 float userZoom; | 99 float userZoom; |
| 111 float orientation; | |
| 112 float deprecatedTargetDensityDPI; // Only used for Android WebView | 100 float deprecatedTargetDensityDPI; // Only used for Android WebView |
| 113 | 101 |
| 114 bool operator==(const ViewportArguments& other) const | 102 bool operator==(const ViewportArguments& other) const |
| 115 { | 103 { |
| 116 // Used for figuring out whether to reset the viewport or not, | 104 // Used for figuring out whether to reset the viewport or not, |
| 117 // thus we are not taking type into account. | 105 // thus we are not taking type into account. |
| 118 return width == other.width | 106 return width == other.width |
| 119 && minWidth == other.minWidth | 107 && minWidth == other.minWidth |
| 120 && maxWidth == other.maxWidth | 108 && maxWidth == other.maxWidth |
| 121 && height == other.height | 109 && height == other.height |
| 122 && minHeight == other.minHeight | 110 && minHeight == other.minHeight |
| 123 && maxHeight == other.maxHeight | 111 && maxHeight == other.maxHeight |
| 124 && zoom == other.zoom | 112 && zoom == other.zoom |
| 125 && minZoom == other.minZoom | 113 && minZoom == other.minZoom |
| 126 && maxZoom == other.maxZoom | 114 && maxZoom == other.maxZoom |
| 127 && userZoom == other.userZoom | 115 && userZoom == other.userZoom |
| 128 && orientation == other.orientation | |
| 129 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; | 116 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; |
| 130 } | 117 } |
| 131 | 118 |
| 132 bool operator!=(const ViewportArguments& other) const | 119 bool operator!=(const ViewportArguments& other) const |
| 133 { | 120 { |
| 134 return !(*this == other); | 121 return !(*this == other); |
| 135 } | 122 } |
| 136 | |
| 137 // FIXME: We're going to keep this constant around until all embedders | |
| 138 // refactor their code to no longer need it. | |
| 139 static const float deprecatedTargetDPI; | |
| 140 }; | 123 }; |
| 141 | 124 |
| 142 ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktop
Width, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibl
eViewport); | |
| 143 | |
| 144 void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSiz
e visibleViewport, float devicePixelRatio); | |
| 145 void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& resu
lt); | |
| 146 float computeMinimumScaleFactorForContentContained(const ViewportAttributes& res
ult, const IntSize& viewportSize, const IntSize& contentSize); | |
| 147 | |
| 148 void setViewportFeature(const String& keyString, const String& valueString, Docu
ment*, void* data); | 125 void setViewportFeature(const String& keyString, const String& valueString, Docu
ment*, void* data); |
| 149 void reportViewportWarning(Document*, ViewportErrorCode, const String& replaceme
nt1, const String& replacement2); | 126 void reportViewportWarning(Document*, ViewportErrorCode, const String& replaceme
nt1, const String& replacement2); |
| 150 | 127 |
| 151 } // namespace WebCore | 128 } // namespace WebCore |
| 152 | 129 |
| 153 #endif // ViewportArguments_h | 130 #endif // ViewportArguments_h |
| OLD | NEW |