зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1127066 - Use a weak reference to the widget in APZEventState to avoid reference cycles. r=kats
--HG-- extra : source : fa8926018068e8de68b0b9c44ad0bdc87acf2033
This commit is contained in:
Родитель
9fd2a6c742
Коммит
c83b7760e1
|
@ -25,7 +25,7 @@ static bool sActiveDurationMsSet = false;
|
||||||
|
|
||||||
APZEventState::APZEventState(nsIWidget* aWidget,
|
APZEventState::APZEventState(nsIWidget* aWidget,
|
||||||
const nsRefPtr<ContentReceivedInputBlockCallback>& aCallback)
|
const nsRefPtr<ContentReceivedInputBlockCallback>& aCallback)
|
||||||
: mWidget(aWidget)
|
: mWidget(do_GetWeakReference(aWidget))
|
||||||
, mActiveElementManager(new ActiveElementManager())
|
, mActiveElementManager(new ActiveElementManager())
|
||||||
, mContentReceivedInputBlockCallback(aCallback)
|
, mContentReceivedInputBlockCallback(aCallback)
|
||||||
, mPendingTouchPreventedResponse(false)
|
, mPendingTouchPreventedResponse(false)
|
||||||
|
@ -49,10 +49,10 @@ class DelayedFireSingleTapEvent MOZ_FINAL : public nsITimerCallback
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
DelayedFireSingleTapEvent(nsIWidget* aWidget,
|
DelayedFireSingleTapEvent(nsWeakPtr aWidget,
|
||||||
LayoutDevicePoint& aPoint,
|
LayoutDevicePoint& aPoint,
|
||||||
nsITimer* aTimer)
|
nsITimer* aTimer)
|
||||||
: mWidget(do_GetWeakReference(aWidget))
|
: mWidget(aWidget)
|
||||||
, mPoint(aPoint)
|
, mPoint(aPoint)
|
||||||
// Hold the reference count until we are called back.
|
// Hold the reference count until we are called back.
|
||||||
, mTimer(aTimer)
|
, mTimer(aTimer)
|
||||||
|
@ -92,18 +92,23 @@ APZEventState::ProcessSingleTap(const CSSPoint& aPoint,
|
||||||
APZES_LOG("Handling single tap at %s on %s with %d\n",
|
APZES_LOG("Handling single tap at %s on %s with %d\n",
|
||||||
Stringify(aPoint).c_str(), Stringify(aGuid).c_str(), mTouchEndCancelled);
|
Stringify(aPoint).c_str(), Stringify(aGuid).c_str(), mTouchEndCancelled);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||||
|
if (!widget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mTouchEndCancelled) {
|
if (mTouchEndCancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutDevicePoint currentPoint =
|
LayoutDevicePoint currentPoint =
|
||||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
||||||
* mWidget->GetDefaultScale();;
|
* widget->GetDefaultScale();;
|
||||||
if (!mActiveElementManager->ActiveElementUsesStyle()) {
|
if (!mActiveElementManager->ActiveElementUsesStyle()) {
|
||||||
// If the active element isn't visually affected by the :active style, we
|
// If the active element isn't visually affected by the :active style, we
|
||||||
// have no need to wait the extra sActiveDurationMs to make the activation
|
// have no need to wait the extra sActiveDurationMs to make the activation
|
||||||
// visually obvious to the user.
|
// visually obvious to the user.
|
||||||
APZCCallbackHelper::FireSingleTapEvent(currentPoint, mWidget);
|
APZCCallbackHelper::FireSingleTapEvent(currentPoint, widget);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +135,11 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
|
||||||
{
|
{
|
||||||
APZES_LOG("Handling long tap at %s\n", Stringify(aPoint).c_str());
|
APZES_LOG("Handling long tap at %s\n", Stringify(aPoint).c_str());
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||||
|
if (!widget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SendPendingTouchPreventedResponse(false, aGuid);
|
SendPendingTouchPreventedResponse(false, aGuid);
|
||||||
|
|
||||||
bool eventHandled =
|
bool eventHandled =
|
||||||
|
@ -144,10 +154,10 @@ APZEventState::ProcessLongTap(const nsCOMPtr<nsIDOMWindowUtils>& aUtils,
|
||||||
if (!eventHandled) {
|
if (!eventHandled) {
|
||||||
LayoutDevicePoint currentPoint =
|
LayoutDevicePoint currentPoint =
|
||||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, aPresShellResolution)
|
||||||
* mWidget->GetDefaultScale();
|
* widget->GetDefaultScale();
|
||||||
int time = 0;
|
int time = 0;
|
||||||
nsEventStatus status =
|
nsEventStatus status =
|
||||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_MOZLONGTAP, time, currentPoint, mWidget);
|
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_MOZLONGTAP, time, currentPoint, widget);
|
||||||
eventHandled = (status == nsEventStatus_eConsumeNoDefault);
|
eventHandled = (status == nsEventStatus_eConsumeNoDefault);
|
||||||
APZES_LOG("MOZLONGTAP event handled: %d\n", eventHandled);
|
APZES_LOG("MOZLONGTAP event handled: %d\n", eventHandled);
|
||||||
}
|
}
|
||||||
|
@ -289,6 +299,13 @@ APZEventState::SendPendingTouchPreventedResponse(bool aPreventDefault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIWidget>
|
||||||
|
APZEventState::GetWidget() const
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIWidget> result = do_QueryReferent(mWidget);
|
||||||
|
return result.forget();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
#include "mozilla/layers/GeckoContentController.h" // for APZStateChange
|
#include "mozilla/layers/GeckoContentController.h" // for APZStateChange
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
|
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
|
||||||
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
||||||
#include "nsRefPtr.h"
|
#include "nsRefPtr.h"
|
||||||
|
|
||||||
|
template <class> class nsCOMPtr;
|
||||||
class nsIDOMWindowUtils;
|
class nsIDOMWindowUtils;
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
|
|
||||||
|
@ -69,8 +71,9 @@ private:
|
||||||
~APZEventState();
|
~APZEventState();
|
||||||
void SendPendingTouchPreventedResponse(bool aPreventDefault,
|
void SendPendingTouchPreventedResponse(bool aPreventDefault,
|
||||||
const ScrollableLayerGuid& aGuid);
|
const ScrollableLayerGuid& aGuid);
|
||||||
|
already_AddRefed<nsIWidget> GetWidget() const;
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIWidget> mWidget;
|
nsWeakPtr mWidget;
|
||||||
nsRefPtr<ActiveElementManager> mActiveElementManager;
|
nsRefPtr<ActiveElementManager> mActiveElementManager;
|
||||||
nsRefPtr<ContentReceivedInputBlockCallback> mContentReceivedInputBlockCallback;
|
nsRefPtr<ContentReceivedInputBlockCallback> mContentReceivedInputBlockCallback;
|
||||||
bool mPendingTouchPreventedResponse;
|
bool mPendingTouchPreventedResponse;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче