tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ContentProcessController.cpp (4176B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "ContentProcessController.h"
      8 
      9 #include "mozilla/PresShell.h"
     10 #include "mozilla/dom/BrowserChild.h"
     11 #include "mozilla/layers/APZCCallbackHelper.h"
     12 #include "mozilla/layers/APZChild.h"
     13 #include "mozilla/layers/DoubleTapToZoom.h"
     14 #include "nsIContentInlines.h"
     15 
     16 #include "InputData.h"  // for InputData
     17 
     18 namespace mozilla {
     19 namespace layers {
     20 
     21 ContentProcessController::ContentProcessController(
     22    const RefPtr<dom::BrowserChild>& aBrowser)
     23    : mBrowser(aBrowser) {
     24  MOZ_ASSERT(mBrowser);
     25 }
     26 
     27 void ContentProcessController::NotifyLayerTransforms(
     28    nsTArray<MatrixMessage>&& aTransforms) {
     29  // This should never get called
     30  MOZ_ASSERT(false);
     31 }
     32 
     33 void ContentProcessController::RequestContentRepaint(
     34    const RepaintRequest& aRequest) {
     35  if (mBrowser && !mBrowser->IsDestroyed()) {
     36    mBrowser->UpdateFrame(aRequest);
     37  }
     38 }
     39 
     40 void ContentProcessController::HandleTap(
     41    TapType aType, const LayoutDevicePoint& aPoint, Modifiers aModifiers,
     42    const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId,
     43    const Maybe<DoubleTapToZoomMetrics>& aMetrics) {
     44  // This should never get called
     45  MOZ_ASSERT(false);
     46 }
     47 
     48 void ContentProcessController::NotifyPinchGesture(
     49    PinchGestureInput::PinchGestureType aType, const ScrollableLayerGuid& aGuid,
     50    const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
     51    Modifiers aModifiers) {
     52  // This should never get called
     53  MOZ_ASSERT_UNREACHABLE("Unexpected message to content process");
     54 }
     55 
     56 void ContentProcessController::NotifyAPZStateChange(
     57    const ScrollableLayerGuid& aGuid, APZStateChange aChange, int aArg,
     58    Maybe<uint64_t> aInputBlockId) {
     59  if (mBrowser && !mBrowser->IsDestroyed()) {
     60    mBrowser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg,
     61                                   aInputBlockId);
     62  }
     63 }
     64 
     65 void ContentProcessController::NotifyMozMouseScrollEvent(
     66    const ScrollableLayerGuid::ViewID& aScrollId, const nsString& aEvent) {
     67  if (mBrowser && !mBrowser->IsDestroyed()) {
     68    APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
     69  }
     70 }
     71 
     72 void ContentProcessController::NotifyFlushComplete() {
     73  if (mBrowser && !mBrowser->IsDestroyed()) {
     74    RefPtr<PresShell> presShell = mBrowser->GetTopLevelPresShell();
     75    APZCCallbackHelper::NotifyFlushComplete(presShell);
     76  }
     77 }
     78 
     79 void ContentProcessController::NotifyAsyncScrollbarDragInitiated(
     80    uint64_t aDragBlockId, const ScrollableLayerGuid::ViewID& aScrollId,
     81    ScrollDirection aDirection) {
     82  APZCCallbackHelper::NotifyAsyncScrollbarDragInitiated(aDragBlockId, aScrollId,
     83                                                        aDirection);
     84 }
     85 
     86 void ContentProcessController::NotifyAsyncScrollbarDragRejected(
     87    const ScrollableLayerGuid::ViewID& aScrollId) {
     88  APZCCallbackHelper::NotifyAsyncScrollbarDragRejected(aScrollId);
     89 }
     90 
     91 void ContentProcessController::NotifyAsyncAutoscrollRejected(
     92    const ScrollableLayerGuid::ViewID& aScrollId) {
     93  APZCCallbackHelper::NotifyAsyncAutoscrollRejected(aScrollId);
     94 }
     95 
     96 void ContentProcessController::CancelAutoscroll(
     97    const ScrollableLayerGuid& aGuid) {
     98  // This should never get called
     99  MOZ_ASSERT_UNREACHABLE("Unexpected message to content process");
    100 }
    101 
    102 void ContentProcessController::NotifyScaleGestureComplete(
    103    const ScrollableLayerGuid& aGuid, float aScale) {
    104  // This should never get called
    105  MOZ_ASSERT_UNREACHABLE("Unexpected message to content process");
    106 }
    107 
    108 bool ContentProcessController::IsRepaintThread() { return NS_IsMainThread(); }
    109 
    110 void ContentProcessController::DispatchToRepaintThread(
    111    already_AddRefed<Runnable> aTask) {
    112  NS_DispatchToMainThread(std::move(aTask));
    113 }
    114 
    115 PresShell* ContentProcessController::GetTopLevelPresShell() const {
    116  if (!mBrowser || mBrowser->IsDestroyed()) {
    117    return nullptr;
    118  }
    119  return mBrowser->GetTopLevelPresShell();
    120 }
    121 
    122 }  // namespace layers
    123 }  // namespace mozilla