Closed
Bug 1477533
Opened 5 years ago
Closed 5 years ago
Convert NS_STYLE_COLUMN_FILL_* and NS_STYLE_COLUMN_SPAN_* to enum classes
Categories
(Core :: CSS Parsing and Computation, enhancement, P3)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
mozilla63
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: TYLin, Assigned: TYLin)
Details
Attachments
(3 files)
Also, convert NS_STYLE_COLUMN_COUNT_AUTO to a static const class variable.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•5 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=154138b2cfc05d42a5aa2946e8d266ffd256135f
Comment 5•5 years ago
|
||
mozreview-review |
Comment on attachment 8993989 [details] Bug 1477533 - Use static const class variable to represent column-count: auto. https://reviewboard.mozilla.org/r/258596/#review265578 r=me although I wonder whether we should avoid making individual style struct members be initialized in their declaration rather than the constructor, since if we are not consistent about where we do this, then it makes it a little harder to understand what the constructor is doing. But it's not a big deal.
Attachment #8993989 -
Flags: review?(cam) → review+
Comment 6•5 years ago
|
||
The style guide https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#CC_practices says "For constructors, initialize member variables with : nsFoo aFoo(bFoo) syntax." so I think that means we should avoid initializing in the declaration.
Comment 7•5 years ago
|
||
mozreview-review |
Comment on attachment 8993990 [details] Bug 1477533 - Convert NS_STYLE_COLUMN_FILL_* to an enum class. https://reviewboard.mozilla.org/r/258598/#review265580
Attachment #8993990 -
Flags: review?(cam) → review+
Comment 8•5 years ago
|
||
(In reply to Cameron McCormack (:heycam) from comment #6) > The style guide > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/ > Coding_Style#CC_practices says "For constructors, initialize member > variables with : nsFoo aFoo(bFoo) syntax." so I think that means we should > avoid initializing in the declaration. I'm moderately sure that predates the ability to initialize in the declaration, and that it's done to avoid constructors like: Foo::Foo() { mBar = 3; mBaz = 5; } Maybe worth asking for a clarification to the list or something?
Comment 9•5 years ago
|
||
mozreview-review |
Comment on attachment 8993991 [details] Bug 1477533 - Convert NS_STYLE_COLUMN_SPAN_* to an enum class. https://reviewboard.mozilla.org/r/258600/#review265582
Attachment #8993991 -
Flags: review?(cam) → review+
Comment 10•5 years ago
|
||
The rule mentioned in comment 6 / comment 8 was added relatively recently (a couple years ago) in: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style$revision/1073782 https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style$compare?locale=en-US&to=1073782&from=1060866 Not sure whether that accounted for initialization in the declaration, I don't see any related thread anywhere.
Assignee | ||
Comment 11•5 years ago
|
||
We should be able to use all the features in C++11 per https://developer.mozilla.org/en-US/docs/Mozilla/Using_CXX_in_Mozilla_code. In this case, it should be the "member initializers" feature. Though initializing in the declaration is not very popular, we do have a few usages in nsStyleStruct.h such as https://searchfox.org/mozilla-central/rev/ad36eff63e208b37bc9441b91b7cea7291d82890/layout/style/nsStyleStruct.h#2047-2048 IMHO, I like this feature because if a class has multiple constructors, we don't need to initialize a member in all the constructors' initializer list unless some constructor wants to assign different initial value.
Comment 12•5 years ago
|
||
I think https://developer.mozilla.org/en-US/docs/Mozilla/Using_CXX_in_Mozilla_code is really about whether the compilers and platforms we build on support various C++ features, and still we must use judgement as to the clarity of the code. (For example, "auto" is allowed per that page, but most of the time it's clearer to write out the type.) Though Emilio is probably right about the rule I quoted being about avoiding `mFoo = blah`, rather than avoiding initializers on the declarations. I do think it looks a bit funny if one or two member variables are initialized like this, while the rest aren't, but I don't feel strongly about it so feel free to land the patches as is.
Assignee | ||
Comment 13•5 years ago
|
||
Right, "auto" is a good example which should only be used under certain circumstances. And thanks for the clarification about your preference. I'm going to land the patch as is.
Comment 14•5 years ago
|
||
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/dea3f75dbe56 Use static const class variable to represent column-count: auto. r=heycam https://hg.mozilla.org/integration/autoland/rev/799227e35bc5 Convert NS_STYLE_COLUMN_FILL_* to an enum class. r=heycam https://hg.mozilla.org/integration/autoland/rev/428ca334e24f Convert NS_STYLE_COLUMN_SPAN_* to an enum class. r=heycam
Comment 15•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/dea3f75dbe56 https://hg.mozilla.org/mozilla-central/rev/799227e35bc5 https://hg.mozilla.org/mozilla-central/rev/428ca334e24f
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•