tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DocumentPictureInPicture.h (2305B)


      1 /* -*- Mode: C++; tab-width: 2; 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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_documentpip_DocumentPictureInPicture_h
      8 #define mozilla_dom_documentpip_DocumentPictureInPicture_h
      9 
     10 #include "mozilla/DOMEventTargetHelper.h"
     11 #include "mozilla/dom/DocumentPictureInPictureBinding.h"
     12 #include "nsIDOMEventListener.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class DocumentPictureInPicture final : public DOMEventTargetHelper,
     17                                       public nsIObserver,
     18                                       public nsIDOMEventListener {
     19 public:
     20  NS_DECL_NSIDOMEVENTLISTENER
     21  NS_DECL_NSIOBSERVER
     22 
     23  NS_DECL_ISUPPORTS_INHERITED
     24  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentPictureInPicture,
     25                                           DOMEventTargetHelper)
     26 
     27  explicit DocumentPictureInPicture(nsPIDOMWindowInner* aWindow);
     28 
     29  JSObject* WrapObject(JSContext* aCx,
     30                       JS::Handle<JSObject*> aGivenProto) override;
     31 
     32  already_AddRefed<Promise> RequestWindow(
     33      const DocumentPictureInPictureOptions& aOptions, ErrorResult& aRv);
     34 
     35  // Get the current PiP window, exposed as webidl property
     36  nsGlobalWindowInner* GetWindow();
     37 
     38  IMPL_EVENT_HANDLER(enter);
     39 
     40  static Maybe<CSSIntRect> GetScreenRect(nsPIDOMWindowOuter* aWindow);
     41 
     42  static CSSIntSize CalcMaxDimensions(const CSSIntRect& screen);
     43 
     44  CSSIntRect DetermineExtent(bool aPreferInitialWindowPlacement,
     45                             int aRequestedWidth, int aRequestedHeight,
     46                             const CSSIntRect& screen);
     47 
     48 private:
     49  ~DocumentPictureInPicture();
     50 
     51  MOZ_CAN_RUN_SCRIPT void OnPiPResized();
     52 
     53  void OnPiPClosed();
     54 
     55  static const CSSIntSize sDefaultSize, sMinSize;
     56 
     57  // The extent of the most recently closed PiP
     58  Maybe<CSSIntRect> mPreviousExtent;
     59 
     60  // The size with which the most recent PiP was requested
     61  Maybe<CSSIntSize> mLastRequestedSize;
     62 
     63  // The currently open PiP (if any)
     64  RefPtr<nsPIDOMWindowInner> mLastOpenedWindow;
     65 };
     66 
     67 }  // namespace mozilla::dom
     68 
     69 #endif  // mozilla_dom_documentpip_DocumentPictureInPicture_h