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