widget/gonk/ParentProcessController.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 }

mercurial