Bug 757847 - Use a reference rather than a pointer that is never null. r=ajuma

This commit is contained in:
Kartikaya Gupta 2012-05-23 21:52:29 -04:00
Родитель 4901fe54de
Коммит c0ccebee74
1 изменённых файлов: 26 добавлений и 42 удалений

Просмотреть файл

@ -347,38 +347,36 @@ CompositorParent::TransformShadowTree()
ShadowLayer* shadow = layer->AsShadowLayer(); ShadowLayer* shadow = layer->AsShadowLayer();
ContainerLayer* container = layer->AsContainerLayer(); ContainerLayer* container = layer->AsContainerLayer();
const FrameMetrics* metrics = &container->GetFrameMetrics(); const FrameMetrics& metrics = container->GetFrameMetrics();
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform(); const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform(); const gfx3DMatrix& currentTransform = layer->GetTransform();
float rootScaleX = rootTransform.GetXScale(); float rootScaleX = rootTransform.GetXScale();
float rootScaleY = rootTransform.GetYScale(); float rootScaleY = rootTransform.GetYScale();
if (mIsFirstPaint && metrics) { if (mIsFirstPaint) {
mContentRect = metrics->mContentRect; mContentRect = metrics.mContentRect;
SetFirstPaintViewport(metrics->mViewportScrollOffset, SetFirstPaintViewport(metrics.mViewportScrollOffset,
1/rootScaleX, 1/rootScaleX,
mContentRect, mContentRect,
metrics->mCSSContentRect); metrics.mCSSContentRect);
mIsFirstPaint = false; mIsFirstPaint = false;
} else if (metrics && !metrics->mContentRect.IsEqualEdges(mContentRect)) { } else if (!metrics.mContentRect.IsEqualEdges(mContentRect)) {
mContentRect = metrics->mContentRect; mContentRect = metrics.mContentRect;
SetPageRect(1/rootScaleX, mContentRect, metrics->mCSSContentRect); SetPageRect(1/rootScaleX, mContentRect, metrics.mCSSContentRect);
} }
// We synchronise the viewport information with Java after sending the above // We synchronise the viewport information with Java after sending the above
// notifications, so that Java can take these into account in its response. // notifications, so that Java can take these into account in its response.
if (metrics) {
// Calculate the absolute display port to send to Java // Calculate the absolute display port to send to Java
nsIntRect displayPort = metrics->mDisplayPort; nsIntRect displayPort = metrics.mDisplayPort;
nsIntPoint scrollOffset = metrics->mViewportScrollOffset; nsIntPoint scrollOffset = metrics.mViewportScrollOffset;
displayPort.x += scrollOffset.x; displayPort.x += scrollOffset.x;
displayPort.y += scrollOffset.y; displayPort.y += scrollOffset.y;
SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated, SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale); mScrollOffset, mXScale, mYScale);
mLayersUpdated = false; mLayersUpdated = false;
}
// Handle transformations for asynchronous panning and zooming. We determine the // Handle transformations for asynchronous panning and zooming. We determine the
// zoom used by Gecko from the transformation set on the root layer, and we // zoom used by Gecko from the transformation set on the root layer, and we
@ -386,32 +384,18 @@ CompositorParent::TransformShadowTree()
// primary scrollable layer. We compare this to the desired zoom and scroll // primary scrollable layer. We compare this to the desired zoom and scroll
// offset in the view transform we obtained from Java in order to compute the // offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply. // transformation we need to apply.
if (metrics) {
float tempScaleDiffX = rootScaleX * mXScale; float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale; float tempScaleDiffY = rootScaleY * mYScale;
nsIntPoint metricsScrollOffset(0, 0); nsIntPoint metricsScrollOffset(0, 0);
if (metrics->IsScrollable()) if (metrics.IsScrollable())
metricsScrollOffset = metrics->mViewportScrollOffset; metricsScrollOffset = metrics.mViewportScrollOffset;
nsIntPoint scrollCompensation( nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale, (mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale); (mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale); ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform); shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
// Alter the scroll offset so that fixed position layers remain within
// the page area.
int offsetX = NS_MAX(0, NS_MIN(mScrollOffset.x, mContentRect.width - mWidgetSize.width));
int offsetY = NS_MAX(0, NS_MIN(mScrollOffset.y, mContentRect.height - mWidgetSize.height));
gfxPoint reverseViewTranslation(offsetX / tempScaleDiffX - metricsScrollOffset.x,
offsetY / tempScaleDiffY - metricsScrollOffset.y);
TranslateFixedLayers(layer, reverseViewTranslation);
} else {
ViewTransform treeTransform(nsIntPoint(0,0), mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
}
} }
void void