WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
171645
Drop remaining uses of PassRefPtr from CompositeEditCommand
https://bugs.webkit.org/show_bug.cgi?id=171645
Summary
Drop remaining uses of PassRefPtr from CompositeEditCommand
Chris Dumez
Reported
2017-05-03 21:34:32 PDT
Drop remaining uses of PassRefPtr from CompositeEditCommand.
Attachments
Patch
(102.11 KB, patch)
2017-05-03 21:35 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(102.46 KB, patch)
2017-05-03 21:56 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(116.32 KB, patch)
2017-05-04 20:50 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2017-05-03 21:35:43 PDT
Created
attachment 309013
[details]
Patch
Chris Dumez
Comment 2
2017-05-03 21:56:59 PDT
Created
attachment 309015
[details]
Patch
Darin Adler
Comment 3
2017-05-04 17:51:42 PDT
Comment on
attachment 309015
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=309015&action=review
> Source/WebCore/editing/CompositeEditCommand.cpp:308 > -void applyCommand(PassRefPtr<CompositeEditCommand> command) > +void applyCommand(CompositeEditCommand& command) > { > - command->apply(); > + command.apply(); > }
This gets rid of the protection that references the command for the duration of apply. Is that OK? If we don’t need protection, then why do we need this function if this is literally its implementation? Seems like we should dump it and change call sites to call apply directly.
> Source/WebCore/editing/CompositeEditCommand.cpp:654 > + if (RefPtr<Node> highestNodeToRemove = highestNodeToRemoveInPruning(node)) > + removeNode(*highestNodeToRemove);
Seems strange to get a RefPtr here instead of a raw pointer just to call removeNode. Seems that removeNode itself needs to protect the node, but not the caller.
> Source/WebCore/editing/DeleteSelectionCommand.cpp:379 > +void DeleteSelectionCommand::removeNode(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
Is this function guaranteed to do the right thing without protecting "node"? I couldn’t tell if so just by reading the code quickly.
> Source/WebCore/editing/DeleteSelectionCommand.cpp:654 > if (!endBlock || !endBlock->contains(startOfParagraphToMove.deepEquivalent().deprecatedNode()) || !startOfParagraphToMove.deepEquivalent().deprecatedNode()) { > - removeNode(enclosingBlock(m_downstreamEnd.deprecatedNode())); > + if (endBlock) > + removeNode(*endBlock); > return; > }
Maybe should break this up: if (!endBlock) return; if (!endBlock->contains[...]) { removeNode(*endBlock); return; }
> Source/WebCore/editing/Editor.cpp:3624 > + auto replaceCommand = ReplaceRangeWithTextCommand::create(range.get(), acceptedCandidate.replacement); > + applyCommand(replaceCommand);
Shorter as a one-liner.
> Source/WebCore/editing/ReplaceSelectionCommand.cpp:227 > +void ReplacementFragment::removeNodePreservingChildren(Node& node)
I think the node needs to be protected while removing its children.
Chris Dumez
Comment 4
2017-05-04 18:49:46 PDT
Comment on
attachment 309015
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=309015&action=review
>> Source/WebCore/editing/CompositeEditCommand.cpp:308 >> } > > This gets rid of the protection that references the command for the duration of apply. Is that OK? > > If we don’t need protection, then why do we need this function if this is literally its implementation? Seems like we should dump it and change call sites to call apply directly.
command is not used in this function after the call to apply(). Therefore, I do not think ref'ing command for the duration of this function can be useful. I would agree it would make sense to get rid of this function all together.
>> Source/WebCore/editing/CompositeEditCommand.cpp:654 >> + removeNode(*highestNodeToRemove); > > Seems strange to get a RefPtr here instead of a raw pointer just to call removeNode. Seems that removeNode itself needs to protect the node, but not the caller.
ok
>> Source/WebCore/editing/DeleteSelectionCommand.cpp:379 >> +void DeleteSelectionCommand::removeNode(Node& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) > > Is this function guaranteed to do the right thing without protecting "node"? I couldn’t tell if so just by reading the code quickly.
It is hard to tell, I think I will protect it to maintain previous behavior.
>> Source/WebCore/editing/DeleteSelectionCommand.cpp:654 >> } > > Maybe should break this up: > > if (!endBlock) > return; > if (!endBlock->contains[...]) { > removeNode(*endBlock); > return; > }
ok
>> Source/WebCore/editing/Editor.cpp:3624 >> + applyCommand(replaceCommand); > > Shorter as a one-liner.
ok
>> Source/WebCore/editing/ReplaceSelectionCommand.cpp:227 >> +void ReplacementFragment::removeNodePreservingChildren(Node& node) > > I think the node needs to be protected while removing its children.
ok.
Chris Dumez
Comment 5
2017-05-04 20:50:58 PDT
Created
attachment 309138
[details]
Patch
WebKit Commit Bot
Comment 6
2017-05-04 22:10:00 PDT
Comment on
attachment 309138
[details]
Patch Clearing flags on attachment: 309138 Committed
r216233
: <
http://trac.webkit.org/changeset/216233
>
WebKit Commit Bot
Comment 7
2017-05-04 22:10:02 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 8
2017-05-05 16:33:21 PDT
Comment on
attachment 309015
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=309015&action=review
>>> Source/WebCore/editing/CompositeEditCommand.cpp:308 >>> } >> >> This gets rid of the protection that references the command for the duration of apply. Is that OK? >> >> If we don’t need protection, then why do we need this function if this is literally its implementation? Seems like we should dump it and change call sites to call apply directly. > > command is not used in this function after the call to apply(). Therefore, I do not think ref'ing command for the duration of this function can be useful. I would agree it would make sense to get rid of this function all together.
I was worrying about code *inside* apply indirectly causing the command to be deref’d. Maybe that’s not a real issue.
Chris Dumez
Comment 9
2017-05-05 16:52:22 PDT
(In reply to Darin Adler from
comment #8
)
> Comment on
attachment 309015
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=309015&action=review
> > >>> Source/WebCore/editing/CompositeEditCommand.cpp:308 > >>> } > >> > >> This gets rid of the protection that references the command for the duration of apply. Is that OK? > >> > >> If we don’t need protection, then why do we need this function if this is literally its implementation? Seems like we should dump it and change call sites to call apply directly. > > > > command is not used in this function after the call to apply(). Therefore, I do not think ref'ing command for the duration of this function can be useful. I would agree it would make sense to get rid of this function all together. > > I was worrying about code *inside* apply indirectly causing the command to > be deref’d. Maybe that’s not a real issue.
Oh, I undestand now. I'll double check to make sure it is safe.
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