forked from mirrors/gecko-dev
		
	 680815cd6e
			
		
	
	
		680815cd6e
		
	
	
	
	
		
			
			This patch was generated automatically by the "modeline.py" script, available here: https://github.com/amccreight/moz-source-tools/blob/master/modeline.py For every file that is modified in this patch, the changes are as follows: (1) The patch changes the file to use the exact C++ mode lines from the Mozilla coding style guide, available here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line (2) The patch deletes any blank lines between the mode line & the MPL boilerplate comment. (3) If the file previously had the mode lines and MPL boilerplate in a single contiguous C++ comment, then the patch splits them into separate C++ comments, to match the boilerplate in the coding style. MozReview-Commit-ID: EuRsDue63tK --HG-- extra : rebase_source : 3356d4b80ff6213935192e87cdbc9103fec6084c
		
			
				
	
	
		
			102 lines
		
	
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | |
| /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 | |
| /* 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 MobileViewportManager_h_
 | |
| #define MobileViewportManager_h_
 | |
| 
 | |
| #include "mozilla/Maybe.h"
 | |
| #include "nsIDOMEventListener.h"
 | |
| #include "nsIObserver.h"
 | |
| #include "Units.h"
 | |
| 
 | |
| class nsIDOMEventTarget;
 | |
| class nsIDocument;
 | |
| class nsIPresShell;
 | |
| class nsViewportInfo;
 | |
| 
 | |
| class MobileViewportManager final : public nsIDOMEventListener
 | |
|                                   , public nsIObserver
 | |
| {
 | |
| public:
 | |
|   NS_DECL_ISUPPORTS
 | |
|   NS_DECL_NSIDOMEVENTLISTENER
 | |
|   NS_DECL_NSIOBSERVER
 | |
| 
 | |
|   MobileViewportManager(nsIPresShell* aPresShell,
 | |
|                         nsIDocument* aDocument);
 | |
|   void Destroy();
 | |
| 
 | |
|   /* Provide a resolution to use during the first paint instead of the default
 | |
|    * resolution computed from the viewport info metadata. This is in the same
 | |
|    * "units" as the argument to nsDOMWindowUtils::SetResolutionAndScaleTo.
 | |
|    * Also takes the previous display dimensions as they were at the time the
 | |
|    * resolution was stored in order to correctly adjust the resolution if the
 | |
|    * device was rotated in the meantime. */
 | |
|   void SetRestoreResolution(float aResolution,
 | |
|                             mozilla::LayoutDeviceIntSize aDisplaySize);
 | |
| 
 | |
| private:
 | |
|   void SetRestoreResolution(float aResolution);
 | |
| 
 | |
| public:
 | |
|   /* Notify the MobileViewportManager that a reflow was requested in the
 | |
|    * presShell.*/
 | |
|   void RequestReflow();
 | |
| 
 | |
|   /* Notify the MobileViewportManager that the resolution on the presShell was
 | |
|    * updated, and the SPCSPS needs to be updated. */
 | |
|   void ResolutionUpdated();
 | |
| 
 | |
| private:
 | |
|   ~MobileViewportManager();
 | |
| 
 | |
|   /* Called to compute the initial viewport on page load or before-first-paint,
 | |
|    * whichever happens first. */
 | |
|   void SetInitialViewport();
 | |
| 
 | |
|   /* Main helper method to update the CSS viewport and any other properties that
 | |
|    * need updating. */
 | |
|   void RefreshViewportSize(bool aForceAdjustResolution);
 | |
| 
 | |
|   /* Secondary main helper method to update just the SPCSPS. */
 | |
|   void RefreshSPCSPS();
 | |
| 
 | |
|   /* Helper to clamp the given zoom by the min/max in the viewport info. */
 | |
|   mozilla::CSSToScreenScale ClampZoom(const mozilla::CSSToScreenScale& aZoom,
 | |
|                                       const nsViewportInfo& aViewportInfo);
 | |
| 
 | |
|   /* Helper to update the given resolution according to changed display and viewport widths. */
 | |
|   mozilla::LayoutDeviceToLayerScale
 | |
|   ScaleResolutionWithDisplayWidth(const mozilla::LayoutDeviceToLayerScale& aRes,
 | |
|                                   const float& aDisplayWidthChangeRatio,
 | |
|                                   const mozilla::CSSSize& aNewViewport,
 | |
|                                   const mozilla::CSSSize& aOldViewport);
 | |
| 
 | |
|   /* Updates the presShell resolution and returns the new zoom. */
 | |
|   mozilla::CSSToScreenScale UpdateResolution(const nsViewportInfo& aViewportInfo,
 | |
|                                              const mozilla::ScreenIntSize& aDisplaySize,
 | |
|                                              const mozilla::CSSSize& aViewport,
 | |
|                                              const mozilla::Maybe<float>& aDisplayWidthChangeRatio);
 | |
| 
 | |
|   /* Updates the scroll-position-clamping scrollport size */
 | |
|   void UpdateSPCSPS(const mozilla::ScreenIntSize& aDisplaySize,
 | |
|                     const mozilla::CSSToScreenScale& aZoom);
 | |
| 
 | |
|   /* Updates the displayport margins for the presShell's root scrollable frame */
 | |
|   void UpdateDisplayPortMargins();
 | |
| 
 | |
|   nsCOMPtr<nsIDocument> mDocument;
 | |
|   nsIPresShell* MOZ_NON_OWNING_REF mPresShell; // raw ref since the presShell owns this
 | |
|   nsCOMPtr<nsIDOMEventTarget> mEventTarget;
 | |
|   bool mIsFirstPaint;
 | |
|   bool mPainted;
 | |
|   mozilla::LayoutDeviceIntSize mDisplaySize;
 | |
|   mozilla::CSSSize mMobileViewportSize;
 | |
|   mozilla::Maybe<float> mRestoreResolution;
 | |
|   mozilla::Maybe<mozilla::ScreenIntSize> mRestoreDisplaySize;
 | |
| };
 | |
| 
 | |
| #endif
 |