Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sky/engine/core/dom/ViewportDescription.h

Issue 654693004: Remove meta viewport and @viewport CSS rules. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
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/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
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
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 *
26 */
27
28 #ifndef ViewportDescription_h
29 #define ViewportDescription_h
30
31 #include "platform/Length.h"
32 #include "platform/geometry/FloatSize.h"
33
34 namespace blink {
35
36 class LocalFrame;
37
38 struct ViewportDescription {
39
40 enum Type {
41 // These are ordered in increasing importance.
42 UserAgentStyleSheet,
43 HandheldFriendlyMeta,
44 MobileOptimizedMeta,
45 ViewportMeta,
46 AuthorStyleSheet
47 } type;
48
49 enum {
50 ValueAuto = -1,
51 ValueDeviceWidth = -2,
52 ValueDeviceHeight = -3,
53 ValuePortrait = -4,
54 ValueLandscape = -5,
55 ValueDeviceDPI = -6,
56 ValueLowDPI = -7,
57 ValueMediumDPI = -8,
58 ValueHighDPI = -9,
59 ValueExtendToZoom = -10
60 };
61
62 ViewportDescription(Type type = UserAgentStyleSheet)
63 : type(type)
64 , zoom(ValueAuto)
65 , minZoom(ValueAuto)
66 , maxZoom(ValueAuto)
67 , userZoom(true)
68 , orientation(ValueAuto)
69 , deprecatedTargetDensityDPI(ValueAuto)
70 , zoomIsExplicit(false)
71 , minZoomIsExplicit(false)
72 , maxZoomIsExplicit(false)
73 , userZoomIsExplicit(false)
74 {
75 }
76
77 Length minWidth;
78 Length maxWidth;
79 Length minHeight;
80 Length maxHeight;
81 float zoom;
82 float minZoom;
83 float maxZoom;
84 bool userZoom;
85 float orientation;
86 float deprecatedTargetDensityDPI; // Only used for Android WebView
87
88 // Whether the computed value was explicitly specified rather than being
89 // inferred.
90 bool zoomIsExplicit;
91 bool minZoomIsExplicit;
92 bool maxZoomIsExplicit;
93 bool userZoomIsExplicit;
94
95 bool operator==(const ViewportDescription& other) const
96 {
97 // Used for figuring out whether to reset the viewport or not,
98 // thus we are not taking type into account.
99 return minWidth == other.minWidth
100 && maxWidth == other.maxWidth
101 && minHeight == other.minHeight
102 && maxHeight == other.maxHeight
103 && zoom == other.zoom
104 && minZoom == other.minZoom
105 && maxZoom == other.maxZoom
106 && userZoom == other.userZoom
107 && orientation == other.orientation
108 && deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI
109 && zoomIsExplicit == other.zoomIsExplicit
110 && minZoomIsExplicit == other.minZoomIsExplicit
111 && maxZoomIsExplicit == other.maxZoomIsExplicit
112 && userZoomIsExplicit == other.userZoomIsExplicit;
113 }
114
115 bool operator!=(const ViewportDescription& other) const
116 {
117 return !(*this == other);
118 }
119
120 bool isLegacyViewportType() const { return type >= HandheldFriendlyMeta && t ype <= ViewportMeta; }
121 bool isMetaViewportType() const { return type == ViewportMeta; }
122 bool isSpecifiedByAuthor() const { return type != UserAgentStyleSheet; }
123
124 // Reports UMA stat on whether the page is considered mobile or desktop and what kind of
125 // mobile it is. Applies only to Android, must only be called once per page load.
126 void reportMobilePageStats(const LocalFrame*) const;
127
128 private:
129 enum Direction { Horizontal, Vertical };
130 static float resolveViewportLength(const Length&, const FloatSize& initialVi ewportSize, Direction);
131 };
132
133 } // namespace blink
134
135 #endif // ViewportDescription_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698