WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 177852
Replace some stack raw pointers with RefPtrs within WebCore/dom
https://bugs.webkit.org/show_bug.cgi?id=177852
Summary
Replace some stack raw pointers with RefPtrs within WebCore/dom
Jiewen Tan
Reported
2017-10-03 18:30:21 PDT
Replace some stack raw pointers with RefPtrs within WebCore/dom. This is an effort to reduce raw pointer usage in DOM code.
Attachments
Patch
(12.61 KB, patch)
2017-10-04 11:09 PDT
,
Jiewen Tan
rniwa
: review+
Details
Formatted Diff
Diff
Patch for landing
(11.79 KB, patch)
2017-10-06 11:18 PDT
,
Jiewen Tan
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2017-10-03 18:30:59 PDT
<
rdar://problem/34804487
>
Jiewen Tan
Comment 2
2017-10-04 11:09:49 PDT
Created
attachment 322692
[details]
Patch
Build Bot
Comment 3
2017-10-04 11:12:29 PDT
Attachment 322692
[details]
did not pass style-queue: ERROR: Source/WebCore/dom/RadioButtonGroups.cpp:77: 'oldCheckedButton' is incorrectly named. It should be named 'protector' or 'protectedCheckedButton'. [readability/naming/protected] [4] ERROR: Source/WebCore/dom/ContainerNodeAlgorithms.cpp:158: 'next' is incorrectly named. It should be named 'protector' or 'protectedNullptr'. [readability/naming/protected] [4] Total errors found: 2 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
Jiewen Tan
Comment 4
2017-10-04 17:06:59 PDT
No performance regression has been identified with a local test with speedometer. Now try performance try-bots.
Ryosuke Niwa
Comment 5
2017-10-04 20:56:04 PDT
Comment on
attachment 322692
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=322692&action=review
> Source/WebCore/dom/EventTarget.cpp:236 > + RefPtr<EventTarget> protectedThis(this); // Try to prevent this event target being removed by an event handler.
I don't think we should add this protectThis objects in this refactoring effort. protectedThis is really an anti-pattern that only exists because we don't have caller which holds onto a Ref/RefPtr of this.
> Source/WebCore/dom/MouseRelatedEvent.cpp:172 > - Node* n = targetNode; > + Node* n = targetNode.get();
Use RefPtr here.
Jiewen Tan
Comment 6
2017-10-05 14:37:26 PDT
Comment on
attachment 322692
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=322692&action=review
Thanks Ryosuke for r+ my patch. I will upload another patch to address all of the comments once I got the results from the performance try-bots.
>> Source/WebCore/dom/EventTarget.cpp:236 >> + RefPtr<EventTarget> protectedThis(this); // Try to prevent this event target being removed by an event handler. > > I don't think we should add this protectThis objects in this refactoring effort. > protectedThis is really an anti-pattern that only exists because we don't have caller which holds onto a Ref/RefPtr of this.
True, we should deal with the heap raw pointers/references after dealing with the stack ones.
>> Source/WebCore/dom/MouseRelatedEvent.cpp:172 >> + Node* n = targetNode.get(); > > Use RefPtr here.
Since this raw pointer doesn't fall into my target ones at this moment, I didn't replace it. I am fine with replacing it with RefPtr.
Jiewen Tan
Comment 7
2017-10-06 11:14:40 PDT
Comment on
attachment 322692
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=322692&action=review
>>> Source/WebCore/dom/EventTarget.cpp:236 >>> + RefPtr<EventTarget> protectedThis(this); // Try to prevent this event target being removed by an event handler. >> >> I don't think we should add this protectThis objects in this refactoring effort. >> protectedThis is really an anti-pattern that only exists because we don't have caller which holds onto a Ref/RefPtr of this. > > True, we should deal with the heap raw pointers/references after dealing with the stack ones.
Removed.
>>> Source/WebCore/dom/MouseRelatedEvent.cpp:172 >>> + Node* n = targetNode.get(); >> >> Use RefPtr here. > > Since this raw pointer doesn't fall into my target ones at this moment, I didn't replace it. I am fine with replacing it with RefPtr.
Semantically, I didn't see the value of replacing this Node* n with RefPtr<Node>. Therefore, I didn't replace it.
Jiewen Tan
Comment 8
2017-10-06 11:18:12 PDT
Created
attachment 323029
[details]
Patch for landing
Build Bot
Comment 9
2017-10-06 11:20:11 PDT
Attachment 323029
[details]
did not pass style-queue: ERROR: Source/WebCore/dom/RadioButtonGroups.cpp:77: 'oldCheckedButton' is incorrectly named. It should be named 'protector' or 'protectedCheckedButton'. [readability/naming/protected] [4] ERROR: Source/WebCore/dom/ContainerNodeAlgorithms.cpp:158: 'next' is incorrectly named. It should be named 'protector' or 'protectedNullptr'. [readability/naming/protected] [4] Total errors found: 2 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 10
2017-10-06 13:10:29 PDT
Comment on
attachment 323029
[details]
Patch for landing Clearing flags on attachment: 323029 Committed
r222993
: <
http://trac.webkit.org/changeset/222993
>
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