mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1125419 - Add dummy touch event listener to touch/selection carets to prevent apz scroll when dragging touch/selection carets. r=roc
--HG-- extra : rebase_source : 53aa339fca8e0a1287a9c47e98e162cd695c7b22
This commit is contained in:
parent
2d221c476f
commit
c8b0b1c49e
@ -53,6 +53,8 @@ NS_QUERYFRAME_HEAD(nsCanvasFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsCanvasFrame::DummyTouchListener, nsIDOMEventListener)
|
||||
|
||||
void
|
||||
nsCanvasFrame::ShowCustomContentContainer()
|
||||
{
|
||||
@ -101,6 +103,12 @@ nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
classValue.AppendLiteral("moz-touchcaret hidden");
|
||||
rv = mTouchCaretElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
|
||||
classValue, true);
|
||||
|
||||
if (!mDummyTouchListener) {
|
||||
mDummyTouchListener = new DummyTouchListener();
|
||||
}
|
||||
mTouchCaretElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -124,6 +132,14 @@ nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
rv = mSelectionCaretsEndElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
|
||||
NS_LITERAL_STRING("moz-selectioncaret-right hidden"),
|
||||
true);
|
||||
|
||||
if (!mDummyTouchListener) {
|
||||
mDummyTouchListener = new DummyTouchListener();
|
||||
}
|
||||
mSelectionCaretsStartElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
mSelectionCaretsEndElement->AddEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -179,6 +195,21 @@ nsCanvasFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
||||
sf->RemoveScrollPositionListener(this);
|
||||
}
|
||||
|
||||
if (mTouchCaretElement) {
|
||||
mTouchCaretElement->RemoveEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
}
|
||||
|
||||
if (mSelectionCaretsStartElement) {
|
||||
mSelectionCaretsStartElement->RemoveEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
}
|
||||
|
||||
if (mSelectionCaretsEndElement) {
|
||||
mSelectionCaretsEndElement->RemoveEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
}
|
||||
|
||||
nsContentUtils::DestroyAnonymousContent(&mTouchCaretElement);
|
||||
nsContentUtils::DestroyAnonymousContent(&mSelectionCaretsStartElement);
|
||||
nsContentUtils::DestroyAnonymousContent(&mSelectionCaretsEndElement);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsIScrollPositionListener.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
||||
class nsPresContext;
|
||||
class nsRenderingContext;
|
||||
@ -168,6 +169,24 @@ protected:
|
||||
nsCOMPtr<mozilla::dom::Element> mSelectionCaretsStartElement;
|
||||
nsCOMPtr<mozilla::dom::Element> mSelectionCaretsEndElement;
|
||||
nsCOMPtr<mozilla::dom::Element> mCustomContentContainer;
|
||||
|
||||
class DummyTouchListener MOZ_FINAL : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
~DummyTouchListener() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* A no-op touch-listener used for APZ purposes.
|
||||
*/
|
||||
nsRefPtr<DummyTouchListener> mDummyTouchListener;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user