tor-browser

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

HitTestInfoManager.h (2519B)


      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 GFX_HITTESTINFOMANAGER_H
      8 #define GFX_HITTESTINFOMANAGER_H
      9 
     10 #include "mozilla/gfx/CompositorHitTestInfo.h"
     11 #include "mozilla/layers/ScrollableLayerGuid.h"
     12 #include "mozilla/webrender/WebRenderAPI.h"
     13 #include "nsRect.h"
     14 
     15 namespace mozilla {
     16 
     17 class nsDisplayItem;
     18 class nsDisplayListBuilder;
     19 
     20 namespace wr {
     21 class DisplayListBuilder;
     22 }
     23 
     24 namespace layers {
     25 
     26 /**
     27 * This class extracts the hit testing information (area, flags, ViewId) from
     28 * Gecko display items and pushes them into WebRender display list.
     29 *
     30 * The hit testing information is deduplicated: a new hit test item is only
     31 * added if the new area is not contained in the previous area, or if the flags,
     32 * ViewId, or current spatial id is different.
     33 */
     34 class HitTestInfoManager {
     35 public:
     36  HitTestInfoManager();
     37 
     38  /**
     39   * Resets the previous hit testing information.
     40   */
     41  void Reset();
     42 
     43  /**
     44   * Extracts the hit testing information from |aItem|, and if necessary, adds
     45   * a new WebRender hit test item using |aBuilder|.
     46   *
     47   * Returns true if a hit test item was pushed.
     48   */
     49  bool ProcessItem(nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder,
     50                   nsDisplayListBuilder* aDisplayListBuilder);
     51 
     52  /**
     53   * Process an item which cannot create WebRender commands and needs to be
     54   * pushed as an image instead (WebRenderCommandBuilder::PushItemAsImage).
     55   * Such items need to produce, in addition to the image, a hit test item
     56   * with the eIrregularArea flag set, so that the compositor knows to defer
     57   * to the main thread for more detailed hit test information.
     58   */
     59  void ProcessItemAsImage(nsDisplayItem* aItem, const wr::LayoutRect& aRect,
     60                          wr::DisplayListBuilder& aBuilder,
     61                          nsDisplayListBuilder* aDisplayListBuilder);
     62 
     63 private:
     64  bool Update(const nsRect& aArea, const gfx::CompositorHitTestInfo& aFlags,
     65              const ScrollableLayerGuid::ViewID& aViewId,
     66              const wr::WrSpaceAndClipChain& aSpaceAndClip);
     67 
     68  nsRect mArea;
     69  gfx::CompositorHitTestInfo mFlags;
     70  ScrollableLayerGuid::ViewID mViewId;
     71  wr::WrSpaceAndClipChain mSpaceAndClipChain;
     72 };
     73 
     74 }  // namespace layers
     75 }  // namespace mozilla
     76 
     77 #endif