Skip to content

Commit

Permalink
DrawingAreaProxy should hold a CheckedRef to WebPageProxy instead of …
Browse files Browse the repository at this point in the history
…a raw reference

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

Reviewed by Chris Dumez.

Use CheckedRef to point to WebPageProxy as warned by the clang static analyzer.

* Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
(WebKit::DrawingAreaProxyCoordinatedGraphics::forceUpdateIfNeeded):
(WebKit::DrawingAreaProxyCoordinatedGraphics::incorporateUpdate):
(WebKit::DrawingAreaProxyCoordinatedGraphics::sizeDidChange):
(WebKit::DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange):
(WebKit::DrawingAreaProxyCoordinatedGraphics::adjustTransientZoom):
(WebKit::DrawingAreaProxyCoordinatedGraphics::commitTransientZoom):
(WebKit::DrawingAreaProxyCoordinatedGraphics::update):
(WebKit::DrawingAreaProxyCoordinatedGraphics::targetRefreshRateDidChange):
(WebKit::DrawingAreaProxyCoordinatedGraphics::alwaysUseCompositing const):
(WebKit::DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyCoordinatedGraphics::exitAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyCoordinatedGraphics::updateAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyCoordinatedGraphics::sendUpdateGeometry):
(WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStore):
(WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):
* Source/WebKit/UIProcess/DrawingAreaProxy.cpp:
(WebKit::DrawingAreaProxy::protectedWebPageProxy const):
(WebKit::DrawingAreaProxy::didChangeViewExposedRect):
(WebKit::DrawingAreaProxy::viewExposedRectChangedTimerFired):
* Source/WebKit/UIProcess/DrawingAreaProxy.h:
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
(WebKit::RemoteLayerTreeDrawingAreaProxy::sizeDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxy::viewWillStartLiveResize):
(WebKit::RemoteLayerTreeDrawingAreaProxy::viewWillEndLiveResize):
(WebKit::RemoteLayerTreeDrawingAreaProxy::deviceScaleFactorDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxy::didUpdateGeometry):
(WebKit::RemoteLayerTreeDrawingAreaProxy::sendUpdateGeometry):
(WebKit::RemoteLayerTreeDrawingAreaProxy::processStateForConnection):
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTreeNotTriggered):
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTreeTransaction):
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidEnd):
(WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorLocation const):
(WebKit::RemoteLayerTreeDrawingAreaProxy::indicatorScale const):
(WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
(WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay):
(WebKit::RemoteLayerTreeDrawingAreaProxy::windowKindDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxy::minimumSizeForAutoLayoutDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxy::sizeToContentAutoSizeMaximumSizeDidChange):
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeDrawingAreaProxyMac.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::createScrollingCoordinatorProxy const):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::existingDisplayLink):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::displayLink):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::layoutBannerLayers):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::didCommitLayerTree):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::adjustTransientZoom):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::commitTransientZoom):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::windowScreenDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::didRefreshDisplay):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::colorSpaceDidChange):
(WebKit::RemoteLayerTreeDrawingAreaProxyMac::createFence):
* Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::sizeDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::colorSpaceDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::minimumSizeForAutoLayoutDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::sizeToContentAutoSizeMaximumSizeDidChange):
(WebKit::TiledCoreAnimationDrawingAreaProxy::enterAcceleratedCompositingMode):
(WebKit::TiledCoreAnimationDrawingAreaProxy::updateAcceleratedCompositingMode):
(WebKit::TiledCoreAnimationDrawingAreaProxy::didFirstLayerFlush):
(WebKit::TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry):
(WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateActivityState):
(WebKit::TiledCoreAnimationDrawingAreaProxy::willSendUpdateGeometry):
(WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
(WebKit::TiledCoreAnimationDrawingAreaProxy::sendUpdateGeometry):
(WebKit::TiledCoreAnimationDrawingAreaProxy::adjustTransientZoom):
(WebKit::TiledCoreAnimationDrawingAreaProxy::commitTransientZoom):
(WebKit::TiledCoreAnimationDrawingAreaProxy::displayNominalFramesPerSecond):
* Source/WebKit/UIProcess/wc/DrawingAreaProxyWC.cpp:
(WebKit::DrawingAreaProxyWC::sizeDidChange):
(WebKit::DrawingAreaProxyWC::update):
(WebKit::DrawingAreaProxyWC::incorporateUpdate):

Canonical link: https://commits.webkit.org/267845@main
  • Loading branch information
rniwa committed Sep 10, 2023
1 parent 3d6b8f4 commit d7c53fa
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,22 @@ bool DrawingAreaProxyCoordinatedGraphics::forceUpdateIfNeeded()
{
ASSERT(!isInAcceleratedCompositingMode());

if (!m_webPageProxy.hasRunningProcess())
auto webPageProxy = protectedWebPageProxy();
if (!webPageProxy->hasRunningProcess())
return false;

if (m_webPageProxy.process().state() == WebProcessProxy::State::Launching)
if (webPageProxy->process().state() == WebProcessProxy::State::Launching)
return false;

if (m_isWaitingForDidUpdateGeometry)
return false;

if (!m_webPageProxy.isViewVisible())
if (!webPageProxy->isViewVisible())
return false;

SetForScope inForceUpdate(m_inForceUpdate, true);
m_webPageProxy.send(Messages::DrawingArea::ForceUpdate(), m_identifier);
m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::Update>(m_identifier, Seconds::fromMilliseconds(500));
webPageProxy->send(Messages::DrawingArea::ForceUpdate(), m_identifier);
webPageProxy->process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::Update>(m_identifier, Seconds::fromMilliseconds(500));
return !!m_backingStore;
}

Expand All @@ -114,7 +115,7 @@ void DrawingAreaProxyCoordinatedGraphics::incorporateUpdate(UpdateInfo&& updateI
return;

if (!m_backingStore || m_backingStore->size() != updateInfo.viewSize || m_backingStore->deviceScaleFactor() != updateInfo.deviceScaleFactor)
m_backingStore = makeUnique<BackingStore>(updateInfo.viewSize, updateInfo.deviceScaleFactor, m_webPageProxy);
m_backingStore = makeUnique<BackingStore>(updateInfo.viewSize, updateInfo.deviceScaleFactor, protectedWebPageProxy());

if (m_inForceUpdate) {
m_backingStore->incorporateUpdate(WTFMove(updateInfo));
Expand All @@ -126,16 +127,16 @@ void DrawingAreaProxyCoordinatedGraphics::incorporateUpdate(UpdateInfo&& updateI
for (const auto& rect : updateInfo.updateRects)
damageRegion.unite(rect);
} else
damageRegion = IntRect(IntPoint(), m_webPageProxy.viewSize());
damageRegion = IntRect(IntPoint(), m_webPageProxy->viewSize());

m_backingStore->incorporateUpdate(WTFMove(updateInfo));
m_webPageProxy.setViewNeedsDisplay(damageRegion);
protectedWebPageProxy()->setViewNeedsDisplay(damageRegion);
}
#endif

void DrawingAreaProxyCoordinatedGraphics::sizeDidChange()
{
if (!m_webPageProxy.hasRunningProcess())
if (!m_webPageProxy->hasRunningProcess())
return;

if (m_isWaitingForDidUpdateGeometry)
Expand All @@ -146,7 +147,7 @@ void DrawingAreaProxyCoordinatedGraphics::sizeDidChange()

void DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange()
{
m_webPageProxy.send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy.deviceScaleFactor()), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy->deviceScaleFactor()), m_identifier);
}

