Bug 1213095 - Don't allow RequestContentRepaint to mutate the provided FrameMetrics. r=botond

--HG--
extra : commitid : FZAETJ9CtR2
This commit is contained in:
Kartikaya Gupta 2016-01-18 15:23:08 -05:00
Родитель c44f6aace4
Коммит 38fba1fdeb
2 изменённых файлов: 21 добавлений и 24 удалений

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

@ -2762,7 +2762,7 @@ void AsyncPanZoomController::FlushRepaintForNewInputBlock() {
APZC_LOG("%p flushing repaint for new input block\n", this);
ReentrantMonitorAutoEnter lock(mMonitor);
RequestContentRepaint(mFrameMetrics);
RequestContentRepaint();
UpdateSharedCompositorFrameMetrics();
}
@ -2805,7 +2805,11 @@ int32_t AsyncPanZoomController::GetLastTouchIdentifier() const {
}
void AsyncPanZoomController::RequestContentRepaint() {
RequestContentRepaint(mFrameMetrics);
ParentLayerPoint velocity = GetVelocityVector();
mFrameMetrics.SetDisplayPortMargins(CalculatePendingDisplayPort(mFrameMetrics, velocity));
mFrameMetrics.SetUseDisplayPortMargins(true);
mFrameMetrics.SetPaintRequestTime(TimeStamp::Now());
RequestContentRepaint(mFrameMetrics, velocity);
}
/*static*/ CSSRect
@ -2819,12 +2823,10 @@ GetDisplayPortRect(const FrameMetrics& aFrameMetrics)
return baseRect;
}
void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
void
AsyncPanZoomController::RequestContentRepaint(const FrameMetrics& aFrameMetrics,
const ParentLayerPoint& aVelocity)
{
ParentLayerPoint velocity = GetVelocityVector();
aFrameMetrics.SetDisplayPortMargins(CalculatePendingDisplayPort(aFrameMetrics, velocity));
aFrameMetrics.SetUseDisplayPortMargins(true);
// If we're trying to paint what we already think is painted, discard this
// request since it's a pointless paint.
ScreenMargin marginDelta = (mLastPaintRequestMetrics.GetDisplayPortMargins()
@ -2846,7 +2848,6 @@ void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
return;
}
aFrameMetrics.SetPaintRequestTime(TimeStamp::Now());
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
@ -2855,7 +2856,7 @@ void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
APZC_LOG_FM(aFrameMetrics, "%p requesting content repaint", this);
if (mCheckerboardEvent) {
std::stringstream info;
info << " velocity " << velocity;
info << " velocity " << aVelocity;
std::string str = info.str();
mCheckerboardEvent->UpdateRendertraceProperty(
CheckerboardEvent::RequestedDisplayPort, GetDisplayPortRect(aFrameMetrics),
@ -2870,7 +2871,6 @@ void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
}
mExpectedGeckoMetrics = aFrameMetrics;
mLastPaintRequestMetrics = aFrameMetrics;
aFrameMetrics.SetPresShellId(mLastContentPaintMetrics.GetPresShellId());
}
bool AsyncPanZoomController::UpdateAnimation(const TimeStamp& aSampleTime,
@ -3453,9 +3453,6 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
}
endZoomToMetrics.SetScrollOffset(aRect.TopLeft());
endZoomToMetrics.SetDisplayPortMargins(
CalculatePendingDisplayPort(endZoomToMetrics, ParentLayerPoint(0,0)));
endZoomToMetrics.SetUseDisplayPortMargins(true);
StartAnimation(new ZoomAnimation(
mFrameMetrics.GetScrollOffset(),
@ -3465,7 +3462,12 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
// Schedule a repaint now, so the new displayport will be painted before the
// animation finishes.
RequestContentRepaint(endZoomToMetrics);
ParentLayerPoint velocity(0, 0);
endZoomToMetrics.SetDisplayPortMargins(
CalculatePendingDisplayPort(endZoomToMetrics, velocity));
endZoomToMetrics.SetUseDisplayPortMargins(true);
endZoomToMetrics.SetPaintRequestTime(TimeStamp::Now());
RequestContentRepaint(endZoomToMetrics, velocity);
}
}

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

@ -577,21 +577,16 @@ protected:
/**
* Utility function to send updated FrameMetrics to Gecko so that it can paint
* the displayport area. Calls into GeckoContentController to do the actual
* work. Note that only one paint request can be active at a time. If a paint
* request is made while a paint is currently happening, it gets queued up. If
* a new paint request arrives before a paint is completed, the old request
* gets discarded.
* work. This call will use the current metrics.
*/
void RequestContentRepaint();
/**
* Tell the paint throttler to request a content repaint with the given
* metrics. (Helper function used by RequestContentRepaint.) If aThrottled
* is set to false, the repaint request is sent directly without going through
* the paint throttler. In particular, the GeckoContentController::RequestContentRepaint
* function will be invoked before this function returns.
* Send the provided metrics to Gecko to trigger a repaint. This function
* may filter duplicate calls with the same metrics.
*/
void RequestContentRepaint(FrameMetrics& aFrameMetrics);
void RequestContentRepaint(const FrameMetrics& aFrameMetrics,
const ParentLayerPoint& aVelocity);
/**
* Gets the current frame metrics. This is *not* the Gecko copy stored in the