| Index: Source/core/dom/ViewportAttributes.cpp
|
| diff --git a/Source/modules/donottrack/NavigatorDoNotTrack.cpp b/Source/core/dom/ViewportAttributes.cpp
|
| similarity index 50%
|
| copy from Source/modules/donottrack/NavigatorDoNotTrack.cpp
|
| copy to Source/core/dom/ViewportAttributes.cpp
|
| index 5fee3b5536ae29b0637a6b4b389cf8727490f158..f15d28fdc2ba2ef8be11de1cb696241da6aaacea 100644
|
| --- a/Source/modules/donottrack/NavigatorDoNotTrack.cpp
|
| +++ b/Source/core/dom/ViewportAttributes.cpp
|
| @@ -29,48 +29,56 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "modules/donottrack/NavigatorDoNotTrack.h"
|
| -
|
| -#include "core/loader/FrameLoader.h"
|
| -#include "core/loader/FrameLoaderClient.h"
|
| -#include "core/page/Frame.h"
|
| -#include "core/page/Navigator.h"
|
| -#include "wtf/PassOwnPtr.h"
|
| +#include "ViewportAttributes.h"
|
|
|
| namespace WebCore {
|
|
|
| -NavigatorDoNotTrack::NavigatorDoNotTrack(Frame* frame)
|
| - : DOMWindowProperty(frame)
|
| -{
|
| -}
|
| +ViewportAttributes::ViewportAttributes()
|
| + : initialScale(-1), minimumScale(-1), maximumScale(-1) { }
|
|
|
| -NavigatorDoNotTrack::~NavigatorDoNotTrack()
|
| -{
|
| -}
|
| +ViewportAttributes::ViewportAttributes(float initial, float minimum, float maximum)
|
| + : initialScale(initial), minimumScale(minimum), maximumScale(maximum) { }
|
|
|
| -const char* NavigatorDoNotTrack::supplementName()
|
| +void ViewportAttributes::overrideWith(const ViewportAttributes& other)
|
| {
|
| - return "NavigatorDoNotTrack";
|
| + if (other.initialScale != -1) {
|
| + initialScale = other.initialScale;
|
| + if (minimumScale != -1)
|
| + minimumScale = std::min(minimumScale, other.initialScale);
|
| + }
|
| + if (other.minimumScale != -1)
|
| + minimumScale = other.minimumScale;
|
| + if (other.maximumScale != -1)
|
| + maximumScale = other.maximumScale;
|
| + if (!other.layoutSize.isEmpty())
|
| + layoutSize = other.layoutSize;
|
| + clampAll();
|
| }
|
|
|
| -NavigatorDoNotTrack* NavigatorDoNotTrack::from(Navigator* navigator)
|
| +float ViewportAttributes::clampToConstraints(float pageScaleFactor) const
|
| {
|
| - NavigatorDoNotTrack* supplement = static_cast<NavigatorDoNotTrack*>(Supplement<Navigator>::from(navigator, supplementName()));
|
| - if (!supplement) {
|
| - supplement = new NavigatorDoNotTrack(navigator->frame());
|
| - provideTo(navigator, supplementName(), adoptPtr(supplement));
|
| - }
|
| - return supplement;
|
| + if (pageScaleFactor == -1)
|
| + return pageScaleFactor;
|
| + if (minimumScale != -1)
|
| + pageScaleFactor = std::max(pageScaleFactor, minimumScale);
|
| + if (maximumScale != -1)
|
| + pageScaleFactor = std::min(pageScaleFactor, maximumScale);
|
| + return pageScaleFactor;
|
| }
|
|
|
| -String NavigatorDoNotTrack::doNotTrack(Navigator* navigator)
|
| +void ViewportAttributes::clampAll()
|
| {
|
| - return NavigatorDoNotTrack::from(navigator)->doNotTrack();
|
| + if (minimumScale != -1 && maximumScale != -1)
|
| + maximumScale = std::max(minimumScale, maximumScale);
|
| + initialScale = clampToConstraints(initialScale);
|
| }
|
|
|
| -String NavigatorDoNotTrack::doNotTrack()
|
| +bool ViewportAttributes::operator==(const ViewportAttributes& other) const
|
| {
|
| - return frame() ? frame()->loader()->client()->doNotTrackValue() : String();
|
| + return layoutSize == other.layoutSize
|
| + && initialScale == other.initialScale
|
| + && minimumScale == other.minimumScale
|
| + && maximumScale == other.maximumScale;
|
| }
|
|
|
| } // namespace WebCore
|
|
|