mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1065244 - Part 3 - Fix SelectionCarets::SelectWord() is hard to trigger. f=mtseng, r=roc
Fix this issue by deploying the same logic as selection carets in TouchCaret::IsOnTouchCaret().
This commit is contained in:
parent
b98446503e
commit
5d804d7cd5
@ -51,7 +51,7 @@ static const int32_t kBoundaryAppUnits = 61;
|
||||
|
||||
NS_IMPL_ISUPPORTS(TouchCaret, nsISelectionListener)
|
||||
|
||||
/*static*/ int32_t TouchCaret::sTouchCaretMaxDistance = 0;
|
||||
/*static*/ int32_t TouchCaret::sTouchCaretInflateSize = 0;
|
||||
/*static*/ int32_t TouchCaret::sTouchCaretExpirationTime = 0;
|
||||
|
||||
TouchCaret::TouchCaret(nsIPresShell* aPresShell)
|
||||
@ -65,8 +65,8 @@ TouchCaret::TouchCaret(nsIPresShell* aPresShell)
|
||||
|
||||
static bool addedTouchCaretPref = false;
|
||||
if (!addedTouchCaretPref) {
|
||||
Preferences::AddIntVarCache(&sTouchCaretMaxDistance,
|
||||
"touchcaret.distance.threshold");
|
||||
Preferences::AddIntVarCache(&sTouchCaretInflateSize,
|
||||
"touchcaret.inflatesize.threshold");
|
||||
Preferences::AddIntVarCache(&sTouchCaretExpirationTime,
|
||||
"touchcaret.expiration.time");
|
||||
addedTouchCaretPref = true;
|
||||
@ -295,27 +295,8 @@ TouchCaret::MoveCaret(const nsPoint& movePoint)
|
||||
bool
|
||||
TouchCaret::IsOnTouchCaret(const nsPoint& aPoint)
|
||||
{
|
||||
// Return false if touch caret is not visible.
|
||||
if (!mVisible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRect tcRect = GetTouchFrameRect();
|
||||
|
||||
// Check if the click was in the bounding box of the touch caret.
|
||||
int32_t distance;
|
||||
if (tcRect.Contains(aPoint.x, aPoint.y)) {
|
||||
distance = 0;
|
||||
} else {
|
||||
// If click is outside the bounding box of the touch caret, check the
|
||||
// distance to the center of the touch caret.
|
||||
int32_t posX = (tcRect.x + (tcRect.width / 2));
|
||||
int32_t posY = (tcRect.y + (tcRect.height / 2));
|
||||
int32_t dx = Abs(aPoint.x - posX);
|
||||
int32_t dy = Abs(aPoint.y - posY);
|
||||
distance = dx + dy;
|
||||
}
|
||||
return (distance <= TouchCaretMaxDistance());
|
||||
return mVisible && nsLayoutUtils::ContainsPoint(GetTouchFrameRect(), aPoint,
|
||||
TouchCaretInflateSize());
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -228,10 +228,12 @@ private:
|
||||
*/
|
||||
nscoord mCaretCenterToDownPointOffsetY;
|
||||
|
||||
static int32_t TouchCaretMaxDistance()
|
||||
{
|
||||
return sTouchCaretMaxDistance;
|
||||
}
|
||||
/**
|
||||
* Get from pref "touchcaret.inflatesize.threshold". This will inflate the
|
||||
* size of the touch caret frame when checking if user clicks on the caret
|
||||
* or not. In app units.
|
||||
*/
|
||||
static int32_t TouchCaretInflateSize() { return sTouchCaretInflateSize; }
|
||||
|
||||
static int32_t TouchCaretExpirationTime()
|
||||
{
|
||||
@ -246,7 +248,7 @@ private:
|
||||
nsCOMPtr<nsITimer> mTouchCaretExpirationTimer;
|
||||
|
||||
// Preference
|
||||
static int32_t sTouchCaretMaxDistance;
|
||||
static int32_t sTouchCaretInflateSize;
|
||||
static int32_t sTouchCaretExpirationTime;
|
||||
|
||||
// The auto scroll timer's interval in miliseconds.
|
||||
|
@ -4245,10 +4245,9 @@ pref("snav.enabled", false);
|
||||
// Turn off touch caret by default.
|
||||
pref("touchcaret.enabled", false);
|
||||
|
||||
// Maximum distance to the center of touch caret (in app unit square) which
|
||||
// will be accepted to drag touch caret (0 means only in the bounding box of touch
|
||||
// caret is accepted)
|
||||
pref("touchcaret.distance.threshold", 1500);
|
||||
// This will inflate the size of the touch caret frame when checking if user
|
||||
// clicks on the caret or not. In app units.
|
||||
pref("touchcaret.inflatesize.threshold", 40);
|
||||
|
||||
// We'll start to increment time when user release the control of touch caret.
|
||||
// When time exceed this expiration time, we'll hide touch caret.
|
||||
|
Loading…
Reference in New Issue
Block a user