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-2013 Intel Corporation. All rights reserved. |
10 * | 10 * |
11 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
15 * | 15 * |
16 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 19 * Library General Public License for more details. |
20 * | 20 * |
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/page/PageScaleConstraints.h" | 31 #include "core/page/PageScaleConstraints.h" |
32 #include "core/platform/graphics/FloatSize.h" | 32 #include "core/platform/graphics/FloatSize.h" |
33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
34 | 34 |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
37 class Document; | 37 class Document; |
38 | 38 |
39 enum ViewportErrorCode { | |
40 UnrecognizedViewportArgumentKeyError, | |
41 UnrecognizedViewportArgumentValueError, | |
42 TruncatedViewportArgumentValueError, | |
43 MaximumScaleTooLargeError, | |
44 TargetDensityDpiUnsupported | |
45 }; | |
46 | |
47 struct ViewportArguments { | 39 struct ViewportArguments { |
48 | 40 |
49 enum Type { | |
50 // These are ordered in increasing importance. | |
51 Implicit, | |
52 XHTMLMobileProfile, | |
53 HandheldFriendlyMeta, | |
54 MobileOptimizedMeta, | |
55 ViewportMeta, | |
56 CSSDeviceAdaptation | |
57 } type; | |
58 | |
59 enum { | 41 enum { |
60 ValueAuto = -1, | 42 ValueAuto = -1, |
61 ValueDeviceWidth = -2, | |
62 ValueDeviceHeight = -3, | |
63 ValuePortrait = -4, | 43 ValuePortrait = -4, |
64 ValueLandscape = -5, | 44 ValueLandscape = -5, |
65 ValueDeviceDPI = -6, | 45 ValueDeviceDPI = -6, |
66 ValueLowDPI = -7, | 46 ValueLowDPI = -7, |
67 ValueMediumDPI = -8, | 47 ValueMediumDPI = -8, |
68 ValueHighDPI = -9 | 48 ValueHighDPI = -9, |
| 49 ValueExtendToZoom = -10 |
69 }; | 50 }; |
70 | 51 |
71 ViewportArguments(Type type = Implicit) | 52 ViewportArguments() |
72 : type(type) | 53 : minWidth(ValueAuto) |
73 , width(ValueAuto) | |
74 , minWidth(ValueAuto) | |
75 , maxWidth(ValueAuto) | 54 , maxWidth(ValueAuto) |
76 , height(ValueAuto) | |
77 , minHeight(ValueAuto) | 55 , minHeight(ValueAuto) |
78 , maxHeight(ValueAuto) | 56 , maxHeight(ValueAuto) |
79 , zoom(ValueAuto) | 57 , zoom(ValueAuto) |
80 , minZoom(ValueAuto) | 58 , minZoom(ValueAuto) |
81 , maxZoom(ValueAuto) | 59 , maxZoom(ValueAuto) |
82 , userZoom(ValueAuto) | 60 , userZoom(ValueAuto) |
83 , orientation(ValueAuto) | 61 , orientation(ValueAuto) |
84 , deprecatedTargetDensityDPI(ValueAuto) | 62 , deprecatedTargetDensityDPI(ValueAuto) |
85 { | 63 { |
86 } | 64 } |
87 | 65 |
88 // All arguments are in CSS units. | 66 PageScaleConstraints resolve(const FloatSize& initialViewportSizeInCSSUnits)
const; |
89 PageScaleConstraints resolve(const FloatSize& initialViewportSize, const Flo
atSize& deviceSize, int defaultWidth) const; | |
90 | 67 |
91 float width; | |
92 float minWidth; | 68 float minWidth; |
93 float maxWidth; | 69 float maxWidth; |
94 float height; | |
95 float minHeight; | 70 float minHeight; |
96 float maxHeight; | 71 float maxHeight; |
97 float zoom; | 72 float zoom; |
98 float minZoom; | 73 float minZoom; |
99 float maxZoom; | 74 float maxZoom; |
100 float userZoom; | 75 float userZoom; |
101 float orientation; | 76 float orientation; |
102 float deprecatedTargetDensityDPI; // Only used for Android WebView | 77 float deprecatedTargetDensityDPI; // Only used for Android WebView |
103 | 78 |
104 bool operator==(const ViewportArguments& other) const | 79 bool operator==(const ViewportArguments& other) const |
105 { | 80 { |
106 // Used for figuring out whether to reset the viewport or not, | 81 return minWidth == other.minWidth |
107 // thus we are not taking type into account. | |
108 return width == other.width | |
109 && minWidth == other.minWidth | |
110 && maxWidth == other.maxWidth | 82 && maxWidth == other.maxWidth |
111 && height == other.height | |
112 && minHeight == other.minHeight | 83 && minHeight == other.minHeight |
113 && maxHeight == other.maxHeight | 84 && maxHeight == other.maxHeight |
114 && zoom == other.zoom | 85 && zoom == other.zoom |
115 && minZoom == other.minZoom | 86 && minZoom == other.minZoom |
116 && maxZoom == other.maxZoom | 87 && maxZoom == other.maxZoom |
117 && userZoom == other.userZoom | 88 && userZoom == other.userZoom |
118 && orientation == other.orientation | 89 && orientation == other.orientation |
119 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; | 90 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; |
120 } | 91 } |
121 | 92 |
122 bool operator!=(const ViewportArguments& other) const | 93 bool operator!=(const ViewportArguments& other) const |
123 { | 94 { |
124 return !(*this == other); | 95 return !(*this == other); |
125 } | 96 } |
126 }; | 97 }; |
127 | 98 |
128 void setViewportFeature(const String& keyString, const String& valueString, Docu
ment*, void* data); | |
129 void reportViewportWarning(Document*, ViewportErrorCode, const String& replaceme
nt1, const String& replacement2); | |
130 | |
131 } // namespace WebCore | 99 } // namespace WebCore |
132 | 100 |
133 #endif // ViewportArguments_h | 101 #endif // ViewportArguments_h |
OLD | NEW |