ZoomConstraintsClient.h (1564B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef ZoomConstraintsClient_h_ 8 #define ZoomConstraintsClient_h_ 9 10 #include "mozilla/Maybe.h" 11 #include "mozilla/layers/ScrollableLayerGuid.h" 12 #include "mozilla/layers/ZoomConstraints.h" 13 #include "nsCOMPtr.h" 14 #include "nsIDOMEventListener.h" 15 #include "nsIObserver.h" 16 17 namespace mozilla { 18 class PresShell; 19 namespace dom { 20 class Document; 21 class EventTarget; 22 } // namespace dom 23 } // namespace mozilla 24 25 class ZoomConstraintsClient final : public nsIDOMEventListener, 26 public nsIObserver { 27 public: 28 NS_DECL_ISUPPORTS 29 NS_DECL_NSIDOMEVENTLISTENER 30 NS_DECL_NSIOBSERVER 31 32 ZoomConstraintsClient(); 33 34 private: 35 ~ZoomConstraintsClient(); 36 37 public: 38 void Init(mozilla::PresShell* aPresShell, mozilla::dom::Document* aDocument); 39 void Destroy(); 40 void ScreenSizeChanged(); 41 42 bool GetAllowZoom() const { return mZoomConstraints.mAllowZoom; } 43 44 private: 45 void RefreshZoomConstraints(); 46 47 RefPtr<mozilla::dom::Document> mDocument; 48 // raw ref since the presShell owns this 49 mozilla::PresShell* MOZ_NON_OWNING_REF mPresShell; 50 nsCOMPtr<mozilla::dom::EventTarget> mEventTarget; 51 mozilla::Maybe<mozilla::layers::ScrollableLayerGuid> mGuid; 52 mozilla::layers::ZoomConstraints mZoomConstraints; 53 }; 54 55 #endif