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;
float shrinkToFit;
};
struct ViewportArguments {
enum Type {
Implicit,
#if PLATFORM(IOS)
PluginDocument,
ImageDocument,
#endif
ViewportMeta,
CSSDeviceAdaptation
} type;
enum {
ValueAuto = -1,
ValueDeviceWidth = -2,
ValueDeviceHeight = -3,
ValuePortrait = -4,
ValueLandscape = -5
};
explicit ViewportArguments(Type type = Implicit)
: type(type)
{
}
ViewportAttributes resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const;
float width { ValueAuto };
float minWidth { ValueAuto };
float maxWidth { ValueAuto };
float height { ValueAuto };
float minHeight { ValueAuto };
float maxHeight { ValueAuto };
float zoom { ValueAuto };
float minZoom { ValueAuto };
float maxZoom { ValueAuto };
float userZoom { ValueAuto };
float orientation { ValueAuto };
float shrinkToFit { ValueAuto };
bool operator==(const ViewportArguments& other) const
{
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
&& shrinkToFit == other.shrinkToFit;
}
bool operator!=(const ViewportArguments& other) const
{
return !(*this == other);
}
#if PLATFORM(GTK)
static const float deprecatedTargetDPI;
#endif
};
WEBCORE_EXPORT ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibleViewport);
WEBCORE_EXPORT void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport, float devicePixelRatio);
WEBCORE_EXPORT 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);
}
#endif // ViewportArguments_h