Bug 196427 - REGRESSION (r135972): WebCore::TextIterator::plainText() discards value from Document::displayStringModifiedByEncoding() when isDisplayString == true
Summary: REGRESSION (r135972): WebCore::TextIterator::plainText() discards value from ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-03-30 09:42 PDT by David Kilzer (:ddkilzer)
Modified: 2023-05-23 08:47 PDT (History)
6 users (show)

See Also:


Attachments
Patch (no tests; checking EWS) (1.15 KB, patch)
2019-03-30 09:44 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2019-03-30 09:42:25 PDT
WebCore::TextIterator::plainText() discards value from WebCore::Document::displayStringModifiedByEncoding() when argument isDisplayString == true.

<https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/editing/TextIterator.cpp#L2655>

String plainText(Position start, Position end, TextIteratorBehavior defaultBehavior, bool isDisplayString)
{
    […]
    String result = builder.toString();

    if (isDisplayString)
        document->displayStringModifiedByEncoding(result);

    return result;
}

Looks like this regressed with this commit:

Bug 103295: TextIterator unnecessarily converts 8 bit strings to 16 bits
<https://bugs.webkit.org/show_bug.cgi?id=103295>
<https://trac.webkit.org/changeset/135972>

The method call changed, but the new method returned an updated string instead of modifying it in place:

     if (isDisplayString && r->ownerDocument())
-        r->ownerDocument()->displayBufferModifiedByEncoding(result, bufferLength);
+        r->ownerDocument()->displayStringModifiedByEncoding(result);

And Document::displayBufferModifiedByEncoding() was removed by:

Bug 166569: Remove PassRefPtr use from the "dom" directory, related cleanup
<https://bugs.webkit.org/show_bug.cgi?id=166569>
<https://trac.webkit.org/changeset/210216>
Comment 1 David Kilzer (:ddkilzer) 2019-03-30 09:42:43 PDT
<rdar://problem/49450607>
Comment 2 David Kilzer (:ddkilzer) 2019-03-30 09:44:50 PDT
Created attachment 366364 [details]
Patch (no tests; checking EWS)
Comment 3 David Kilzer (:ddkilzer) 2019-03-30 09:49:00 PDT
(In reply to David Kilzer (:ddkilzer) from comment #2)
> Created attachment 366364 [details]
> Patch (no tests to check EWS)

Interesting...the style bot doesn't complain about a missing ChangeLog.
Comment 4 Ryosuke Niwa 2019-03-30 13:25:21 PDT
We need a test for this...
Comment 5 Darin Adler 2019-03-31 16:45:36 PDT
I agree.

And also, maybe soon we can remove the special yen sign and backslash handling if it’s not needed in practice.
Comment 6 Ryosuke Niwa 2019-03-31 18:34:06 PDT
(In reply to Darin Adler from comment #5)
> I agree.
> 
> And also, maybe soon we can remove the special yen sign and backslash
> handling if it’s not needed in practice.

Unfortunately, I don't think the situation is changing anytime soon about the yen mark :( There is simply too much legacy content out there...
Comment 7 Ahmad Saleem 2023-05-23 05:47:33 PDT
Backslash handling was removed by Blink in this commit:

https://src.chromium.org/viewvc/blink?view=revision&revision=159589
Comment 8 Alexey Proskuryakov 2023-05-23 08:47:34 PDT
It's certainly interesting that this bug hasn't been fixed, and we don't seem to be seeing any complaints. That said, I'd be very cautious about putting too much weight Blink decisions in this area.