Bug 120215 - MediaQuery::expressions() should return a reference
Summary: MediaQuery::expressions() should return a reference
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Pratik Solanki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 11:28 PDT by Pratik Solanki
Modified: 2013-08-23 17:13 PDT (History)
12 users (show)

See Also:


Attachments
Patch (4.62 KB, patch)
2013-08-23 11:35 PDT, Pratik Solanki
no flags Details | Formatted Diff | Diff
Patch (6.13 KB, patch)
2013-08-23 12:29 PDT, Pratik Solanki
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pratik Solanki 2013-08-23 11:28:27 PDT
Code ensures that m_expressions is never null so we can just return a reference.
Comment 1 Pratik Solanki 2013-08-23 11:35:44 PDT
Created attachment 209479 [details]
Patch
Comment 2 Andreas Kling 2013-08-23 11:39:44 PDT
Comment on attachment 209479 [details]
Patch

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

> Source/WebCore/css/MediaQueryEvaluator.cpp:145
> -            const Vector<OwnPtr<MediaQueryExp> >* exps = query->expressions();
> +            const Vector<OwnPtr<MediaQueryExp> >& exps = query->expressions();

Since you are touching every line with this variable on it, you could also rename it to "expressions" while you're here :)
Comment 3 Early Warning System Bot 2013-08-23 11:41:18 PDT
Comment on attachment 209479 [details]
Patch

Attachment 209479 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/1523967
Comment 4 Early Warning System Bot 2013-08-23 11:42:20 PDT
Comment on attachment 209479 [details]
Patch

Attachment 209479 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/1542358
Comment 5 EFL EWS Bot 2013-08-23 11:56:20 PDT
Comment on attachment 209479 [details]
Patch

Attachment 209479 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/1558051
Comment 6 EFL EWS Bot 2013-08-23 12:14:59 PDT
Comment on attachment 209479 [details]
Patch

Attachment 209479 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/1555303
Comment 7 Pratik Solanki 2013-08-23 12:29:49 PDT
Created attachment 209491 [details]
Patch
Comment 8 WebKit Commit Bot 2013-08-23 12:32:29 PDT
Attachment 209491 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/css/MediaList.cpp', u'Source/WebCore/css/MediaQuery.cpp', u'Source/WebCore/css/MediaQuery.h', u'Source/WebCore/css/MediaQueryEvaluator.cpp']" exit_code: 1
Source/WebCore/css/MediaQueryEvaluator.cpp:145:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/MediaList.cpp:331:  Missing spaces around >>  [whitespace/operators] [3]
Total errors found: 2 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Anders Carlsson 2013-08-23 15:59:35 PDT
Comment on attachment 209491 [details]
Patch

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

> Source/WebCore/css/MediaQuery.cpp:82
> +MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)

Didn’t we decide that this should be PassOwnPtr<Vector<OwnPtr<MediaQueryExp>>>?
Comment 10 Pratik Solanki 2013-08-23 16:25:31 PDT
Comment on attachment 209491 [details]
Patch

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

>> Source/WebCore/css/MediaQuery.cpp:82
>> +MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)
> 
> Didn’t we decide that this should be PassOwnPtr<Vector<OwnPtr<MediaQueryExp>>>?

Since this was in MediaQuery.cpp, I felt it was okay to use the internal typedef ExpressionVector. Header says PassOwnPtr<Vector<OwnPtr<MediaQueryExp>>> for clarity.
Comment 11 Pratik Solanki 2013-08-23 16:32:49 PDT
Actually, MediaQuery.h uses ExpressionVector in some of it's public methods. We should just use Vector<OwnPtr<MediaQueryExp>> there to be clearer for callers. I'll make that change and land. Thanks for the review.
Comment 12 Pratik Solanki 2013-08-23 17:13:12 PDT
Committed r154533: <http://trac.webkit.org/changeset/154533>