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
137858
Kill toRenderedDocumentMarker() by using tighter typing
https://bugs.webkit.org/show_bug.cgi?id=137858
Summary
Kill toRenderedDocumentMarker() by using tighter typing
Chris Dumez
Reported
2014-10-18 15:14:41 PDT
Kill toRenderedDocumentMarker() by using tighter typing. This method was doing no type validation, just a static_cast<>().
Attachments
Patch
(28.87 KB, patch)
2014-10-18 15:21 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(30.79 KB, patch)
2014-10-18 15:54 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(31.85 KB, patch)
2014-10-18 18:27 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(46.01 KB, patch)
2014-10-19 20:52 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2014-10-18 15:21:13 PDT
Created
attachment 240074
[details]
Patch
Chris Dumez
Comment 2
2014-10-18 15:54:24 PDT
Created
attachment 240075
[details]
Patch
Chris Dumez
Comment 3
2014-10-18 18:27:07 PDT
Created
attachment 240079
[details]
Patch
Darin Adler
Comment 4
2014-10-19 19:51:52 PDT
Comment on
attachment 240079
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=240079&action=review
> Source/WebCore/dom/DocumentMarkerController.cpp:409 > + Vector<RenderedDocumentMarker*> markers = markersFor(node); > + for (auto* marker : markers) {
Believe it or not, we don’t even need the local variable here. This will work: for (auto* marker : markersFor(node)) { However, some other similar constructions wouldn’t work. Only the result of the entire expression on the right gets its lifetime extended in the right way. So maybe you don’t want to do this?
> Source/WebCore/dom/DocumentMarkerController.cpp:681 > + Vector<RenderedDocumentMarker*> markers = markersFor(node); > + for (auto* marker : markers) {
Same thing again.
> Source/WebCore/editing/AlternativeTextController.cpp:474 > + Vector<RenderedDocumentMarker*> markers = node->document().markers().markersFor(node); > + for (const auto* marker : markers) {
Same thing again. Also not sure why we bother putting the const here; doesn’t add much.
> Source/WebCore/editing/AlternativeTextController.cpp:554 > + Vector<RenderedDocumentMarker*> correctedOnceMarkers = markers.markersInRange(rangeOfCorrection, DocumentMarker::Autocorrected);
A line like this is where other people hate, and I love, auto.
> Source/WebCore/editing/AlternativeTextController.cpp:735 > for (size_t i = 0; i < dictationAlternativesMarkers.size(); ++i)
Could use a modern for loop here.
> Source/WebCore/rendering/InlineTextBox.h:161 > - void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&, bool grammar); > - void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&); > + void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, RenderedDocumentMarker*, const RenderStyle&, const Font&, bool grammar); > + void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, RenderedDocumentMarker*, const RenderStyle&, const Font&); > > - void computeRectForReplacementMarker(DocumentMarker*, const RenderStyle&, const Font&); > + void computeRectForReplacementMarker(RenderedDocumentMarker*, const RenderStyle&, const Font&);
Seems like these should all take references, not pointers.
Chris Dumez
Comment 5
2014-10-19 20:52:32 PDT
Created
attachment 240096
[details]
Patch
WebKit Commit Bot
Comment 6
2014-10-19 22:17:06 PDT
Comment on
attachment 240096
[details]
Patch Clearing flags on attachment: 240096 Committed
r174876
: <
http://trac.webkit.org/changeset/174876
>
WebKit Commit Bot
Comment 7
2014-10-19 22:17:13 PDT
All reviewed patches have been landed. Closing bug.
Ryosuke Niwa
Comment 8
2017-10-19 13:25:32 PDT
Nice!
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