Change the subdoc invalidation callback to handle overflow. (bug 1345891 part 5, r=mattwoodrow)

This commit is contained in:
David Anderson
2017-08-03 21:22:49 -07:00
parent 6b1a9d7a48
commit 5cbc12627e
4 changed files with 19 additions and 9 deletions

View File

@@ -136,7 +136,8 @@ NotifySubdocumentInvalidation(Layer* aLayer, NotifySubDocInvalidationFunc aCallb
{ {
ContainerLayer* container = layer->AsContainerLayer(); ContainerLayer* container = layer->AsContainerLayer();
if (container) { if (container) {
aCallback(container, container->GetLocalVisibleRegion().ToUnknownRegion()); nsIntRegion region = container->GetLocalVisibleRegion().ToUnknownRegion();
aCallback(container, &region);
} }
}); });
} }
@@ -471,7 +472,7 @@ public:
} }
if (aCallback) { if (aCallback) {
aCallback(container, result); aCallback(container, areaOverflowed ? nullptr : &result);
} }
if (childrenChanged || areaOverflowed) { if (childrenChanged || areaOverflowed) {

View File

@@ -21,10 +21,10 @@ class ContainerLayer;
* *
* @param aContainer ContainerLayer being invalidated. * @param aContainer ContainerLayer being invalidated.
* @param aRegion Invalidated region in the ContainerLayer's coordinate * @param aRegion Invalidated region in the ContainerLayer's coordinate
* space. * space. If null, then the entire region must be invalidated.
*/ */
typedef void (*NotifySubDocInvalidationFunc)(ContainerLayer* aLayer, typedef void (*NotifySubDocInvalidationFunc)(ContainerLayer* aLayer,
const nsIntRegion& aRegion); const nsIntRegion* aRegion);
/** /**
* A set of cached layer properties (including those of child layers), * A set of cached layer properties (including those of child layers),

View File

@@ -97,6 +97,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::layers; using namespace mozilla::layers;
uint8_t gNotifySubDocInvalidationData; uint8_t gNotifySubDocInvalidationData;
@@ -2609,7 +2610,7 @@ nsPresContext::NotifyInvalidation(uint64_t aTransactionId, const nsRect& aRect)
/* static */ void /* static */ void
nsPresContext::NotifySubDocInvalidation(ContainerLayer* aContainer, nsPresContext::NotifySubDocInvalidation(ContainerLayer* aContainer,
const nsIntRegion& aRegion) const nsIntRegion* aRegion)
{ {
ContainerLayerPresContext *data = ContainerLayerPresContext *data =
static_cast<ContainerLayerPresContext*>( static_cast<ContainerLayerPresContext*>(
@@ -2618,15 +2619,23 @@ nsPresContext::NotifySubDocInvalidation(ContainerLayer* aContainer,
return; return;
} }
nsIntPoint topLeft = aContainer->GetVisibleRegion().ToUnknownRegion().GetBounds().TopLeft(); uint64_t transactionId = aContainer->Manager()->GetLastTransactionId();
IntRect visibleBounds = aContainer->GetVisibleRegion().GetBounds().ToUnknownRect();
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) { if (!aRegion) {
IntRect rect(IntPoint(0, 0), visibleBounds.Size());
data->mPresContext->NotifyInvalidation(transactionId, rect);
return;
}
nsIntPoint topLeft = visibleBounds.TopLeft();
for (auto iter = aRegion->RectIter(); !iter.Done(); iter.Next()) {
nsIntRect rect(iter.Get()); nsIntRect rect(iter.Get());
//PresContext coordinate space is relative to the start of our visible //PresContext coordinate space is relative to the start of our visible
// region. Is this really true? This feels like the wrong way to get the right // region. Is this really true? This feels like the wrong way to get the right
// answer. // answer.
rect.MoveBy(-topLeft); rect.MoveBy(-topLeft);
data->mPresContext->NotifyInvalidation(aContainer->Manager()->GetLastTransactionId(), rect); data->mPresContext->NotifyInvalidation(transactionId, rect);
} }
} }

View File

@@ -1028,7 +1028,7 @@ public:
// Callback for catching invalidations in ContainerLayers // Callback for catching invalidations in ContainerLayers
// Passed to LayerProperties::ComputeDifference // Passed to LayerProperties::ComputeDifference
static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer, static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer,
const nsIntRegion& aRegion); const nsIntRegion* aRegion);
void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer); void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer); static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
bool IsDOMPaintEventPending(); bool IsDOMPaintEventPending();