Backed out changeset c6fc27e68f45 (bug 953012) for mochitest-mc bustage

This commit is contained in:
Wes Kocher 2014-03-11 15:39:31 -07:00
Родитель d0d349e99f
Коммит c1df08207e
2 изменённых файлов: 55 добавлений и 110 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include "UIABridgePrivate.h"
#include "MetroAppShell.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/Preferences.h" // for Preferences
#include "WinUtils.h"
#include "nsIPresShell.h"
@ -21,6 +22,7 @@
// System headers (alphabetical)
#include <windows.ui.core.h> // ABI::Window::UI::Core namespace
#include <windows.ui.input.h> // ABI::Window::UI::Input namespace
//#define DEBUG_INPUT
@ -236,6 +238,20 @@ namespace {
aData->mChanged = false;
return PL_DHASH_NEXT;
}
// Helper for making sure event ptrs get freed.
class AutoDeleteEvent
{
public:
AutoDeleteEvent(WidgetGUIEvent* aPtr) :
mPtr(aPtr) {}
~AutoDeleteEvent() {
if (mPtr) {
delete mPtr;
}
}
WidgetGUIEvent* mPtr;
};
}
namespace mozilla {
@ -524,19 +540,19 @@ MetroInput::OnPointerPressed(UI::Core::ICoreWindow* aSender,
LogFunction();
#endif
UI::Input::IPointerPoint* currentPoint;
WRL::ComPtr<UI::Input::IPointerPoint> currentPoint;
WRL::ComPtr<Devices::Input::IPointerDevice> device;
Devices::Input::PointerDeviceType deviceType;
aArgs->get_CurrentPoint(&currentPoint);
aArgs->get_CurrentPoint(currentPoint.GetAddressOf());
currentPoint->get_PointerDevice(device.GetAddressOf());
device->get_PointerDeviceType(&deviceType);
// For mouse and pen input, simply call our helper function
if (deviceType !=
Devices::Input::PointerDeviceType::PointerDeviceType_Touch) {
OnPointerNonTouch(currentPoint);
mGestureRecognizer->ProcessDownEvent(currentPoint);
OnPointerNonTouch(currentPoint.Get());
mGestureRecognizer->ProcessDownEvent(currentPoint.Get());
return S_OK;
}
@ -546,7 +562,7 @@ MetroInput::OnPointerPressed(UI::Core::ICoreWindow* aSender,
// Create the new touch point and add it to our event.
uint32_t pointerId;
currentPoint->get_PointerId(&pointerId);
nsRefPtr<Touch> touch = CreateDOMTouch(currentPoint);
nsRefPtr<Touch> touch = CreateDOMTouch(currentPoint.Get());
touch->mChanged = true;
mTouches.Put(pointerId, touch);
@ -566,31 +582,25 @@ MetroInput::OnPointerPressed(UI::Core::ICoreWindow* aSender,
}
InitTouchEventTouchList(touchEvent);
DispatchAsyncTouchEvent(new TouchEventQueueEntry(touchEvent, currentPoint));
DispatchAsyncTouchEvent(touchEvent);
if (ShouldDeliverInputToRecognizer()) {
mGestureRecognizer->ProcessDownEvent(currentPoint.Get());
}
return S_OK;
}
void
MetroInput::AddPointerMoveDataToRecognizer(IPointerEventArgs* aArgs)
MetroInput::AddPointerMoveDataToRecognizer(UI::Core::IPointerEventArgs* aArgs)
{
if (ShouldDeliverInputToRecognizer()) {
WRL::ComPtr<PointerPointVector> pointerPoints;
WRL::ComPtr<Foundation::Collections::IVector<UI::Input::PointerPoint*>>
pointerPoints;
aArgs->GetIntermediatePoints(pointerPoints.GetAddressOf());
mGestureRecognizer->ProcessMoveEvents(pointerPoints.Get());
}
}
void
MetroInput::DeliverNextQueuedNoMoveTouch() {
nsAutoPtr<TouchEventQueueEntry> queueEntry =
static_cast<TouchEventQueueEntry*>(mInputEventQueue.PopFront());
if (ShouldDeliverInputToRecognizer()) {
mGestureRecognizer->ProcessMoveEvents(queueEntry->GetPointerPoints());
}
}
// This event is raised when the user moves the mouse, moves a pen that is
// in contact with the surface, or moves a finger that is in contact with
// a touch screen.
@ -634,19 +644,12 @@ MetroInput::OnPointerMoved(UI::Core::ICoreWindow* aSender,
return S_OK;
}
PointerPointVector* pointerPoints;
aArgs->GetIntermediatePoints(&pointerPoints);
AddPointerMoveDataToRecognizer(aArgs);
// If the point hasn't moved, filter it out per the spec. Pres shell does
// this as well, but we need to know when our first touchmove is going to
// get delivered so we can check the result.
if (!HasPointMoved(touch, currentPoint.Get())) {
// Even when the pointer has not moved, the gesture recognizer requires it.
// Doing it asynchronously to keep the event's order.
mInputEventQueue.Push(new TouchEventQueueEntry(nullptr, pointerPoints));
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedNoMoveTouch);
NS_DispatchToCurrentThread(runnable);
return S_OK;
}
@ -658,8 +661,7 @@ MetroInput::OnPointerMoved(UI::Core::ICoreWindow* aSender,
WidgetTouchEvent* touchEvent =
new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
InitTouchEventTouchList(touchEvent);
DispatchAsyncTouchEvent(new TouchEventQueueEntry(touchEvent, pointerPoints));
DispatchAsyncTouchEvent(touchEvent);
return S_OK;
}
@ -674,19 +676,19 @@ MetroInput::OnPointerReleased(UI::Core::ICoreWindow* aSender,
LogFunction();
#endif
UI::Input::IPointerPoint* currentPoint;
WRL::ComPtr<UI::Input::IPointerPoint> currentPoint;
WRL::ComPtr<Devices::Input::IPointerDevice> device;
Devices::Input::PointerDeviceType deviceType;
aArgs->get_CurrentPoint(&currentPoint);
aArgs->get_CurrentPoint(currentPoint.GetAddressOf());
currentPoint->get_PointerDevice(device.GetAddressOf());
device->get_PointerDeviceType(&deviceType);
// For mouse and pen input, simply call our helper function
if (deviceType !=
Devices::Input::PointerDeviceType::PointerDeviceType_Touch) {
OnPointerNonTouch(currentPoint);
mGestureRecognizer->ProcessUpEvent(currentPoint);
OnPointerNonTouch(currentPoint.Get());
mGestureRecognizer->ProcessUpEvent(currentPoint.Get());
return S_OK;
}
@ -703,7 +705,7 @@ MetroInput::OnPointerReleased(UI::Core::ICoreWindow* aSender,
WidgetTouchEvent* touchEvent =
new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
InitTouchEventTouchList(touchEvent);
DispatchAsyncTouchEvent(new TouchEventQueueEntry(touchEvent, (IPointerPoint*)nullptr));
DispatchAsyncTouchEvent(touchEvent);
}
// Remove this touch point from our map. Eventually all touch points are
@ -714,8 +716,12 @@ MetroInput::OnPointerReleased(UI::Core::ICoreWindow* aSender,
// touchend events only have a single touch; the touch that has been removed
WidgetTouchEvent* touchEvent =
new WidgetTouchEvent(true, NS_TOUCH_END, mWidget.Get());
touchEvent->touches.AppendElement(CreateDOMTouch(currentPoint));
DispatchAsyncTouchEvent(new TouchEventQueueEntry(touchEvent, currentPoint));
touchEvent->touches.AppendElement(CreateDOMTouch(currentPoint.Get()));
DispatchAsyncTouchEvent(touchEvent);
if (ShouldDeliverInputToRecognizer()) {
mGestureRecognizer->ProcessUpEvent(currentPoint.Get());
}
return S_OK;
}
@ -1130,13 +1136,12 @@ MetroInput::DeliverNextQueuedEventIgnoreStatus()
}
void
MetroInput::DispatchAsyncTouchEvent(TouchEventQueueEntry* queueEntry)
MetroInput::DispatchAsyncTouchEvent(WidgetTouchEvent* aEvent)
{
WidgetTouchEvent* event = queueEntry->GetEvent();
event->time = ::GetMessageTime();
aEvent->time = ::GetMessageTime();
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(*event);
mInputEventQueue.Push(queueEntry);
mModifierKeyState.InitInputEvent(*aEvent);
mInputEventQueue.Push(aEvent);
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedTouchEvent);
NS_DispatchToCurrentThread(runnable);
@ -1347,13 +1352,12 @@ MetroInput::DeliverNextQueuedTouchEvent()
*/
nsEventStatus status = nsEventStatus_eIgnore;
nsAutoPtr<TouchEventQueueEntry> queueEntry =
static_cast<TouchEventQueueEntry*>(mInputEventQueue.PopFront());
WidgetTouchEvent* event = queueEntry->GetEvent();
WidgetTouchEvent* event =
static_cast<WidgetTouchEvent*>(mInputEventQueue.PopFront());
MOZ_ASSERT(event);
AutoDeleteEvent wrap(event);
// Test for non-apz vs. apz target. To do this we only use the first touch
// point since that will be the input batch target. Cache this for touch events
// since HitTestChrome has to send a dom event.
@ -1383,25 +1387,6 @@ MetroInput::DeliverNextQueuedTouchEvent()
mCancelable = false;
}
}
}
if (ShouldDeliverInputToRecognizer()) {
switch (event->message) {
case NS_TOUCH_START:
mGestureRecognizer->ProcessDownEvent(queueEntry->GetPointerPoint());
break;
case NS_TOUCH_END:
mGestureRecognizer->ProcessUpEvent(queueEntry->GetPointerPoint());
break;
case NS_TOUCH_MOVE:
if (queueEntry->GetPointerPoints()) {
mGestureRecognizer->ProcessMoveEvents(queueEntry->GetPointerPoints());
}
break;
}
}
if (mNonApzTargetForTouch) {
return;
}

