gecko-dev/layout/base/MVMContext.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 строки
2.5 KiB
C
Исходник Обычный вид История

/* 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 "mozilla/PresShellForwards.h"
#include "nsISupportsImpl.h"
#include "nsStringFwd.h"
#include "nsViewportInfo.h"
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;
virtual bool IsInReaderMode() const = 0;
virtual bool IsDocumentLoading() const = 0;
virtual void SetResolutionAndScaleTo(float aResolution,
ResolutionChangeOrigin aOrigin) = 0;
virtual void SetVisualViewportSize(const CSSSize& aSize) = 0;
virtual void PostVisualViewportResizeEventByDynamicToolbar() = 0;
virtual void UpdateDisplayPortMargins() = 0;
Bug 1551659 - Remove MVMContext::ResizeEventFlag and related code. r=botond,hiro D46944 / bug 1583534 is what fixes the root cause of bug 1528052 by not having the first call to ResizeReflow have a wrong old size of 0x0. This removes the code that bug introduces to suppress resize events, which fixes this bug. I think our behavior now is pretty sane. In particular, consider the test-case: <!doctype html> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <a href="" target="_blank">Open me in a separate tab</a> <pre id="log"></pre> <script> // This shouldn't be needed, but otherwise Fenix doesn't show the tooltip on // longpress... document.querySelector("a").href = location.href; function logSize() { log.innerText += window.innerWidth + "x" + window.innerHeight + "\n"; } logSize(); onresize = logSize; </script> (Hosted at https://crisal.io/tmp/gecko-mobile-resize.html for convenience) Right now on trunk, when you click the link from GVE or Fenix, we're only getting an initial size of 0x0 (which is not great, btw), and only after first paint we get the real device size, but content doesn't get a resize event. This is obviously wrong, every time the layout viewport changes we should fire resize events. Pages that get opened in new tabs and get refreshed when resized may get an extra reload with this approach, but this seems not avoidable unless widget sets the viewport size right in advance (which from discussion with snorp and agi doesn't seem possible in the general case). What used to happen is that we were triggering a redundant resize reflow from the initial paint which didn't update the layout viewport (because the content viewer and co had the right viewport from the previous navigation). Now that we optimize those away, I think our behavior should be correct. Differential Revision: https://phabricator.services.mozilla.com/D46956 --HG-- extra : moz-landing-system : lando
2019-09-25 22:35:29 +03:00
virtual void Reflow(const CSSSize& aNewSize) = 0;
};
} // namespace mozilla
#endif // MVMContext_h_