Skip to content

Commit

Permalink
WebKit Cursor Pulsing is too slow while dictating
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264061
<radar://111583491>

Reviewed by Aditya Keerthi.

Refine the animation so it matches Messages.

* Source/WebCore/platform/DictationCaretAnimator.cpp:
(WebCore::keyframe):
Decouple the pulse speed from the animation rate.

(WebCore::DictationCaretAnimator::updateAnimationProperties):
The initial pulse is shorter in Messages, shorten it in WebKit to match.

(WebCore::DictationCaretAnimator::expandedCaretRect const):
Adjust how much the cursor expands during the initial pulse animation.

Canonical link: https://commits.webkit.org/270138@main
  • Loading branch information
mwyrzykowski committed Nov 2, 2023
1 parent 3b3a233 commit 3666f20
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/WebCore/platform/DictationCaretAnimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ static constexpr size_t dictationCaretAnimatorUpdateRate = 60;

static constexpr KeyFrame keyframe(size_t i)
{
i %= dictationCaretAnimatorUpdateRate;
constexpr float inverseFrameRate = 1.f / static_cast<float>(dictationCaretAnimatorUpdateRate);
constexpr auto updateRate = 40;
i %= updateRate;
constexpr float inverseFrameRate = 1.f / static_cast<float>(updateRate);
return KeyFrame { Seconds(i * inverseFrameRate), fabs(sinf(static_cast<float>(M_PI * i * inverseFrameRate))) };
}

Expand Down Expand Up @@ -158,7 +159,7 @@ void DictationCaretAnimator::updateAnimationProperties()

m_currentKeyframeIndex++;
updateGlowTail(elapsedTime);
constexpr auto scaleAnimationSpeed = 2.f;
constexpr auto scaleAnimationSpeed = 4.f;
m_initialScale = std::max(0.f, m_initialScale - scaleAnimationSpeed * static_cast<float>(elapsedTime.value()));

m_blinkTimer.startOneShot(keyframeTimeDelta());
Expand Down Expand Up @@ -280,7 +281,7 @@ FloatRoundedRect DictationCaretAnimator::expandedCaretRect(const FloatRect& rect
auto extraScaleFactor = 1.f;
auto pulseExpansion = 1.f;
if (m_initialScale > 0.f)
extraScaleFactor = 1.f + sinf(2.f * m_initialScale);
extraScaleFactor = 1.f + 1.4f * sinf(2.f * m_initialScale);
else
pulseExpansion = 0.75f * m_presentationProperties.opacity * extraScaleFactor;

Expand Down

0 comments on commit 3666f20

Please sign in to comment.