DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (31ec81b5d7bb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "APZController.h"
#include "base/message_loop.h"
#include "mozilla/layers/GeckoContentController.h"
#include "nsThreadUtils.h"
#include "MetroUtils.h"
#include "nsPrintfCString.h"

namespace mozilla {
namespace widget {
namespace winrt {

class RequestContentRepaintEvent : public nsRunnable
{
    typedef mozilla::layers::FrameMetrics FrameMetrics;

public:
    RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics)
    {
    }

    NS_IMETHOD Run() {
        // This event shuts down the worker thread and so must be main thread.
        MOZ_ASSERT(NS_IsMainThread());

        CSSToScreenScale resolution = mFrameMetrics.mZoom;
        CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels();

        NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \
                                                    "  \"resolution\": %.2f, " \
                                                    "  \"scrollId\": %d, " \
                                                    "  \"compositedRect\": { \"width\": %d, \"height\": %d }, " \
                                                    "  \"displayPort\":    { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \
                                                    "  \"scrollTo\":       { \"x\": %d, \"y\": %d }" \
                                                    "}",
                                                    (float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale),
                                                    (int)mFrameMetrics.mScrollId,
                                                    (int)compositedRect.width,
                                                    (int)compositedRect.height,
                                                    (int)mFrameMetrics.mDisplayPort.x,
                                                    (int)mFrameMetrics.mDisplayPort.y,
                                                    (int)mFrameMetrics.mDisplayPort.width,
                                                    (int)mFrameMetrics.mDisplayPort.height,
                                                    (int)mFrameMetrics.mScrollOffset.x,
                                                    (int)mFrameMetrics.mScrollOffset.y));

        MetroUtils::FireObserver("apzc-request-content-repaint", data.get());
        return NS_OK;
    }
protected:
    const FrameMetrics mFrameMetrics;
};

void
APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
  // Send the result back to the main thread so that it can shutdown
  nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics);
  if (!NS_IsMainThread()) {
    NS_DispatchToMainThread(r1);
  } else {
    r1->Run();
  }
}

void
APZController::HandleDoubleTap(const CSSIntPoint& aPoint)
{
}

void
APZController::HandleSingleTap(const CSSIntPoint& aPoint)
{
}

void
APZController::HandleLongTap(const CSSIntPoint& aPoint)
{
}

void
APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
{
}

void
APZController::PostDelayedTask(Task* aTask, int aDelayMs)
{
  MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}

void
APZController::HandlePanBegin()
{
  MetroUtils::FireObserver("apzc-handle-pan-begin", L"");
}

void
APZController::HandlePanEnd()
{
  MetroUtils::FireObserver("apzc-handle-pan-end", L"");
}

} } }