# HG changeset patch # User Kartikaya Gupta Add InputEventContext diff --git a/gfx/layers/apz/util/InputEventContext.cpp b/gfx/layers/apz/util/InputEventContext.cpp new file mode 100644 index 0000000..76a205f --- /dev/null +++ b/gfx/layers/apz/util/InputEventContext.cpp @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 "InputEventContext.h" + +namespace mozilla { +namespace layers { + +ScrollableLayerGuid InputEventContext::sGuid; +uint64_t InputEventContext::sBlockId = 0; + +/*static*/ ScrollableLayerGuid +InputEventContext::GetTargetLayerGuid() +{ + return sGuid; +} + +/*static*/ uint64_t +InputEventContext::GetInputBlockId() +{ + return sBlockId; +} + +InputEventContext::InputEventContext(const ScrollableLayerGuid& aGuid, + const uint64_t& aBlockId) + : mOldGuid(sGuid) + , mOldBlockId(sBlockId) +{ + sGuid = aGuid; + sBlockId = aBlockId; +} + +InputEventContext::~InputEventContext() +{ + sGuid = mOldGuid; + sBlockId = mOldBlockId; +} + +} +} diff --git a/gfx/layers/apz/util/InputEventContext.h b/gfx/layers/apz/util/InputEventContext.h new file mode 100644 index 0000000..3af9f3d --- /dev/null +++ b/gfx/layers/apz/util/InputEventContext.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#ifndef mozilla_layers_InputEventContext_h +#define mozilla_layers_InputEventContext_h + +#include "FrameMetrics.h" + +namespace mozilla { +namespace layers { + +/* This class contains some helper methods that facilitate implementing the + GeckoContentController callback interface required by the AsyncPanZoomController. + Since different platforms need to implement this interface in similar-but- + not-quite-the-same ways, this utility class provides some helpful methods + to hold code that can be shared across the different platform implementations. + */ +class MOZ_STACK_CLASS InputEventContext +{ +private: + static ScrollableLayerGuid sGuid; + static uint64_t sBlockId; + +public: + static ScrollableLayerGuid GetTargetLayerGuid(); + static uint64_t GetInputBlockId(); + + InputEventContext(const ScrollableLayerGuid& aGuid, + const uint64_t& aBlockId); + ~InputEventContext(); + +private: + ScrollableLayerGuid mOldGuid; + uint64_t mOldBlockId; +}; + +} +} + +#endif /* mozilla_layers_InputEventContext_h */ diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index de95569..c88db65 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -109,16 +109,17 @@ EXPORTS.mozilla.layers += [ 'apz/public/GeckoContentController.h', # exporting things from apz/src is temporary until we extract a # proper interface for the code there 'apz/src/APZCTreeManager.h', 'apz/testutil/APZTestData.h', 'apz/util/ActiveElementManager.h', 'apz/util/APZCCallbackHelper.h', 'apz/util/ChromeProcessController.h', + 'apz/util/InputEventContext.h', 'AtomicRefCountedWithFinalize.h', 'AxisPhysicsModel.h', 'AxisPhysicsMSDModel.h', 'basic/BasicCompositor.h', 'basic/MacIOSurfaceTextureHostBasic.h', 'basic/TextureHostBasic.h', 'client/CanvasClient.h', 'client/CompositableClient.h', @@ -241,16 +242,17 @@ UNIFIED_SOURCES += [ 'apz/src/InputBlockState.cpp', 'apz/src/InputQueue.cpp', 'apz/src/OverscrollHandoffState.cpp', 'apz/src/TaskThrottler.cpp', 'apz/testutil/APZTestData.cpp', 'apz/util/ActiveElementManager.cpp', 'apz/util/APZCCallbackHelper.cpp', 'apz/util/ChromeProcessController.cpp', + 'apz/util/InputEventContext.cpp', 'AxisPhysicsModel.cpp', 'AxisPhysicsMSDModel.cpp', 'basic/BasicCanvasLayer.cpp', 'basic/BasicColorLayer.cpp', 'basic/BasicCompositor.cpp', 'basic/BasicContainerLayer.cpp', 'basic/BasicImages.cpp', 'basic/BasicLayerManager.cpp',