mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1255555 - When a frame reconstruction triggers caret elements to be cloned, ensure the dummy touch listeners are re-registered on the clones. r=tylin
MozReview-Commit-ID: 8txWmd64LC9
This commit is contained in:
parent
6968f9a027
commit
e0f363fe61
@ -187,6 +187,18 @@ AccessibleCaret::Contains(const nsPoint& aPoint) const
|
||||
return rect.Contains(aPoint);
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaret::EnsureApzAware()
|
||||
{
|
||||
// If the caret element was cloned, the listener might have been lost. So
|
||||
// if that's the case we register a dummy listener if there isn't one on
|
||||
// the element already.
|
||||
if (!CaretElement()->IsApzAware()) {
|
||||
CaretElement()->AddEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaret::InjectCaretElement(nsIDocument* aDocument)
|
||||
{
|
||||
@ -200,8 +212,7 @@ AccessibleCaret::InjectCaretElement(nsIDocument* aDocument)
|
||||
// InsertAnonymousContent will clone the element to make an AnonymousContent.
|
||||
// Since event listeners are not being cloned when cloning a node, we need to
|
||||
// add the listener here.
|
||||
CaretElement()->AddEventListener(NS_LITERAL_STRING("touchstart"),
|
||||
mDummyTouchListener, false);
|
||||
EnsureApzAware();
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
|
@ -136,6 +136,10 @@ public:
|
||||
return mCaretElementHolder->GetContentNode();
|
||||
}
|
||||
|
||||
// Ensures that the caret element is made "APZ aware" so that the APZ code
|
||||
// doesn't scroll the page when the user is trying to drag the caret.
|
||||
void EnsureApzAware();
|
||||
|
||||
protected:
|
||||
// Argument aRect should be relative to CustomContentContainerFrame().
|
||||
void SetCaretElementStyle(const nsRect& aRect, float aZoomLevel);
|
||||
|
@ -401,6 +401,10 @@ AccessibleCaretEventHub::~AccessibleCaretEventHub()
|
||||
void
|
||||
AccessibleCaretEventHub::Init()
|
||||
{
|
||||
if (mInitialized && mManager) {
|
||||
mManager->OnFrameReconstruction();
|
||||
}
|
||||
|
||||
if (mInitialized || !mPresShell || !mPresShell->GetCanvasFrame() ||
|
||||
!mPresShell->GetCanvasFrame()->GetCustomContentContainer()) {
|
||||
return;
|
||||
|
@ -697,6 +697,13 @@ AccessibleCaretManager::OnKeyboardEvent()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaretManager::OnFrameReconstruction()
|
||||
{
|
||||
mFirstCaret->EnsureApzAware();
|
||||
mSecondCaret->EnsureApzAware();
|
||||
}
|
||||
|
||||
Selection*
|
||||
AccessibleCaretManager::GetSelection() const
|
||||
{
|
||||
|
@ -98,6 +98,10 @@ public:
|
||||
// Handle key event.
|
||||
virtual void OnKeyboardEvent();
|
||||
|
||||
// The canvas frame holding the accessible caret anonymous content elements
|
||||
// was reconstructed, resulting in the content elements getting cloned.
|
||||
virtual void OnFrameReconstruction();
|
||||
|
||||
protected:
|
||||
// This enum representing the number of AccessibleCarets on the screen.
|
||||
enum class CaretMode : uint8_t {
|
||||
|
Loading…
Reference in New Issue
Block a user