LCOV - code coverage report
Current view: top level - gfx/layers/apz/src - DragTracker.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 14 21 66.7 %
Date: 2017-07-14 16:53:18 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #include "DragTracker.h"
       7             : 
       8             : #include "InputData.h"
       9             : 
      10             : #define DRAG_LOG(...)
      11             : // #define DRAG_LOG(...) printf_stderr("DRAG: " __VA_ARGS__)
      12             : 
      13             : namespace mozilla {
      14             : namespace layers {
      15             : 
      16           1 : DragTracker::DragTracker()
      17           1 :   : mInDrag(false)
      18             : {
      19           1 : }
      20             : 
      21             : /*static*/ bool
      22          12 : DragTracker::StartsDrag(const MouseInput& aInput)
      23             : {
      24          12 :   return aInput.IsLeftButton() && aInput.mType == MouseInput::MOUSE_DOWN;
      25             : }
      26             : 
      27             : /*static*/ bool
      28           4 : DragTracker::EndsDrag(const MouseInput& aInput)
      29             : {
      30             :   // On Windows, we don't receive a MOUSE_UP at the end of a drag if an
      31             :   // actual drag session took place. As a backup, we detect the end of the
      32             :   // drag using the MOUSE_DRAG_END event, which normally is routed directly
      33             :   // to content, but we're specially routing to APZ for this purpose. Bug
      34             :   // 1265105 tracks a solution to this at the Windows widget layer; once
      35             :   // that is implemented, this workaround can be removed.
      36           8 :   return (aInput.IsLeftButton() && aInput.mType == MouseInput::MOUSE_UP)
      37           8 :       || aInput.mType == MouseInput::MOUSE_DRAG_END;
      38             : }
      39             : 
      40             : void
      41           4 : DragTracker::Update(const MouseInput& aInput)
      42             : {
      43           4 :   if (StartsDrag(aInput)) {
      44             :     DRAG_LOG("Starting drag\n");
      45           0 :     mInDrag = true;
      46           4 :   } else if (EndsDrag(aInput)) {
      47             :     DRAG_LOG("Ending drag\n");
      48           0 :     mInDrag = false;
      49           0 :     mOnScrollbar = Nothing();
      50             :   }
      51           4 : }
      52             : 
      53             : bool
      54           4 : DragTracker::InDrag() const
      55             : {
      56           4 :   return mInDrag;
      57             : }
      58             : 
      59             : bool
      60           0 : DragTracker::IsOnScrollbar(bool aOnScrollbar)
      61             : {
      62           0 :   if (!mOnScrollbar) {
      63             :     DRAG_LOG("Setting hitscrollbar %d\n", aOnScrollbar);
      64           0 :     mOnScrollbar = Some(aOnScrollbar);
      65             :   }
      66           0 :   return mOnScrollbar.value();
      67             : }
      68             : 
      69             : } // namespace layers
      70             : } // namespace mozilla

Generated by: LCOV version 1.13