Bug 128117 - Manage MediaQuery and MediaQueryExp classes through std::unique_ptr instead of OwnPtr
Summary: Manage MediaQuery and MediaQueryExp classes through std::unique_ptr instead o...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on:
Blocks: 128007
  Show dependency treegraph
 
Reported: 2014-02-03 12:46 PST by Zan Dobersek
Modified: 2014-02-04 09:55 PST (History)
9 users (show)

See Also:


Attachments
Patch (20.94 KB, patch)
2014-02-03 12:47 PST, Zan Dobersek
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2014-02-03 12:46:29 PST
Manage MediaQuery and MediaQueryExp classes through std::unique_ptr instead of OwnPtr
Comment 1 Zan Dobersek 2014-02-03 12:47:24 PST
Created attachment 223011 [details]
Patch
Comment 2 Darin Adler 2014-02-03 15:52:42 PST
Comment on attachment 223011 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223011&action=review

> Source/WebCore/css/CSSGrammar.y.in:522
> -            $$ = MediaQueryExp::create(emptyString(), nullptr).leakPtr();
> +            $$ = std::make_unique<MediaQueryExp>(emptyString(), nullptr).release();

Elsewhere in this file we just use new for this sort of thing. Not sure how we decide when to do make_unique/release vs. new.

> Source/WebCore/css/CSSGrammar.y.in:543
> +        $$ = new Vector<std::unique_ptr<MediaQueryExp>>;

Here’s an example where we are using new (see comment above).

> Source/WebCore/css/MediaList.cpp:252
> +    const Vector<std::unique_ptr<MediaQuery>>& queries = m_mediaQueries->queryVector();

I suggest "auto&" here instead of "const Vector<std::unique_ptr<MediaQuery>>&".

> Source/WebCore/css/MediaList.cpp:321
> +    const Vector<std::unique_ptr<MediaQuery>>& mediaQueries = mediaQuerySet->queryVector();

I suggest "auto&" here instead of "const Vector<std::unique_ptr<MediaQuery>>&".

> Source/WebCore/css/MediaList.cpp:331
> +            const Vector<std::unique_ptr<MediaQueryExp>>& expressions = query->expressions();

I suggest "auto&" here instead of "const Vector<std::unique_ptr<MediaQueryExp>>&".

> Source/WebCore/css/MediaQueryEvaluator.cpp:137
> +    const Vector<std::unique_ptr<MediaQuery>>& queries = querySet->queryVector();

auto& would be better here

> Source/WebCore/css/MediaQueryEvaluator.cpp:150
> +            const Vector<std::unique_ptr<MediaQueryExp>>& expressions = query->expressions();

auto& would be better here
Comment 3 Zan Dobersek 2014-02-04 09:41:52 PST
Comment on attachment 223011 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=223011&action=review

>> Source/WebCore/css/CSSGrammar.y.in:522
>> +            $$ = std::make_unique<MediaQueryExp>(emptyString(), nullptr).release();
> 
> Elsewhere in this file we just use new for this sort of thing. Not sure how we decide when to do make_unique/release vs. new.

I'll revert to using 'new' until more rigid guidelines are established for such cases (and will adjust accordingly at that point, if necessary).

>> Source/WebCore/css/MediaList.cpp:252
>> +    const Vector<std::unique_ptr<MediaQuery>>& queries = m_mediaQueries->queryVector();
> 
> I suggest "auto&" here instead of "const Vector<std::unique_ptr<MediaQuery>>&".

OK, m_mediaQueries->queryVector() does note, to some degree, what type the method call returns.
Comment 4 Zan Dobersek 2014-02-04 09:55:23 PST
Committed r163385: <http://trac.webkit.org/changeset/163385>