Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 55c2f6469ac3478b019f93af970bd4ebc1117589
https://github.com/WebKit/WebKit/commit/55c2f6469ac3478b019f93af970bd4ebc1117589
Author: Tim Horton <[email protected]>
Date: 2026-03-03 (Tue, 03 Mar 2026)
Changed paths:
M Source/WebCore/editing/Editor.cpp
M Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm
Log Message:
-----------
Font Picker: Style selection becomes unusable after changing fonts (when
editing multiple lines of text)
https://bugs.webkit.org/show_bug.cgi?id=309056
rdar://110651645
Reviewed by Wenson Hsieh.
Various editing operations result in a document structure in which font changes
are applied
at the deepest point in the tree, leaving intermediate unstyled elements. For
example, using
the font panel to set a font on this structure:
First
<div>Second</div>
results in this:
<font face=...>First</font>
<div><font face=...>Second</font></div>
Making a selection that spans the two words intersects the second line's <div>,
which is unstyled.
The existing code in Editor::fontForSelection takes *every* element's font into
account when deciding
whether to indicate multiple selection in the font panel. This results in a
failure to round-trip the
font selection (because it comes back as "multiple"), and an unusable panel.
Fix this by only taking the font of elements with immediate text node children
into account.
Test: Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::fontForSelection):
* Tools/TestWebKitAPI/Tests/mac/FontManagerTests.mm:
(TestWebKitAPI::TEST(FontManagerTests,
SelectionSpanningEmptyElementDoesNotReportMultipleFonts)):
(TestWebKitAPI::TEST(FontManagerTests,
SelectionSpanningTwoFontsDoesReportMultipleFonts)):
(TestWebKitAPI::TEST(FontManagerTests,
SelectionSpanningBRDoesReportMultipleFonts)):
Canonical link: https://commits.webkit.org/308562@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications