#ifndef ViewportDescription_h
#define ViewportDescription_h
#include "core/page/PageScaleConstraints.h"
#include "platform/Length.h"
#include "platform/geometry/FloatSize.h"
namespace WebCore {
struct ViewportDescription {
enum Type {
UserAgentStyleSheet,
HandheldFriendlyMeta,
MobileOptimizedMeta,
ViewportMeta,
AuthorStyleSheet
} type;
enum {
ValueAuto = -1,
ValueDeviceWidth = -2,
ValueDeviceHeight = -3,
ValuePortrait = -4,
ValueLandscape = -5,
ValueDeviceDPI = -6,
ValueLowDPI = -7,
ValueMediumDPI = -8,
ValueHighDPI = -9,
ValueExtendToZoom = -10
};
ViewportDescription(Type type = UserAgentStyleSheet)
: type(type)
, zoom(ValueAuto)
, minZoom(ValueAuto)
, maxZoom(ValueAuto)
, userZoom(ValueAuto)
, orientation(ValueAuto)
, deprecatedTargetDensityDPI(ValueAuto)
{
}
PageScaleConstraints resolve(const FloatSize& initialViewportSize, Length legacyFallbackWidth) const;
Length minWidth;
Length maxWidth;
Length minHeight;
Length maxHeight;
float zoom;
float minZoom;
float maxZoom;
float userZoom;
float orientation;
float deprecatedTargetDensityDPI;
bool operator==(const ViewportDescription& other) const
{
return minWidth == other.minWidth
&& maxWidth == other.maxWidth
&& minHeight == other.minHeight
&& maxHeight == other.maxHeight
&& zoom == other.zoom
&& minZoom == other.minZoom
&& maxZoom == other.maxZoom
&& userZoom == other.userZoom
&& orientation == other.orientation
&& deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI;
}
bool operator!=(const ViewportDescription& other) const
{
return !(*this == other);
}
bool isLegacyViewportType() const { return type >= HandheldFriendlyMeta && type <= ViewportMeta; }
bool isMetaViewportType() const { return type == ViewportMeta; }
bool isSpecifiedByAuthor() const { return type != UserAgentStyleSheet; }
private:
enum Direction { Horizontal, Vertical };
static float resolveViewportLength(const Length&, const FloatSize& initialViewportSize, Direction);
};
}
#endif