gfx/layers/apz/src/TouchCounter.cpp
author Dorel Luca <dluca@mozilla.com>
Fri, 01 Mar 2019 23:28:36 +0200
changeset 519910 48b049ff10f16c25a2ac43812d8087a044bd04ca
parent 519873 gfx/layers/apz/util/TouchCounter.cpp@cd326f5e4eb883c0daa8dd5022c99fc886dda9bf
child 520039 d016ded4616b2c02f00a75f9e80c233b6b050f01
permissions -rw-r--r--
Backed out 3 changesets (bug 1525570) for mochitest failures in gfx/layers/apz/test/mochitest/test_group_zoom.html | helper_zoom_prevented.html Backed out changeset ee394d0b085d (bug 1525570) Backed out changeset 77625f533af6 (bug 1525570) Backed out changeset cd326f5e4eb8 (bug 1525570)

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "TouchCounter.h"

#include "InputData.h"

namespace mozilla {
namespace layers {

TouchCounter::TouchCounter() : mActiveTouchCount(0) {}

void TouchCounter::Update(const MultiTouchInput& aInput) {
  switch (aInput.mType) {
    case MultiTouchInput::MULTITOUCH_START:
      // touch-start event contains all active touches of the current session
      mActiveTouchCount = aInput.mTouches.Length();
      break;
    case MultiTouchInput::MULTITOUCH_END:
      if (mActiveTouchCount >= aInput.mTouches.Length()) {
        // touch-end event contains only released touches
        mActiveTouchCount -= aInput.mTouches.Length();
      } else {
        NS_WARNING("Got an unexpected touchend/touchcancel");
        mActiveTouchCount = 0;
      }
      break;
    case MultiTouchInput::MULTITOUCH_CANCEL:
      mActiveTouchCount = 0;
      break;
    case MultiTouchInput::MULTITOUCH_MOVE:
      break;
  }
}

uint32_t TouchCounter::GetActiveTouchCount() const { return mActiveTouchCount; }

}  // namespace layers
}  // namespace mozilla