Skip to content

Commit

Permalink
Deploy more smart pointers in AbortSignal.cpp, BroadcastChannel.cpp, …
Browse files Browse the repository at this point in the history
…NodeRareData.h, and Range.cpp

https://bugs.webkit.org/show_bug.cgi?id=264624

Reviewed by Chris Dumez.

Deploy smart pointers as warned by the clang static analyzer.

* Source/WebCore/dom/AbortSignal.cpp:
(WebCore::AbortSignal::throwIfAborted):
* Source/WebCore/dom/BroadcastChannel.cpp:
(WebCore::BroadcastChannel::MainThreadBridge::MainThreadBridge):
* Source/WebCore/dom/NodeRareData.h:
(WebCore::NodeListsNodeData::removeChildNodeList):
(WebCore::NodeListsNodeData::removeEmptyChildNodeList):
* Source/WebCore/dom/Range.cpp:
(WebCore::Range::processContents):
(WebCore::Range::surroundContents):
(WebCore::boundaryTextNodesSplit):

Canonical link: https://commits.webkit.org/270578@main
  • Loading branch information
rniwa committed Nov 11, 2023
1 parent 3dbba0e commit 97f82b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/dom/AbortSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void AbortSignal::throwIfAborted(JSC::JSGlobalObject& lexicalGlobalObject)
if (!aborted())
return;

auto& vm = lexicalGlobalObject.vm();
Ref vm = lexicalGlobalObject.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwException(&lexicalGlobalObject, scope, m_reason.getValue());
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/BroadcastChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ BroadcastChannel::MainThreadBridge::MainThreadBridge(BroadcastChannel& channel,
: m_broadcastChannel(channel)
, m_identifier(BroadcastChannelIdentifier::generate())
, m_name(name.isolatedCopy())
, m_origin(partitionedSecurityOriginFromContext(*channel.scriptExecutionContext()).isolatedCopy())
, m_origin(partitionedSecurityOriginFromContext(*channel.protectedScriptExecutionContext()).isolatedCopy())
{
}

Expand Down
6 changes: 4 additions & 2 deletions Source/WebCore/dom/NodeRareData.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class NodeListsNodeData {
void removeChildNodeList(ChildNodeList* list)
{
ASSERT(m_childNodeList == list);
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode()))
Ref ownerNode = list->ownerNode();
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(ownerNode))
return;
m_childNodeList = nullptr;
}
Expand All @@ -86,7 +87,8 @@ class NodeListsNodeData {
void removeEmptyChildNodeList(EmptyNodeList* list)
{
ASSERT(m_emptyChildNodeList == list);
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode()))
Ref ownerNode = list->ownerNode();
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(ownerNode))
return;
m_emptyChildNodeList = nullptr;
}
Expand Down
10 changes: 5 additions & 5 deletions Source/WebCore/dom/Range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ ExceptionOr<RefPtr<DocumentFragment>> Range::processContents(ActionType action)
ASSERT(commonRoot);

if (action == Extract) {
auto& commonRootDocument = commonRoot->document();
RefPtr doctype = commonRootDocument.doctype();
Ref commonRootDocument = commonRoot->document();
RefPtr doctype = commonRootDocument->doctype();
if (doctype && contains(makeSimpleRange(*this), { *doctype, 0 }))
return Exception { ExceptionCode::HierarchyRequestError };
}
Expand Down Expand Up @@ -847,10 +847,10 @@ ExceptionOr<void> Range::surroundContents(Node& newParent)
Ref protectedNewParent = newParent;

// Step 1: If a non-Text node is partially contained in the context object, then throw an InvalidStateError.
Node* startNonTextContainer = &startContainer();
RefPtr startNonTextContainer = &startContainer();
if (startNonTextContainer->nodeType() == Node::TEXT_NODE)
startNonTextContainer = startNonTextContainer->parentNode();
Node* endNonTextContainer = &endContainer();
RefPtr endNonTextContainer = &endContainer();
if (endNonTextContainer->nodeType() == Node::TEXT_NODE)
endNonTextContainer = endNonTextContainer->parentNode();
if (startNonTextContainer != endNonTextContainer)
Expand Down Expand Up @@ -1029,7 +1029,7 @@ void Range::textNodesMerged(NodeWithIndex& oldNode, unsigned offset)

static inline void boundaryTextNodesSplit(RangeBoundaryPoint& boundary, Text& oldNode)
{
auto* parent = oldNode.parentNode();
RefPtr parent = oldNode.parentNode();
if (&boundary.container() == &oldNode) {
unsigned splitOffset = oldNode.length();
unsigned boundaryOffset = boundary.offset();
Expand Down

0 comments on commit 97f82b7

Please sign in to comment.