Skip to content

Commit

Permalink
Adopt even more smart pointers in DOM code
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263505

Reviewed by Darin Adler.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::protectedWindowProxy const):
(WebCore::Document::checkedSelection):
(WebCore::Document::checkedSelection const):
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/DocumentParser.cpp:
(WebCore::DocumentParser::protectedDocument const):
* Source/WebCore/dom/DocumentParser.h:
* Source/WebCore/dom/PendingScript.h:
* Source/WebCore/dom/Range.cpp:
(WebCore::Range::Range):
(WebCore::Range::~Range):
(WebCore::Range::protectedOwnerDocument):
(WebCore::Range::updateAssociatedSelection):
(WebCore::Range::updateAssociatedHighlight):
(WebCore::Range::updateDocument):
(WebCore::childOfCommonRootBeforeOffset):
(WebCore::Range::protectedStartContainer const):
(WebCore::Range::protectedEndContainer const):
(WebCore::Range::processContents):
(WebCore::processContentsBetweenOffsets):
(WebCore::processAncestorsAndTheirSiblings):
(WebCore::Range::insertNode):
(WebCore::Range::toString const):
(WebCore::Range::createContextualFragment):
(WebCore::Range::checkNodeOffsetPair):
(WebCore::Range::cloneRange const):
(WebCore::Range::setStartAfter):
(WebCore::Range::setEndBefore):
(WebCore::Range::setEndAfter):
(WebCore::Range::selectNode):
(WebCore::Range::surroundContents):
(WebCore::Range::setStartBefore):
(WebCore::Range::updateRangeForParentlessNodeMovedToNewDocument):
(WebCore::boundaryTextNodesMerged):
(WebCore::boundaryTextNodesSplit):
(WebCore::Range::expand):
(WebCore::Range::getClientRects const):
(WebCore::Range::getBoundingClientRect const):
(WebCore::setBothEndpoints):
(WebCore::makeSimpleRange):
(WebCore::createLiveRange):
* Source/WebCore/dom/Range.h:
* Source/WebCore/dom/RangeBoundaryPoint.h:
(WebCore::RangeBoundaryPoint::set):
(WebCore::RangeBoundaryPoint::setToAfterNode):
* Source/WebCore/dom/RawDataDocumentParser.h:
* Source/WebCore/dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* Source/WebCore/dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::dispatchEvent const):
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::ref const):
(WebCore::ScriptElement::deref const):
(WebCore::ScriptElement::ref): Deleted.
(WebCore::ScriptElement::deref): Deleted.
* Source/WebCore/dom/ScriptElement.h:
* Source/WebCore/dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::~ScriptRunner):
(WebCore::ScriptRunner::queueScriptForExecution):
(WebCore::ScriptRunner::resume):
(WebCore::ScriptRunner::notifyFinished):
(WebCore::ScriptRunner::timerFired):
* Source/WebCore/dom/ScriptRunner.h:
* Source/WebCore/dom/ScriptableDocumentParser.cpp:
(WebCore::ScriptableDocumentParser::scriptsWaitingForStylesheetsExecutionTimerFired):
* Source/WebCore/dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::registerCallback):
(WebCore::ScriptedAnimationController::cancelCallback):
(WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
(WebCore::ScriptedAnimationController::scheduleAnimation):
(WebCore::ScriptedAnimationController::protectedDocument):
* Source/WebCore/dom/ScriptedAnimationController.h:
* Source/WebCore/dom/SecurityContext.cpp:
(WebCore::SecurityContext::inheritPolicyContainerFrom):
(WebCore::SecurityContext::checkedContentSecurityPolicy):
* Source/WebCore/dom/SecurityContext.h:
* Source/WebCore/dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::insertedIntoAncestor):
(WebCore::ShadowRoot::removedFromAncestor):
(WebCore::ShadowRoot::moveShadowRootToNewParentScope):
(WebCore::ShadowRoot::removeAllEventListeners):
(WebCore::ShadowRoot::findAssignedSlot):
(WebCore::ShadowRoot::assignedNodesForSlot):
(WebCore::assignedShadowRootsIfSlotted):
(): Deleted.
* Source/WebCore/dom/ShadowRoot.h:
* Source/WebCore/dom/SimpleRange.cpp:
(WebCore::makeRangeSelectingNode):
* Source/WebCore/dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent):
(WebCore::simulateClick):
* Source/WebCore/dom/SlotAssignment.cpp:
(WebCore::NamedSlotAssignment::addSlotElementByName):
(WebCore::NamedSlotAssignment::didChangeSlot):
(WebCore::NamedSlotAssignment::assignSlots):
(WebCore::ManualSlotAssignment::addSlotElementByName):
(WebCore::ManualSlotAssignment::slotManualAssignmentDidChange):
(WebCore::ManualSlotAssignment::didRemoveManuallyAssignedNode):
* Source/WebCore/dom/StaticRange.cpp:
(WebCore::StaticRange::create):
* Source/WebCore/dom/StringCallback.cpp:
(WebCore::StringCallback::scheduleCallback):
* Source/WebCore/dom/StyledElement.cpp:
(WebCore::StyledElement::setInlineStyleFromString):
(WebCore::StyledElement::invalidateStyleAttribute):
(WebCore::StyledElement::addSubresourceAttributeURLs const):
* Source/WebCore/dom/TagCollection.cpp:
(WebCore::TagCollectionNS::~TagCollectionNS):
(WebCore::TagCollection::~TagCollection):
(WebCore::HTMLTagCollection::~HTMLTagCollection):
* Source/WebCore/dom/TemplateContentDocumentFragment.h:
* Source/WebCore/dom/Text.cpp:
(WebCore::Text::splitText):
(WebCore::Text::replaceWholeText):
(WebCore::Text::virtualCreate):
(WebCore::Text::updateRendererAfterContentChange):
(WebCore::Text::setDataAndUpdate):
* Source/WebCore/dom/TextDecoderStreamDecoder.cpp:
(WebCore::TextDecoderStreamDecoder::decode):
(WebCore::TextDecoderStreamDecoder::flush):
(WebCore::TextDecoderStreamDecoder::protectedTextDecoder):
* Source/WebCore/dom/TextDecoderStreamDecoder.h:
* Source/WebCore/editing/FrameSelection.h:
* Source/WebCore/page/csp/ContentSecurityPolicy.h:

