• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.torchmobile.com/)
8  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public License
21  * along with this library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  */
26 
27 #ifndef ViewportArguments_h
28 #define ViewportArguments_h
29 
30 #include "IntSize.h"
31 #include <wtf/Forward.h>
32 
33 namespace WebCore {
34 
35 class Document;
36 
37 enum ViewportErrorCode {
38     UnrecognizedViewportArgumentKeyError,
39     UnrecognizedViewportArgumentValueError,
40     TruncatedViewportArgumentValueError,
41     MaximumScaleTooLargeError,
42     TargetDensityDpiTooSmallOrLargeError
43 };
44 
45 struct ViewportAttributes {
46     IntSize layoutSize;
47 
48     float devicePixelRatio;
49 
50     float initialScale;
51     float minimumScale;
52     float maximumScale;
53 
54     float userScalable;
55 };
56 
57 struct ViewportArguments {
58 
59     enum {
60         ValueAuto = -1,
61         ValueDesktopWidth = -2,
62         ValueDeviceWidth = -3,
63         ValueDeviceHeight = -4,
64         ValueDeviceDPI = -5,
65         ValueLowDPI = -6,
66         ValueMediumDPI = -7,
67         ValueHighDPI = -8
68     };
69 
ViewportArgumentsViewportArguments70     ViewportArguments()
71         : initialScale(ValueAuto)
72         , minimumScale(ValueAuto)
73         , maximumScale(ValueAuto)
74         , width(ValueAuto)
75         , height(ValueAuto)
76         , targetDensityDpi(ValueAuto)
77         , userScalable(ValueAuto)
78     {
79     }
80 
81     float initialScale;
82     float minimumScale;
83     float maximumScale;
84     float width;
85     float height;
86     float targetDensityDpi;
87     float userScalable;
88 
89     bool operator==(const ViewportArguments& other) const
90     {
91         return initialScale == other.initialScale
92             && minimumScale == other.minimumScale
93             && maximumScale == other.maximumScale
94             && width == other.width
95             && height == other.height
96             && targetDensityDpi == other.targetDensityDpi
97             && userScalable == other.userScalable;
98     }
99 };
100 
101 ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
102 
103 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
104 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
105 
106 } // namespace WebCore
107 
108 #endif // ViewportArguments_h
109