зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1098161 - Notify shortcut mode to system app when long tap on content with empty text. r=roc
This commit is contained in:
Родитель
d676e9ef65
Коммит
20e2506fa0
|
@ -547,6 +547,7 @@ SelectionCarets::SelectWord()
|
|||
bool selectable;
|
||||
ptFrame->IsSelectable(&selectable, nullptr);
|
||||
if (!selectable) {
|
||||
SELECTIONCARETS_LOG("Unable to select");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -557,14 +558,18 @@ SelectionCarets::SelectWord()
|
|||
// target frame isn't editable and our focus content is editable, we should
|
||||
// clear focus.
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
|
||||
nsIContent* editingHost = ptFrame->GetContent()->GetEditingHost();
|
||||
if (editingHost) {
|
||||
SELECTIONCARETS_LOG("Select editable content %p", editingHost);
|
||||
nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(editingHost->GetParent());
|
||||
if (elt) {
|
||||
fm->SetFocus(elt, 0);
|
||||
}
|
||||
} else {
|
||||
nsIContent* focusedContent = GetFocusedContent();
|
||||
SELECTIONCARETS_LOG("Select non-editable content %p", focusedContent);
|
||||
|
||||
if (focusedContent && focusedContent->GetTextEditorRootContent()) {
|
||||
nsIDOMWindow* win = mPresShell->GetDocument()->GetWindow();
|
||||
if (win) {
|
||||
|
@ -573,6 +578,18 @@ SelectionCarets::SelectWord()
|
|||
}
|
||||
}
|
||||
|
||||
nsIContent* selectedContent = ptFrame->GetContent();
|
||||
if (selectedContent && !nsContentUtils::HasNonEmptyTextContent(
|
||||
selectedContent, nsContentUtils::eRecurseIntoChildren)) {
|
||||
SELECTIONCARETS_LOG("Select content %p with empty text", selectedContent);
|
||||
// Long tap event on this non-editable content with empty text, no action
|
||||
// for selectioncarets but need to dispatch the touchcarettap event
|
||||
// to support the short cut mode
|
||||
DispatchCustomEvent(NS_LITERAL_STRING("touchcarettap"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
SetSelectionDragState(true);
|
||||
nsFrame* frame = static_cast<nsFrame*>(ptFrame);
|
||||
nsresult rs = frame->SelectByTypeAtPoint(mPresShell->GetPresContext(), ptInFrame,
|
||||
|
@ -1008,6 +1025,20 @@ SelectionCarets::GetSelectionBoundingRect(Selection* aSel)
|
|||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionCarets::DispatchCustomEvent(const nsAString& aEvent)
|
||||
{
|
||||
bool defaultActionEnabled = true;
|
||||
nsIDocument* doc = mPresShell->GetDocument();
|
||||
MOZ_ASSERT(doc);
|
||||
nsContentUtils::DispatchTrustedEvent(doc,
|
||||
ToSupports(doc),
|
||||
aEvent,
|
||||
true,
|
||||
false,
|
||||
&defaultActionEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
SelectionCarets::DispatchSelectionStateChangedEvent(Selection* aSelection,
|
||||
SelectionState aState)
|
||||
|
|
|
@ -207,6 +207,7 @@ private:
|
|||
dom::SelectionState aState);
|
||||
void DispatchSelectionStateChangedEvent(dom::Selection* aSelection,
|
||||
const dom::Sequence<dom::SelectionState>& aStates);
|
||||
void DispatchCustomEvent(const nsAString& aEvent);
|
||||
nsRect GetSelectionBoundingRect(dom::Selection* aSel);
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче