Bug 1304598 Part 2 - Strip "dom::" prefix by using namespace in TouchManager.cpp
MozReview-Commit-ID: EYDEQum6K1G
--- a/layout/base/TouchManager.cpp
+++ b/layout/base/TouchManager.cpp
@@ -7,16 +7,18 @@
#include "TouchManager.h"
#include "mozilla/dom/EventTarget.h"
#include "nsIFrame.h"
#include "nsPresShell.h"
#include "nsView.h"
+using namespace mozilla::dom;
+
namespace mozilla {
nsDataHashtable<nsUint32HashKey, TouchManager::TouchInfo>* TouchManager::sCaptureTouchList;
/*static*/ void
TouchManager::InitializeStatics()
{
NS_ASSERTION(!sCaptureTouchList, "InitializeStatics called multiple times!");
@@ -42,27 +44,27 @@ void
TouchManager::Destroy()
{
EvictTouches();
mDocument = nullptr;
mPresShell = nullptr;
}
static nsIContent*
-GetNonAnonymousAncestor(dom::EventTarget* aTarget)
+GetNonAnonymousAncestor(EventTarget* aTarget)
{
nsCOMPtr<nsIContent> content(do_QueryInterface(aTarget));
if (content && content->IsInNativeAnonymousSubtree()) {
content = content->FindFirstNonChromeOnlyAccessContent();
}
return content;
}
/*static*/ void
-TouchManager::EvictTouchPoint(RefPtr<dom::Touch>& aTouch,
+TouchManager::EvictTouchPoint(RefPtr<Touch>& aTouch,
nsIDocument* aLimitToDocument)
{
nsCOMPtr<nsINode> node(do_QueryInterface(aTouch->mTarget));
if (node) {
nsIDocument* doc = node->GetUncomposedDoc();
if (doc && (!aLimitToDocument || aLimitToDocument == doc)) {
nsIPresShell* presShell = doc->GetShell();
if (presShell) {
@@ -87,17 +89,17 @@ TouchManager::EvictTouchPoint(RefPtr<dom
}
/*static*/ void
TouchManager::AppendToTouchList(WidgetTouchEvent::TouchArray* aTouchList)
{
for (auto iter = sCaptureTouchList->Iter();
!iter.Done();
iter.Next()) {
- RefPtr<dom::Touch>& touch = iter.Data().mTouch;
+ RefPtr<Touch>& touch = iter.Data().mTouch;
touch->mChanged = false;
aTouchList->AppendElement(touch);
}
}
void
TouchManager::EvictTouches()
{
@@ -126,17 +128,17 @@ TouchManager::PreHandleEvent(WidgetEvent
WidgetTouchEvent::AutoTouchArray touches;
AppendToTouchList(&touches);
for (uint32_t i = 0; i < touches.Length(); ++i) {
EvictTouchPoint(touches[i]);
}
}
// Add any new touches to the queue
for (uint32_t i = 0; i < touchEvent->mTouches.Length(); ++i) {
- dom::Touch* touch = touchEvent->mTouches[i];
+ Touch* touch = touchEvent->mTouches[i];
int32_t id = touch->Identifier();
if (!sCaptureTouchList->Get(id, nullptr)) {
// If it is not already in the queue, it is a new touch
touch->mChanged = true;
}
touch->mMessage = aEvent->mMessage;
TouchInfo info = { touch, GetNonAnonymousAncestor(touch->mTarget) };
sCaptureTouchList->Put(id, info);
@@ -145,35 +147,35 @@ TouchManager::PreHandleEvent(WidgetEvent
}
case eTouchMove: {
// Check for touches that changed. Mark them add to queue
WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
WidgetTouchEvent::TouchArray& touches = touchEvent->mTouches;
bool haveChanged = false;
for (int32_t i = touches.Length(); i; ) {
--i;
- dom::Touch* touch = touches[i];
+ Touch* touch = touches[i];
if (!touch) {
continue;
}
int32_t id = touch->Identifier();
touch->mMessage = aEvent->mMessage;
TouchInfo info;
if (!sCaptureTouchList->Get(id, &info)) {
touches.RemoveElementAt(i);
continue;
}
- RefPtr<dom::Touch> oldTouch = info.mTouch;
+ RefPtr<Touch> oldTouch = info.mTouch;
if (!touch->Equals(oldTouch)) {
touch->mChanged = true;
haveChanged = true;
}
- nsCOMPtr<dom::EventTarget> targetPtr = oldTouch->mTarget;
+ nsCOMPtr<EventTarget> targetPtr = oldTouch->mTarget;
if (!targetPtr) {
touches.RemoveElementAt(i);
continue;
}
nsCOMPtr<nsINode> targetNode(do_QueryInterface(targetPtr));
if (!targetNode->IsInComposedDoc()) {
targetPtr = do_QueryInterface(info.mNonAnonymousTarget);
}
@@ -214,17 +216,17 @@ TouchManager::PreHandleEvent(WidgetEvent
// Fall through to touchcancel code
MOZ_FALLTHROUGH;
case eTouchCancel: {
// Remove the changed touches
// need to make sure we only remove touches that are ending here
WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
WidgetTouchEvent::TouchArray& touches = touchEvent->mTouches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
- dom::Touch* touch = touches[i];
+ Touch* touch = touches[i];
if (!touch) {
continue;
}
touch->mMessage = aEvent->mMessage;
touch->mChanged = true;
int32_t id = touch->Identifier();
TouchInfo info;
@@ -254,38 +256,38 @@ TouchManager::PreHandleEvent(WidgetEvent
/*static*/ already_AddRefed<nsIContent>
TouchManager::GetAnyCapturedTouchTarget()
{
nsCOMPtr<nsIContent> result = nullptr;
if (sCaptureTouchList->Count() == 0) {
return result.forget();
}
for (auto iter = sCaptureTouchList->Iter(); !iter.Done(); iter.Next()) {
- RefPtr<dom::Touch>& touch = iter.Data().mTouch;
+ RefPtr<Touch>& touch = iter.Data().mTouch;
if (touch) {
- dom::EventTarget* target = touch->GetTarget();
+ EventTarget* target = touch->GetTarget();
if (target) {
result = do_QueryInterface(target);
break;
}
}
}
return result.forget();
}
/*static*/ bool
TouchManager::HasCapturedTouch(int32_t aId)
{
return sCaptureTouchList->Contains(aId);
}
-/*static*/ already_AddRefed<dom::Touch>
+/*static*/ already_AddRefed<Touch>
TouchManager::GetCapturedTouch(int32_t aId)
{
- RefPtr<dom::Touch> touch;
+ RefPtr<Touch> touch;
TouchInfo info;
if (sCaptureTouchList->Get(aId, &info)) {
touch = info.mTouch;
}
return touch.forget();
}
} // namespace mozilla