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