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-2013 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 18 matching lines...) Expand all Loading... |
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, |
69 ValueExtendToZoom = -10 | 49 ValueExtendToZoom = -10 |
70 }; | 50 }; |
71 | 51 |
72 ViewportArguments(Type type = Implicit) | 52 ViewportArguments() |
73 : type(type) | 53 : minWidth(ValueAuto) |
74 , width(ValueAuto) | |
75 , minWidth(ValueAuto) | |
76 , maxWidth(ValueAuto) | 54 , maxWidth(ValueAuto) |
77 , height(ValueAuto) | |
78 , minHeight(ValueAuto) | 55 , minHeight(ValueAuto) |
79 , maxHeight(ValueAuto) | 56 , maxHeight(ValueAuto) |
80 , zoom(ValueAuto) | 57 , zoom(ValueAuto) |
81 , minZoom(ValueAuto) | 58 , minZoom(ValueAuto) |
82 , maxZoom(ValueAuto) | 59 , maxZoom(ValueAuto) |
83 , userZoom(ValueAuto) | 60 , userZoom(ValueAuto) |
84 , orientation(ValueAuto) | 61 , orientation(ValueAuto) |
85 , deprecatedTargetDensityDPI(ValueAuto) | 62 , deprecatedTargetDensityDPI(ValueAuto) |
86 { | 63 { |
87 } | 64 } |
88 | 65 |
89 // All arguments are in CSS units. | 66 PageScaleConstraints resolve(const FloatSize& initialViewportSizeInCSSUnits)
const; |
90 PageScaleConstraints resolve(const FloatSize& initialViewportSize, int defau
ltWidth) const; | |
91 | 67 |
92 float width; | |
93 float minWidth; | 68 float minWidth; |
94 float maxWidth; | 69 float maxWidth; |
95 float height; | |
96 float minHeight; | 70 float minHeight; |
97 float maxHeight; | 71 float maxHeight; |
98 float zoom; | 72 float zoom; |
99 float minZoom; | 73 float minZoom; |
100 float maxZoom; | 74 float maxZoom; |
101 float userZoom; | 75 float userZoom; |
102 float orientation; | 76 float orientation; |
103 float deprecatedTargetDensityDPI; // Only used for Android WebView | 77 float deprecatedTargetDensityDPI; // Only used for Android WebView |
104 | 78 |
105 bool operator==(const ViewportArguments& other) const | 79 bool operator==(const ViewportArguments& other) const |
106 { | 80 { |
107 // Used for figuring out whether to reset the viewport or not, | 81 return minWidth == other.minWidth |
108 // thus we are not taking type into account. | |
109 return width == other.width | |
110 && minWidth == other.minWidth | |
111 && maxWidth == other.maxWidth | 82 && maxWidth == other.maxWidth |
112 && height == other.height | |
113 && minHeight == other.minHeight | 83 && minHeight == other.minHeight |
114 && maxHeight == other.maxHeight | 84 && maxHeight == other.maxHeight |
115 && zoom == other.zoom | 85 && zoom == other.zoom |
116 && minZoom == other.minZoom | 86 && minZoom == other.minZoom |
117 && maxZoom == other.maxZoom | 87 && maxZoom == other.maxZoom |
118 && userZoom == other.userZoom | 88 && userZoom == other.userZoom |
119 && orientation == other.orientation | 89 && orientation == other.orientation |
120 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; | 90 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI; |
121 } | 91 } |
122 | 92 |
123 bool operator!=(const ViewportArguments& other) const | 93 bool operator!=(const ViewportArguments& other) const |
124 { | 94 { |
125 return !(*this == other); | 95 return !(*this == other); |
126 } | 96 } |
127 }; | 97 }; |
128 | 98 |
129 void setViewportFeature(const String& keyString, const String& valueString, Docu
ment*, void* data); | |
130 void reportViewportWarning(Document*, ViewportErrorCode, const String& replaceme
nt1, const String& replacement2); | |
131 | |
132 } // namespace WebCore | 99 } // namespace WebCore |
133 | 100 |
134 #endif // ViewportArguments_h | 101 #endif // ViewportArguments_h |
OLD | NEW |