This is a follow up for Darin's comment in https://bugs.webkit.org/show_bug.cgi?id=183165#c2. If m_weight is negative, clampTo<uint16_t> or static_cast<uint16_t> will give the wrong value.
m_result is a Vector<char> because that's what SharedBuffer::create() accepts.
Created attachment 335067 [details] Patch
Comment on attachment 335067 [details] Patch Clearing flags on attachment: 335067 Committed r229328: <https://trac.webkit.org/changeset/229328>
All reviewed patches have been landed. Closing bug.
<rdar://problem/38185027>
(In reply to Myles C. Maxfield from comment #1) > m_result is a Vector<char> because that's what SharedBuffer::create() > accepts. At some point I intend to change Vector<char> to Vector<uint8_t> throughout WebKit for this sort of thing.
(In reply to Darin Adler from comment #6) > (In reply to Myles C. Maxfield from comment #1) > > m_result is a Vector<char> because that's what SharedBuffer::create() > > accepts. > > At some point I intend to change Vector<char> to Vector<uint8_t> throughout > WebKit for this sort of thing. Yes! π
Comment on attachment 335067 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335067&action=review > Source/WebCore/svg/SVGToOTFFontConversion.cpp:528 > + if (ok && value >= std::numeric_limits<uint8_t>::min() && value <= std::numeric_limits<uint8_t>::max()) If this pattern is common I think we should add a helper function. > Source/WebCore/svg/SVGToOTFFontConversion.cpp:1464 > + m_weight = std::max(std::min((value + 50) / 100, static_cast<int>(std::numeric_limits<uint8_t>::max())), static_cast<int>(std::numeric_limits<uint8_t>::min())); This is what clampTo is for, and itβs much easier to read: m_weight = clampTo<uint8_t>((value + 50) / 100);