-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Address Safer cpp failures in TextPainter #47356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address Safer cpp failures in TextPainter #47356
Conversation
@@ -97,7 +96,7 @@ ShadowApplier::~ShadowApplier() | |||
m_context.clearDropShadow(); | |||
} | |||
|
|||
TextPainter::TextPainter(GraphicsContext& context, const FontCascade& font, const RenderStyle& renderStyle, const TextPaintStyle& textPaintStyle, const FixedVector<Style::TextShadow>& shadow, const FilterOperations* shadowColorFilter, const AtomString& emphasisMark, float emphasisMarkOffset, const RenderCombineText* combinedText) | |||
TextPainter::TextPainter(GraphicsContext& context, const CheckedRef<const FontCascade> font, const CheckedRef<const RenderStyle> renderStyle, const TextPaintStyle& textPaintStyle, const FixedVector<Style::TextShadow>& shadow, const FilterOperations* shadowColorFilter, const AtomString& emphasisMark, float emphasisMarkOffset, const CheckedPtr<const RenderCombineText> combinedText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing in safer cpp should cause you to update parameter types. This change is incorrect, we do not pass smart pointers as parameters, unless we transfer ownership and then we use r-value references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Fixed.
@@ -203,13 +202,13 @@ void TextPainter::paintTextAndEmphasisMarksIfNeeded(const TextRun& textRun, cons | |||
FloatPoint boxOrigin = boxRect.location(); | |||
updateGraphicsContext(m_context, paintStyle, UseEmphasisMarkColor); | |||
static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(StringView { span(objectReplacementCharacter) }); | |||
const TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : textRun; | |||
FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + m_font.metricsOfPrimaryFont().intAscent()) : textOrigin; | |||
const CheckedRef emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : textRun; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop const
now.
@@ -54,7 +53,7 @@ static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirecti | |||
|
|||
class TextPainter { | |||
public: | |||
TextPainter(GraphicsContext&, const FontCascade&, const RenderStyle&, const TextPaintStyle&, const FixedVector<Style::TextShadow>&, const FilterOperations*, const AtomString& emphasisMark, float emphasisMarkOffset, const RenderCombineText*); | |||
TextPainter(GraphicsContext&, const CheckedRef<const FontCascade>, const CheckedRef<const RenderStyle>, const TextPaintStyle&, const FixedVector<Style::TextShadow>&, const FilterOperations*, const AtomString& emphasisMark, float emphasisMarkOffset, const CheckedPtr<const RenderCombineText>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow our style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
31e5dea
to
fc35b59
Compare
fc35b59
to
2384f1c
Compare
EWS run on previous version of this PR (hash 2384f1c) |
Safer C++ Build #42018 (2384f1c)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
2384f1c
to
a4e4d5d
Compare
EWS run on previous version of this PR (hash a4e4d5d) |
a4e4d5d
to
de6af53
Compare
EWS run on previous version of this PR (hash de6af53) |
de6af53
to
3c2e218
Compare
EWS run on previous version of this PR (hash 3c2e218) |
@@ -244,7 +244,7 @@ String TextPainter::cachedGlyphDisplayListsForTextNodeAsText(Text& textNode, Opt | |||
|
|||
StringBuilder builder; | |||
|
|||
for (auto textBox : InlineIterator::textBoxesFor(*textNode.renderer())) { | |||
for (auto textBox : InlineIterator::textBoxesFor(*CheckedPtr { textNode.renderer() })) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use *textNode.checkedRenderer()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
*/ | ||
|
||
#pragma once | ||
|
||
#include "AffineTransform.h" | ||
#include "FloatRect.h" | ||
#include "GlyphDisplayListCache.h" | ||
#include "RenderCombineText.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might regress compile times. I suspect that instead you need to include CheckedPtr if that's what you get an error for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I bet it wouldn't be needed if we moved ~TextPainter()
out of line. Currently, it is implicit and thus inline in the header.
3c2e218
to
1ae8733
Compare
EWS run on current version of this PR (hash 1ae8733) |
Safe-Merge-Queue: Build #61886. |
https://bugs.webkit.org/show_bug.cgi?id=295182 rdar://problem/154618319 Reviewed by Chris Dumez. Fix clang static analyzer warnings in TextPainter. * Source/WebCore/SaferCPPExpectations/ForwardDeclCheckerExpectations: * Source/WebCore/SaferCPPExpectations/NoUncheckedPtrMemberCheckerExpectations: * Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations: * Source/WebCore/SaferCPPExpectations/UncheckedLocalVarsCheckerExpectations: * Source/WebCore/rendering/TextPainter.cpp: (WebCore::TextPainter::paintTextWithShadows): (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): * Source/WebCore/rendering/TextPainter.h: Canonical link: https://commits.webkit.org/296830@main
1ae8733
to
df16d2d
Compare
Committed 296830@main (df16d2d): https://commits.webkit.org/296830@main Reviewed commits have been landed. Closing PR #47356 and removing active labels. |
df16d2d
1ae8733