2013-09-16 14:45:31 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ParentProcessController.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2014-04-17 04:54:25 -07:00
|
|
|
#include "mozilla/layers/APZCCallbackHelper.h"
|
2013-09-16 14:45:31 -07:00
|
|
|
#include "base/message_loop.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
class RequestContentRepaintEvent : public nsRunnable
|
|
|
|
{
|
|
|
|
typedef mozilla::layers::FrameMetrics FrameMetrics;
|
|
|
|
|
|
|
|
public:
|
|
|
|
RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics)
|
|
|
|
: mFrameMetrics(aFrameMetrics)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2014-03-21 14:48:08 -07:00
|
|
|
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.GetScrollId());
|
2013-09-16 14:45:31 -07:00
|
|
|
if (content) {
|
2014-04-17 04:54:25 -07:00
|
|
|
mozilla::layers::APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics);
|
2013-09-16 14:45:31 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-12-05 05:12:12 -08:00
|
|
|
FrameMetrics mFrameMetrics;
|
2013-09-16 14:45:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
|
|
|
|
{
|
2014-03-21 14:48:08 -07:00
|
|
|
if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) {
|
2013-09-16 14:45:31 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> r = new RequestContentRepaintEvent(aFrameMetrics);
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
} else {
|
|
|
|
r->Run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-05 14:43:20 -08:00
|
|
|
void
|
|
|
|
ParentProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
|
|
|
|
const uint32_t& aScrollGeneration)
|
|
|
|
{
|
2014-04-17 04:54:25 -07:00
|
|
|
mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
|
2014-02-05 14:43:20 -08:00
|
|
|
}
|
|
|
|
|
2013-09-16 14:45:31 -07:00
|
|
|
void
|
|
|
|
ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs)
|
|
|
|
{
|
|
|
|
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|