Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[Webpage Translation] Avoid removing elements with no children during…
… text manipulation https://bugs.webkit.org/show_bug.cgi?id=240287 rdar://91882797 Reviewed by Tim Horton. After invoking webpage translation on a particular website, the entire page becomes blank and unusable when scrolling. This happens because of an uncaught JavaScript exception that's thrown when this page's script attempts to remove an element from its parent using `p.removeChild(c)`, where the node `p` is not a parent of the given node `c`; this, in turn, happens because `TextManipulationController` has already unparented `c` from `p` while performing text replacement during translation. In this particular case, the former child node `c` is an empty `div` element with no text or children. As such, it's unnecessary to flag this element for removal in the first place, since doing so isn't necessary to fill in translated text. We can avoid this issue by simply skipping over such nodes (i.e. containers that contain no text, no child elements, and also are not replaced elements) to avoid this and similar compatibility issues that arise when the DOM is mutated underneath the page, during translation. Test: TextManipulation.CompleteTextManipulationSkipsEmptyContainers * editing/TextManipulationController.cpp: (WebCore::TextManipulationController::replace): [Webpage Translation] Avoid removing elements with no children during text manipulation https://bugs.webkit.org/show_bug.cgi?id=240287 rdar://91882797 Reviewed by Tim Horton. Add a new API test to exercise the change. * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/250467@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294063 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters