From f6a0ce293369baa123d3916a6034d5c90e6b9017 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Wed, 5 May 2021 15:37:51 +0000 Subject: [PATCH] Bug 1709614. Allow the double tap heuristic to look at grand parent for table cells. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D114361 --- .../helper_doubletap_zoom_tablecell.html | 31 ++++++++++++++++--- gfx/layers/apz/util/DoubleTapToZoom.cpp | 8 ++++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/gfx/layers/apz/test/mochitest/helper_doubletap_zoom_tablecell.html b/gfx/layers/apz/test/mochitest/helper_doubletap_zoom_tablecell.html index cb88cb0a0992..72e7eda55dce 100644 --- a/gfx/layers/apz/test/mochitest/helper_doubletap_zoom_tablecell.html +++ b/gfx/layers/apz/test/mochitest/helper_doubletap_zoom_tablecell.html @@ -12,23 +12,30 @@ async function test() { let useTouchpad = (location.search == "?touchpad"); - var resolution = getResolution(); + let resolution = getResolution(); ok(resolution > 0, "The initial_resolution is " + resolution + ", which is some sane value"); // Check that double-tapping does not zoom in info("sending first double tap"); await doubleTapOn(document.getElementById("target1"), 10, 10, useTouchpad); - var prev_resolution = resolution; + let prev_resolution = resolution; resolution = getResolution(); ok(resolution == prev_resolution, "The first double-tap did not change the resolution: " + resolution); - // Check that double-tapping does zoom in + // Check that double-tapping does not zoom in info("sending second double tap"); await doubleTapOn(document.getElementById("target2"), 10, 10, useTouchpad); prev_resolution = resolution; resolution = getResolution(); - ok(resolution > prev_resolution, "The second double-tap has increased the resolution to " + resolution); + ok(resolution == prev_resolution, "The second double-tap did not change the resolution: " + resolution); + + // Check that double-tapping does zoom in + info("sending third double tap"); + await doubleTapOn(document.getElementById("target3"), 10, 10, useTouchpad); + prev_resolution = resolution; + resolution = getResolution(); + ok(resolution > prev_resolution, "The third double-tap has increased the resolution to " + resolution); } waitUntilApzStable() @@ -78,7 +85,21 @@ waitUntilApzStable() - The table body +
The table body
+ with two columns + + + + + + + + + + + + + diff --git a/gfx/layers/apz/util/DoubleTapToZoom.cpp b/gfx/layers/apz/util/DoubleTapToZoom.cpp index bbe6b72e29cc..693deeaa39b6 100644 --- a/gfx/layers/apz/util/DoubleTapToZoom.cpp +++ b/gfx/layers/apz/util/DoubleTapToZoom.cpp @@ -72,7 +72,7 @@ static already_AddRefed ElementFromPoint( return nullptr; } -// Get table cell from element or parent. +// Get table cell from element, parent or grand parent. static dom::Element* GetNearbyTableCell( const nsCOMPtr& aElement) { nsTableCellFrame* tableCell = do_QueryFrame(aElement->GetPrimaryFrame()); @@ -84,6 +84,12 @@ static dom::Element* GetNearbyTableCell( if (tableCell) { return parent; } + if (dom::Element* grandParent = parent->GetFlattenedTreeParentElement()) { + tableCell = do_QueryFrame(grandParent->GetPrimaryFrame()); + if (tableCell) { + return grandParent; + } + } } return nullptr; }
The table header
The table body with two columns