<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:darin@apple.com" title="Darin Adler <darin@apple.com>"> <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@apple.com" title="Darin Adler <darin@apple.com>"> <span class="fn">Darin Adler</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=252586&action=diff" name="attach_252586" title="Patch">attachment 252586</a> <a href="attachment.cgi?id=252586&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=252586&action=review">https://bugs.webkit.org/attachment.cgi?id=252586&action=review</a>
I’m OK with this patch, but I think it’s unnecessarily awkward.
<span class="quote">> Source/WebCore/css/SourceSizeList.cpp:59
> -static unsigned computeLength(CSSValue* value, RenderStyle& style, RenderView* view)
> +static bool computeLength(CSSValue* value, RenderStyle& style, RenderView* view, unsigned& 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">> Source/WebCore/css/SourceSizeList.cpp:86
> + if (!computeLength(sourceSize.length.get(), style, view, sourceSizeLength))
> + 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">> Source/WebCore/css/SourceSizeList.cpp:93
> - return computeLength(CSSPrimitiveValue::create(100, CSSPrimitiveValue::CSS_VW).ptr(), style, view);
> + if (computeLength(CSSPrimitiveValue::create(100, CSSPrimitiveValue::CSS_VW).ptr(), style, view, sourceSizeLength))
> + return sourceSizeLength;
> + ASSERT_NOT_REACHED();
> + 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>