<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fix sizes crash and add invalid value tests."
   href="https://bugs.webkit.org/show_bug.cgi?id=144739">bug 144739</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #252586 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fix sizes crash and add invalid value tests."
   href="https://bugs.webkit.org/show_bug.cgi?id=144739#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fix sizes crash and add invalid value tests."
   href="https://bugs.webkit.org/show_bug.cgi?id=144739">bug 144739</a>
              from <span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=252586&amp;action=diff" name="attach_252586" title="Patch">attachment 252586</a> <a href="attachment.cgi?id=252586&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=252586&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=252586&amp;action=review</a>

I’m OK with this patch, but I think it’s unnecessarily awkward.

<span class="quote">&gt; Source/WebCore/css/SourceSizeList.cpp:59
&gt; -static unsigned computeLength(CSSValue* value, RenderStyle&amp; style, RenderView* view)
&gt; +static bool computeLength(CSSValue* value, RenderStyle&amp; style, RenderView* view, unsigned&amp; sourceSizeLength)</span >

Seems a little inelegant to do the checking in the same function that computes lengths, given that we do this work in a loop and we only need the check once. I suggest putting the checking into a separate function. Maybe we should even have parseSizesAttribute use two separate loops for CSSPrimitiveValue and CSSCalcValue rather than constantly branching inside the loop.

<span class="quote">&gt; Source/WebCore/css/SourceSizeList.cpp:86
&gt; +            if (!computeLength(sourceSize.length.get(), style, view, sourceSizeLength))
&gt; +                break;</span >

I think it’s strange to check if the value is a length inside this loop instead of checking it outside the loop. The break here is illogical until you think it through.

<span class="quote">&gt; Source/WebCore/css/SourceSizeList.cpp:93
&gt; -    return computeLength(CSSPrimitiveValue::create(100, CSSPrimitiveValue::CSS_VW).ptr(), style, view);
&gt; +    if (computeLength(CSSPrimitiveValue::create(100, CSSPrimitiveValue::CSS_VW).ptr(), style, view, sourceSizeLength))
&gt; +        return sourceSizeLength;
&gt; +    ASSERT_NOT_REACHED();
&gt; +    return 0;</span >

Combining the checking with the computation makes this ugly too. That ASSERT_NOT_REACHED is self-inflicted.

Also seems a shame that we have to allocation memory just to reuse code. Could we refactor this so we don’t have to heap-allocated a reference counted object and then delete it just to do the length computation?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>