@@ -198,7 +198,7 @@ CapturingContentInfo nsIPresShell::gCaptureInfo =
198
198
{ false /* mAllowed */, false /* mPointerLock */, false /* mRetargetToElement */,
199
199
false /* mPreventDrag */, nullptr /* mContent */ };
200
200
nsIContent* nsIPresShell::gKeyDownTarget;
201
- nsInterfaceHashtable <nsUint32HashKey, nsIDOMTouch > nsIPresShell::gCaptureTouchList;
201
+ nsRefPtrHashtable <nsUint32HashKey, dom::Touch > nsIPresShell::gCaptureTouchList;
202
202
bool nsIPresShell::gPreventMouseEvents = false;
203
203
204
204
// convert a color value to a string, in the CSS format #RRGGBB
@@ -5862,11 +5862,11 @@ PresShell::RecordMouseLocation(nsGUIEvent* aEvent)
5862
5862
}
5863
5863
5864
5864
static void
5865
- EvictTouchPoint(nsCOMPtr<nsIDOMTouch >& aTouch)
5865
+ EvictTouchPoint(nsRefPtr<dom::Touch >& aTouch)
5866
5866
{
5867
5867
nsIWidget *widget = nullptr;
5868
5868
// is there an easier/better way to dig out the widget?
5869
- nsCOMPtr<nsINode> node(do_QueryInterface(aTouch->GetTarget() ));
5869
+ nsCOMPtr<nsINode> node(do_QueryInterface(aTouch->mTarget ));
5870
5870
if (!node) {
5871
5871
return;
5872
5872
}
@@ -5899,21 +5899,21 @@ EvictTouchPoint(nsCOMPtr<nsIDOMTouch>& aTouch)
5899
5899
}
5900
5900
5901
5901
static PLDHashOperator
5902
- AppendToTouchList(const uint32_t& aKey, nsCOMPtr<nsIDOMTouch >& aData, void *aTouchList)
5902
+ AppendToTouchList(const uint32_t& aKey, nsRefPtr<dom::Touch >& aData, void *aTouchList)
5903
5903
{
5904
- nsTArray<nsCOMPtr<nsIDOMTouch> > *touches = static_cast<nsTArray<nsCOMPtr<nsIDOMTouch> > *>(aTouchList);
5904
+ nsTArray< nsRefPtr<dom::Touch> >* touches =
5905
+ static_cast<nsTArray< nsRefPtr<dom::Touch> >*>(aTouchList);
5905
5906
aData->mChanged = false;
5906
5907
touches->AppendElement(aData);
5907
5908
return PL_DHASH_NEXT;
5908
5909
}
5909
5910
5910
5911
static PLDHashOperator
5911
- FindAnyTarget(const uint32_t& aKey, nsCOMPtr<nsIDOMTouch >& aData,
5912
+ FindAnyTarget(const uint32_t& aKey, nsRefPtr<dom::Touch >& aData,
5912
5913
void* aAnyTarget)
5913
5914
{
5914
5915
if (aData) {
5915
- nsCOMPtr<nsIDOMEventTarget> target;
5916
- aData->GetTarget(getter_AddRefs(target));
5916
+ dom::EventTarget* target = aData->Target();
5917
5917
if (target) {
5918
5918
nsCOMPtr<nsIContent>* content =
5919
5919
static_cast<nsCOMPtr<nsIContent>*>(aAnyTarget);
@@ -6133,7 +6133,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
6133
6133
// the start of a new touch session and evict any old touches in the
6134
6134
// queue
6135
6135
if (touchEvent->touches.Length() == 1) {
6136
- nsTArray<nsCOMPtr<nsIDOMTouch > > touches;
6136
+ nsTArray< nsRefPtr<dom::Touch > > touches;
6137
6137
gCaptureTouchList.Enumerate(&AppendToTouchList, (void *)&touches);
6138
6138
for (uint32_t i = 0; i < touches.Length(); ++i) {
6139
6139
EvictTouchPoint(touches[i]);
@@ -6152,12 +6152,10 @@ PresShell::HandleEvent(nsIFrame *aFrame,
6152
6152
// Add any new touches to the queue
6153
6153
for (int32_t i = touchEvent->touches.Length(); i; ) {
6154
6154
--i;
6155
- nsIDOMTouch *touch = touchEvent->touches[i];
6156
- Touch *domtouch = static_cast<Touch*>(touch);
6155
+ dom::Touch* touch = touchEvent->touches[i];
6157
6156
touch->mMessage = aEvent->message;
6158
6157
6159
- int32_t id = 0;
6160
- touch->GetIdentifier(&id);
6158
+ int32_t id = touch->Identifier();
6161
6159
if (!gCaptureTouchList.Get(id, nullptr)) {
6162
6160
// This event is a new touch. Mark it as a changedTouch and
6163
6161
// add it to the queue.
@@ -6177,7 +6175,7 @@ PresShell::HandleEvent(nsIFrame *aFrame,
6177
6175
while (anyTarget && !anyTarget->IsElement()) {
6178
6176
anyTarget = anyTarget->GetParent();
6179
6177
}
6180
- domtouch ->SetTarget(anyTarget);
6178
+ touch ->SetTarget(anyTarget);
6181
6179
gCaptureTouchList.Put(id, touch);
6182
6180
} else {
6183
6181
nsIFrame* newTargetFrame = nullptr;
@@ -6217,13 +6215,11 @@ PresShell::HandleEvent(nsIFrame *aFrame,
6217
6215
// This touch is an old touch, we need to ensure that is not
6218
6216
// marked as changed and set its target correctly
6219
6217
touch->mChanged = false;
6220
- int32_t id;
6221
- touch->GetIdentifier(&id);
6218
+ int32_t id = touch->Identifier();
6222
6219
6223
- nsCOMPtr<nsIDOMTouch> oldTouch;
6224
- gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
6220
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
6225
6221
if (oldTouch) {
6226
- domtouch ->SetTarget(oldTouch->GetTarget() );
6222
+ touch ->SetTarget(oldTouch->mTarget );
6227
6223
gCaptureTouchList.Put(id, touch);
6228
6224
}
6229
6225
}
@@ -6286,24 +6282,21 @@ PresShell::HandleEvent(nsIFrame *aFrame,
6286
6282
case NS_TOUCH_END: {
6287
6283
// get the correct shell to dispatch to
6288
6284
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
6289
- nsTArray<nsCOMPtr<nsIDOMTouch > > & touches = touchEvent->touches;
6285
+ nsTArray< nsRefPtr<dom::Touch > >& touches = touchEvent->touches;
6290
6286
for (uint32_t i = 0; i < touches.Length(); ++i) {
6291
- nsIDOMTouch * touch = touches[i];
6287
+ dom::Touch* touch = touches[i];
6292
6288
if (!touch) {
6293
6289
break;
6294
6290
}
6295
6291
6296
- int32_t id;
6297
- touch->GetIdentifier(&id);
6298
- nsCOMPtr<nsIDOMTouch> oldTouch;
6299
- gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
6292
+ nsRefPtr<dom::Touch> oldTouch =
6293
+ gCaptureTouchList.GetWeak(touch->Identifier());
6300
6294
if (!oldTouch) {
6301
6295
break;
6302
6296
}
6303
6297
6304
- nsCOMPtr<nsIDOMEventTarget> targetPtr;
6305
- oldTouch->GetTarget(getter_AddRefs(targetPtr));
6306
- nsCOMPtr<nsIContent> content = do_QueryInterface(targetPtr);
6298
+ nsCOMPtr<nsIContent> content =
6299
+ do_QueryInterface(oldTouch->Target());
6307
6300
if (!content) {
6308
6301
break;
6309
6302
}
@@ -6681,28 +6674,24 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
6681
6674
// Remove the changed touches
6682
6675
// need to make sure we only remove touches that are ending here
6683
6676
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
6684
- nsTArray<nsCOMPtr<nsIDOMTouch > > & touches = touchEvent->touches;
6677
+ nsTArray< nsRefPtr<dom::Touch > >& touches = touchEvent->touches;
6685
6678
for (uint32_t i = 0; i < touches.Length(); ++i) {
6686
- nsIDOMTouch *touch = touches[i];
6687
- Touch *domtouch = static_cast<Touch*>(touch);
6679
+ dom::Touch* touch = touches[i];
6688
6680
if (!touch) {
6689
6681
continue;
6690
6682
}
6691
6683
touch->mMessage = aEvent->message;
6692
6684
touch->mChanged = true;
6693
- nsCOMPtr<nsIDOMTouch> oldTouch;
6694
6685
6695
- int32_t id;
6696
- touch->GetIdentifier(&id);
6697
-
6698
- gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
6686
+ int32_t id = touch->Identifier();
6687
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
6699
6688
if (!oldTouch) {
6700
6689
continue;
6701
6690
}
6702
- nsCOMPtr<EventTarget> targetPtr = oldTouch->GetTarget() ;
6691
+ nsCOMPtr<EventTarget> targetPtr = oldTouch->mTarget ;
6703
6692
6704
6693
mCurrentEventContent = do_QueryInterface(targetPtr);
6705
- domtouch ->SetTarget(targetPtr);
6694
+ touch ->SetTarget(targetPtr);
6706
6695
gCaptureTouchList.Remove(id);
6707
6696
}
6708
6697
// add any touches left in the touch list, but ensure changed=false
@@ -6712,36 +6701,33 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
6712
6701
case NS_TOUCH_MOVE: {
6713
6702
// Check for touches that changed. Mark them add to queue
6714
6703
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
6715
- nsTArray<nsCOMPtr<nsIDOMTouch > >& touches = touchEvent->touches;
6704
+ nsTArray< nsRefPtr<dom::Touch > >& touches = touchEvent->touches;
6716
6705
bool haveChanged = false;
6717
6706
for (int32_t i = touches.Length(); i; ) {
6718
6707
--i;
6719
- nsIDOMTouch *touch = touches[i];
6720
- Touch *domtouch = static_cast<Touch*>(touch);
6708
+ dom::Touch* touch = touches[i];
6721
6709
if (!touch) {
6722
6710
continue;
6723
6711
}
6724
- int32_t id;
6725
- touch->GetIdentifier(&id);
6712
+ int32_t id = touch->Identifier();
6726
6713
touch->mMessage = aEvent->message;
6727
6714
6728
- nsCOMPtr<nsIDOMTouch> oldTouch;
6729
- gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
6715
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
6730
6716
if (!oldTouch) {
6731
6717
touches.RemoveElementAt(i);
6732
6718
continue;
6733
6719
}
6734
- if(domtouch ->Equals(oldTouch)) {
6720
+ if (touch ->Equals(oldTouch)) {
6735
6721
touch->mChanged = true;
6736
6722
haveChanged = true;
6737
6723
}
6738
6724
6739
- nsCOMPtr<EventTarget> targetPtr = oldTouch->GetTarget() ;
6725
+ nsCOMPtr<dom:: EventTarget> targetPtr = oldTouch->mTarget ;
6740
6726
if (!targetPtr) {
6741
6727
touches.RemoveElementAt(i);
6742
6728
continue;
6743
6729
}
6744
- domtouch ->SetTarget(targetPtr);
6730
+ touch ->SetTarget(targetPtr);
6745
6731
6746
6732
gCaptureTouchList.Put(id, touch);
6747
6733
// if we're moving from touchstart to touchmove for this touch
0 commit comments