Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6063669dc45d7f10481798a4266f613e4b3cfb5e
      
https://github.com/WebKit/WebKit/commit/6063669dc45d7f10481798a4266f613e4b3cfb5e
  Author: Richard Robinson <richard_robins...@apple.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/editing/FrameSelection.cpp
    M Source/WebCore/editing/FrameSelection.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    A Source/WebCore/platform/CaretAnimator.cpp
    A Source/WebCore/platform/CaretAnimator.h
    A Source/WebCore/platform/SimpleCaretAnimator.cpp
    A Source/WebCore/platform/SimpleCaretAnimator.h

  Log Message:
  -----------
  Refactor caret animation out of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=248112
rdar://102535758

Reviewed by Simon Fraser and Darin Adler.

Simplifies `FrameSelection` by factoring out the animation logic into its own
class, to fit with how we handle other animations. Instead of `FrameSelection`
owning its own caret blinking timer, the caret is now subject to the repaint 
cycle
of `Page::updateRendering`.

This PR introduces a new `CaretAnimation` virtual class, with a 
`CaretAnimationSimple`
subclass to model how the current caret blinking works. This inheritence
hierarchy is modelled after how `ScrollAnimation` works.

The CaretAnimation now owns a timer, which when fired, schedules a rendering
update for the caret to update its appearance. When the rendering update 
happens,
`CaretAnimation::serviceAnimation` is triggered, which performs the actual
adjustment to the caret's presentation's properties. 
`FrameSelection::invalidateCaretRect`
is then triggered which causes the actual painting of the care to reflect its
new appearance.

Note that because the animation is now tied to `Page::updateRendering`,
`CaretAnimation::serviceAnimation` may be called at any given time, and so the
animation must track when the last time it was called was and account for this.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::serviceCaretAnimation):
* Source/WebCore/dom/Document.h:
* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::FrameSelection):
(WebCore::FrameSelection::willBeRemovedFromFrame):
(WebCore::FrameSelection::paintCaret):
(WebCore::FrameSelection::setCaretBlinkingSuspended):
(WebCore::FrameSelection::isCaretBlinkingSuspended const):
(WebCore::FrameSelection::caretAnimationDidUpdate):
(WebCore::FrameSelection::document):
(WebCore::FrameSelection::updateAppearance):
(WebCore::FrameSelection::setCaretVisibility):
(WebCore::FrameSelection::setCaretColor):
(WebCore::FrameSelection::caretBlinkTimerFired): Deleted.
(WebCore::FrameSelection::setCaretBlinks): Deleted.
* Source/WebCore/editing/FrameSelection.h:
(WebCore::FrameSelection::currentCaretAnimator):
(WebCore::FrameSelection::currentCaretAnimator const):
(WebCore::FrameSelection::setCaretBlinkingSuspended): Deleted.
(WebCore::FrameSelection::isCaretBlinkingSuspended const): Deleted.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering):
(WebCore::Page::finalizeRenderingUpdate):
(WebCore::operator<<):
* Source/WebCore/page/Page.h:
* Source/WebCore/platform/CaretAnimator.cpp: Added.
(WebCore::CaretAnimator::page const):
(WebCore::CaretAnimator::serviceCaretAnimation):
(WebCore::CaretAnimator::scheduleAnimation):
* Source/WebCore/platform/CaretAnimator.h: Added.
(WebCore::CaretAnimationClient::caretAnimationDidUpdate):
(WebCore::CaretAnimationClient::caretAnimationWillStart):
(WebCore::CaretAnimationClient::caretAnimationDidEnd):
(WebCore::CaretAnimator::CaretAnimator):
(WebCore::CaretAnimator::stop):
(WebCore::CaretAnimator::isActive const):
(WebCore::CaretAnimator::setCaretBlinkingSuspended):
(WebCore::CaretAnimator::isCaretBlinkingSuspended const):
(WebCore::CaretAnimator::didStart):
(WebCore::CaretAnimator::didEnd):
(WebCore::CaretAnimator::timeSinceStart const):
* Source/WebCore/platform/SimpleCaretAnimator.cpp: Added.
(WebCore::SimpleCaretAnimator::SimpleCaretAnimator):
(WebCore::SimpleCaretAnimator::serviceAnimation):
(WebCore::SimpleCaretAnimator::start):
(WebCore::SimpleCaretAnimator::debugDescription const):
* Source/WebCore/platform/SimpleCaretAnimator.h: Added.

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to