<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>257414</bug_id>
          
          <creation_ts>2023-05-27 01:34:53 -0700</creation_ts>
          <short_desc>Remove stripLeadingAndTrailingHTMLSpaces()</short_desc>
          <delta_ts>2023-05-30 22:57:07 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>257438</dependson>
          <blocked>255467</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne van Kesteren">annevk</reporter>
          <assigned_to name="Anne van Kesteren">annevk</assigned_to>
          <cc>achristensen</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1958375</commentid>
    <comment_count>0</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-05-27 01:34:53 -0700</bug_when>
    <thetext>Now that we have trim() this abstraction isn&apos;t really needed anymore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958376</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-05-27 01:35:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/109923008&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958379</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-05-27 02:11:39 -0700</bug_when>
    <thetext>Unfortunately this is not a straightforward fix due to the existence of NSString. Is there a way to convert those to String or StringView so trim() can then be used?

Search for HTMLSpace in https://github.com/WebKit/WebKit/blob/main/Source/WebCore/editing/cocoa/HTMLConverter.mm to see some instances of the problem.


The other thing I noticed is that we&apos;re invoking this a lot before passing the string to the URL parser (often via completeURL()). However, the URL parser will trim all C0 control or space code points as per https://url.spec.whatwg.org/#concept-basic-url-parser (and as far as I can tell our implementation matches that). This means that we&apos;re doing the work twice. Perhaps someone can confirm I&apos;m correct here and then I could create an initial PR that just removes these callers as they are redundant with the URL parser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958413</commentid>
    <comment_count>3</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2023-05-27 08:37:11 -0700</bug_when>
    <thetext>I&apos;m pretty sure the calls to stripLeadingAndTrailingHTMLSpaces in HTMLConverter.mm are implicitly calling the WTF::String constructor from an NSString *.

I&apos;m pretty sure trimming space before passing to the URL parser is redundant work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958682</commentid>
    <comment_count>4</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-05-30 00:46:37 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/14467</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958956</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-05-30 22:57:05 -0700</bug_when>
    <thetext>Committed 264713@main (ea527fa9c22d): &lt;https://commits.webkit.org/264713@main&gt;

Reviewed commits have been landed. Closing PR #14467 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>