Bug 1056155 - Follow-up to bug 1051985 to not assume only ContainerLayers have FrameMetrics. r=mattwoodrow

This commit is contained in:
Kartikaya Gupta 2014-08-21 05:40:00 -04:00
parent 6fda146273
commit c6ff8a9edf
3 changed files with 21 additions and 26 deletions

View File

@ -62,21 +62,20 @@ LayerManager::GetPrimaryScrollableLayer()
nsTArray<Layer*> queue;
queue.AppendElement(mRoot);
while (queue.Length()) {
ContainerLayer* containerLayer = queue[0]->AsContainerLayer();
Layer* layer = queue[0];
queue.RemoveElementAt(0);
if (!containerLayer) {
continue;
}
const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
const FrameMetrics& frameMetrics = layer->GetFrameMetrics();
if (frameMetrics.IsScrollable()) {
return containerLayer;
return layer;
}
Layer* child = containerLayer->GetFirstChild();
while (child) {
queue.AppendElement(child);
child = child->GetNextSibling();
if (ContainerLayer* containerLayer = layer->AsContainerLayer()) {
Layer* child = containerLayer->GetFirstChild();
while (child) {
queue.AppendElement(child);
child = child->GetNextSibling();
}
}
}
@ -93,22 +92,21 @@ LayerManager::GetScrollableLayers(nsTArray<Layer*>& aArray)
nsTArray<Layer*> queue;
queue.AppendElement(mRoot);
while (!queue.IsEmpty()) {
ContainerLayer* containerLayer = queue.LastElement()->AsContainerLayer();
Layer* layer = queue.LastElement();
queue.RemoveElementAt(queue.Length() - 1);
if (!containerLayer) {
continue;
}
const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
const FrameMetrics& frameMetrics = layer->GetFrameMetrics();
if (frameMetrics.IsScrollable()) {
aArray.AppendElement(containerLayer);
aArray.AppendElement(layer);
continue;
}
Layer* child = containerLayer->GetFirstChild();
while (child) {
queue.AppendElement(child);
child = child->GetNextSibling();
if (ContainerLayer* containerLayer = layer->AsContainerLayer()) {
Layer* child = containerLayer->GetFirstChild();
while (child) {
queue.AppendElement(child);
child = child->GetNextSibling();
}
}
}
}

View File

@ -343,7 +343,8 @@ public:
/**
* Returns a list of all descendant layers for which
* GetFrameMetrics().IsScrollable() is true.
* GetFrameMetrics().IsScrollable() is true and that
* do not already have an ancestor in the return list.
*/
void GetScrollableLayers(nsTArray<Layer*>& aArray);

View File

@ -690,11 +690,7 @@ LayerTransactionParent::RecvSetAsyncScrollOffset(PLayerParent* aLayer,
if (!layer) {
return false;
}
ContainerLayer* containerLayer = layer->AsContainerLayer();
if (!containerLayer) {
return false;
}
AsyncPanZoomController* controller = containerLayer->GetAsyncPanZoomController();
AsyncPanZoomController* controller = layer->GetAsyncPanZoomController();
if (!controller) {
return false;
}