2013-09-04 04:30:57 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef ACTIVELAYERTRACKER_H_
|
|
|
|
#define ACTIVELAYERTRACKER_H_
|
|
|
|
|
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
|
|
|
|
class nsIFrame;
|
2014-05-13 10:30:11 -07:00
|
|
|
class nsIContent;
|
2014-10-21 18:54:32 -07:00
|
|
|
class nsDisplayListBuilder;
|
2013-09-04 04:30:57 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class receives various notifications about style changes and content
|
|
|
|
* changes that affect layerization decisions, and implements the heuristics
|
|
|
|
* that drive those decisions. It manages per-frame state to support those
|
|
|
|
* heuristics.
|
|
|
|
*/
|
|
|
|
class ActiveLayerTracker {
|
|
|
|
public:
|
2013-09-04 04:47:23 -07:00
|
|
|
static void Shutdown();
|
|
|
|
|
2013-09-04 04:30:57 -07:00
|
|
|
/*
|
2013-09-09 17:08:41 -07:00
|
|
|
* We track style changes to selected styles:
|
|
|
|
* eCSSProperty_transform
|
|
|
|
* eCSSProperty_opacity
|
|
|
|
* eCSSProperty_left, eCSSProperty_top, eCSSProperty_right, eCSSProperty_bottom
|
2013-09-04 04:30:57 -07:00
|
|
|
* and use that information to guess whether style changes are animated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify aFrame's style property as having changed due to a restyle,
|
|
|
|
* and therefore possibly wanting an active layer to render that style.
|
|
|
|
* Any such marking will time out after a short period.
|
|
|
|
* @param aProperty the property that has changed
|
|
|
|
*/
|
|
|
|
static void NotifyRestyle(nsIFrame* aFrame, nsCSSProperty aProperty);
|
2013-09-09 17:08:41 -07:00
|
|
|
/**
|
|
|
|
* Notify aFrame's left/top/right/bottom properties as having (maybe)
|
|
|
|
* changed due to a restyle, and therefore possibly wanting an active layer
|
|
|
|
* to render that style. Any such marking will time out after a short period.
|
|
|
|
*/
|
|
|
|
static void NotifyOffsetRestyle(nsIFrame* aFrame);
|
2013-09-04 04:30:57 -07:00
|
|
|
/**
|
|
|
|
* Mark aFrame as being known to have an animation of aProperty.
|
|
|
|
* Any such marking will time out after a short period.
|
|
|
|
*/
|
|
|
|
static void NotifyAnimated(nsIFrame* aFrame, nsCSSProperty aProperty);
|
2013-09-04 04:47:23 -07:00
|
|
|
/**
|
|
|
|
* Notify that a property in the inline style rule of aFrame's element
|
|
|
|
* has been modified.
|
|
|
|
* This notification is incomplete --- not all modifications to inline
|
|
|
|
* style will trigger this.
|
|
|
|
*/
|
|
|
|
static void NotifyInlineStyleRuleModified(nsIFrame* aFrame, nsCSSProperty aProperty);
|
2014-10-21 18:55:55 -07:00
|
|
|
/**
|
|
|
|
* Return true if aFrame's aProperty style should be considered as being animated
|
|
|
|
* for pre-rendering.
|
|
|
|
*/
|
|
|
|
static bool IsStyleMaybeAnimated(nsIFrame* aFrame, nsCSSProperty aProperty);
|
2013-09-04 04:30:57 -07:00
|
|
|
/**
|
|
|
|
* Return true if aFrame's aProperty style should be considered as being animated
|
|
|
|
* for constructing active layers.
|
|
|
|
*/
|
2014-10-21 18:54:32 -07:00
|
|
|
static bool IsStyleAnimated(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsCSSProperty aProperty);
|
2013-09-09 17:08:41 -07:00
|
|
|
/**
|
|
|
|
* Return true if any of aFrame's offset property styles should be considered
|
|
|
|
* as being animated for constructing active layers.
|
|
|
|
*/
|
2013-09-09 17:08:42 -07:00
|
|
|
static bool IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame);
|
2014-05-13 10:30:11 -07:00
|
|
|
/**
|
|
|
|
* Transfer the LayerActivity property to the frame's content node when the
|
|
|
|
* frame is about to be destroyed so that layer activity can be tracked
|
|
|
|
* throughout reframes of an element. Only call this when aFrame is the
|
|
|
|
* primary frame of aContent.
|
|
|
|
*/
|
|
|
|
static void TransferActivityToContent(nsIFrame* aFrame, nsIContent* aContent);
|
|
|
|
/**
|
|
|
|
* Transfer the LayerActivity property back to the content node's primary
|
|
|
|
* frame after the frame has been created.
|
|
|
|
*/
|
|
|
|
static void TransferActivityToFrame(nsIContent* aContent, nsIFrame* aFrame);
|
2013-09-04 04:30:57 -07:00
|
|
|
|
2013-09-04 04:47:23 -07:00
|
|
|
/*
|
|
|
|
* We track modifications to the content of certain frames (i.e. canvas frames)
|
|
|
|
* and use that to make layering decisions.
|
|
|
|
*/
|
|
|
|
|
2013-09-04 04:30:57 -07:00
|
|
|
/**
|
|
|
|
* Mark aFrame's content as being active. This marking will time out after
|
2013-09-04 04:47:23 -07:00
|
|
|
* a short period.
|
2013-09-04 04:30:57 -07:00
|
|
|
*/
|
|
|
|
static void NotifyContentChange(nsIFrame* aFrame);
|
|
|
|
/**
|
|
|
|
* Return true if this frame's content is still marked as active.
|
|
|
|
*/
|
|
|
|
static bool IsContentActive(nsIFrame* aFrame);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ACTIVELAYERTRACKER_H_ */
|