WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
215143
Make GlyphBufferAdvance and GlyphBufferOrigin more robust
https://bugs.webkit.org/show_bug.cgi?id=215143
Summary
Make GlyphBufferAdvance and GlyphBufferOrigin more robust
Myles C. Maxfield
Reported
2020-08-04 15:08:20 PDT
Make GlyphBufferAdvance and GlyphBufferOrigin more robust
Attachments
Patch
(49.65 KB, patch)
2020-08-04 16:14 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(47.78 KB, patch)
2020-08-04 16:21 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(45.84 KB, patch)
2020-08-04 21:49 PDT
,
Myles C. Maxfield
zalan
: review+
Details
Formatted Diff
Diff
Patch for committing
(51.10 KB, patch)
2020-09-05 21:15 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch for committing
(49.37 KB, patch)
2020-09-05 21:34 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch for committing
(49.37 KB, patch)
2020-09-06 15:09 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch for committing
(54.63 KB, patch)
2020-09-06 16:47 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2020-08-04 16:14:21 PDT
Created
attachment 405957
[details]
Patch
Myles C. Maxfield
Comment 2
2020-08-04 16:21:39 PDT
Created
attachment 405959
[details]
Patch
Darin Adler
Comment 3
2020-08-04 16:53:46 PDT
Comment on
attachment 405959
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405959&action=review
Thanks for considering my suggestion.
> Source/WebCore/platform/graphics/GlyphBuffer.h:90 > + m_origins.append(createGlyphBufferOrigin());
m_origins.append({ });
> Source/WebCore/platform/graphics/GlyphBuffer.h:110 > + m_origins.insertVector(location, Vector<GlyphBufferOrigin>(length, createGlyphBufferOrigin()));
Can just use { } here.
> Source/WebCore/platform/graphics/GlyphBuffer.h:153 > + m_advances[i] = createGlyphBufferAdvance(FloatSize(
Maybe overload makeGlyphBufferAdvance so we don’t need to cast to FloatSize here? And/or just use { } instead of FloatSize().
> Source/WebCore/platform/graphics/GlyphBufferMembers.h:72 > +inline GlyphBufferAdvance createGlyphBufferAdvance(const FloatSize& = FloatSize()); > +inline FloatSize floatSizeFromGlyphBufferAdvance(const GlyphBufferAdvance&); > +inline void setGlyphBufferAdvanceWidth(GlyphBufferAdvance&, float); > +inline void setGlyphBufferAdvanceHeight(GlyphBufferAdvance&, float); > +inline float glyphBufferAdvanceWidth(const GlyphBufferAdvance&); > +inline float glyphBufferAdvanceHeight(const GlyphBufferAdvance&); > +inline GlyphBufferOrigin createGlyphBufferOrigin(const FloatPoint& = FloatPoint()); > +inline FloatPoint floatPointFromGlyphBufferOrigin(const GlyphBufferOrigin&); > +inline void setGlyphBufferOriginX(GlyphBufferOrigin&, float); > +inline void setGlyphBufferOriginY(GlyphBufferOrigin&, float); > +inline float glyphBufferOriginX(const GlyphBufferOrigin&); > +inline float glyphBufferOriginY(const GlyphBufferOrigin&);
In WebKit, I generally suggest reserving the word create for things that are heap-allocated and use make for things that are not. Also, because C++ has overloading, a lot of these functions could have shorter names. I suggest these names: makeGlyphBufferAdvance size setWidth setHeight width height makeGlyphBufferOrigin point setX setY x y It’s possible these names are *too* short, but I think we should try to get closer to these names. Code won’t be readable if the names are too long.
Myles C. Maxfield
Comment 4
2020-08-04 17:26:55 PDT
Comment on
attachment 405959
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405959&action=review
>> Source/WebCore/platform/graphics/GlyphBuffer.h:90 >> + m_origins.append(createGlyphBufferOrigin()); > > m_origins.append({ });
Will this actually zero-fill a CGPoint struct?
Darin Adler
Comment 5
2020-08-04 17:54:57 PDT
Comment on
attachment 405959
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=405959&action=review
>>> Source/WebCore/platform/graphics/GlyphBuffer.h:90 >>> + m_origins.append(createGlyphBufferOrigin()); >> >> m_origins.append({ }); > > Will this actually zero-fill a CGPoint struct?
Yes. Roughly speaking, there are only a few ways to *not* initialize scalars, and the mostly get zero-initialized. In the specific case of CGPoint and { }, this technically is aggregate initialization. Since the number of initializer clauses (0) is less than the number of members (2) the remaining members are value-initialized, which for scalars means they are zero-initialized.
Myles C. Maxfield
Comment 6
2020-08-04 21:49:54 PDT
Created
attachment 405984
[details]
Patch
Radar WebKit Bug Importer
Comment 7
2020-08-11 15:09:34 PDT
<
rdar://problem/66864884
>
Darin Adler
Comment 8
2020-09-05 08:20:05 PDT
Comment on
attachment 405984
[details]
Patch This is great!
Myles C. Maxfield
Comment 9
2020-09-05 21:15:40 PDT
Created
attachment 408113
[details]
Patch for committing
Myles C. Maxfield
Comment 10
2020-09-05 21:34:10 PDT
Created
attachment 408114
[details]
Patch for committing
Myles C. Maxfield
Comment 11
2020-09-06 15:09:20 PDT
Created
attachment 408137
[details]
Patch for committing
Myles C. Maxfield
Comment 12
2020-09-06 16:30:56 PDT
I see what's happening. I need to initialize m_initialAdvance to (0, 0).
Myles C. Maxfield
Comment 13
2020-09-06 16:47:42 PDT
Created
attachment 408150
[details]
Patch for committing
Darin Adler
Comment 14
2020-09-06 16:54:58 PDT
Comment on
attachment 408150
[details]
Patch for committing View in context:
https://bugs.webkit.org/attachment.cgi?id=408150&action=review
> Source/WebCore/platform/graphics/GlyphBuffer.h:216 > + GlyphBufferAdvance m_initialAdvance { makeGlyphBufferAdvance() };
I would have expected that just empty braces, { }, would do the trick here; surprised that a call to makeGlyphBufferAdvance() is needed.
EWS
Comment 15
2020-09-06 17:52:57 PDT
Committed
r266688
: <
https://trac.webkit.org/changeset/266688
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 408150
[details]
.
Myles C. Maxfield
Comment 16
2020-09-06 18:05:08 PDT
Comment on
attachment 408150
[details]
Patch for committing View in context:
https://bugs.webkit.org/attachment.cgi?id=408150&action=review
>> Source/WebCore/platform/graphics/GlyphBuffer.h:216 >> + GlyphBufferAdvance m_initialAdvance { makeGlyphBufferAdvance() }; > > I would have expected that just empty braces, { }, would do the trick here; surprised that a call to makeGlyphBufferAdvance() is needed.
Me too! But this looks like the reason why the obsoleted patches were red.
Darin Adler
Comment 17
2020-09-07 09:49:54 PDT
Comment on
attachment 408150
[details]
Patch for committing View in context:
https://bugs.webkit.org/attachment.cgi?id=408150&action=review
>>> Source/WebCore/platform/graphics/GlyphBuffer.h:216 >>> + GlyphBufferAdvance m_initialAdvance { makeGlyphBufferAdvance() }; >> >> I would have expected that just empty braces, { }, would do the trick here; surprised that a call to makeGlyphBufferAdvance() is needed. > > Me too! But this looks like the reason why the obsoleted patches were red.
In those obsoleted patches there were no braces at all. That would leave it uninitialized. My point is that you do need the braces but don’t need the function call.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug