Bug 598482 part 1 - Never force synchronous plugin geometry updates because it forces paints at bad times. r=roc

This commit is contained in:
Markus Stange 2011-12-23 22:52:20 -05:00
parent 6254508462
commit 4aec0df173
2 changed files with 4 additions and 45 deletions

View File

@ -2615,35 +2615,6 @@ nsRootPresContext::UpdatePluginGeometry()
DidApplyPluginGeometryUpdates();
}
void
nsRootPresContext::SynchronousPluginGeometryUpdate()
{
if (!mNeedsToUpdatePluginGeometry) {
// Nothing to do
return;
}
// Force synchronous paint
nsIPresShell* shell = GetPresShell();
if (!shell)
return;
nsIFrame* rootFrame = shell->GetRootFrame();
if (!rootFrame)
return;
nsCOMPtr<nsIWidget> widget = rootFrame->GetNearestWidget();
if (!widget)
return;
// Force synchronous paint of a single pixel, just to force plugin
// updates to be flushed. Doing plugin updates during paint is the best
// way to ensure that plugin updates are in sync with our content.
widget->Invalidate(nsIntRect(0,0,1,1), true);
// Update plugin geometry just in case that invalidate didn't work
// (e.g. if none of the widget is visible, it might not have processed
// a paint event). Normally this won't need to do anything.
UpdatePluginGeometry();
}
void
nsRootPresContext::RequestUpdatePluginGeometry(nsIFrame* aFrame)
{
@ -2651,15 +2622,11 @@ nsRootPresContext::RequestUpdatePluginGeometry(nsIFrame* aFrame)
return;
if (!mNeedsToUpdatePluginGeometry) {
// We'll update the plugin geometry during the next paint in this
// presContext (either from nsPresShell::WillPaint or from
// nsPresShell::DidPaint, depending on the platform) or on the next
// layout flush, whichever comes first.
mNeedsToUpdatePluginGeometry = true;
// Dispatch a Gecko event to ensure plugin geometry gets updated
// XXX this really should be done through the refresh driver, once
// all painting happens in the refresh driver
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &nsRootPresContext::SynchronousPluginGeometryUpdate);
NS_DispatchToMainThread(event);
mUpdatePluginGeometryForFrame = aFrame;
mUpdatePluginGeometryForFrame->PresContext()->
SetContainsUpdatePluginGeometryFrame(true);

View File

@ -1269,14 +1269,6 @@ public:
virtual bool IsRoot() { return true; }
/**
* This method is called off an event to force the plugin geometry to
* be updated. First we try to paint, since updating plugin geometry
* during paint is best for keeping plugins in sync with content.
* But we also force geometry updates in case painting doesn't work.
*/
void SynchronousPluginGeometryUpdate();
/**
* Call this after reflow and scrolling to ensure that the geometry
* of any windowed plugins is updated. aFrame is the root of the