ViewportArguments.h [plain text]
#ifndef ViewportArguments_h
#define ViewportArguments_h
#include "FloatSize.h"
#include <wtf/Forward.h>
namespace WebCore {
class Document;
enum ViewportErrorCode {
UnrecognizedViewportArgumentKeyError,
UnrecognizedViewportArgumentValueError,
TruncatedViewportArgumentValueError,
MaximumScaleTooLargeError
};
struct ViewportAttributes {
FloatSize layoutSize;
float initialScale;
float minimumScale;
float maximumScale;
float userScalable;
float orientation;
};
struct ViewportArguments {
enum Type {
Implicit,
#if ENABLE(LEGACY_VIEWPORT_ADAPTION)
XHTMLMobileProfile,
HandheldFriendlyMeta,
MobileOptimizedMeta,
#endif
#if PLATFORM(IOS)
PluginDocument,
ImageDocument,
#endif
ViewportMeta,
CSSDeviceAdaptation
} type;
enum {
ValueAuto = -1,
ValueDeviceWidth = -2,
ValueDeviceHeight = -3,
ValuePortrait = -4,
ValueLandscape = -5
};
ViewportArguments(Type type = Implicit)
: type(type)
, width(ValueAuto)
, minWidth(ValueAuto)
, maxWidth(ValueAuto)
, height(ValueAuto)
, minHeight(ValueAuto)
, maxHeight(ValueAuto)
, zoom(ValueAuto)
, minZoom(ValueAuto)
, maxZoom(ValueAuto)
, userZoom(ValueAuto)
, orientation(ValueAuto)
#if PLATFORM(IOS)
, minimalUI(false)
#endif
{
}
ViewportAttributes resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const;
float width;
float minWidth;
float maxWidth;
float height;
float minHeight;
float maxHeight;
float zoom;
float minZoom;
float maxZoom;
float userZoom;
float orientation;
#if PLATFORM(IOS)
bool minimalUI;
#endif
bool operator==(const ViewportArguments& other) const
{
#if PLATFORM(IOS)
#endif
return width == other.width
&& minWidth == other.minWidth
&& maxWidth == other.maxWidth
&& height == other.height
&& minHeight == other.minHeight
&& maxHeight == other.maxHeight
&& zoom == other.zoom
&& minZoom == other.minZoom
&& maxZoom == other.maxZoom
&& userZoom == other.userZoom
&& orientation == other.orientation;
}
bool operator!=(const ViewportArguments& other) const
{
return !(*this == other);
}
#if PLATFORM(BLACKBERRY) || PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT)
static const float deprecatedTargetDPI;
#endif
};
ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibleViewport);
void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport, float devicePixelRatio);
void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result);
float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& viewportSize, const IntSize& contentSize);
void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
#if PLATFORM(IOS)
void finializeViewportArguments(ViewportArguments& args);
#endif
}
#endif // ViewportArguments_h