Skip to content

Commit

Permalink
Some more assorted downcast<> cleanup in WebCore
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270782

Reviewed by Charlie Wolfe.

For security & performance.

* Source/WebCore/history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):
* Source/WebCore/rendering/RenderFragmentedFlow.h:
* Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp:
(WebCore::canMergeContiguousAnonymousBlocks):

Canonical link: https://commits.webkit.org/275961@main
  • Loading branch information
annevk committed Mar 12, 2024
1 parent 3130b40 commit b7a0227
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Source/WebCore/history/CachedFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ CachedFrame::CachedFrame(Frame& frame)
document->suspend(ReasonForSuspension::BackForwardCache);
}

m_cachedFrameScriptData = is<LocalFrame>(frame) ? makeUnique<ScriptCachedFrameData>(downcast<LocalFrame>(frame)) : nullptr;
RefPtr localFrame = dynamicDowncast<LocalFrame>(frame);
m_cachedFrameScriptData = localFrame ? makeUnique<ScriptCachedFrameData>(*localFrame) : nullptr;

if (document)
document->protectedWindow()->suspendForBackForwardCache();
Expand All @@ -195,7 +196,6 @@ CachedFrame::CachedFrame(Frame& frame)
localFrameView->resetLayoutMilestones();

// The main frame is reused for the navigation and the opener link to its should thus persist.
RefPtr localFrame = dynamicDowncast<LocalFrame>(frame);
if (localFrame) {
CheckedRef frameLoader = localFrame->loader();
if (!frame.isMainFrame())
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/rendering/RenderFragmentedFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class RenderFragmentedFlow: public RenderBlockFlow {

virtual void removeFlowChildInfo(RenderElement&);
#ifndef NDEBUG
bool hasChildInfo(RenderObject* child) const { return is<RenderBox>(child) && m_fragmentRangeMap.contains(downcast<RenderBox>(child)); }
bool hasChildInfo(RenderObject* child) const
{
auto* renderBox = dynamicDowncast<RenderBox>(child);
return renderBox && m_fragmentRangeMap.contains(*renderBox);
}
#endif

#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool canMergeContiguousAnonymousBlocks(RenderObject& oldChild, RenderObje
if (oldChild.isInline())
return false;

if (is<RenderBoxModelObject>(oldChild) && downcast<RenderBoxModelObject>(oldChild).continuation())
if (auto* boxModelObject = dynamicDowncast<RenderBoxModelObject>(oldChild); boxModelObject && boxModelObject->continuation())
return false;

if (previous) {
Expand Down

0 comments on commit b7a0227

Please sign in to comment.