Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "ParentProcessController.h"
7 #include "nsIContent.h"
8 #include "nsLayoutUtils.h"
9 #include "mozilla/layers/APZCCallbackHelper.h"
10 #include "base/message_loop.h"
12 namespace mozilla {
13 namespace widget {
15 class RequestContentRepaintEvent : public nsRunnable
16 {
17 typedef mozilla::layers::FrameMetrics FrameMetrics;
19 public:
20 RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics)
21 : mFrameMetrics(aFrameMetrics)
22 {
23 }
25 NS_IMETHOD Run() {
26 MOZ_ASSERT(NS_IsMainThread());
27 nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.GetScrollId());
28 if (content) {
29 mozilla::layers::APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics);
30 }
31 return NS_OK;
32 }
34 protected:
35 FrameMetrics mFrameMetrics;
36 };
38 void
39 ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
40 {
41 if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) {
42 return;
43 }
45 nsCOMPtr<nsIRunnable> r = new RequestContentRepaintEvent(aFrameMetrics);
46 if (!NS_IsMainThread()) {
47 NS_DispatchToMainThread(r);
48 } else {
49 r->Run();
50 }
51 }
53 void
54 ParentProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
55 const uint32_t& aScrollGeneration)
56 {
57 mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
58 }
60 void
61 ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs)
62 {
63 MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
64 }
66 }
67 }