Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt more smart pointers in History.cpp #27975

Conversation

rwlbuis
Copy link
Contributor

@rwlbuis rwlbuis commented May 1, 2024

@rwlbuis rwlbuis requested a review from cdumez as a code owner May 1, 2024 09:06
@rwlbuis rwlbuis self-assigned this May 1, 2024
@rwlbuis rwlbuis added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label May 1, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 1, 2024
@rwlbuis rwlbuis removed the merging-blocked Applied to prevent a change from being merged label May 1, 2024
@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from 6d52e3f to b7987e2 Compare May 1, 2024 09:23
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 1, 2024
@rwlbuis rwlbuis removed the merging-blocked Applied to prevent a change from being merged label May 1, 2024
@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from b7987e2 to 9faab32 Compare May 1, 2024 15:58
@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from 9faab32 to c8e85a2 Compare May 1, 2024 21:39
@rwlbuis rwlbuis requested review from szewai and removed request for cdumez May 1, 2024 21:40
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 2, 2024
@rwlbuis rwlbuis removed the merging-blocked Applied to prevent a change from being merged label May 2, 2024
@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from c8e85a2 to 04d2614 Compare May 2, 2024 08:41
return documentNotFullyActive();

auto* historyItem = frame->history().currentItem();
SUPPRESS_UNCOUNTED_LOCAL auto* historyItem = frame->history().currentItem();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add SUPPRESS_UNCOUNTED_LOCAL I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

return documentNotFullyActive();
m_lastStateObjectRequested = stateInternal();
return m_lastStateObjectRequested.get();
}

SerializedScriptValue* History::stateInternal() const
{
auto* frame = this->frame();
SUPPRESS_UNCOUNTED_LOCAL auto* frame = this->frame();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

if (!frame)
return nullptr;
auto* historyItem = frame->history().currentItem();
SUPPRESS_UNCOUNTED_LOCAL auto* historyItem = frame->history().currentItem();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also removed.

Comment on lines 200 to 201
return frame->document()->url();
return frame->document()->completeURL(urlString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to null check document (or assert) here, and protect it before invoking completeURL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I now use protectedDocument. For urlForState I removed reffing of the frame since the (only) caller (stateObjectAdded) already has a ref to the frame.

@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from 04d2614 to 4311ea4 Compare May 2, 2024 18:10
@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from 4311ea4 to c1353ce Compare May 2, 2024 18:23
@rwlbuis rwlbuis requested review from cdumez and szewai May 2, 2024 21:30
return documentNotFullyActive();

auto* historyItem = frame->history().currentItem();
RefPtr historyItem = frame->history().currentItem();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this can be simplified as:

if (RefPtr historyItem = frame->history().currentItem())
    historyItem->setShouldRestoreScrollPosition(scrollRestoration == ScrollRestoration::Auto);

@rwlbuis rwlbuis force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from c1353ce to 3ecb068 Compare May 3, 2024 08:19
@rwlbuis rwlbuis added the merge-queue Applied to send a pull request to merge-queue label May 3, 2024
https://bugs.webkit.org/show_bug.cgi?id=273541

Reviewed by Sihui Liu.

Adopt more smart pointers in History.cpp based on the
[alpha.webkit.UncountedLocalVarsChecker] warning.

* Source/WebCore/page/History.cpp:
(WebCore::History::length const):
(WebCore::History::scrollRestoration const):
(WebCore::History::setScrollRestoration):
(WebCore::History::go):
(WebCore::History::urlForState):

Canonical link: https://commits.webkit.org/278310@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Adopt-more-smart-pointers-in-History-cpp branch from 3ecb068 to cde4840 Compare May 3, 2024 10:09
@webkit-commit-queue
Copy link
Collaborator

Committed 278310@main (cde4840): https://commits.webkit.org/278310@main

Reviewed commits have been landed. Closing PR #27975 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit cde4840 into WebKit:main May 3, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 3, 2024
@rwlbuis rwlbuis deleted the eng/Adopt-more-smart-pointers-in-History-cpp branch May 3, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
6 participants