mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1098161 - Notify shortcut mode to system app when long tap on content with empty text. r=roc
This commit is contained in:
parent
15214fdece
commit
0b5289330f
@ -577,6 +577,7 @@ SelectionCarets::SelectWord()
|
||||
bool selectable;
|
||||
ptFrame->IsSelectable(&selectable, nullptr);
|
||||
if (!selectable) {
|
||||
SELECTIONCARETS_LOG(" frame %p is not selectable", ptFrame);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -593,6 +594,17 @@ SelectionCarets::SelectWord()
|
||||
if (elt) {
|
||||
fm->SetFocus(elt, 0);
|
||||
}
|
||||
|
||||
if (!nsContentUtils::HasNonEmptyTextContent(
|
||||
editingHost, nsContentUtils::eRecurseIntoChildren)) {
|
||||
SELECTIONCARETS_LOG("Select a editable content %p with empty text",
|
||||
editingHost);
|
||||
// Long tap on the 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;
|
||||
}
|
||||
} else {
|
||||
nsIContent* focusedContent = GetFocusedContent();
|
||||
if (focusedContent && focusedContent->GetTextEditorRootContent()) {
|
||||
@ -1038,6 +1050,21 @@ SelectionCarets::GetSelectionBoundingRect(Selection* aSel)
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionCarets::DispatchCustomEvent(const nsAString& aEvent)
|
||||
{
|
||||
SELECTIONCARETS_LOG("dispatch %s event", NS_ConvertUTF16toUTF8(aEvent).get());
|
||||
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);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user