Bug 227234

Summary: Web Inspector: Sources: Scope Chain sidebar panel is stripping repeating whitespace from strings
Product: WebKit Reporter: Patrick Angle <pangle>
Component: Web InspectorAssignee: Patrick Angle <pangle>
Status: RESOLVED FIXED    
Severity: Normal CC: drousso, ews-watchlist, inspector-bugzilla-changes, pangle, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Screenshot of Issue
none
Patch v1.0
none
Screenshot of Issue
none
Screenshot of Patch v1.0 none

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].