<?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>249771</bug_id>
          
          <creation_ts>2022-12-22 06:32:35 -0800</creation_ts>
          <short_desc>Fix Decimal.floor() + Decimal.ceiling() for many non-integral values</short_desc>
          <delta_ts>2024-06-19 22:09:46 -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>Forms</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=106456</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1921360</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-12-22 06:32:35 -0800</bug_when>
    <thetext>Hi Team,

While going through Blink&apos;s commit, I came across another failing test case:

Test Case - &lt;input type=&quot;number&quot; min=&quot;1.3&quot; value=&quot;1.51&quot; step=&quot;0.2&quot;/&gt;

^ Try to do step-up in Safari, it will first go from 1.51 to 1.5 and then 1.7 while Chrome Canary 111 and Firefox Nightly 110 works perfectly fine.

Blink Commit - https://src.chromium.org/viewvc/blink?view=revision&amp;revision=162197

WebKit GitHub Source - https://github.com/WebKit/WebKit/blob/dced9d40e0ba387b976739efb45a6513be9bcd4a/Source/WebCore/platform/Decimal.cpp#L622

Just wanted to raise it so we can fix it later.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921646</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-12-23 02:02:39 -0800</bug_when>
    <thetext>Manage to have testcase - will try to do PR later today - https://jsfiddle.net/mwn0jy35/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922171</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-12-29 06:33:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/103759613&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926112</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-17 15:32:13 -0800</bug_when>
    <thetext>I am closing this PR for time being because I noted that we still have other pre-requisite bugs to fix in StepUp and StepDown and closing my PR for time being with following comment:

&apos;&apos;

NOTE to myself - I am going to close this PR since there are still bugs in StepUp and StepDown, which we should fix since this might be causing this to fail. So I will look into this later, once I fix other bugs.

&apos;&apos;


PR - https://github.com/WebKit/WebKit/pull/8045</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2026519</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-06 09:49:21 -0700</bug_when>
    <thetext>Just copying that following compiles when added to &apos;Decimal.cpp&apos; (for TestWebKit API):

// Simulate core/html/forms/StepRange
class DecimalStepRange {

public:
    Decimal maximum;
    Decimal minimum;
    Decimal step;

    DecimalStepRange(const Decimal&amp; minimum, const Decimal&amp; maximum, const Decimal&amp; step)
        : maximum(maximum)
        , minimum(minimum)
        , step(step)
    {
    }

    Decimal clampValue(Decimal value) const
    {
        const Decimal result = minimum + ((value - minimum) / step).round() * step;
        ASSERT(result.isFinite());
        return result &gt; maximum ? result - step : result;
    }
};

class Decimcal : public testing::Test {
protected:
    using Sign = Decimal::Sign;
    static constexpr Sign positive = Decimal::Positive;
    static constexpr Sign negative = Decimal::Negative;

    Decimal encode(uint64_t coefficient, int exponent, Sign sign)
    {
        return Decimal(sign, exponent, coefficient);
    }

    Decimal fromString(const String&amp; string)
    {
        return Decimal::fromString(string);
    }

    Decimal stepDown(const String&amp; minimum, const String&amp; maximum, const String&amp; step, const String&amp; valueString, int numberOfStepTimes)
    {
        DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step));
        Decimal value = fromString(valueString);

        for (int i = 0; i &lt; numberOfStepTimes; ++i) {
            value -= stepRange.step;
            value = stepRange.clampValue(value);
        }
        return value;
    }

    Decimal stepUp(const String&amp; minimum, const String&amp; maximum, const String&amp; step, const String&amp; valueString, int numberOfStepTimes)
    {
        DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step));
        Decimal value = fromString(valueString);

        for (int i = 0; i &lt; numberOfStepTimes; ++i) {
            value += stepRange.step;
            value = stepRange.clampValue(value);
        }
        return value;
    }
};</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2042166</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-06-19 22:09:44 -0700</bug_when>
    <thetext>Committed 280189@main (c79f2cd50054): &lt;https://commits.webkit.org/280189@main&gt;

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

    </bug>

</bugzilla>