|
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/. */ |
|
5 |
|
6 #include "ParentProcessController.h" |
|
7 #include "nsIContent.h" |
|
8 #include "nsLayoutUtils.h" |
|
9 #include "mozilla/layers/APZCCallbackHelper.h" |
|
10 #include "base/message_loop.h" |
|
11 |
|
12 namespace mozilla { |
|
13 namespace widget { |
|
14 |
|
15 class RequestContentRepaintEvent : public nsRunnable |
|
16 { |
|
17 typedef mozilla::layers::FrameMetrics FrameMetrics; |
|
18 |
|
19 public: |
|
20 RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) |
|
21 : mFrameMetrics(aFrameMetrics) |
|
22 { |
|
23 } |
|
24 |
|
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 } |
|
33 |
|
34 protected: |
|
35 FrameMetrics mFrameMetrics; |
|
36 }; |
|
37 |
|
38 void |
|
39 ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) |
|
40 { |
|
41 if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) { |
|
42 return; |
|
43 } |
|
44 |
|
45 nsCOMPtr<nsIRunnable> r = new RequestContentRepaintEvent(aFrameMetrics); |
|
46 if (!NS_IsMainThread()) { |
|
47 NS_DispatchToMainThread(r); |
|
48 } else { |
|
49 r->Run(); |
|
50 } |
|
51 } |
|
52 |
|
53 void |
|
54 ParentProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, |
|
55 const uint32_t& aScrollGeneration) |
|
56 { |
|
57 mozilla::layers::APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); |
|
58 } |
|
59 |
|
60 void |
|
61 ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs) |
|
62 { |
|
63 MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); |
|
64 } |
|
65 |
|
66 } |
|
67 } |