Bug 227234 - Web Inspector: Sources: Scope Chain sidebar panel is stripping repeating whitespace from strings
Summary: Web Inspector: Sources: Scope Chain sidebar panel is stripping repeating whit...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Patrick Angle
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-21 14:00 PDT by Patrick Angle
Modified: 2021-06-25 11:50 PDT (History)
5 users (show)

See Also:


Attachments
Screenshot of Issue (765.55 KB, image/png)
2021-06-21 14:00 PDT, Patrick Angle
no flags Details
Patch v1.0 (1.84 KB, patch)
2021-06-22 15:25 PDT, Patrick Angle
no flags Details | Formatted Diff | Diff
Screenshot of Issue (529.31 KB, image/png)
2021-06-22 15:25 PDT, Patrick Angle
no flags Details
Screenshot of Patch v1.0 (529.34 KB, image/png)
2021-06-22 15:26 PDT, Patrick Angle
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Angle 2021-06-21 14:00:36 PDT
Created attachment 431905 [details]
Screenshot of Issue

See attached screenshot.

Notice that on hover the `text` local variable has two spaces between `1px` and `red`, but in the Scope Chain sidebar panel, it is shown with a single space. In this case if I check the string's length in my source, it is 8 characters, which is what I would expect, but the sidebar panel is only showing seven characters.
Comment 1 Patrick Angle 2021-06-22 15:25:31 PDT
Created attachment 432001 [details]
Patch v1.0
Comment 2 Patrick Angle 2021-06-22 15:25:51 PDT
Created attachment 432002 [details]
Screenshot of Issue
Comment 3 Patrick Angle 2021-06-22 15:26:05 PDT
Created attachment 432003 [details]
Screenshot of Patch v1.0
Comment 4 Radar WebKit Bug Importer 2021-06-22 16:01:37 PDT
<rdar://problem/79637908>
Comment 5 Devin Rousso 2021-06-23 20:28:18 PDT
Comment on attachment 432001 [details]
Patch v1.0

View in context: https://bugs.webkit.org/attachment.cgi?id=432001&action=review

r=me

> Source/WebInspectorUI/ChangeLog:11
> +        which makes sure that the text does not wrap unless it contains a newline, and these previews have newlines
> +        replaced with a Unicode symbol to visually represent a newline without breaking to a new line.

Perhaps worth adding an assertion inside `WI.FormattedValue.createLinkifiedElementString` that there are no `'\n'` then?
Comment 6 Patrick Angle 2021-06-25 09:52:34 PDT
Comment on attachment 432001 [details]
Patch v1.0

View in context: https://bugs.webkit.org/attachment.cgi?id=432001&action=review

>> Source/WebInspectorUI/ChangeLog:11
>> +        replaced with a Unicode symbol to visually represent a newline without breaking to a new line.
> 
> Perhaps worth adding an assertion inside `WI.FormattedValue.createLinkifiedElementString` that there are no `'\n'` then?

I don't think that would be the right place to assert this. `WI.FormattedValue.createLinkifiedElementString` is only called in `ConsoleMessageView.prototype._formatParameterAsString`, which wouldn't be affected by this CSS change anyways, as object trees handle creating the tree entries using `WI.FormattedValue.createElementForTypesAndValue` (via one of the functions in FormattedValue.js:269-324). The class name is added dynamically here, which makes it not entirely clear that `.formatted-string` is used anywhere other than where you found it in `WI.FormattedValue.createLinkifiedElementString`.

I don't think adding an assertion to `WI.FormattedValue.createElementForTypesAndValue` helps us since if the type is `string` newlines are explicitly removed here instead of relying on the input to be pre-formatted.
Comment 7 EWS 2021-06-25 11:50:24 PDT
Committed r279294 (239170@main): <https://commits.webkit.org/239170@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 432001 [details].