tor-browser

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

InputAPZContext.h (2688B)


      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 mozilla_layers_InputAPZContext_h
      8 #define mozilla_layers_InputAPZContext_h
      9 
     10 #include "mozilla/EventForwards.h"
     11 #include "mozilla/layers/ScrollableLayerGuid.h"
     12 
     13 namespace mozilla {
     14 namespace layers {
     15 
     16 // InputAPZContext is used to communicate various pieces of information
     17 // around the codebase without having to plumb it through lots of functions
     18 // and codepaths. Conceptually it is attached to a WidgetInputEvent that is
     19 // relevant to APZ.
     20 //
     21 // There are two types of information bits propagated using this class. One
     22 // type is propagated "downwards" (from a process entry point like nsIWidget
     23 // or BrowserChild) into deeper code that is run during complicated operations
     24 // like event dispatch. The other type is information that is propagated
     25 // "upwards", from the deeper code back to the entry point.
     26 class MOZ_STACK_CLASS InputAPZContext {
     27 private:
     28  // State that is propagated downwards from InputAPZContext creation into
     29  // "deeper" code.
     30  static ScrollableLayerGuid sGuid;
     31  static uint64_t sBlockId;
     32  static nsEventStatus sApzResponse;
     33  static bool sPendingLayerization;
     34 
     35  // State that is set in deeper code and propagated upwards.
     36  static bool sRoutedToChildProcess;
     37  // True if the WidgetInputEvent was dropped (which means the event wasn't
     38  // dispatched) on the main-thread.
     39  static bool sDropped;
     40 
     41 public:
     42  // Functions to access downwards-propagated data
     43  static ScrollableLayerGuid GetTargetLayerGuid();
     44  static uint64_t GetInputBlockId();
     45  static nsEventStatus GetApzResponse();
     46  static bool HavePendingLayerization();
     47 
     48  // Functions to access upwards-propagated data
     49  static bool WasRoutedToChildProcess();
     50 
     51  static bool WasDropped();
     52 
     53  // Constructor sets the data to be propagated downwards
     54  InputAPZContext(const ScrollableLayerGuid& aGuid, const uint64_t& aBlockId,
     55                  const nsEventStatus& aApzResponse,
     56                  bool aPendingLayerization = false);
     57  ~InputAPZContext();
     58 
     59  // Functions to set data to be propagated upwards
     60  static void SetRoutedToChildProcess();
     61  static void SetDropped();
     62 
     63 private:
     64  ScrollableLayerGuid mOldGuid;
     65  uint64_t mOldBlockId;
     66  nsEventStatus mOldApzResponse;
     67  bool mOldPendingLayerization;
     68 
     69  bool mOldRoutedToChildProcess;
     70  bool mOldDropped;
     71 };
     72 
     73 }  // namespace layers
     74 }  // namespace mozilla
     75 
     76 #endif /* mozilla_layers_InputAPZContext_h */