diff -r 000000000000 -r 6474c204b198 widget/gonk/ParentProcessController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widget/gonk/ParentProcessController.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,67 @@ +/* -*- 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" +#include "mozilla/layers/APZCCallbackHelper.h" +#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()); + nsCOMPtr content = nsLayoutUtils::FindContentFor(mFrameMetrics.GetScrollId()); + if (content) { + mozilla::layers::APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics); + } + return NS_OK; + } + +protected: + FrameMetrics mFrameMetrics; +}; + +void +ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) +{ + if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) { + return; + } + + nsCOMPtr r = new RequestContentRepaintEvent(aFrameMetrics); + if (!NS_IsMainThread()) { + NS_DispatchToMainThread(r); + } else { + r->Run(); + } +} + +void +ParentProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, + const uint32_t& aScrollGeneration) +{ + mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); +} + +void +ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs) +{ + MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); +} + +} +}