Bug 183339

Summary: Change the type of SVGToOTFFontConverter::m_weight to be not a char
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: SVGAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, commit-queue, darin, mmaxfield, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Said Abou-Hallawa
Reported 2018-03-05 11:17:07 PST
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.
Attachments
Patch (2.62 KB, patch)
2018-03-05 20:16 PST, Myles C. Maxfield
no flags
Myles C. Maxfield
Comment 1 2018-03-05 20:03:21 PST
m_result is a Vector<char> because that's what SharedBuffer::create() accepts.
Myles C. Maxfield
Comment 2 2018-03-05 20:16:11 PST
WebKit Commit Bot
Comment 3 2018-03-06 10:35:54 PST
Comment on attachment 335067 [details] Patch Clearing flags on attachment: 335067 Committed r229328: <https://trac.webkit.org/changeset/229328>
WebKit Commit Bot
Comment 4 2018-03-06 10:36:13 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 5 2018-03-06 10:37:21 PST
Darin Adler
Comment 6 2018-03-06 20:36:46 PST
(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.
Myles C. Maxfield
Comment 7 2018-03-06 20:46:18 PST
(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! ๐Ÿ‘
Darin Adler
Comment 8 2018-03-10 17:52:34 PST
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);
Note You need to log in before you can comment on or make changes to this bug.