<?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>279033</bug_id>
          
          <creation_ts>2024-09-02 13:13:45 -0700</creation_ts>
          <short_desc>Refactor `computePositionedLogicalWidthUsing` to use shrink-to-fit in one step</short_desc>
          <delta_ts>2025-12-14 21:17:02 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>282213</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Ahmad Saleem">ahmad.saleem792</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>commit-queue</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2057090</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-09-02 13:13:45 -0700</bug_when>
    <thetext>Hi Team,

This is just refactoring in `computePositionedLogicalWidthUsing` by reduce reuse of variables:

auto shrinkToFitLogicalWidth = [this](LayoutUnit availableLogicalWidth, LayoutUnit bordersPlusPadding) -&gt; LayoutUnit {
            LayoutUnit preferredLogicalWidth = maxPreferredLogicalWidth() - bordersPlusPadding;
            LayoutUnit preferredMinLogicalWidth = minPreferredLogicalWidth() - bordersPlusPadding;
            return std::min(std::max(preferredMinLogicalWidth, availableLogicalWidth), preferredLogicalWidth);
        };

and

then changing from:

computedValues.m_extent = std::min(std::max(preferredMinWidth, availableWidth), preferredWidth);

to:

computedValues.m_extent = shrinkToFitLogicalWidth(availableSpace - logicalLeftValue, bordersPlusPadding);

___

It is here: https://github.com/WebKit/WebKit/blob/12aaa71a5803d48572e89111e28771be7969119b/Source/WebCore/rendering/RenderBox.cpp#L4284

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2057091</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-09-02 13:15:02 -0700</bug_when>
    <thetext>We can even use std:clamp here - return std::clamp(availableLogicalWidth, preferredMinLogicalWidth, preferredLogicalWidth);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2057098</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-09-02 14:08:39 -0700</bug_when>
    <thetext>&lt;rdar://problem/135156089&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2057099</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-09-02 14:11:42 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/33042</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2057132</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-09-02 17:57:09 -0700</bug_when>
    <thetext>Committed 283073@main (6b0b9db9aa93): &lt;https://commits.webkit.org/283073@main&gt;

Reviewed commits have been landed. Closing PR #33042 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2071098</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2024-10-28 16:52:30 -0700</bug_when>
    <thetext>Re-opened since this is blocked by bug 282213</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2165815</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-12-14 21:17:02 -0800</bug_when>
    <thetext>can&apos;t seems to find this code, so it might be gone, so it is not applicable anymore.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>