gecko-dev/layout/base/GeckoMVMContext.h

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

70 строки
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 GeckoMVMContext_h_
#define GeckoMVMContext_h_
#include "MVMContext.h"
#include "mozilla/Attributes.h" // for MOZ_NON_OWNING_REF
#include "mozilla/RefPtr.h"
#include "nsCOMPtr.h"
namespace mozilla {
class PresShell;
namespace dom {
class Document;
class EventTarget;
} // namespace dom
/**
* An implementation of MVMContext that uses actual Gecko components.
* This is intended for production use (whereas TestMVMContext is intended for
* testing.)
*/
class GeckoMVMContext : public MVMContext {
public:
explicit GeckoMVMContext(dom::Document* aDocument, PresShell* aPresShell);
void AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener,
bool aUseCapture) override;
void RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
bool aUseCapture) override;
void AddObserver(nsIObserver* aObserver, const char* aTopic,
bool aOwnsWeak) override;
void RemoveObserver(nsIObserver* aObserver, const char* aTopic) override;
void Destroy() override;
nsViewportInfo GetViewportInfo(
const ScreenIntSize& aDisplaySize) const override;
CSSToLayoutDeviceScale CSSToDevPixelScale() const override;
float GetResolution() const override;
bool SubjectMatchesDocument(nsISupports* aSubject) const override;
Maybe<CSSRect> CalculateScrollableRectForRSF() const override;
bool IsResolutionUpdatedByApz() const override;
LayoutDeviceMargin ScrollbarAreaToExcludeFromCompositionBounds()
const override;
Maybe<LayoutDeviceIntSize> GetContentViewerSize() const override;
bool AllowZoomingForDocument() const override;
bool IsInReaderMode() const override;
bool IsDocumentLoading() const override;
void SetResolutionAndScaleTo(float aResolution,
ResolutionChangeOrigin aOrigin) override;
void SetVisualViewportSize(const CSSSize& aSize) override;
void PostVisualViewportResizeEventByDynamicToolbar() override;
void UpdateDisplayPortMargins() override;
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
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Reflow(const CSSSize& aNewSize) override;
private:
RefPtr<dom::Document> mDocument;
// raw ref since the presShell owns this
PresShell* MOZ_NON_OWNING_REF mPresShell;
nsCOMPtr<dom::EventTarget> mEventTarget;
};
} // namespace mozilla
#endif // GeckoMVMContext_h_