Просмотреть файл

@ -8,17 +8,15 @@
// Moz headers (alphabetical)
#include "keyboardlayout.h" // mModifierKeyState
#include "nsBaseHashtable.h" // mTouches
#include "nsDeque.h"
#include "nsHashKeys.h" // type of key for mTouches
#include "mozwrlbase.h"
#include "nsDeque.h"
#include "mozilla/EventForwards.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/TouchEvents.h"
#include "mozwrlbase.h"
// System headers (alphabetical)
#include <EventToken.h> // EventRegistrationToken
#include <stdint.h> // uint32_t
#include <windows.ui.input.h> // ABI::Window::UI::Input namespace
#include <wrl\client.h> // Microsoft::WRL::ComPtr class
#include <wrl\implements.h> // Microsoft::WRL::InspectableClass macro
@ -70,41 +68,6 @@ namespace mozilla {
namespace widget {
namespace winrt {
class TouchEventQueueEntry {
private:
typedef ABI::Windows::UI::Input::IPointerPoint IPointerPoint;
typedef ABI::Windows::UI::Input::PointerPoint PointerPoint;
typedef ABI::Windows::Foundation::Collections::IVector<PointerPoint*> PointerPointVector;
Microsoft::WRL::ComPtr<PointerPointVector> mPointerPoints;
Microsoft::WRL::ComPtr<IPointerPoint> mPointerPoint;
nsAutoPtr<WidgetTouchEvent> mTouchEvent;
public:
TouchEventQueueEntry(WidgetTouchEvent* aTouchEvent, IPointerPoint* aPointerPoint)
: mTouchEvent(aTouchEvent), mPointerPoint(aPointerPoint)
{
}
TouchEventQueueEntry(WidgetTouchEvent* aTouchEvent, PointerPointVector* aPointerPoints)
: mTouchEvent(aTouchEvent), mPointerPoints(aPointerPoints)
{
}
IPointerPoint* GetPointerPoint() {
return mPointerPoint.Get();
}
PointerPointVector* GetPointerPoints() {
return mPointerPoints.Get();
}
WidgetTouchEvent* GetEvent() {
return mTouchEvent;
}
};
class MetroInput : public Microsoft::WRL::RuntimeClass<IInspectable>
{
InspectableClass(L"MetroInput", BaseTrust);
@ -116,6 +79,9 @@ private:
// Devices
typedef ABI::Windows::Devices::Input::PointerDeviceType PointerDeviceType;
// Foundation
typedef ABI::Windows::Foundation::Point Point;
// UI::Core
typedef ABI::Windows::UI::Core::ICoreWindow ICoreWindow;
typedef ABI::Windows::UI::Core::IAcceleratorKeyEventArgs \
@ -137,11 +103,6 @@ private:
typedef ABI::Windows::UI::Input::IRightTappedEventArgs IRightTappedEventArgs;
typedef ABI::Windows::UI::Input::ITappedEventArgs ITappedEventArgs;
typedef ABI::Windows::UI::Input::ManipulationDelta ManipulationDelta;
typedef ABI::Windows::UI::Input::PointerPoint PointerPoint;
// Foundation
typedef ABI::Windows::Foundation::Point Point;
typedef ABI::Windows::Foundation::Collections::IVector<PointerPoint*> PointerPointVector;
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
@ -322,12 +283,11 @@ private:
// Async event dispatching
void DispatchAsyncEventIgnoreStatus(WidgetInputEvent* aEvent);
void DispatchAsyncTouchEvent(TouchEventQueueEntry* queueEntry);
void DispatchAsyncTouchEvent(WidgetTouchEvent* aEvent);
// Async event callbacks
void DeliverNextQueuedEventIgnoreStatus();
void DeliverNextQueuedTouchEvent();
void DeliverNextQueuedNoMoveTouch();
void HandleFirstTouchStartEvent(WidgetTouchEvent* aEvent);
void HandleFirstTouchMoveEvent(WidgetTouchEvent* aEvent);