Bug 1726807 - Assert on valid wp_viewport values, r=gfx-reviewers,mstange

Submitting invalid values to the Wayland compositor will trigger a
protocol error, which in turn will trigger an unhandled crash.
In order to create crash reports in such cases, assert on valid
values in such cases.

In the long run we can replace this with a general Wayland protocol
error handler.

Differential Revision: https://phabricator.services.mozilla.com/D123286
This commit is contained in:
Robert Mader 2021-08-21 15:43:44 +00:00
Родитель 433d8ce3b4
Коммит 5787ce04bc
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -683,6 +683,11 @@ void NativeLayerWayland::SetViewportSourceRect(const Rect aSourceRect) {
}
mViewportSourceRect = aSourceRect;
MOZ_RELEASE_ASSERT(
(mViewportSourceRect.x >= 0 && mViewportSourceRect.y >= 0 &&
mViewportSourceRect.width > 0 && mViewportSourceRect.height > 0) ||
(mViewportSourceRect.x == -1 && mViewportSourceRect.y == -1 &&
mViewportSourceRect.width == -1 && mViewportSourceRect.height == -1));
wp_viewport_set_source(mViewport, wl_fixed_from_double(mViewportSourceRect.x),
wl_fixed_from_double(mViewportSourceRect.y),
wl_fixed_from_double(mViewportSourceRect.width),
@ -699,6 +704,10 @@ void NativeLayerWayland::SetViewportDestinationSize(int aWidth, int aHeight) {
mViewportDestinationSize.width = aWidth;
mViewportDestinationSize.height = aHeight;
MOZ_RELEASE_ASSERT((mViewportDestinationSize.width > 0 &&
mViewportDestinationSize.height > 0) ||
(mViewportDestinationSize.width == -1 &&
mViewportDestinationSize.height == -1));
wp_viewport_set_destination(mViewport, mViewportDestinationSize.width,
mViewportDestinationSize.height);
}