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,
TargetDensityDpiTooSmallOrLargeError
};
struct ViewportAttributes {
FloatSize layoutSize;
float devicePixelRatio;
float initialScale;
float minimumScale;
float maximumScale;
float userScalable;
};
struct ViewportArguments {
enum Type {
Implicit,
ViewportMeta
} type;
enum {
ValueAuto = -1,
ValueDefault = -2,
ValueDeviceWidth = -3,
ValueDeviceHeight = -4,
};
ViewportArguments(Type type = Implicit)
: type(type)
, initialScale(ValueAuto)
, minimumScale(ValueAuto)
, maximumScale(ValueAuto)
, width(ValueAuto)
, height(ValueAuto)
, userScalable(ValueAuto)
{
}
float initialScale;
float minimumScale;
float maximumScale;
float width;
float height;
float userScalable;
bool operator==(const ViewportArguments& other) const
{
return initialScale == other.initialScale
&& minimumScale == other.minimumScale
&& maximumScale == other.maximumScale
&& width == other.width
&& height == other.height
&& userScalable == other.userScalable;
}
};
ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport);
void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result);
void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
void finializeViewportArguments(ViewportArguments& args);
}
#endif // ViewportArguments_h