Canonical link: https://commits.webkit.org/269644@main
  • Loading branch information
cdumez committed Oct 23, 2023
1 parent c69c97c commit 0e12ca3
Show file tree
Hide file tree
Showing 38 changed files with 252 additions and 172 deletions.
15 changes: 15 additions & 0 deletions Source/WebCore/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5488,6 +5488,11 @@ WindowProxy* Document::windowProxy() const
return &m_frame->windowProxy();
}

RefPtr<WindowProxy> Document::protectedWindowProxy() const
{
return windowProxy();
}

Document& Document::contextDocument() const
{
if (m_contextDocument)
Expand Down Expand Up @@ -7428,6 +7433,16 @@ void Document::clearScriptedAnimationController()
scriptedAnimationController->clearDocumentPointer();
}

CheckedRef<FrameSelection> Document::checkedSelection()
{
return m_selection.get();
}

CheckedRef<const FrameSelection> Document::checkedSelection() const
{
return m_selection.get();
}

int Document::requestIdleCallback(Ref<IdleRequestCallback>&& callback, Seconds timeout)
{
if (!m_idleCallbackController)
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/dom/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ class Document

// In DOM Level 2, the Document's LocalDOMWindow is called the defaultView.
WEBCORE_EXPORT WindowProxy* windowProxy() const;
RefPtr<WindowProxy> protectedWindowProxy() const;

inline bool hasBrowsingContext() const; // Defined in DocumentInlines.h.

Expand Down Expand Up @@ -1775,6 +1776,8 @@ class Document
const Editor& editor() const { return m_editor; }
FrameSelection& selection() { return m_selection; }
const FrameSelection& selection() const { return m_selection; }
CheckedRef<FrameSelection> checkedSelection();
CheckedRef<const FrameSelection> checkedSelection() const;

void setFragmentDirective(const String& fragmentDirective) { m_fragmentDirective = fragmentDirective; }
const String& fragmentDirective() const { return m_fragmentDirective; }
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/dom/DocumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ void DocumentParser::resumeScheduledTasks()
{
}

RefPtr<Document> DocumentParser::protectedDocument() const
{
return document();
}

} // namespace WebCore
1 change: 1 addition & 0 deletions Source/WebCore/dom/DocumentParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DocumentParser : public RefCounted<DocumentParser> {

// document() will return 0 after detach() is called.
Document* document() const { ASSERT(m_document); return m_document.get(); }
RefPtr<Document> protectedDocument() const;

bool isParsing() const { return m_state == ParserState::Parsing; }
bool isStopping() const { return m_state == ParserState::Stopping; }
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/dom/PendingScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class PendingScript final : public RefCounted<PendingScript>, public LoadableScr

ScriptElement& element() { return m_element.get(); }
const ScriptElement& element() const { return m_element.get(); }
Ref<ScriptElement> protectedElement() { return m_element; }
Ref<const ScriptElement> protectedElement() const { return m_element; }

LoadableScript* loadableScript() const;
bool needsLoading() const { return loadableScript(); }
Expand Down
Loading

0 comments on commit 0e12ca3

Please sign in to comment.