mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
b3541682d0
- bug 1157569 part 1 - Rename BC_BORDER_{TOP,RIGHT,BOTTOM,LEFT}_HALF* to BC_BORDER_{START,END}_HALF*. r=roc (2ef82ce76)
- Bug 1157569 part 2 - Convert output parameters of GetColorAndStyle/GetPaintStyleInfo in nsTableFrame to use pointers. r=roc (c58bbe734)
- Bug 1157569 part 3 - Merge two GetColorAndStyle functions in nsTableFrame. r=roc (009df4d97)
- Bug 1157569 part 4 - Replace mTableIsLTR with mTableWM in BCMapCellInfo & BCPaintBorderIterator. r=roc (9784a46eb)
- Bug 1157569 part 5 - Convert GetColorAndStyle, GetPaintStyleInfo, and CompareBorders in nsTableFrame to accept writing mode and logical side. r=roc (aaddc4a80)
- Bug 1157569 part 6 - Rename methods and fields in BCMapCellInfo from physicals to logicals. r=roc (aeaa0b18c)
- Bug 1157569 part 7 - Rename methods and fields in nsTableColFrame from physicals to logicals. r=roc (fd4e1e667)
- Bug 1157569 part 8 - Move some code in BCPaintBorderIterator::SetDamageArea for less computation. r=roc (634f19ca7)
- missing bit of Bug 895096 - Part 1 (a96e3d35c)
- Bug 1157569 part 9 - Rename methods and fields in nsTableRowFrame from physicals to logicals. r=roc (d097f1e4f)
- Bug 1157569 part 10 - Add operator+= for LogicalMargin. r=jfkthame (c651b685f)
- Bug 1159101 part 4 - Override GetWritingMode() in nsTable{{Col,Row}{,Group},Cell}Frame. r=roc (34d90d10b)
- Bug 1159101 part 5 - Initialize writing mode of desired mode of table cell frame from its table frame on a CLOSED TREE. r=roc (8bc6978ca)
- Bug 1157569 part 11 - Rename methods and fields in nsTableCellFrame from physicals to logicals. r=roc (bcfd4514b)
- Bug 1157569 part 12 - Remove useless m{Start,End}Side from BCMapCellInfo. r=roc (1df59d670)
- Bug 1159127 - Always redirect inserting col group frame to first-in-flow table frame. r=mats (2e41bbeeb)
- Bug 1167765: Misc whitespace cleanup in nsTableFrame.cpp. whitespace/rewrapping-only, no review, DONTBUILD (f256939c9)
- Bug 1167696 part 1: Remove nsTableReflowState's unused constructor & nsPresContext arg. r=mats (5b8beadb9)
- Bug 1167696 part 2: Remove nsTableReflowState's frame constructor-arg; get it from passed-in reflow state instead. r=mats (205dad74f)
- Bug 1155412: Use mozilla::Maybe instead of hardcoded placement-new, for reflow state created in nsTableOuterFrame::OuterBeginReflowChild() and used by its caller. r=dbaron (ebf9e9891)
- Bug 1147834: Use abstract coordinates in nsHTMLReflowState, r=jfkthame (30e644a14)
- Bug 1169432 part 2: Refactor nsTableFrame::Init. r=mats (779928597)
- Bug 1169432 part 3: Use nsTArray::Contains instead of nsTArray::IndexOf(), for brevity, in nsTableFrame. r=mats (aa6aee3c4)
- Bug 1169432 part 4: Convert NS_ASSERTION(false, ...) to NS_ERROR(...) in nsTableFrame. r=mats (9cbb2f53f)
- Bug 1169432 part 5: Use range-based 'for' loops when walking frame lists, in nsTableFrame. r=mats (bd4e7d0d4)
- Bug 1171328 - Convert nsTableFrame::GetChildAreaOffset() and its friends to use LogicalMargin. r=dholbert (196955d0c)
- Remove unneeded code from SmoothScrollAnimation. (bug 1139220 part 4, r=kats) (68c6af9f8)
- Use stronger typing for GetScrollWheelDelta. (bug 1139220 part 5, r=kats) (4669d1f38)
- When APZ is enabled, only apply the root scroll delta override to root frames. (bug 1155800, r=kats) (2a738ee82)
- Bug 1168629. Clear frame metrics on the root layer if we aren't setting new frame metrics because the layer may be recycled and still have frame metrics from last time. r=mstange (dc0889fae)
- Bug 1158424 - Rename FrameMetrics::mIsRoot to mIsRootContent. r=kats (0005fb016)
- Bug 1148078: Replace the word "Logical" with "Flex-Relative" in some vars & functions in flexbox layout. r=mats (601497c55)
- Bug 1148298 part 1: Convert most flexbox-layout IsAxisHorizontal() calls into IsMainAxisHorizontal()/IsCrossAxisHorizontal(). r=mats (ff2aaa5b3)
- Bug 1148298 part 3: Make flexbox helper GetBaselineOffsetFromOuterCrossEdge take a FlexboxAxisTracker instead of an explicit axis. r=mats (009dd9f7e)
- Bug 1148298 part 4: Convert flexbox helper-function IsAxisHorizontal() to be a private implementation detail of FlexboxAxisTracker. r=mats (901f830d6)
- Bug 1148298 part 2: Replace flexbox static helper-function GetSizeProBug 1148298 part 2: Replace flexbox static helper-function GetSizePro (3d2940f88)
- Bug 1158290 part 1: Use AvailableBSize instead of AvailableHeight, throughout flex layout. r=mats (49e2075f8)
- Bug 1148294 part 1: Determine flex axes (in FlexboxAxisTracker) using the flex container's writing mode. r=mats (67f12cf58)
- Bug 1148294 part 2: Add one reftest for writing-mode & direction properties' influence on flex axes. (85e0ede9d)
- Bug 1148294 part 3: Add more reftests for writing-mode & direction properties' influence on flex axes (as modified copies of first test). (fac965a24)
- Bug 1148294 followup: fix spec links in reftests flexbox-writing-mode-* to point to TR instead of ED spec version. (no review) (84333c728)
- Bug 1158290 part 2: Use logical (not physical) skipsides & borderpadding when chipping away from available BSize. r=mats (987b4edfa)
- Bug 1152913 part 1: Make FlexboxAxisTracker store the WritingMode & representation of how flex axes map to it. r=mats (675737981)
- Bug 1152951: Delete the copy-constructor and reassignment operator for FlexboxAxisTracker & PositionTracker state-management classes. r=mats (71c88e7e9)
- Bug 1152913 part 2: Convert flexbox 'IsAxisHorizontal' checks to use new logical-axis member data. r=mats (122b434a5)
- Bug 1158290 part 3: Convert GenerateFlexLines to use logical axes & sizes. r=mats (367cb1c01)
- Bug 1158290 part 4: Clarify documentation & naming of ClampFlexContainerMainSize (now called ResolveFlexContainerMainSize). r=mats (5af11ff23)
- Bug 1149383 part 1: Make flexbox writing-mode tests use different widths vs. heights to reveal bug with vertical writing-modes. (test-only) (c4782feaa)
- Bug 1149383 part 2: Reorder width/height decls in flexbox-writing-mode reftests for consistency. (test-only) (bba907b70)
- Bug 1158290 part 5: Use logical coords & axes in methods that computeBug 1158290 part 5: Use logical coords & axes in methods that compute (b78726528)
- Bug 1158290 part 6: Use new GET_[MAIN|CROSS]_COMPONENT_LOGICAL macros, to reduce explicit width/height usage. r=mats (25d2e20a3)
- Bug 1152913 part 3: Make flexbox's PositionTracker classes track whether axis is reversed, & directly convert flex item final sizes/positions to logical coords. r=mats (1feee7e6d)
- Bug 1174507 - Replace the frame flag CONTAINS_RELATIVE_HEIGHT with CONTAINS_RELATIVE_BSIZE, and adjust callsites appropriately. r=dholbert (0e981d5ac)
- Clip async scrollframes based on the displaylist clip, not the composition bounds. (bug 1148582 part 4, r=tn) (f2b1196ed)
- Bug 1148582 - Add mask layers to FrameMetrics for ancestor scroll frame clips. r=mattwoodrow (008239305)
- Bug 1148582 - Factor mask layer creation out of ContainerState::SetupMaskLayer. r=mstange (1d739614e)
- piece of Bug 1138442 (e98de18dd)
- Bug 1173307 - Convert nsTableCellFrame to work with logical coordinates. r=dholbert (81d0aa811)
- Bug 1174700 - patch 1 - Convert nsTableRowFrame and nsTableRowGroupFrame to work with logical coordinates. r=dholbert (09ee9c814)
- Bug 1174700 - patch 2 - Convert nsTableFrame::SetColumnDimensions to work with logical-order iteration over the table, so that column coordinates and collapsed borders are correct. r=dholbert (7957e377b)
- Bug 1129040 - Provide a way for content processes to query the chrome side blocklist service. r=billm (5ea750b8b)
- Bug 1174711 - patch 1 - Rename nsIPercentHeightObserver to nsIPercentBSizeObserver, and update related frame methods to match. r=dholbert (7a17fbe4f)
- Bug 1174711 - patch 2 - Convert nsTableFrame to work with logical coordinates. r=dholbert (329776abe)
- Bug 1174711 - patch 3 - Rename a couple more frame-state bits from physical to logical. r=dholbert (d61c9624d)
- Bug 1174711 - patch 4 - Rename mSpecialHeightReflow to mSpecialBSizeReflow, and update comments to match. r=dholbert (49969e512)
- Bug 1174711 patch 5 - Copy inline-size rather than width from prev-in-flow when initializing nsTableFrame. r=dholbert (7afb6c80a)
- pointer style (52cd6f9af)
- pointer style (ba99b3f74)
- Bug 1149797 - Use the loop's *static* block object when freshening a loop's block object, then copy in values from the old cloned block. Using the old cloned block directly isn't valid when the cloned block might be extended with additional variables created by eval or added by nested function statements. r=shu (deba22790)
- Bug 1165486 - Cleanup: use standard object allocation functions when allocating scope objects. (r=terrence) (b35a4d7aa)
- pointer style (74ea6d085)
- Bug 1165486 - Add StaticNonSyntacticScopeObjects and teach scope iterators about it. (r=luke) (18a526ed3)
- Bug 1144371: Implement DEBUG-only JS shell function |dumpStringRepresentation|. r=jandem (35524cf42)
- Bug 1148963 - OdinMonkey: add CompileOptions::lazyParsingDisabled and testing function setDiscardSource (r=bz) (53f9c8fe6)
- pointer style (edaa05d69)
- Bug 1165486 - Rename hasPollutedGlobalScope to hasNonSyntacticScope. (r=luke) (505fc8d05)
- pointer style (3c4435038)
- Bug 1165486 - Remove PollutedGlobalScopeOption in favor of using the static scope chain to detect non-syntactic scopes. (r=luke) (73ca126f5)
- Bug 1150106 - Async loadSubscript - Part 1, add `async` to loadSubscriptWithOptions r=bholley,mcrr8 (a0ffeed0d)
- Bug 1150106 - Add an async version of loadSubscript - Part 2, tests r=bholley (6aeaa93e4)
- Bug 1165486 - Use JS::CompileForNonSyntacticScope in Gecko where we used to set polluted global scope. (r=bz, rs=bholley) (073332ac9)
- Bug 1165486 - Split JS::Compile into JS::Compile and JS::CompileForNonSyntacticScope. (r=luke) (0b82c73c4)
- Bug 1165486 - Restructure function and script cloning in light of PollutingGlobal scope changes. (r=Waldo) (b4e39652c)
- Bug 1141865 - Part 7: Make new.target work in generator functions. (r=jorendorff, r=jandem) (a9f5ce1ad)
- Bug 1165486 - Detect with scopes at parse time using the static scope chain for non-function scripts. Also cache static scope properties on SharedGlobalContext. (r=efaust) (a7d4283cb)
- Bug 1176070 - Optimize nsTableFrame's FirstInFlow() lookups from calls to GetColumnISize(). r=dholbert (beed47b93)
- fix misspatch of Bug 1141862 - Part 6 (d091f70a2)
- Bug 1169736 - Temporarily disallow eval and arrow functions inside derived class constructors. (r=jorendorff) (6cf8a2db1)
- Bug 1150855 - Disallow method syntax without curly brackets. r=efaust (26086ee95)
- part of Bug 1150855 - Remove uses of the curly syntax. (bfe86ea19)
- Bug 1169853 - Require semicolon after export default AssignmentExpression. r=shu (580ff7e30)
- Bug 1174009 - Remove a couple of unused AutoRooter types; r=sfink (113aee16a)
526 lines
17 KiB
C++
526 lines
17 KiB
C++
/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* 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/. */
|
|
|
|
#include "LayerTreeInvalidation.h"
|
|
#include <stdint.h> // for uint32_t
|
|
#include "ImageContainer.h" // for ImageContainer
|
|
#include "ImageLayers.h" // for ImageLayer, etc
|
|
#include "Layers.h" // for Layer, ContainerLayer, etc
|
|
#include "Units.h" // for ParentLayerIntRect
|
|
#include "gfxColor.h" // for gfxRGBA
|
|
#include "GraphicsFilter.h" // for GraphicsFilter
|
|
#include "gfxRect.h" // for gfxRect
|
|
#include "gfxUtils.h" // for gfxUtils
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
|
#include "nsAutoPtr.h" // for nsRefPtr, nsAutoPtr, etc
|
|
#include "nsDataHashtable.h" // for nsDataHashtable
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
|
#include "nsHashKeys.h" // for nsPtrHashKey
|
|
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
|
#include "nsRect.h" // for IntRect
|
|
#include "nsTArray.h" // for nsAutoTArray, nsTArray_Impl
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
struct LayerPropertiesBase;
|
|
UniquePtr<LayerPropertiesBase> CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask = false);
|
|
|
|
static IntRect
|
|
TransformRect(const IntRect& aRect, const Matrix4x4& aTransform)
|
|
{
|
|
if (aRect.IsEmpty()) {
|
|
return IntRect();
|
|
}
|
|
|
|
Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
|
|
rect = aTransform.TransformBounds(rect);
|
|
rect.RoundOut();
|
|
|
|
IntRect intRect;
|
|
if (!gfxUtils::GfxRectToIntRect(ThebesRect(rect), &intRect)) {
|
|
return IntRect();
|
|
}
|
|
|
|
return intRect;
|
|
}
|
|
|
|
static void
|
|
AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform)
|
|
{
|
|
nsIntRegionRectIterator iter(aSource);
|
|
const IntRect *r;
|
|
while ((r = iter.Next())) {
|
|
aDest.Or(aDest, TransformRect(*r, aTransform));
|
|
}
|
|
aDest.SimplifyOutward(20);
|
|
}
|
|
|
|
static void
|
|
AddRegion(nsIntRegion& aDest, const nsIntRegion& aSource)
|
|
{
|
|
aDest.Or(aDest, aSource);
|
|
aDest.SimplifyOutward(20);
|
|
}
|
|
|
|
/**
|
|
* Walks over this layer, and all descendant layers.
|
|
* If any of these are a ContainerLayer that reports invalidations to a PresShell,
|
|
* then report that the entire bounds have changed.
|
|
*/
|
|
static void
|
|
NotifySubdocumentInvalidationRecursive(Layer* aLayer, NotifySubDocInvalidationFunc aCallback)
|
|
{
|
|
aLayer->ClearInvalidRect();
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
if (aLayer->GetMaskLayer()) {
|
|
NotifySubdocumentInvalidationRecursive(aLayer->GetMaskLayer(), aCallback);
|
|
}
|
|
for (size_t i = 0; i < aLayer->GetAncestorMaskLayerCount(); i++) {
|
|
Layer* maskLayer = aLayer->GetAncestorMaskLayerAt(i);
|
|
NotifySubdocumentInvalidationRecursive(maskLayer, aCallback);
|
|
}
|
|
|
|
if (!container) {
|
|
return;
|
|
}
|
|
|
|
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
NotifySubdocumentInvalidationRecursive(child, aCallback);
|
|
}
|
|
|
|
aCallback(container, container->GetVisibleRegion());
|
|
}
|
|
|
|
struct LayerPropertiesBase : public LayerProperties
|
|
{
|
|
explicit LayerPropertiesBase(Layer* aLayer)
|
|
: mLayer(aLayer)
|
|
, mMaskLayer(nullptr)
|
|
, mVisibleRegion(aLayer->GetVisibleRegion())
|
|
, mInvalidRegion(aLayer->GetInvalidRegion())
|
|
, mPostXScale(aLayer->GetPostXScale())
|
|
, mPostYScale(aLayer->GetPostYScale())
|
|
, mOpacity(aLayer->GetLocalOpacity())
|
|
, mUseClipRect(!!aLayer->GetClipRect())
|
|
{
|
|
MOZ_COUNT_CTOR(LayerPropertiesBase);
|
|
if (aLayer->GetMaskLayer()) {
|
|
mMaskLayer = CloneLayerTreePropertiesInternal(aLayer->GetMaskLayer(), true);
|
|
}
|
|
for (size_t i = 0; i < aLayer->GetAncestorMaskLayerCount(); i++) {
|
|
Layer* maskLayer = aLayer->GetAncestorMaskLayerAt(i);
|
|
mAncestorMaskLayers.AppendElement(CloneLayerTreePropertiesInternal(maskLayer, true));
|
|
}
|
|
if (mUseClipRect) {
|
|
mClipRect = *aLayer->GetClipRect();
|
|
}
|
|
mTransform = aLayer->GetLocalTransform();
|
|
}
|
|
LayerPropertiesBase()
|
|
: mLayer(nullptr)
|
|
, mMaskLayer(nullptr)
|
|
{
|
|
MOZ_COUNT_CTOR(LayerPropertiesBase);
|
|
}
|
|
~LayerPropertiesBase()
|
|
{
|
|
MOZ_COUNT_DTOR(LayerPropertiesBase);
|
|
}
|
|
|
|
virtual nsIntRegion ComputeDifferences(Layer* aRoot,
|
|
NotifySubDocInvalidationFunc aCallback,
|
|
bool* aGeometryChanged);
|
|
|
|
virtual void MoveBy(const IntPoint& aOffset);
|
|
|
|
nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback,
|
|
bool& aGeometryChanged)
|
|
{
|
|
bool transformChanged = !mTransform.FuzzyEqualsMultiplicative(mLayer->GetLocalTransform()) ||
|
|
mLayer->GetPostXScale() != mPostXScale ||
|
|
mLayer->GetPostYScale() != mPostYScale;
|
|
const Maybe<ParentLayerIntRect>& otherClip = mLayer->GetClipRect();
|
|
nsIntRegion result;
|
|
|
|
bool ancestorMaskChanged = mAncestorMaskLayers.Length() != mLayer->GetAncestorMaskLayerCount();
|
|
if (!ancestorMaskChanged) {
|
|
for (size_t i = 0; i < mAncestorMaskLayers.Length(); i++) {
|
|
if (mLayer->GetAncestorMaskLayerAt(i) != mAncestorMaskLayers[i]->mLayer) {
|
|
ancestorMaskChanged = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Layer* otherMask = mLayer->GetMaskLayer();
|
|
if ((mMaskLayer ? mMaskLayer->mLayer : nullptr) != otherMask ||
|
|
ancestorMaskChanged ||
|
|
(mUseClipRect != !!otherClip) ||
|
|
mLayer->GetLocalOpacity() != mOpacity ||
|
|
transformChanged)
|
|
{
|
|
aGeometryChanged = true;
|
|
result = OldTransformedBounds();
|
|
AddRegion(result, NewTransformedBounds());
|
|
|
|
// We can't bail out early because we need to update mChildrenChanged.
|
|
}
|
|
|
|
AddRegion(result, ComputeChangeInternal(aCallback, aGeometryChanged));
|
|
AddTransformedRegion(result, mLayer->GetInvalidRegion(), mTransform);
|
|
|
|
if (mMaskLayer && otherMask) {
|
|
AddTransformedRegion(result, mMaskLayer->ComputeChange(aCallback, aGeometryChanged),
|
|
mTransform);
|
|
}
|
|
|
|
for (size_t i = 0;
|
|
i < std::min(mAncestorMaskLayers.Length(), mLayer->GetAncestorMaskLayerCount());
|
|
i++)
|
|
{
|
|
AddTransformedRegion(result,
|
|
mAncestorMaskLayers[i]->ComputeChange(aCallback, aGeometryChanged),
|
|
mTransform);
|
|
}
|
|
|
|
if (mUseClipRect && otherClip) {
|
|
if (!mClipRect.IsEqualInterior(*otherClip)) {
|
|
aGeometryChanged = true;
|
|
nsIntRegion tmp;
|
|
tmp.Xor(ParentLayerIntRect::ToUntyped(mClipRect), ParentLayerIntRect::ToUntyped(*otherClip));
|
|
AddRegion(result, tmp);
|
|
}
|
|
}
|
|
|
|
mLayer->ClearInvalidRect();
|
|
return result;
|
|
}
|
|
|
|
IntRect NewTransformedBounds()
|
|
{
|
|
return TransformRect(mLayer->GetVisibleRegion().GetBounds(), mLayer->GetLocalTransform());
|
|
}
|
|
|
|
IntRect OldTransformedBounds()
|
|
{
|
|
return TransformRect(mVisibleRegion.GetBounds(), mTransform);
|
|
}
|
|
|
|
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
|
|
bool& aGeometryChanged)
|
|
{
|
|
return IntRect();
|
|
}
|
|
|
|
nsRefPtr<Layer> mLayer;
|
|
UniquePtr<LayerPropertiesBase> mMaskLayer;
|
|
nsTArray<UniquePtr<LayerPropertiesBase>> mAncestorMaskLayers;
|
|
nsIntRegion mVisibleRegion;
|
|
nsIntRegion mInvalidRegion;
|
|
Matrix4x4 mTransform;
|
|
float mPostXScale;
|
|
float mPostYScale;
|
|
float mOpacity;
|
|
ParentLayerIntRect mClipRect;
|
|
bool mUseClipRect;
|
|
};
|
|
|
|
struct ContainerLayerProperties : public LayerPropertiesBase
|
|
{
|
|
explicit ContainerLayerProperties(ContainerLayer* aLayer)
|
|
: LayerPropertiesBase(aLayer)
|
|
, mPreXScale(aLayer->GetPreXScale())
|
|
, mPreYScale(aLayer->GetPreYScale())
|
|
{
|
|
for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
mChildren.AppendElement(Move(CloneLayerTreePropertiesInternal(child)));
|
|
}
|
|
}
|
|
|
|
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
|
|
bool& aGeometryChanged)
|
|
{
|
|
ContainerLayer* container = mLayer->AsContainerLayer();
|
|
nsIntRegion result;
|
|
|
|
bool childrenChanged = false;
|
|
|
|
if (mPreXScale != container->GetPreXScale() ||
|
|
mPreYScale != container->GetPreYScale()) {
|
|
aGeometryChanged = true;
|
|
result = OldTransformedBounds();
|
|
AddRegion(result, NewTransformedBounds());
|
|
childrenChanged = true;
|
|
|
|
// Can't bail out early, we need to update the child container layers
|
|
}
|
|
|
|
// A low frame rate is especially visible to users when scrolling, so we
|
|
// particularly want to avoid unnecessary invalidation at that time. For us
|
|
// here, that means avoiding unnecessary invalidation of child items when
|
|
// other children are added to or removed from our container layer, since
|
|
// that may be caused by children being scrolled in or out of view. We are
|
|
// less concerned with children changing order.
|
|
// TODO: Consider how we could avoid unnecessary invalidation when children
|
|
// change order, and whether the overhead would be worth it.
|
|
|
|
nsDataHashtable<nsPtrHashKey<Layer>, uint32_t> oldIndexMap(mChildren.Length());
|
|
for (uint32_t i = 0; i < mChildren.Length(); ++i) {
|
|
oldIndexMap.Put(mChildren[i]->mLayer, i);
|
|
}
|
|
|
|
uint32_t i = 0; // cursor into the old child list mChildren
|
|
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
bool invalidateChildsCurrentArea = false;
|
|
if (i < mChildren.Length()) {
|
|
uint32_t childsOldIndex;
|
|
if (oldIndexMap.Get(child, &childsOldIndex)) {
|
|
if (childsOldIndex >= i) {
|
|
// Invalidate the old areas of layers that used to be between the
|
|
// current |child| and the previous |child| that was also in the
|
|
// old list mChildren (if any of those children have been reordered
|
|
// rather than removed, we will invalidate their new area when we
|
|
// encounter them in the new list):
|
|
for (uint32_t j = i; j < childsOldIndex; ++j) {
|
|
AddRegion(result, mChildren[j]->OldTransformedBounds());
|
|
childrenChanged |= true;
|
|
}
|
|
// Invalidate any regions of the child that have changed:
|
|
nsIntRegion region = mChildren[childsOldIndex]->ComputeChange(aCallback, aGeometryChanged);
|
|
i = childsOldIndex + 1;
|
|
if (!region.IsEmpty()) {
|
|
AddRegion(result, region);
|
|
childrenChanged |= true;
|
|
}
|
|
} else {
|
|
// We've already seen this child in mChildren (which means it must
|
|
// have been reordered) and invalidated its old area. We need to
|
|
// invalidate its new area too:
|
|
invalidateChildsCurrentArea = true;
|
|
}
|
|
} else {
|
|
// |child| is new
|
|
invalidateChildsCurrentArea = true;
|
|
}
|
|
} else {
|
|
// |child| is new, or was reordered to a higher index
|
|
invalidateChildsCurrentArea = true;
|
|
}
|
|
if (invalidateChildsCurrentArea) {
|
|
aGeometryChanged = true;
|
|
AddTransformedRegion(result, child->GetVisibleRegion(), child->GetLocalTransform());
|
|
if (aCallback) {
|
|
NotifySubdocumentInvalidationRecursive(child, aCallback);
|
|
} else {
|
|
ClearInvalidations(child);
|
|
}
|
|
}
|
|
childrenChanged |= invalidateChildsCurrentArea;
|
|
}
|
|
|
|
// Process remaining removed children.
|
|
while (i < mChildren.Length()) {
|
|
childrenChanged |= true;
|
|
AddRegion(result, mChildren[i]->OldTransformedBounds());
|
|
i++;
|
|
}
|
|
|
|
if (aCallback) {
|
|
aCallback(container, result);
|
|
}
|
|
|
|
if (childrenChanged) {
|
|
container->SetChildrenChanged(true);
|
|
}
|
|
|
|
result.Transform(gfx::To3DMatrix(mLayer->GetLocalTransform()));
|
|
|
|
return result;
|
|
}
|
|
|
|
// The old list of children:
|
|
nsAutoTArray<UniquePtr<LayerPropertiesBase>,1> mChildren;
|
|
float mPreXScale;
|
|
float mPreYScale;
|
|
};
|
|
|
|
struct ColorLayerProperties : public LayerPropertiesBase
|
|
{
|
|
explicit ColorLayerProperties(ColorLayer *aLayer)
|
|
: LayerPropertiesBase(aLayer)
|
|
, mColor(aLayer->GetColor())
|
|
, mBounds(aLayer->GetBounds())
|
|
{ }
|
|
|
|
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
|
|
bool& aGeometryChanged)
|
|
{
|
|
ColorLayer* color = static_cast<ColorLayer*>(mLayer.get());
|
|
|
|
if (mColor != color->GetColor()) {
|
|
aGeometryChanged = true;
|
|
return NewTransformedBounds();
|
|
}
|
|
|
|
nsIntRegion boundsDiff;
|
|
boundsDiff.Xor(mBounds, color->GetBounds());
|
|
|
|
nsIntRegion result;
|
|
AddTransformedRegion(result, boundsDiff, mTransform);
|
|
|
|
return result;
|
|
}
|
|
|
|
gfxRGBA mColor;
|
|
IntRect mBounds;
|
|
};
|
|
|
|
struct ImageLayerProperties : public LayerPropertiesBase
|
|
{
|
|
explicit ImageLayerProperties(ImageLayer* aImage, bool aIsMask)
|
|
: LayerPropertiesBase(aImage)
|
|
, mContainer(aImage->GetContainer())
|
|
, mFilter(aImage->GetFilter())
|
|
, mScaleToSize(aImage->GetScaleToSize())
|
|
, mScaleMode(aImage->GetScaleMode())
|
|
, mIsMask(aIsMask)
|
|
{
|
|
}
|
|
|
|
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
|
|
bool& aGeometryChanged)
|
|
{
|
|
ImageLayer* imageLayer = static_cast<ImageLayer*>(mLayer.get());
|
|
|
|
if (!imageLayer->GetVisibleRegion().IsEqual(mVisibleRegion)) {
|
|
aGeometryChanged = true;
|
|
IntRect result = NewTransformedBounds();
|
|
result = result.Union(OldTransformedBounds());
|
|
return result;
|
|
}
|
|
|
|
ImageContainer* container = imageLayer->GetContainer();
|
|
if (mContainer != container ||
|
|
mFilter != imageLayer->GetFilter() ||
|
|
mScaleToSize != imageLayer->GetScaleToSize() ||
|
|
mScaleMode != imageLayer->GetScaleMode()) {
|
|
aGeometryChanged = true;
|
|
|
|
if (mIsMask) {
|
|
// Mask layers have an empty visible region, so we have to
|
|
// use the image size instead.
|
|
IntSize size = container->GetCurrentSize();
|
|
IntRect rect(0, 0, size.width, size.height);
|
|
return TransformRect(rect, mLayer->GetLocalTransform());
|
|
|
|
} else {
|
|
return NewTransformedBounds();
|
|
}
|
|
}
|
|
|
|
return IntRect();
|
|
}
|
|
|
|
nsRefPtr<ImageContainer> mContainer;
|
|
GraphicsFilter mFilter;
|
|
gfx::IntSize mScaleToSize;
|
|
ScaleMode mScaleMode;
|
|
bool mIsMask;
|
|
};
|
|
|
|
UniquePtr<LayerPropertiesBase>
|
|
CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask /* = false */)
|
|
{
|
|
if (!aRoot) {
|
|
return MakeUnique<LayerPropertiesBase>();
|
|
}
|
|
|
|
MOZ_ASSERT(!aIsMask || aRoot->GetType() == Layer::TYPE_IMAGE);
|
|
|
|
switch (aRoot->GetType()) {
|
|
case Layer::TYPE_CONTAINER:
|
|
case Layer::TYPE_REF:
|
|
return MakeUnique<ContainerLayerProperties>(aRoot->AsContainerLayer());
|
|
case Layer::TYPE_COLOR:
|
|
return MakeUnique<ColorLayerProperties>(static_cast<ColorLayer*>(aRoot));
|
|
case Layer::TYPE_IMAGE:
|
|
return MakeUnique<ImageLayerProperties>(static_cast<ImageLayer*>(aRoot), aIsMask);
|
|
default:
|
|
return MakeUnique<LayerPropertiesBase>(aRoot);
|
|
}
|
|
|
|
return UniquePtr<LayerPropertiesBase>(nullptr);
|
|
}
|
|
|
|
/* static */ UniquePtr<LayerProperties>
|
|
LayerProperties::CloneFrom(Layer* aRoot)
|
|
{
|
|
return CloneLayerTreePropertiesInternal(aRoot);
|
|
}
|
|
|
|
/* static */ void
|
|
LayerProperties::ClearInvalidations(Layer *aLayer)
|
|
{
|
|
aLayer->ClearInvalidRect();
|
|
if (aLayer->GetMaskLayer()) {
|
|
ClearInvalidations(aLayer->GetMaskLayer());
|
|
}
|
|
for (size_t i = 0; i < aLayer->GetAncestorMaskLayerCount(); i++) {
|
|
ClearInvalidations(aLayer->GetAncestorMaskLayerAt(i));
|
|
}
|
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
if (!container) {
|
|
return;
|
|
}
|
|
|
|
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
ClearInvalidations(child);
|
|
}
|
|
}
|
|
|
|
nsIntRegion
|
|
LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFunc aCallback,
|
|
bool* aGeometryChanged = nullptr)
|
|
{
|
|
NS_ASSERTION(aRoot, "Must have a layer tree to compare against!");
|
|
if (mLayer != aRoot) {
|
|
if (aCallback) {
|
|
NotifySubdocumentInvalidationRecursive(aRoot, aCallback);
|
|
} else {
|
|
ClearInvalidations(aRoot);
|
|
}
|
|
IntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(),
|
|
aRoot->GetLocalTransform());
|
|
result = result.Union(OldTransformedBounds());
|
|
if (aGeometryChanged != nullptr) {
|
|
*aGeometryChanged = true;
|
|
}
|
|
return result;
|
|
} else {
|
|
bool geometryChanged = (aGeometryChanged != nullptr) ? *aGeometryChanged : false;
|
|
nsIntRegion invalid = ComputeChange(aCallback, geometryChanged);
|
|
if (aGeometryChanged != nullptr) {
|
|
*aGeometryChanged = geometryChanged;
|
|
}
|
|
return invalid;
|
|
}
|
|
}
|
|
|
|
void
|
|
LayerPropertiesBase::MoveBy(const IntPoint& aOffset)
|
|
{
|
|
mTransform.PostTranslate(aOffset.x, aOffset.y, 0);
|
|
}
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|