2019-04-05 01:11:40 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MVMContext_h_
|
|
|
|
#define MVMContext_h_
|
|
|
|
|
|
|
|
#include "Units.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsStringFwd.h"
|
|
|
|
#include "nsViewportInfo.h"
|
2019-08-13 01:22:12 +03:00
|
|
|
#include "PresShell.h"
|
2019-04-05 01:11:40 +03:00
|
|
|
|
|
|
|
class nsIDOMEventListener;
|
|
|
|
class nsIObserver;
|
|
|
|
class nsISupports;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The interface MobileViewportManager uses to interface with its surroundings.
|
|
|
|
* This mainly exists to facilitate testing MobileViewportManager in isolation
|
|
|
|
* from the rest of Gecko.
|
|
|
|
*/
|
|
|
|
class MVMContext {
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MVMContext)
|
|
|
|
protected:
|
|
|
|
virtual ~MVMContext() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
bool aUseCapture) = 0;
|
|
|
|
virtual void RemoveEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
bool aUseCapture) = 0;
|
|
|
|
virtual void AddObserver(nsIObserver* aObserver, const char* aTopic,
|
|
|
|
bool aOwnsWeak) = 0;
|
|
|
|
virtual void RemoveObserver(nsIObserver* aObserver, const char* aTopic) = 0;
|
|
|
|
virtual void Destroy() = 0;
|
|
|
|
|
|
|
|
virtual nsViewportInfo GetViewportInfo(
|
|
|
|
const ScreenIntSize& aDisplaySize) const = 0;
|
|
|
|
virtual CSSToLayoutDeviceScale CSSToDevPixelScale() const = 0;
|
|
|
|
virtual float GetResolution() const = 0;
|
|
|
|
virtual bool SubjectMatchesDocument(nsISupports* aSubject) const = 0;
|
|
|
|
virtual Maybe<CSSRect> CalculateScrollableRectForRSF() const = 0;
|
|
|
|
virtual bool IsResolutionUpdatedByApz() const = 0;
|
|
|
|
virtual LayoutDeviceMargin ScrollbarAreaToExcludeFromCompositionBounds()
|
|
|
|
const = 0;
|
|
|
|
virtual Maybe<LayoutDeviceIntSize> GetContentViewerSize() const = 0;
|
|
|
|
virtual bool AllowZoomingForDocument() const = 0;
|
2019-08-22 02:33:14 +03:00
|
|
|
virtual bool IsInReaderMode() const = 0;
|
2019-08-22 01:00:43 +03:00
|
|
|
virtual bool IsDocumentLoading() const = 0;
|
2019-04-05 01:11:40 +03:00
|
|
|
|
2019-08-13 01:22:12 +03:00
|
|
|
virtual void SetResolutionAndScaleTo(float aResolution,
|
|
|
|
ResolutionChangeOrigin aOrigin) = 0;
|
2019-04-05 01:11:40 +03:00
|
|
|
virtual void SetVisualViewportSize(const CSSSize& aSize) = 0;
|
|
|
|
virtual void UpdateDisplayPortMargins() = 0;
|
2019-04-23 07:14:55 +03:00
|
|
|
|
|
|
|
enum class ResizeEventFlag {
|
|
|
|
IfNecessary, // resize events will be fired if necessary.
|
|
|
|
Suppress, // resize events will never be fired.
|
|
|
|
};
|
Bug 1583534 - Further simplify PresShell::ResizeReflow. r=botond
In particular, not let ResizeReflow take the old and new size. Most of the
callers pass dummy values anyway.
Instead, use the old size of the layout viewport. This ensures we fire resize
events only if the layout viewport actually changes.
This is important because the first resize of the mobile viewport manager
after a navigation has an "old size" of 0x0, even though the layout viewport
is initialized on presshell initialization to the right size.
Thus, we fire resize events unnecessarily in that case, which is the root cause
for bug 1528052.
To do this, we need to shuffle a bit of code in nsDocumentViewer that deals with
delayed resizes, to set the visible area _and_ invalidate layout, rather than
setting the visible area and _then_ relying on doing a resize reflow.
Further cleanup is possible, though not required for my android resizing fix, so
will do separately.
Differential Revision: https://phabricator.services.mozilla.com/D46944
--HG--
extra : moz-landing-system : lando
2019-09-25 22:12:44 +03:00
|
|
|
virtual void Reflow(const CSSSize& aNewSize, ResizeEventFlag) = 0;
|
2019-04-05 01:11:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MVMContext_h_
|