Bug 1590582 - Have AsyncPanZoomController::ConvertToGecko return a Maybe rather than using a bool + outparam. r=tnikkel

Depends on D50362

Differential Revision: https://phabricator.services.mozilla.com/D50363

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-10-23 22:39:48 +00:00
Родитель a503cd9266
Коммит f116543753
2 изменённых файлов: 17 добавлений и 22 удалений

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

@ -1859,21 +1859,17 @@ nsEventStatus AsyncPanZoomController::HandleEndOfPan() {
return nsEventStatus_eConsumeNoDefault;
}
bool AsyncPanZoomController::ConvertToGecko(const ScreenIntPoint& aPoint,
LayoutDevicePoint* aOut) {
Maybe<LayoutDevicePoint> AsyncPanZoomController::ConvertToGecko(
const ScreenIntPoint& aPoint) {
if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
Maybe<ScreenIntPoint> layoutPoint =
treeManagerLocal->ConvertToGecko(aPoint, this);
if (!layoutPoint) {
return false;
if (Maybe<ScreenIntPoint> layoutPoint =
treeManagerLocal->ConvertToGecko(aPoint, this)) {
return Some(LayoutDevicePoint(ViewAs<LayoutDevicePixel>(
*layoutPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent)));
}
*aOut = LayoutDevicePoint(ViewAs<LayoutDevicePixel>(
*layoutPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
return true;
}
return false;
return Nothing();
}
CSSCoord AsyncPanZoomController::ConvertScrollbarPoint(
@ -2712,8 +2708,8 @@ nsEventStatus AsyncPanZoomController::OnLongPress(
APZC_LOG("%p got a long-press in state %d\n", this, mState);
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (controller) {
LayoutDevicePoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
if (Maybe<LayoutDevicePoint> geckoScreenPoint =
ConvertToGecko(aEvent.mPoint)) {
TouchBlockState* touch = GetCurrentTouchBlock();
if (!touch) {
APZC_LOG(
@ -2727,7 +2723,7 @@ nsEventStatus AsyncPanZoomController::OnLongPress(
return nsEventStatus_eIgnore;
}
uint64_t blockId = GetInputQueue()->InjectNewTouchBlock(this);
controller->HandleTap(TapType::eLongTap, geckoScreenPoint,
controller->HandleTap(TapType::eLongTap, *geckoScreenPoint,
aEvent.modifiers, GetGuid(), blockId);
return nsEventStatus_eConsumeNoDefault;
}
@ -2747,8 +2743,7 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(
mozilla::Modifiers aModifiers) {
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (controller) {
LayoutDevicePoint geckoScreenPoint;
if (ConvertToGecko(aPoint, &geckoScreenPoint)) {
if (Maybe<LayoutDevicePoint> geckoScreenPoint = ConvertToGecko(aPoint)) {
TouchBlockState* touch = GetCurrentTouchBlock();
// |touch| may be null in the case where this function is
// invoked by GestureEventListener on a timeout. In that case we already
@ -2775,7 +2770,7 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(
NewRunnableMethod<TapType, LayoutDevicePoint, mozilla::Modifiers,
ScrollableLayerGuid, uint64_t>(
"layers::GeckoContentController::HandleTap", controller,
&GeckoContentController::HandleTap, aType, geckoScreenPoint,
&GeckoContentController::HandleTap, aType, *geckoScreenPoint,
aModifiers, GetGuid(), touch ? touch->GetBlockId() : 0);
controller->PostDelayedTask(runnable.forget(), 0);
@ -2823,9 +2818,9 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(
MOZ_ASSERT(GetCurrentTouchBlock());
if (mZoomConstraints.mAllowDoubleTapZoom &&
GetCurrentTouchBlock()->TouchActionAllowsDoubleTapZoom()) {
LayoutDevicePoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
controller->HandleTap(TapType::eDoubleTap, geckoScreenPoint,
if (Maybe<LayoutDevicePoint> geckoScreenPoint =
ConvertToGecko(aEvent.mPoint)) {
controller->HandleTap(TapType::eDoubleTap, *geckoScreenPoint,
aEvent.modifiers, GetGuid(),
GetCurrentTouchBlock()->GetBlockId());
}

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

@ -885,7 +885,7 @@ class AsyncPanZoomController {
* NOTE: This must be converted to LayoutDevicePoint relative to the child
* document before sending over IPC to a child process.
*/
bool ConvertToGecko(const ScreenIntPoint& aPoint, LayoutDevicePoint* aOut);
Maybe<LayoutDevicePoint> ConvertToGecko(const ScreenIntPoint& aPoint);
enum AxisLockMode {
FREE, /* No locking at all */