1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gonk/ParentProcessController.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "ParentProcessController.h" 1.10 +#include "nsIContent.h" 1.11 +#include "nsLayoutUtils.h" 1.12 +#include "mozilla/layers/APZCCallbackHelper.h" 1.13 +#include "base/message_loop.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace widget { 1.17 + 1.18 +class RequestContentRepaintEvent : public nsRunnable 1.19 +{ 1.20 + typedef mozilla::layers::FrameMetrics FrameMetrics; 1.21 + 1.22 +public: 1.23 + RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) 1.24 + : mFrameMetrics(aFrameMetrics) 1.25 + { 1.26 + } 1.27 + 1.28 + NS_IMETHOD Run() { 1.29 + MOZ_ASSERT(NS_IsMainThread()); 1.30 + nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.GetScrollId()); 1.31 + if (content) { 1.32 + mozilla::layers::APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics); 1.33 + } 1.34 + return NS_OK; 1.35 + } 1.36 + 1.37 +protected: 1.38 + FrameMetrics mFrameMetrics; 1.39 +}; 1.40 + 1.41 +void 1.42 +ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) 1.43 +{ 1.44 + if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) { 1.45 + return; 1.46 + } 1.47 + 1.48 + nsCOMPtr<nsIRunnable> r = new RequestContentRepaintEvent(aFrameMetrics); 1.49 + if (!NS_IsMainThread()) { 1.50 + NS_DispatchToMainThread(r); 1.51 + } else { 1.52 + r->Run(); 1.53 + } 1.54 +} 1.55 + 1.56 +void 1.57 +ParentProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, 1.58 + const uint32_t& aScrollGeneration) 1.59 +{ 1.60 + mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); 1.61 +} 1.62 + 1.63 +void 1.64 +ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs) 1.65 +{ 1.66 + MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); 1.67 +} 1.68 + 1.69 +} 1.70 +}