Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: a03e91423aaffbc1ec753eccb1c7f973e6798177 https://github.com/WebKit/WebKit/commit/a03e91423aaffbc1ec753eccb1c7f973e6798177 Author: Richard Robinson <richard_robins...@apple.com> Date: 2025-09-17 (Wed, 17 Sep 2025)
Changed paths: M Source/WTF/wtf/unicode/CharacterNames.h M Source/WebCore/WebCore.xcodeproj/project.pbxproj M Source/WebCore/editing/Editor.cpp M Source/WebCore/editing/Editor.h M Source/WebCore/editing/InsertTextCommand.cpp M Source/WebCore/editing/InsertTextCommand.h A Source/WebCore/editing/TextListParser.cpp A Source/WebCore/editing/TextListParser.h M Source/WebCore/style/values/lists/StyleListStyleType.cpp M Source/WebCore/style/values/lists/StyleListStyleType.h M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h M Source/WebKit/WebProcess/WebPage/WebPage.h M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj M Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift M Tools/TestWebKitAPI/Tests/WebKit Swift/TestWebKitAPIBundle-Bridging-Header.h M Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartLists.mm A Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartListsSupport.h A Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartListsSupport.swift A Tools/TestWebKitAPI/WebPage+Extras.swift Log Message: ----------- [Smart Lists] Add support for parsing Smart List marker formats https://bugs.webkit.org/show_bug.cgi?id=298831 rdar://160544109 Reviewed by Abrar Rahman Protyasha. Add initial implementation support for Smart Lists, in particular the parser. From a high-level perspective, this adds the following flow: 1. When an InsertTextCommand occurs, the command is intercepted by the Smart List logic if the text is a space character (along with other conditions described in inline comments). 2. When this happens, the space character is not inputted. Instead, a TextList value is parsed from the beginning of the current line up to the current position, which describes the list type, start value, and style type. 3. The corresponding list element is then created and inserted, and the selection becomes inside of its list element child. 4. The appropriate style and attributes are set on the list element. This is a simple implementation mainly to exercise the String -> TextList parser (described below and in comments) and facilitate testing. * Source/WTF/wtf/unicode/CharacterNames.h: Add em-dash, used for dashed list markers. * Source/WebCore/editing/Editor.cpp: (WebCore::Editor::isSmartListsEnabled): (WebCore::Editor::toggleSmartLists): Add additionally guards to exit early if smart lists are unavailable by the system. * Source/WebCore/editing/InsertTextCommand.cpp: (WebCore::setListStyleTypeProperty): Apply the ListStyleType value as an inline property on the specified element by converting the ListStyleType to a Ref<CSSValue>. (WebCore::InsertTextCommand::applySmartListsIfNeeded): If the criteria is met, discard the current command and subtitute an InsertListCommand in its place, using the parsed TextList. Then, apply the relevant attributes and styles, and delete the selection to remove the marker token characters. (WebCore::InsertTextCommand::doApply): Skip the rest of the application of this command if a Smart List was applied. * Source/WebCore/editing/InsertTextCommand.h: Add deeclaration of private helper method. * Source/WebCore/editing/TextListParser.cpp: Added. (WebCore::consumeNumber): (WebCore::tryConsumeUnorderedDiscTextList): (WebCore::tryConsumeUnorderedDashTextList): (WebCore::tryConsumeOrderedDecimalTextList): (WebCore::consumeTextList): (WebCore::parseTextList): * Source/WebCore/editing/TextListParser.h: Added. Implement a rudimentary parser that converts a String to a TextList. The algorithm is described inline. * Source/WebCore/style/values/lists/StyleListStyleType.cpp: (WebCore::Style::ListStyleType::isDecimal const): Add an accessor function to determine if the counter style type is Decimal, like some other of the existing functions. (WebCore::Style::CSSValueCreation<ListStyleType>::operator): It is currently possible to convert a CSSValue to a ListStyleType, however the opposite was not possible. This adds support for that using the standard CSSValueCreation pattern for better composition, by creating a CSSValue depending on the value of the list style type. * Source/WebCore/style/values/lists/StyleListStyleType.h: (WebCore::Style::ListStyleType::ListStyleType): Add a convenience constructor for the decimal style, like some other of the constructors. * Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartLists.mm: (webViewWithMarkup): (insertText): (InputInstruction::InputInstruction): (keyDataForKeyInstruction): (runTest): (TEST(SmartLists, InsertingSpaceAndTextAfterBulletPointGeneratesListWithText)): (TEST(SmartLists, InsertingSpaceAndTextAfterHyphenGeneratesDashedList)): (TEST(SmartLists, InsertingSpaceAfterBulletPointGeneratesEmptyList)): (TEST(SmartLists, InsertingSpaceAfterBulletPointInMiddleOfSentenceDoesNotGenerateList)): (TEST(SmartLists, InsertingSpaceAfterPeriodAtStartOfSentenceDoesNotGenerateList)): (TEST(SmartLists, InsertingSpaceAfterNumberGeneratesOrderedList)): (TEST(SmartLists, InsertingSpaceAfterMultipleDigitNumberGeneratesOrderedList)): (TEST(SmartLists, InsertingSpaceAfterInvalidNumberDoesNotGenerateOrderedList)): (TEST(SmartLists, InsertingListMergesWithPreviousListIfPossible)): Tests. Lots of tests! Canonical link: https://commits.webkit.org/300101@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes