WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
218298
Make WebCore::ContainerNode::ChildChangeType enum class
https://bugs.webkit.org/show_bug.cgi?id=218298
Summary
Make WebCore::ContainerNode::ChildChangeType enum class
Tetsuharu Ohzeki [UTC+9]
Reported
2020-10-28 11:29:46 PDT
...
Attachments
Patch
(12.39 KB, patch)
2020-10-28 11:31 PDT
,
Tetsuharu Ohzeki [UTC+9]
no flags
Details
Formatted Diff
Diff
Patch
(33.01 KB, patch)
2020-10-28 15:10 PDT
,
Tetsuharu Ohzeki [UTC+9]
no flags
Details
Formatted Diff
Diff
Patch
(33.00 KB, patch)
2020-10-29 00:00 PDT
,
Tetsuharu Ohzeki [UTC+9]
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Tetsuharu Ohzeki [UTC+9]
Comment 1
2020-10-28 11:31:22 PDT
Created
attachment 412550
[details]
Patch
Darin Adler
Comment 2
2020-10-28 12:51:18 PDT
Comment on
attachment 412550
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=412550&action=review
I’m going to say review+ even though I am not *sure* this is an improvement.
> Source/WebCore/dom/ContainerNode.h:76 > + enum class ChildChangeType: uint8_t { ElementInserted, ElementRemoved, TextInserted, TextRemoved, TextChanged, AllChildrenRemoved, NonContentsChildRemoved, NonContentsChildInserted, AllChildrenReplaced };
Not sure this is an improvement. I understand that we like the idea of using enum class everywhere, but this makes all the code wordier and it’s not *obvious* to me that it’s better. We know it’s better when the actual enumeration values can have shorter more straightforward names because the enumeration’s name will always be cited just before them. But here we were not able to do that. Maybe this enumeration should be a in the ChildChange structure, with the name "Type" instead of next to the ChildChange structure with the name ChildChangeType. Note that we can set the base type to uint8_t even without switching from enum to enum class.
> Source/WebCore/dom/ContainerNode.h:77 > enum class ChildChangeSource { Parser, API };
Should probably put a base type of bool here?
Tetsuharu Ohzeki [UTC+9]
Comment 3
2020-10-28 14:08:22 PDT
(In reply to Darin Adler from
comment #2
)
> Not sure this is an improvement. I understand that we like the idea of using > enum class everywhere, but this makes all the code wordier and it’s not > *obvious* to me that it’s better.
Ah, I see.
> Maybe this enumeration should be a in the ChildChange structure, with the > name "Type" instead of next to the ChildChange structure with the name > ChildChangeType.
In that case, should we make it enum class or keep it as enum?
> > Source/WebCore/dom/ContainerNode.h:77 > > enum class ChildChangeSource { Parser, API }; > > Should probably put a base type of bool here?
I worried that but I did not touch it. I'll change it in the next patch.
Darin Adler
Comment 4
2020-10-28 14:16:53 PDT
(In reply to Tetsuharu Ohzeki from
comment #3
)
> (In reply to Darin Adler from
comment #2
) > > Maybe this enumeration should be a in the ChildChange structure, with the > > name "Type" instead of next to the ChildChange structure with the name > > ChildChangeType. > > In that case, should we make it enum class or keep it as enum?
I’m conflicted about that.
Tetsuharu Ohzeki [UTC+9]
Comment 5
2020-10-28 14:27:19 PDT
(In reply to Darin Adler from
comment #4
)
> (In reply to Tetsuharu Ohzeki from
comment #3
) > > (In reply to Darin Adler from
comment #2
) > > > Maybe this enumeration should be a in the ChildChange structure, with the > > > name "Type" instead of next to the ChildChange structure with the name > > > ChildChangeType. > > > > In that case, should we make it enum class or keep it as enum? > > I’m conflicted about that.
I'm trying to move ChildChangeType to ChildChange and keep it enum class. it would be a bit redundant like `ChildChange::Type::ElementInserted`. I seem `ChildChange::ElementInserted` is concise at here and we achive to push ChildChangeType into some scope. So I will change to this pattern in the next patch. And then, I also feel that we can move ChildChangeSource to ChildChange with keeping it as enum class. Darin, how do you think about these?
Darin Adler
Comment 6
2020-10-28 14:32:18 PDT
I like ChildChange::Type::ElementInserted. Even though it’s long, the separators actually make it easier to read.
Tetsuharu Ohzeki [UTC+9]
Comment 7
2020-10-28 14:33:15 PDT
Okay. Thank you.
Darin Adler
Comment 8
2020-10-28 14:34:50 PDT
(In reply to Tetsuharu Ohzeki [UTC+9] from
comment #5
)
> And then, I also feel that we can move ChildChangeSource to ChildChange with > keeping it as enum class.
Yes!
Tetsuharu Ohzeki [UTC+9]
Comment 9
2020-10-28 15:10:09 PDT
Created
attachment 412575
[details]
Patch
Darin Adler
Comment 10
2020-10-28 15:26:39 PDT
Comment on
attachment 412575
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=412575&action=review
> Source/WebCore/dom/ContainerNode.cpp:85 > + if (source == ContainerNode::ChildChange::Source::API) {
The ContainerNode prefix isn’t needed here. We are inside a ContainerNode member function here.
> Source/WebCore/dom/ContainerNode.cpp:93 > + ASSERT(source == ContainerNode::ChildChange::Source::Parser);
Ditto.
> Source/WebCore/dom/ContainerNode.cpp:133 > + if (source == ContainerNode::ChildChange::Source::API) {
Ditto.
> Source/WebCore/dom/ContainerNode.cpp:140 > + if (source == ContainerNode::ChildChange::Source::Parser) {
Ditto.
> Source/WebCore/dom/ContainerNode.cpp:169 > + change.type = is<Element>(childToRemove) ? ChildChange::Type::ElementRemoved : (is<Text>(childToRemove) ? ChildChange::Type::TextRemoved : ChildChange::Type::NonContentsChildRemoved);
Here we do it all on one line.
> Source/WebCore/dom/ContainerNode.cpp:208 > + child.isElementNode() ? > + ContainerNode::ChildChange::Type::ElementInserted : > + (child.isTextNode() ? > + ContainerNode::ChildChange::Type::TextInserted : > + ContainerNode::ChildChange::Type::NonContentsChildInserted),
Here we break it into multiple lines. Not really elegant to have that difference.
> Source/WebCore/dom/ContainerNode.h:78 > + enum class Type: uint8_t { ElementInserted, ElementRemoved, TextInserted, TextRemoved, TextChanged, AllChildrenRemoved, NonContentsChildRemoved, NonContentsChildInserted, AllChildrenReplaced }; > + enum class Source: bool { Parser, API };
WebKit’s normal formatting puts a space before the ":".
> Source/WebCore/dom/Element.cpp:2627 > + SiblingCheckType checkType = change.type == ChildChange::Type::ElementRemoved ? SiblingElementRemoved : Other;
I think this is better with "auto" instead of SiblingCheckType.
Tetsuharu Ohzeki [UTC+9]
Comment 11
2020-10-29 00:00:38 PDT
Created
attachment 412619
[details]
Patch
EWS
Comment 12
2020-10-29 12:24:54 PDT
Committed
r269161
: <
https://trac.webkit.org/changeset/269161
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 412619
[details]
.
Radar WebKit Bug Importer
Comment 13
2020-10-29 12:25:21 PDT
<
rdar://problem/70820615
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug