Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 8d503c6

Browse files
Bug 1543315 - part 13: Mark PresShell::Paint() as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D30008 --HG-- extra : moz-landing-system : lando
1 parent 193d49c commit 8d503c6

11 files changed

Lines changed: 31 additions & 19 deletions

dom/base/nsDOMWindowUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ nsDOMWindowUtils::UpdateLayerTree() {
378378
presShell->FlushPendingNotifications(
379379
ChangesToFlush(FlushType::Display, false /* flush animations */));
380380
RefPtr<nsViewManager> vm = presShell->GetViewManager();
381-
nsView* view = vm->GetRootView();
382-
if (view) {
381+
if (nsView* view = vm->GetRootView()) {
383382
nsAutoScriptBlocker scriptBlocker;
384383
presShell->Paint(
385384
view, view->GetBounds(),

dom/ipc/BrowserChild.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ class BrowserChild final : public BrowserChildBase,
701701
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(
702702
const bool& aIsActive) override;
703703

704+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
704705
virtual mozilla::ipc::IPCResult RecvRenderLayers(
705706
const bool& aEnabled, const bool& aForce,
706707
const layers::LayersObserverEpoch& aEpoch) override;

layout/base/PresShell.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,7 @@ class PresShell final : public nsStubDocumentObserver,
12821282
void ThemeChanged() { mPresContext->ThemeChanged(); }
12831283
void BackingScaleFactorChanged() { mPresContext->UIResolutionChangedSync(); }
12841284

1285-
// nsIViewObserver interface
1286-
1285+
MOZ_CAN_RUN_SCRIPT
12871286
void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
12881287
PaintFlags aFlags);
12891288

layout/forms/nsComboboxControlFrame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,8 @@ bool nsComboboxControlFrame::Rollup(uint32_t aCount, bool aFlush,
13881388
if (aFlush && weakFrame.IsAlive()) {
13891389
// The popup's visibility doesn't update until the minimize animation has
13901390
// finished, so call UpdateWidgetGeometry to update it right away.
1391-
nsViewManager* viewManager = mDropdownFrame->GetView()->GetViewManager();
1391+
RefPtr<nsViewManager> viewManager =
1392+
mDropdownFrame->GetView()->GetViewManager();
13921393
viewManager->UpdateWidgetGeometry(); // might destroy us
13931394
}
13941395

layout/forms/nsComboboxControlFrame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class nsComboboxControlFrame final : public nsBlockFrame,
184184
* Hide the dropdown menu and stop capturing mouse events.
185185
* @note This method might destroy |this|.
186186
*/
187+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
187188
virtual bool Rollup(uint32_t aCount, bool aFlush, const nsIntPoint* pos,
188189
nsIContent** aLastRolledUp) override;
189190
virtual void NotifyGeometryChange() override;

layout/xul/nsXULPopupManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class nsXULPopupManager final : public nsIDOMEventListener,
333333
NS_DECL_NSIDOMEVENTLISTENER
334334

335335
// nsIRollupListener
336+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
336337
virtual bool Rollup(uint32_t aCount, bool aFlush, const nsIntPoint* pos,
337338
nsIContent** aLastRolledUp) override;
338339
virtual bool ShouldRollupOnMouseWheelEvent() override;

view/nsView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ class nsView final : public nsIWidgetListener {
389389
virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
390390
int32_t aHeight) override;
391391
virtual bool RequestWindowClose(nsIWidget* aWidget) override;
392+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
392393
virtual void WillPaintWindow(nsIWidget* aWidget) override;
394+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
393395
virtual bool PaintWindow(nsIWidget* aWidget,
394396
LayoutDeviceIntRegion aRegion) override;
395397
virtual void DidPaintWindow() override;

view/nsViewManager.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,17 @@ void nsViewManager::Refresh(nsView* aView,
326326
NS_ASSERTION(GetDisplayRootFor(aView) == aView,
327327
"Widgets that we paint must all be display roots");
328328

329-
if (mPresShell) {
329+
if (RefPtr<PresShell> presShell = mPresShell) {
330330
#ifdef MOZ_DUMP_PAINTING
331331
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
332-
printf_stderr("--COMPOSITE-- %p\n", mPresShell);
332+
printf_stderr("--COMPOSITE-- %p\n", presShell.get());
333333
}
334334
#endif
335-
PaintFlags paintFlags = PaintFlags::PaintComposite;
336335
LayerManager* manager = widget->GetLayerManager();
337336
if (!manager->NeedsWidgetInvalidation()) {
338337
manager->FlushRendering();
339338
} else {
340-
mPresShell->Paint(aView, damageRegion, paintFlags);
339+
presShell->Paint(aView, damageRegion, PaintFlags::PaintComposite);
341340
}
342341
#ifdef MOZ_DUMP_PAINTING
343342
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@@ -394,7 +393,8 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
394393
nsIWidget* widget = widgets[i];
395394
nsView* view = nsView::GetViewFor(widget);
396395
if (view) {
397-
view->GetViewManager()->ProcessPendingUpdatesPaint(widget);
396+
RefPtr<nsViewManager> viewManager = view->GetViewManager();
397+
viewManager->ProcessPendingUpdatesPaint(MOZ_KnownLive(widget));
398398
}
399399
}
400400
SetPainting(false);
@@ -450,16 +450,16 @@ void nsViewManager::ProcessPendingUpdatesPaint(nsIWidget* aWidget) {
450450
return;
451451
}
452452

453-
if (mPresShell) {
453+
if (RefPtr<PresShell> presShell = mPresShell) {
454454
#ifdef MOZ_DUMP_PAINTING
455455
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
456456
printf_stderr(
457457
"---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n",
458-
mPresShell, view, aWidget);
458+
presShell.get(), view, aWidget);
459459
}
460460
#endif
461461

462-
mPresShell->Paint(view, nsRegion(), PaintFlags::PaintLayers);
462+
presShell->Paint(view, nsRegion(), PaintFlags::PaintLayers);
463463
view->SetForcedRepaint(false);
464464

465465
#ifdef MOZ_DUMP_PAINTING
@@ -1006,7 +1006,8 @@ void nsViewManager::IsPainting(bool& aIsPainting) {
10061006

10071007
void nsViewManager::ProcessPendingUpdates() {
10081008
if (!IsRootVM()) {
1009-
RootViewManager()->ProcessPendingUpdates();
1009+
RefPtr<nsViewManager> rootViewManager = RootViewManager();
1010+
rootViewManager->ProcessPendingUpdates();
10101011
return;
10111012
}
10121013

@@ -1023,13 +1024,13 @@ void nsViewManager::ProcessPendingUpdates() {
10231024

10241025
void nsViewManager::UpdateWidgetGeometry() {
10251026
if (!IsRootVM()) {
1026-
RootViewManager()->UpdateWidgetGeometry();
1027+
RefPtr<nsViewManager> rootViewManager = RootViewManager();
1028+
rootViewManager->UpdateWidgetGeometry();
10271029
return;
10281030
}
10291031

10301032
if (mHasPendingWidgetGeometryChanges) {
10311033
mHasPendingWidgetGeometryChanges = false;
1032-
RefPtr<nsViewManager> strongThis(this);
10331034
ProcessPendingUpdatesForView(mRootView, false);
10341035
}
10351036
}

view/nsViewManager.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ class nsViewManager final {
310310
* Flush the accumulated dirty region to the widget and update widget
311311
* geometry.
312312
*/
313-
void ProcessPendingUpdates();
313+
MOZ_CAN_RUN_SCRIPT void ProcessPendingUpdates();
314314

315315
/**
316316
* Just update widget geometry without flushing the dirty region
317317
*/
318-
void UpdateWidgetGeometry();
318+
MOZ_CAN_RUN_SCRIPT void UpdateWidgetGeometry();
319319

320320
int32_t AppUnitsPerDevPixel() const {
321321
return mContext->AppUnitsPerDevPixel();
@@ -328,10 +328,12 @@ class nsViewManager final {
328328
void InvalidateHierarchy();
329329
void FlushPendingInvalidates();
330330

331+
MOZ_CAN_RUN_SCRIPT
331332
void ProcessPendingUpdatesForView(nsView* aView,
332333
bool aFlushDirtyRegion = true);
333334
void ProcessPendingUpdatesRecurse(
334335
nsView* aView, AutoTArray<nsCOMPtr<nsIWidget>, 1>& aWidgets);
336+
MOZ_CAN_RUN_SCRIPT
335337
void ProcessPendingUpdatesPaint(nsIWidget* aWidget);
336338

337339
void FlushDirtyRegionToWidget(nsView* aView);
@@ -347,6 +349,7 @@ class nsViewManager final {
347349
void InvalidateViews(nsView* aView);
348350

349351
// aView is the view for aWidget and aRegion is relative to aWidget.
352+
MOZ_CAN_RUN_SCRIPT
350353
void Refresh(nsView* aView, const LayoutDeviceIntRegion& aRegion);
351354

352355
// Utilities
@@ -380,7 +383,8 @@ class nsViewManager final {
380383
return RootViewManager()->mRefreshDisableCount == 0;
381384
}
382385

383-
void WillPaintWindow(nsIWidget* aWidget);
386+
MOZ_CAN_RUN_SCRIPT void WillPaintWindow(nsIWidget* aWidget);
387+
MOZ_CAN_RUN_SCRIPT
384388
bool PaintWindow(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion);
385389
void DidPaintWindow();
386390

widget/nsIRollupListener.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class nsIRollupListener {
3131
*
3232
* Returns true if the event that the caller is processing should be consumed.
3333
*/
34+
MOZ_CAN_RUN_SCRIPT_BOUNDARY
3435
virtual bool Rollup(uint32_t aCount, bool aFlush, const nsIntPoint* aPoint,
3536
nsIContent** aLastRolledUp) = 0;
3637

0 commit comments

Comments
 (0)