[webkit-changes] [WebKit/WebKit] de89aa: Optimize RenderBlock::paintCarets()

Simon Fraser noreply at github.com
Wed Jul 10 08:33:47 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: de89aaf09e387343d31cc8ae0c5a3a599f368894
      https://github.com/WebKit/WebKit/commit/de89aaf09e387343d31cc8ae0c5a3a599f368894
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2024-07-10 (Wed, 10 Jul 2024)

  Changed paths:
    M Source/WebCore/editing/FrameSelection.cpp
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/TextBoxPainter.cpp

  Log Message:
  -----------
  Optimize RenderBlock::paintCarets()
https://bugs.webkit.org/show_bug.cgi?id=276407
rdar://131436270

Reviewed by Alan Baradlay.

`paintCarets()` calls `paintCaret()` for the two caret types, and in each branch we access
either `frame().selection()` twice, or `page().dragCaretController()` twice, and compute
`isContentEditable` even when we won't use it.

Refactor `RenderBlock::paintCaret()` to just switch once for each caret type, using a lambda
for the tiny bit of common code. Add early returns for the common case of no selection node,
thus no renderer.

`DragCaretController::caretRenderer()` can early return to avoid copying a `Position` by value.

Move some variables in `TextBoxPainter<TextBoxPath>::paintCompositionForeground()` to their point of first use.

* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::DragCaretController::caretRenderer const):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):
* Source/WebCore/rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter<TextBoxPath>::paintCompositionForeground):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list