tor-browser

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

CompositorScrollUpdate.h (1939B)


      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_CompositorScrollUpdate_h
      8 #define mozilla_layers_CompositorScrollUpdate_h
      9 
     10 #include "Units.h"
     11 
     12 namespace mozilla {
     13 namespace layers {
     14 
     15 /**
     16 * An update sent by APZ to interesting consumers (e.g. GeckoView)
     17 * to inform them, on every composite, about the effective visual
     18 * scroll offset and zoom level of the root content APZC at
     19 * composition time.
     20 */
     21 struct CompositorScrollUpdate {
     22  /**
     23   * The compositor state (scroll offset and zoom level) after the update.
     24   */
     25  struct Metrics {
     26    CSSPoint mVisualScrollOffset;
     27    CSSToParentLayerScale mZoom;
     28 
     29    bool operator==(const Metrics& aOther) const;
     30    bool operator!=(const Metrics& aOther) const { return !(*this == aOther); }
     31  };
     32 
     33  /**
     34   * Describes the source of a CompositorScrollUpdate.
     35   *
     36   * This is used for populating the `source` field of
     37   * `GeckoSession.ScrollPositionUpdate`, and should be kept in sync
     38   * with the constants defined in that Java struct.
     39   */
     40  enum class Source {
     41    // The scroll position changed as a direct result of user interaction.
     42    UserInteraction,
     43    // The scroll position changed programmatically. This can includes changes
     44    // caused by script on the page, and changes caused by the browser engine
     45    // such as scrolling an element into view.
     46    Other
     47  };
     48 
     49  Metrics mMetrics;
     50  Source mSource;
     51 
     52  bool operator==(const CompositorScrollUpdate& aOther) const;
     53  bool operator!=(const CompositorScrollUpdate& aOther) const {
     54    return !(*this == aOther);
     55  }
     56 };
     57 
     58 }  // namespace layers
     59 }  // namespace mozilla
     60 
     61 #endif  // mozilla_layers_CompositorScrollUpdate_h