Bug 137858 - Kill toRenderedDocumentMarker() by using tighter typing
Summary: Kill toRenderedDocumentMarker() by using tighter typing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-18 15:14 PDT by Chris Dumez
Modified: 2017-10-19 13:25 PDT (History)
5 users (show)

See Also:


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

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-10-18 15:14:41 PDT
Kill toRenderedDocumentMarker() by using tighter typing. This method was doing no type validation, just a static_cast<>().
Comment 1 Chris Dumez 2014-10-18 15:21:13 PDT
Created attachment 240074 [details]
Patch
Comment 2 Chris Dumez 2014-10-18 15:54:24 PDT
Created attachment 240075 [details]
Patch
Comment 3 Chris Dumez 2014-10-18 18:27:07 PDT
Created attachment 240079 [details]
Patch
Comment 4 Darin Adler 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.
Comment 5 Chris Dumez 2014-10-19 20:52:32 PDT
Created attachment 240096 [details]
Patch
Comment 6 WebKit Commit Bot 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>
Comment 7 WebKit Commit Bot 2014-10-19 22:17:13 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Ryosuke Niwa 2017-10-19 13:25:32 PDT
Nice!