Page MenuHomePhabricator

Bug 1504078 - Use references in the shapes code.
ClosedPublic

Authored by emilio on Nov 2 2018, 12:15 AM.

Details

Reviewers
TYLin
bradwerth
Group Reviewers
Restricted Project
Commits
Restricted Diffusion Commit
rMOZILLACENTRALd34c32dab9c9: Bug 1504078 - Use references in the shapes code. r=bradwerth,TYLin
Bugzilla Bug ID
1504078
Summary

It doesn't make much sense to return const UniquePtr<Foo>& for something that
can't be null, it's just confusing.

Also make more stuff actually const.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

emilio created this revision.Nov 2 2018, 12:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2018, 12:15 AM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".Nov 2 2018, 12:16 AM
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: Restricted Project.
emilio requested review of this revision.Nov 2 2018, 12:16 AM

Good fixes, thanks!

layout/style/nsStyleStruct.h
348

Should we really remove the parameter name here? Seems inconsistent with other methods.

1920–1921

Likewise here -- no parameter name.

layout/svg/nsCSSClipPathInstance.cpp
112–113

Here and in other calls to BasicShape(), it should work to have "const auto&", which might be clearer.

bradwerth accepted this revision.Nov 2 2018, 4:36 PM
This revision is now accepted and ready to land.Nov 2 2018, 4:36 PM
TYLin accepted this revision.Nov 2 2018, 5:29 PM

Nice! r=me with Brad's comment addressed.

layout/svg/nsCSSClipPathInstance.cpp
175–176

Nit: maybe take the chance to reformat this as

const FillRule fillRule = basicShape.GetFillRule() == StyleFillRule::Nonzero
                          ? FillRule::FILL_WINDING : FillRule::FILL_EVEN_ODD;

or

const FillRule fillRule = basicShape.GetFillRule() == StyleFillRule::Nonzero
                          ? FillRule::FILL_WINDING
                          : FillRule::FILL_EVEN_ODD;
232–233

Nit: reindent this line.

emilio marked 6 inline comments as done.Nov 2 2018, 6:18 PM
emilio added inline comments.
layout/style/nsStyleStruct.h
348

Fair enough, will put it back, though in general I think having redundant parameter names is not useful.

emilio updated this revision to Diff 31254.Nov 2 2018, 6:19 PM
emilio marked an inline comment as done.

Address review comments.

This revision was automatically updated to reflect the committed changes.