mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1121468 - Show carets when long-pressing on selection highlight. r=roc
The blur event will hide the carets and produces a standalone selection highlight without carets. When a user long-pressing on the highlight, we should show carets for the original selection highlight instead of select a new word. The helper UpdateCaretsWithHapticFeedback() should only be needed when long-pressing. It should suffice to live within SelectWordOrShortcut() instead of being a member function.
This commit is contained in:
parent
d8820757ca
commit
5ba406e8dd
@ -456,6 +456,11 @@ AccessibleCaretManager::TapCaret(const nsPoint& aPoint)
|
|||||||
nsresult
|
nsresult
|
||||||
AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
|
AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
|
||||||
{
|
{
|
||||||
|
auto UpdateCaretsWithHapticFeedback = [this] {
|
||||||
|
UpdateCarets();
|
||||||
|
ProvideHapticFeedback();
|
||||||
|
};
|
||||||
|
|
||||||
if (!mPresShell) {
|
if (!mPresShell) {
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
@ -488,8 +493,7 @@ AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
|
|||||||
ChangeFocusToOrClearOldFocus(focusableFrame);
|
ChangeFocusToOrClearOldFocus(focusableFrame);
|
||||||
// We need to update carets to get correct information before dispatching
|
// We need to update carets to get correct information before dispatching
|
||||||
// CaretStateChangedEvent.
|
// CaretStateChangedEvent.
|
||||||
UpdateCarets();
|
UpdateCaretsWithHapticFeedback();
|
||||||
ProvideHapticFeedback();
|
|
||||||
DispatchCaretStateChangedEvent(CaretChangedReason::Longpressonemptycontent);
|
DispatchCaretStateChangedEvent(CaretChangedReason::Longpressonemptycontent);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -514,13 +518,22 @@ AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
|
|||||||
// ptFrame is selectable. Now change the focus.
|
// ptFrame is selectable. Now change the focus.
|
||||||
ChangeFocusToOrClearOldFocus(focusableFrame);
|
ChangeFocusToOrClearOldFocus(focusableFrame);
|
||||||
|
|
||||||
|
if (GetCaretMode() == CaretMode::Selection &&
|
||||||
|
!mFirstCaret->IsLogicallyVisible() && !mSecondCaret->IsLogicallyVisible()) {
|
||||||
|
// We have a selection while both carets have Appearance::None because of
|
||||||
|
// previous operations like blur event. Just update carets on the selection
|
||||||
|
// without selecting a new word.
|
||||||
|
AC_LOG("%s: UpdateCarets() for current selection", __FUNCTION__);
|
||||||
|
UpdateCaretsWithHapticFeedback();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Then try select a word under point.
|
// Then try select a word under point.
|
||||||
nsPoint ptInFrame = aPoint;
|
nsPoint ptInFrame = aPoint;
|
||||||
nsLayoutUtils::TransformPoint(rootFrame, ptFrame, ptInFrame);
|
nsLayoutUtils::TransformPoint(rootFrame, ptFrame, ptInFrame);
|
||||||
|
|
||||||
nsresult rv = SelectWord(ptFrame, ptInFrame);
|
nsresult rv = SelectWord(ptFrame, ptInFrame);
|
||||||
UpdateCarets();
|
UpdateCaretsWithHapticFeedback();
|
||||||
ProvideHapticFeedback();
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user