зеркало из https://github.com/mozilla/pjs.git
bug 755070 - Scrolling causes after paint notifications which causes screenshotting which causes checkerboarding, screenshot only on idle r=kats
--HG-- extra : rebase_source : be056e08b6a7d8aa339b12cbeb58d42054f5a118
This commit is contained in:
Родитель
68e265c9bc
Коммит
3fc2c5c095
|
@ -256,6 +256,14 @@ void MessageLoop::PostNonNestableDelayedTask(
|
|||
PostTask_Helper(from_here, task, delay_ms, false);
|
||||
}
|
||||
|
||||
void MessageLoop::PostIdleTask(
|
||||
const tracked_objects::Location& from_here, Task* task) {
|
||||
DCHECK(current() == this);
|
||||
task->SetBirthPlace(from_here);
|
||||
PendingTask pending_task(task, false);
|
||||
deferred_non_nestable_work_queue_.push(pending_task);
|
||||
}
|
||||
|
||||
// Possibly called on a background thread!
|
||||
void MessageLoop::PostTask_Helper(
|
||||
const tracked_objects::Location& from_here, Task* task, int delay_ms,
|
||||
|
|
|
@ -121,6 +121,10 @@ public:
|
|||
void PostNonNestableDelayedTask(
|
||||
const tracked_objects::Location& from_here, Task* task, int delay_ms);
|
||||
|
||||
// PostIdleTask is not thread safe and should be called on this thread
|
||||
void PostIdleTask(
|
||||
const tracked_objects::Location& from_here, Task* task);
|
||||
|
||||
// A variant on PostTask that deletes the given object. This is useful
|
||||
// if the object needs to live until the next run of the MessageLoop (for
|
||||
// example, deleting a RenderProcessHost from within an IPC callback is not
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Make sure the order of included headers
|
||||
#include "base/basictypes.h"
|
||||
#include "nspr/prtypes.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/task.h"
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
#include "nsAppShell.h"
|
||||
|
@ -63,6 +65,34 @@ nsAppShell *nsAppShell::gAppShell = nsnull;
|
|||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsAppShell, nsBaseAppShell, nsIObserver)
|
||||
|
||||
class ScreenshotRunnable : public nsRunnable {
|
||||
public:
|
||||
ScreenshotRunnable(nsIAndroidBrowserApp* aBrowserApp, int aTabId, nsTArray<nsIntPoint>& aPoints, int aToken):
|
||||
mBrowserApp(aBrowserApp), mTabId(aTabId), mPoints(aPoints), mToken(aToken) {}
|
||||
|
||||
virtual nsresult Run() {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIBrowserTab> tab;
|
||||
mBrowserApp->GetBrowserTab(mTabId, getter_AddRefs(tab));
|
||||
if (!tab)
|
||||
return NS_OK;
|
||||
|
||||
tab->GetWindow(getter_AddRefs(domWindow));
|
||||
if (!domWindow)
|
||||
return NS_OK;
|
||||
|
||||
float scale = 1.0;
|
||||
NS_ASSERTION(mPoints.Length() == 4, "Screenshot event does not have enough coordinates");
|
||||
|
||||
AndroidBridge::Bridge()->TakeScreenshot(domWindow, mPoints[0].x, mPoints[0].y, mPoints[1].x, mPoints[1].y, mPoints[3].x, mPoints[3].y, mTabId, scale, mToken);
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIAndroidBrowserApp> mBrowserApp;
|
||||
nsTArray<nsIntPoint> mPoints;
|
||||
int mTabId, mToken;
|
||||
};
|
||||
|
||||
class AfterPaintListener : public nsIDOMEventListener {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -425,21 +455,12 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
|||
break;
|
||||
|
||||
PRInt32 token = curEvent->Flags();
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIBrowserTab> tab;
|
||||
mBrowserApp->GetBrowserTab(curEvent->MetaState(), getter_AddRefs(tab));
|
||||
if (!tab)
|
||||
break;
|
||||
|
||||
tab->GetWindow(getter_AddRefs(domWindow));
|
||||
if (!domWindow)
|
||||
break;
|
||||
|
||||
float scale = 1.0;
|
||||
PRInt32 tabId = curEvent->MetaState();
|
||||
nsTArray<nsIntPoint> points = curEvent->Points();
|
||||
NS_ASSERTION(points.Length() == 4, "Screenshot event does not have enough coordinates");
|
||||
bridge->TakeScreenshot(domWindow, points[0].x, points[0].y, points[1].x, points[1].y, points[3].x, points[3].y, curEvent->MetaState(), scale, curEvent->Flags());
|
||||
nsCOMPtr<ScreenshotRunnable> sr =
|
||||
new ScreenshotRunnable(mBrowserApp, tabId, points, token);
|
||||
MessageLoop::current()->PostIdleTask(
|
||||
FROM_HERE, NewRunnableMethod(sr.get(), &ScreenshotRunnable::Run));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче