Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REGRESSION(257219@main): [GTK] Cursor blinks oddly in text fields, even if blinking disabled #12737

Merged
merged 1 commit into from Apr 14, 2023

Conversation

aperezdc
Copy link
Contributor

@aperezdc aperezdc commented Apr 14, 2023

6a0a835

REGRESSION(257219@main): [GTK] Cursor blinks oddly in text fields, even if blinking disabled
https://bugs.webkit.org/show_bug.cgi?id=252687

Reviewed by Carlos Garcia Campos.

Before 257219@main if RenderTheme::caretBlinkInterval() returned zero
then the timer controlling the blink animation was never started. When
introducing CaretAnimator + SimpleCaretAnimator the check was not
carried over, resulting in the animator trying to paint the caret
on-and-off as fast as possible when blinking should have been disabled.

The fix reintroduces the check, reusing setBlinkingSuspended() to enable
(or disable) blinking depending on RenderTheme::caretBlinkInterval(),
which in turn is changed to return std::optional<Seconds>, with
std::nullopt signalling that blinking is disables. The improved typing
ensures that the code explicitly handles the case of blinking being
disabled.

While at it, remove the RenderThemeGtk.{h,cpp} files, because they only
contained an implementation of caretBlinkInterval() that was exactly the
same code guarded with PLATFORM(GTK) in RenderThemeAdwaita.

* Source/WebCore/SourcesGTK.txt: Remove RenderThemeGtk.cpp from the list.
* Source/WebCore/platform/CaretAnimator.h:
(WebCore::CaretAnimator::didStart): Adapt to use std::optional<Seconds>.
* Source/WebCore/platform/SimpleCaretAnimator.cpp:
(WebCore::SimpleCaretAnimator::updateAnimationProperties): Arrange to
enable or disable caret blinking, adapting to use std::optional<Seconds>.
* Source/WebCore/rendering/RenderTheme.h:
(WebCore::RenderTheme::caretBlinkInterval const): Change the return type
to std::optional<Seconds>.
* Source/WebCore/rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderTheme::singleton): Remove PLATFORM(GTK) guard.
(WebCore::RenderThemeAdwaita::caretBlinkInterval const): Adapt to use
std::optional<Seconds>.
* Source/WebCore/rendering/RenderThemeAdwaita.h: Ditto.
* Source/WebCore/rendering/RenderThemeGtk.cpp: Removed.
* Source/WebCore/rendering/RenderThemeGtk.h: Removed.

Canonical link: https://commits.webkit.org/262954@main

55fc48d

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac βœ… πŸ›  gtk
  πŸ§ͺ ios-wk2-wpt   πŸ§ͺ mac-wk1   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk2   πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim   πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@aperezdc aperezdc self-assigned this Apr 14, 2023
@aperezdc aperezdc added the WebKitGTK Bugs related to the Gtk API layer. label Apr 14, 2023
@aperezdc aperezdc requested review from smfr, rr-codes, darinadler and a team April 14, 2023 09:37
return shouldBlink ? 500_us * time : 0_s;
if (shouldBlink)
return { 500_us * time };
return { };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be std::nullopt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty initializer list is equivalent to std::nullopt, I have seen both styles in WebKit. I can change it before landing if you prefer.

return;
}

// If blinking is disabled, set isBlinkingSuspended() would have made the
// previuos check return early and at this point there must be an interval.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// previuos check return early and at this point there must be an interval.
// previous check return early and at this point there must be an interval.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will fix the typo before landing πŸ‘ŒπŸΌ

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 14, 2023
@aperezdc aperezdc removed the merging-blocked Applied to prevent a change from being merged label Apr 14, 2023
@aperezdc aperezdc added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Apr 14, 2023
…en if blinking disabled

https://bugs.webkit.org/show_bug.cgi?id=252687

Reviewed by Carlos Garcia Campos.

Before 257219@main if RenderTheme::caretBlinkInterval() returned zero
then the timer controlling the blink animation was never started. When
introducing CaretAnimator + SimpleCaretAnimator the check was not
carried over, resulting in the animator trying to paint the caret
on-and-off as fast as possible when blinking should have been disabled.

The fix reintroduces the check, reusing setBlinkingSuspended() to enable
(or disable) blinking depending on RenderTheme::caretBlinkInterval(),
which in turn is changed to return std::optional<Seconds>, with
std::nullopt signalling that blinking is disables. The improved typing
ensures that the code explicitly handles the case of blinking being
disabled.

While at it, remove the RenderThemeGtk.{h,cpp} files, because they only
contained an implementation of caretBlinkInterval() that was exactly the
same code guarded with PLATFORM(GTK) in RenderThemeAdwaita.

* Source/WebCore/SourcesGTK.txt: Remove RenderThemeGtk.cpp from the list.
* Source/WebCore/platform/CaretAnimator.h:
(WebCore::CaretAnimator::didStart): Adapt to use std::optional<Seconds>.
* Source/WebCore/platform/SimpleCaretAnimator.cpp:
(WebCore::SimpleCaretAnimator::updateAnimationProperties): Arrange to
enable or disable caret blinking, adapting to use std::optional<Seconds>.
* Source/WebCore/rendering/RenderTheme.h:
(WebCore::RenderTheme::caretBlinkInterval const): Change the return type
to std::optional<Seconds>.
* Source/WebCore/rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderTheme::singleton): Remove PLATFORM(GTK) guard.
(WebCore::RenderThemeAdwaita::caretBlinkInterval const): Adapt to use
std::optional<Seconds>.
* Source/WebCore/rendering/RenderThemeAdwaita.h: Ditto.
* Source/WebCore/rendering/RenderThemeGtk.cpp: Removed.
* Source/WebCore/rendering/RenderThemeGtk.h: Removed.

Canonical link: https://commits.webkit.org/262954@main
@webkit-commit-queue
Copy link
Collaborator

Committed 262954@main (6a0a835): https://commits.webkit.org/262954@main

Reviewed commits have been landed. Closing PR #12737 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 6a0a835 into WebKit:main Apr 14, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Apr 14, 2023
@aperezdc aperezdc deleted the eng/gtk-caret-animation branch April 14, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKitGTK Bugs related to the Gtk API layer.
Projects
None yet
6 participants