void DrawingAreaProxyCoordinatedGraphics::setBackingStoreIsDiscardable(bool isBackingStoreDiscardable)
Expand All @@ -166,19 +167,19 @@ void DrawingAreaProxyCoordinatedGraphics::setBackingStoreIsDiscardable(bool isBa
#if PLATFORM(GTK)
void DrawingAreaProxyCoordinatedGraphics::adjustTransientZoom(double scale, FloatPoint origin)
{
m_webPageProxy.send(Messages::DrawingArea::AdjustTransientZoom(scale, origin), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::AdjustTransientZoom(scale, origin), m_identifier);
}

void DrawingAreaProxyCoordinatedGraphics::commitTransientZoom(double scale, FloatPoint origin)
{
m_webPageProxy.send(Messages::DrawingArea::CommitTransientZoom(scale, origin), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::CommitTransientZoom(scale, origin), m_identifier);
}
#endif

void DrawingAreaProxyCoordinatedGraphics::update(uint64_t, UpdateInfo&& updateInfo)
{
if (m_isWaitingForDidUpdateGeometry && updateInfo.viewSize != m_lastSentSize) {
m_webPageProxy.send(Messages::DrawingArea::DisplayDidRefresh(), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::DisplayDidRefresh(), m_identifier);
return;
}

Expand All @@ -189,7 +190,7 @@ void DrawingAreaProxyCoordinatedGraphics::update(uint64_t, UpdateInfo&& updateIn
#endif

if (!m_isWaitingForDidUpdateGeometry)
m_webPageProxy.send(Messages::DrawingArea::DisplayDidRefresh(), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::DisplayDidRefresh(), m_identifier);
}

void DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode(uint64_t, const LayerTreeContext& layerTreeContext)
Expand All @@ -212,12 +213,12 @@ void DrawingAreaProxyCoordinatedGraphics::updateAcceleratedCompositingMode(uint6

void DrawingAreaProxyCoordinatedGraphics::targetRefreshRateDidChange(unsigned rate)
{
m_webPageProxy.send(Messages::DrawingArea::TargetRefreshRateDidChange(rate), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::TargetRefreshRateDidChange(rate), m_identifier);
}

bool DrawingAreaProxyCoordinatedGraphics::alwaysUseCompositing() const
{
return m_webPageProxy.preferences().acceleratedCompositingEnabled() && m_webPageProxy.preferences().forceCompositingMode();
return m_webPageProxy->preferences().acceleratedCompositingEnabled() && m_webPageProxy->preferences().forceCompositingMode();
}

void DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
Expand All @@ -227,23 +228,23 @@ void DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode(const
m_backingStore = nullptr;
#endif
m_layerTreeContext = layerTreeContext;
m_webPageProxy.enterAcceleratedCompositingMode(layerTreeContext);
protectedWebPageProxy()->enterAcceleratedCompositingMode(layerTreeContext);
}

void DrawingAreaProxyCoordinatedGraphics::exitAcceleratedCompositingMode()
{
ASSERT(isInAcceleratedCompositingMode());

m_layerTreeContext = { };
m_webPageProxy.exitAcceleratedCompositingMode();
protectedWebPageProxy()->exitAcceleratedCompositingMode();
}

void DrawingAreaProxyCoordinatedGraphics::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
ASSERT(isInAcceleratedCompositingMode());

m_layerTreeContext = layerTreeContext;
m_webPageProxy.updateAcceleratedCompositingMode(layerTreeContext);
protectedWebPageProxy()->updateAcceleratedCompositingMode(layerTreeContext);
}

void DrawingAreaProxyCoordinatedGraphics::sendUpdateGeometry()
Expand All @@ -252,7 +253,7 @@ void DrawingAreaProxyCoordinatedGraphics::sendUpdateGeometry()
m_lastSentSize = m_size;
m_isWaitingForDidUpdateGeometry = true;

m_webPageProxy.sendWithAsyncReply(Messages::DrawingArea::UpdateGeometry(m_size), [weakThis = WeakPtr { *this }] {
protectedWebPageProxy()->sendWithAsyncReply(Messages::DrawingArea::UpdateGeometry(m_size), [weakThis = WeakPtr { *this }] {
if (!weakThis)
return;
weakThis->didUpdateGeometry();
Expand Down Expand Up @@ -290,7 +291,7 @@ void DrawingAreaProxyCoordinatedGraphics::discardBackingStore()
return;

m_backingStore = nullptr;
m_webPageProxy.send(Messages::DrawingArea::DidDiscardBackingStore(), m_identifier);
protectedWebPageProxy()->send(Messages::DrawingArea::DidDiscardBackingStore(), m_identifier);
}
#endif

Expand Down Expand Up @@ -364,13 +365,14 @@ void DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::didDraw()

void DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing(CompletionHandler<void()>&& callbackFunction)
{
if (!m_webPageProxy.hasRunningProcess()) {
auto webPageProxy = protectedWebPageProxy();
if (!webPageProxy->hasRunningProcess()) {
callbackFunction();
return;
}

if (!m_drawingMonitor)
m_drawingMonitor = makeUnique<DrawingAreaProxyCoordinatedGraphics::DrawingMonitor>(m_webPageProxy);
m_drawingMonitor = makeUnique<DrawingAreaProxyCoordinatedGraphics::DrawingMonitor>(webPageProxy);
m_drawingMonitor->start(WTFMove(callbackFunction));
}

Expand Down
13 changes: 9 additions & 4 deletions Source/WebKit/UIProcess/DrawingAreaProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ DrawingAreaProxy::DrawingAreaProxy(DrawingAreaType type, WebPageProxy& webPagePr

DrawingAreaProxy::~DrawingAreaProxy() = default;

Ref<WebPageProxy> DrawingAreaProxy::protectedWebPageProxy() const
{
return m_webPageProxy.get();
}

void DrawingAreaProxy::startReceivingMessages(WebProcessProxy& process)
{
for (auto& name : messageReceiverNames())
Expand Down Expand Up @@ -96,7 +101,7 @@ MachSendRight DrawingAreaProxy::createFence()
#if PLATFORM(MAC)
void DrawingAreaProxy::didChangeViewExposedRect()
{
if (!m_webPageProxy.hasRunningProcess())
if (!m_webPageProxy->hasRunningProcess())
return;

if (!m_viewExposedRectChangedTimer.isActive())
Expand All @@ -105,14 +110,14 @@ void DrawingAreaProxy::didChangeViewExposedRect()

void DrawingAreaProxy::viewExposedRectChangedTimerFired()
{
if (!m_webPageProxy.hasRunningProcess())
if (!m_webPageProxy->hasRunningProcess())
return;

auto viewExposedRect = m_webPageProxy.viewExposedRect();
auto viewExposedRect = m_webPageProxy->viewExposedRect();
if (viewExposedRect == m_lastSentViewExposedRect)
return;

m_webPageProxy.send(Messages::DrawingArea::SetViewExposedRect(viewExposedRect), m_identifier);
m_webPageProxy->send(Messages::DrawingArea::SetViewExposedRect(viewExposedRect), m_identifier);
m_lastSentViewExposedRect = viewExposedRect;
}
#endif // PLATFORM(MAC)
Expand Down
5 changes: 4 additions & 1 deletion Source/WebKit/UIProcess/DrawingAreaProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <WebCore/IntRect.h>
#include <WebCore/IntSize.h>
#include <stdint.h>
#include <wtf/CheckedRef.h>
#include <wtf/Noncopyable.h>
#include <wtf/RunLoop.h>
#include <wtf/TypeCasts.h>
Expand Down Expand Up @@ -139,9 +140,11 @@ class DrawingAreaProxy : public IPC::MessageReceiver {
protected:
DrawingAreaProxy(DrawingAreaType, WebPageProxy&);

Ref<WebPageProxy> protectedWebPageProxy() const;

DrawingAreaType m_type;
DrawingAreaIdentifier m_identifier;
WebPageProxy& m_webPageProxy;
CheckedRef<WebPageProxy> m_webPageProxy;

WebCore::IntSize m_size;
WebCore::IntSize m_scrollOffset;
Expand Down
Loading

0 comments on commit d7c53fa

Please sign in to comment.