Skip to content

Commit f01451c

Browse files
committed
Refactor caret selection painting logic
https://bugs.webkit.org/show_bug.cgi?id=248852 rdar://102450017 Reviewed by Wenson Hsieh. * Source/WebCore/editing/FrameSelection.cpp: (WebCore::CaretBase::fillCaretRect const): (WebCore::CaretBase::paintCaret const): * Source/WebCore/editing/FrameSelection.h: Canonical link: https://commits.webkit.org/257523@main
1 parent aa50ef1 commit f01451c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Source/WebCore/editing/FrameSelection.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,15 @@ bool CaretBase::updateCaretRect(Document& document, const VisiblePosition& caret
17071707
return !m_caretLocalRect.isEmpty();
17081708
}
17091709

1710+
#if USE(APPLE_INTERNAL_SDK)
1711+
#import <WebKitAdditions/FrameSelectionAdditions.cpp>
1712+
#else
1713+
void CaretBase::fillCaretRect(const Node&, GraphicsContext& context, const FloatRect& caret, const Color& color) const
1714+
{
1715+
context.fillRect(caret, color);
1716+
}
1717+
#endif
1718+
17101719
RenderBlock* FrameSelection::caretRendererWithoutUpdatingLayout() const
17111720
{
17121721
return rendererForCaretPainting(m_selection.start().deprecatedNode());
@@ -1886,7 +1895,7 @@ void CaretBase::paintCaret(const Node& node, GraphicsContext& context, const Lay
18861895
caretColor = CaretBase::computeCaretColor(element->renderer()->style(), &node);
18871896

18881897
auto pixelSnappedCaretRect = snapRectToDevicePixels(caret, node.document().deviceScaleFactor());
1889-
context.fillRect(pixelSnappedCaretRect, caretColor);
1898+
fillCaretRect(node, context, pixelSnappedCaretRect, caretColor);
18901899
#else
18911900
UNUSED_PARAM(node);
18921901
UNUSED_PARAM(context);

Source/WebCore/editing/FrameSelection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class CaretBase {
6868
void clearCaretRect();
6969
bool updateCaretRect(Document&, const VisiblePosition& caretPosition);
7070
bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const;
71+
void fillCaretRect(const Node&, GraphicsContext&, const FloatRect&, const Color&) const;
7172
void paintCaret(const Node&, GraphicsContext&, const LayoutPoint&, const LayoutRect& clipRect) const;
7273

7374
const LayoutRect& localCaretRectWithoutUpdate() const { return m_caretLocalRect; }

0 commit comments

Comments
 (0)