WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
151962
Refactor TextPainter::paintText() into sub methods.
https://bugs.webkit.org/show_bug.cgi?id=151962
Summary
Refactor TextPainter::paintText() into sub methods.
alan
Reported
2015-12-07 13:44:18 PST
TextPainter::paintText is way more complicated than it should be.
Attachments
Patch
(8.76 KB, patch)
2015-12-07 13:46 PST
,
alan
no flags
Details
Formatted Diff
Diff
Patch
(8.75 KB, patch)
2015-12-07 14:06 PST
,
alan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
alan
Comment 1
2015-12-07 13:46:46 PST
Created
attachment 266807
[details]
Patch
alan
Comment 2
2015-12-07 13:47:18 PST
This is ::paintText after the change. void TextPainter::paintText() { if (!m_paintSelectedTextOnly) { // For stroked painting, we have to change the text drawing mode. It's probably dangerous to leave that mutated as a side // effect, so only when we know we're stroking, do a save/restore. bool fullLengthPaint = !m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun; int startOffset = fullLengthPaint ? 0 : m_endPositionInTextRun; int endOffset = fullLengthPaint ? m_length : m_startPositionInTextRun; paintTextWithStyle(startOffset, endOffset, m_textPaintStyle, m_textShadow); } // paint only the text that is selected if ((m_paintSelectedTextOnly || m_paintSelectedTextSeparately) && m_startPositionInTextRun < m_endPositionInTextRun) paintTextWithStyle(m_startPositionInTextRun, m_endPositionInTextRun, m_selectionPaintStyle, m_selectionShadow); }
Myles C. Maxfield
Comment 3
2015-12-07 13:59:33 PST
Comment on
attachment 266807
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=266807&action=review
> Source/WebCore/rendering/TextPainter.cpp:153 > +void TextPainter::paintTextWithEmphasisIfNeeded(int startOffset, int endOffset, const TextPaintStyle& paintStyle, const ShadowData* shadow)
I think you should name this "emphasis marks" not "text with emphasis"
> Source/WebCore/rendering/TextPainter.cpp:160 > + DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (StringView(&objectReplacementCharacter, 1)));
static NeverDestroyed
> Source/WebCore/rendering/TextPainter.cpp:167 > + paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, startOffset, endOffset, m_length, emphasisMarkTextOrigin, m_boxRect, shadow, paintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
Why don't we make paintTextWithShadows a member function so we don't have to pass in all these m_ variables
alan
Comment 4
2015-12-07 14:06:03 PST
Created
attachment 266810
[details]
Patch
alan
Comment 5
2015-12-07 14:30:01 PST
(In reply to
comment #3
)
> Comment on
attachment 266807
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=266807&action=review
> > > Source/WebCore/rendering/TextPainter.cpp:153 > > +void TextPainter::paintTextWithEmphasisIfNeeded(int startOffset, int endOffset, const TextPaintStyle& paintStyle, const ShadowData* shadow) > > I think you should name this "emphasis marks" not "text with emphasis" > > > Source/WebCore/rendering/TextPainter.cpp:160 > > + DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (StringView(&objectReplacementCharacter, 1))); > > static NeverDestroyed >
Done.
> > Source/WebCore/rendering/TextPainter.cpp:167 > > + paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, startOffset, endOffset, m_length, emphasisMarkTextOrigin, m_boxRect, shadow, paintStyle.strokeWidth > 0, m_textBoxIsHorizontal); > > Why don't we make paintTextWithShadows a member function so we don't have to > pass in all these m_ variables
Follow up patch is coming up.
WebKit Commit Bot
Comment 6
2015-12-07 15:01:32 PST
Comment on
attachment 266810
[details]
Patch Clearing flags on attachment: 266810 Committed
r193656
: <
http://trac.webkit.org/changeset/193656
>
WebKit Commit Bot
Comment 7
2015-12-07 15:01:36 PST
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 8
2015-12-08 07:57:15 PST
Comment on
attachment 266810
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=266810&action=review
> Source/WebCore/rendering/TextPainter.h:60 > private: > + void paintTextWithStyle(int startOffset, int endOffset, const TextPaintStyle&, const ShadowData*); > + void paintEmphasisMarksIfNeeded(int startOffset, int endOffset, const TextPaintStyle&, const ShadowData*); > + > +private:
I don’t think we need to say private: twice.
alan
Comment 9
2015-12-08 09:05:07 PST
(In reply to
comment #8
)
> Comment on
attachment 266810
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=266810&action=review
> > > Source/WebCore/rendering/TextPainter.h:60 > > private: > > + void paintTextWithStyle(int startOffset, int endOffset, const TextPaintStyle&, const ShadowData*); > > + void paintEmphasisMarksIfNeeded(int startOffset, int endOffset, const TextPaintStyle&, const ShadowData*); > > + > > +private: > > I don’t think we need to say private: twice.
Fixing it in
bug 151994
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