Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: da777142e59de9309b1c4b670730663e1295180a https://github.com/WebKit/WebKit/commit/da777142e59de9309b1c4b670730663e1295180a Author: Ryosuke Niwa <rn...@webkit.org> Date: 2023-03-23 (Thu, 23 Mar 2023)
Changed paths: M Source/WebCore/editing/TextManipulationController.cpp M Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm Log Message: ----------- TextManipulationController can remove whitespace between a list of white-space: nowrap items https://bugs.webkit.org/show_bug.cgi?id=254319 <rdar://103521673> Reviewed by Sihui Liu. There are some websites which use an anchor element with `white-space: nowrap` as a list item and with a fixed width constraint such that each anchor element is displayed on its own line. Prior to this patch, such a content is extracted by TextManipulationController as a one long paragraph because there is no br or block element to explicitly wrap the text. This is problematic since we can strip away those whitespaces between the anchor elements when we're placing the translated results, making the whole content to be in a single contiguous text with `white-space: nowrap` (i.e. all anchor elements appear in a single non-wrapping line). Because whitespaces between these anchor elements are indistinguishable from those that appear within each anchor element, preserving those whitespaces between anchor elements is not enough. Instead, we treat each anchor element with `white-space: nowrap` as its own paragraph so that whitespaces between them are left undisturbed. * Source/WebCore/editing/TextManipulationController.cpp: (WebCore::isEnclosingItemBoundaryElement): Treat an anchor element with `white-space: nowrap` as a boundary element. * Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm: (TextManipulation.CompleteTextManipulationPreservesWhitespacesBetweenItems): Canonical link: https://commits.webkit.org/262036@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes