Unify the usage of FrameChildListID
Categories
(Core :: Layout, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox108 | --- | fixed |
People
(Reporter: TYLin, Assigned: TYLin)
Details
Attachments
(3 files)
FrameChildListID
has many aliases in layout, and its confusing when to use which.
nsIFrame
redefine all of them again in https://searchfox.org/mozilla-central/rev/0b1543e85d13c30a13c57e959ce9815a3f0fa1d3/layout/generic/nsIFrame.h#1760-1781, and most of the frame class uses them. I guess this is to avoid typing::layout
namespace.
static const ChildListID kPrincipalList = mozilla::layout::kPrincipalList;
static const ChildListID kAbsoluteList = mozilla::layout::kAbsoluteList;
...
-
nsCSSFrameConstructior redefines
kPrincipalList
in https://searchfox.org/mozilla-central/rev/0b1543e85d13c30a13c57e959ce9815a3f0fa1d3/layout/base/nsCSSFrameConstructor.cpp#134-135 -
Some callers use its original form
layout::kPrincipalList
, e.g. https://searchfox.org/mozilla-central/rev/0b1543e85d13c30a13c57e959ce9815a3f0fa1d3/layout/xul/nsBoxFrame.cpp#124 -
While some callers spell its full name
FrameChildListID::kAbsoluteList
, e.g. https://searchfox.org/mozilla-central/rev/0b1543e85d13c30a13c57e959ce9815a3f0fa1d3/layout/generic/ScrollAnchorContainer.cpp#676
Assignee | ||
Comment 1•2 years ago
|
||
To improve this, I think we can do the following.
- Remove all the aliases.
- Since
FrameChildListID
is one of the the very few types live undermozilla::layout
namespace, we can move it intomozilla
namespace, and convert it to anenum class
such as
enum class FrameChildListID {
// The individual concrete child lists.
PrincipalList,
PopupList,
...
- Rewrite the callers to use
FrameChildListID::PrincipalList
instead ofkPrincipalList
. The only downside is their names become longer ...
Any suggestion to the proposal / naming is welcome.
Comment 2•2 years ago
|
||
I'd avoid having List
both in the enum class name and in the variants. FrameChildListID::Principal
seems equally clear IMO
Assignee | ||
Comment 3•2 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 4•2 years ago
|
||
After moving FrameChildListID into mozilla namespace, kPrincipalList
etc. are
also exposed in the mozilla namespace. In the next part, I'll convert
FrameChildListID enum into an enum class, so the naming pollution shouldn't be
an issue.
This patch has a nice side effect that it is now easier to remove all the
aliases of FrameChildListID (kPrincipalList
etc.) defined in multiple places
since it is confusion to have the same thing written in different ways, e.g.
nsIFrame::kPrincipalList
, mozilla::layout::kPrincipalList
,
FrameChildListID::kPrincipalList
, kPrincipalList
.
This patch doesn't change behavior.
Depends on D161862
Assignee | ||
Comment 5•2 years ago
|
||
This patch is first generated by the following script under gecko root folder.
#!/bin/bash
function rename() {
echo "Renaming $1 to $2"
rg -l "$1" | xargs sed -i -E -e s/"$1"/"$2"/g
}
rename "kPrincipalList" "FrameChildListID::Principal"
rename "kPopupList" "FrameChildListID::Popup"
rename "kCaptionList" "FrameChildListID::Caption"
rename "kColGroupList" "FrameChildListID::ColGroup"
rename "kAbsoluteList" "FrameChildListID::Absolute"
rename "kFixedList" "FrameChildListID::Fixed"
rename "kOverflowList" "FrameChildListID::Overflow"
rename "kOverflowContainersList" "FrameChildListID::OverflowContainers"
rename "kExcessOverflowContainersList" "FrameChildListID::ExcessOverflowContainers"
rename "kOverflowOutOfFlowList" "FrameChildListID::OverflowOutOfFlow"
rename "kFloatList" "FrameChildListID::Float"
rename "kBulletList" "FrameChildListID::Bullet"
rename "kPushedFloatsList" "FrameChildListID::PushedFloats"
rename "kBackdropList" "FrameChildListID::Backdrop"
rename "kNoReflowPrincipalList" "FrameChildListID::NoReflowPrincipal"
And then:
- Manually fix
FrameChildListID
definition in nsFrameList.h. - Apply clang-format.
Depends on D161863
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/1f84bfb41ab8 Part 1 - Replace GetChildList(kPrincipalList) with PrincipalChildList(). r=emilio https://hg.mozilla.org/integration/autoland/rev/c40fda7a8b0b Part 2 - Flatten the namespace for FrameChildList and co. by removing namespace layout. r=emilio https://hg.mozilla.org/integration/autoland/rev/e559f9dbc76f Part 3 - Convert FrameChildListID to enum class. r=emilio
Comment 7•2 years ago
|
||
Backed out 3 changesets (Bug 1799732) for causing build bustages in nsIFrame.cpp CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=396323774&repo=autoland&lineNumber=18954
Backout: https://hg.mozilla.org/integration/autoland/rev/df2c2c5f1f58c074eca252982537e204f7d179a8
Assignee | ||
Comment 8•2 years ago
|
||
Oh, need to convert the changes added in bug 1740365.
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/6cbd3ceacf7f Part 1 - Replace GetChildList(kPrincipalList) with PrincipalChildList(). r=emilio https://hg.mozilla.org/integration/autoland/rev/88e11f80d5d6 Part 2 - Flatten the namespace for FrameChildList and co. by removing namespace layout. r=emilio https://hg.mozilla.org/integration/autoland/rev/a8df83073f0f Part 3 - Convert FrameChildListID to enum class. r=emilio
Comment 10•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6cbd3ceacf7f
https://hg.mozilla.org/mozilla-central/rev/88e11f80d5d6
https://hg.mozilla.org/mozilla-central/rev/a8df83073f0f
Description
•