Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f5c2130755ab39b4b005c196eabaa05406f586ea
      
https://github.com/WebKit/WebKit/commit/f5c2130755ab39b4b005c196eabaa05406f586ea
  Author: Ryosuke Niwa <rn...@webkit.org>
  Date:   2024-04-05 (Fri, 05 Apr 2024)

  Changed paths:
    M Source/WebCore/editing/TextIterator.cpp
    M Source/WebCore/editing/TextIterator.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm

  Log Message:
  -----------
  Some text fails to translate to Simplified Chinese on Apple TV+ page
https://bugs.webkit.org/show_bug.cgi?id=272214
<rdar://72939899>

Reviewed by Sihui Liu and Wenson Hsieh.

The bug is caused by ParagraphContentIterator::advanceIteratorNodeAndUpdateText 
skipping a whitespace
generated for a tab character that appears at where a line wraps. When the 
layout of the page changes
slightly so that this tab character appears in the middle of a line, we don't 
skip the same whitespace.
As a result, TextManipulationController erroneously conclude that the content 
has changed and reject
the translation.

Fixed the bug by tweaking TextIterator to generate a non-collapsed range in 
this specific case so that
ParagraphContentIterator::advanceIteratorNodeAndUpdateText generates a 
whitespace as expected.
We already had a code path for a space so reuse the same code path for other 
collapsible whitespaces.

This PR also adds TextIterator::showTreeForThis and showTree(TextIterator&) / 
showTree(TextIterator*)
to make debugging TextIterator easier.

Tests: 
TextManipulation.CompleteTextManipulationDoesNotSkipTabCharacterAtLineWrap

* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextRun):
(WebCore::TextIterator::showTreeForThis const): Added.
(showTree): Added.
* Source/WebCore/editing/TextIterator.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
(TextManipulation.CompleteTextManipulationDoesNotSkipTabCharacterAtLineWrap):

Canonical link: https://commits.webkit.org/277150@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

Reply via email to