Bug 1665550 - part 4: Make EventStateManager update mGestureDownFrameOwner when anonymous nodes in <input> or <textarea> are replaced r=smaug
`EventStateManager` gives up to track gesture to start a drag if mouse down content which is stored in `mGestureDownFrameOwner` gets lost its primary frame. When user tries to start to drag selected text in `<input>` or `<textarea>` element, mouse down content is an anonymous node in `TextControlElement`. So, if a reflow occurs after `mousedown` event, the anonymous `<div>` element is replaced with new one and `EventStateManager` gives up to track it. Therefore, this patch makes `EventStateManager` do similar things as `nsBaseDragService`. When `nsTextControlFrame` notifies of remove/add the anonymous nodes, `EventStateManager` tries to keep tracking gesture with a new anonymous node. Differential Revision: https://phabricator.services.mozilla.com/D119488
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "nsILayoutHistoryState.h"
|
||||
|
||||
#include "nsFocusManager.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/PresState.h"
|
||||
#include "mozilla/TextEditor.h"
|
||||
@@ -166,6 +167,13 @@ void nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Otherwise, EventStateManager may track gesture to start drag with native
|
||||
// anonymous nodes in the text control element.
|
||||
else if (textControlElement->GetPresContext(Element::eForComposedDoc)) {
|
||||
textControlElement->GetPresContext(Element::eForComposedDoc)
|
||||
->EventStateManager()
|
||||
->TextControlRootWillBeRemoved(*textControlElement);
|
||||
}
|
||||
|
||||
// If we're a subclass like nsNumberControlFrame, then it owns the root of the
|
||||
// anonymous subtree where mRootNode is.
|
||||
@@ -1350,6 +1358,20 @@ nsTextControlFrame::EditorInitializer::Run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Otherwise, EventStateManager may be tracking gesture to start a drag.
|
||||
else if (TextControlElement* textControlElement =
|
||||
TextControlElement::FromNode(mFrame->GetContent())) {
|
||||
if (nsPresContext* presContext =
|
||||
textControlElement->GetPresContext(Element::eForComposedDoc)) {
|
||||
if (TextEditor* textEditor =
|
||||
textControlElement->GetTextEditorWithoutCreation()) {
|
||||
if (Element* anonymousDivElement = textEditor->GetRoot()) {
|
||||
presContext->EventStateManager()->TextControlRootAdded(
|
||||
*anonymousDivElement, *textControlElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mFrame->FinishedInitializer();
|
||||
return NS_OK;
|
||||
|
||||
Reference in New Issue
Block a user