tor-browser

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

ActiveLayerTracker.h (3843B)


      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 ACTIVELAYERTRACKER_H_
      8 #define ACTIVELAYERTRACKER_H_
      9 
     10 #include "NonCustomCSSPropertyId.h"
     11 
     12 class nsIFrame;
     13 class nsIContent;
     14 class nsCSSPropertyIDSet;
     15 class nsDOMCSSDeclaration;
     16 
     17 namespace mozilla {
     18 
     19 class nsDisplayListBuilder;
     20 
     21 /**
     22 * This class receives various notifications about style changes and content
     23 * changes that affect layerization decisions, and implements the heuristics
     24 * that drive those decisions. It manages per-frame state to support those
     25 * heuristics.
     26 */
     27 class ActiveLayerTracker {
     28 public:
     29  static void Shutdown();
     30 
     31  /*
     32   * We track style changes to selected styles:
     33   *   eCSSProperty_transform, eCSSProperty_translate,
     34   *   eCSSProperty_rotate, eCSSProperty_scale
     35   *   eCSSProperty_offset_path, eCSSProperty_offset_distance,
     36   *   eCSSProperty_offset_rotate, eCSSProperty_offset_anchor,
     37   *   eCSSProperty_offset_position, eCSSProperty_opacity
     38   * and use that information to guess whether style changes are animated.
     39   */
     40 
     41  /**
     42   * Notify aFrame's style property as having changed due to a restyle,
     43   * and therefore possibly wanting an active layer to render that style.
     44   * Any such marking will time out after a short period.
     45   * @param aProperty the property that has changed
     46   */
     47  static void NotifyRestyle(nsIFrame* aFrame, NonCustomCSSPropertyId aProperty);
     48 
     49  /**
     50   * Notify that a property in the inline style rule of aFrame's element
     51   * has been modified.
     52   */
     53  static void NotifyInlineStyleRuleModified(nsIFrame* aFrame,
     54                                            NonCustomCSSPropertyId aProperty);
     55  /**
     56   * Notify that a frame needs to be repainted. This is important for layering
     57   * decisions where, say, aFrame's transform is updated from JS, but we need
     58   * to repaint aFrame anyway, so we get no benefit from giving it its own
     59   * layer.
     60   */
     61  static void NotifyNeedsRepaint(nsIFrame* aFrame);
     62  /**
     63   * Return true if aFrame's property style in |aPropertySet| should be
     64   * considered as being animated for constructing active layers.
     65   */
     66  static bool IsStyleAnimated(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
     67                              const nsCSSPropertyIDSet& aPropertySet);
     68  /**
     69   * Return true if aFrame's transform-like property,
     70   * i.e. transform/translate/rotate/scale, is animated.
     71   */
     72  static bool IsTransformAnimated(nsDisplayListBuilder* aBuilder,
     73                                  nsIFrame* aFrame);
     74  /**
     75   * Return true if aFrame's transform style should be considered as being
     76   * animated for pre-rendering.
     77   */
     78  static bool IsTransformMaybeAnimated(nsIFrame* aFrame);
     79  /**
     80   * Return true if aFrame either has an animated scale now, or is likely to
     81   * have one in the future because it has a CSS animation or transition
     82   * (which may not be playing right now) that affects its scale.
     83   */
     84  static bool IsScaleSubjectToAnimation(nsIFrame* aFrame);
     85 
     86  /**
     87   * Transfer the LayerActivity property to the frame's content node when the
     88   * frame is about to be destroyed so that layer activity can be tracked
     89   * throughout reframes of an element. Only call this when aFrame is the
     90   * primary frame of aContent.
     91   */
     92  static void TransferActivityToContent(nsIFrame* aFrame, nsIContent* aContent);
     93  /**
     94   * Transfer the LayerActivity property back to the content node's primary
     95   * frame after the frame has been created.
     96   */
     97  static void TransferActivityToFrame(nsIContent* aContent, nsIFrame* aFrame);
     98 };
     99 
    100 }  // namespace mozilla
    101 
    102 #endif /* ACTIVELAYERTRACKER_H_ */