From 4e9167a7b11318cfe7b4e058c705332b15ba50db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 14 Jun 2025 09:40:31 +0000 Subject: [PATCH] Bug 1969829 - Non-editable elements should use the frame edge for selection targetting. r=masayuki, a=dmeehan Just like images. Differential Revision: https://phabricator.services.mozilla.com/D253705 --- layout/generic/nsIFrame.cpp | 3 +- .../tests/selection/canvas-click.html | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 testing/web-platform/tests/selection/canvas-click.html diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 35917a9fd751..44c32bd16413 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -5853,7 +5853,8 @@ static bool UseFrameEdge(nsIFrame* aFrame) { return true; } const nsImageFrame* image = do_QueryFrame(aFrame); - if (image && !aFrame->GetContent()->IsEditable()) { + if ((image || aFrame->IsHTMLCanvasFrame()) && + !aFrame->GetContent()->IsEditable()) { // Editable images are a special-case because editing relies on clicking on // an editable image selecting it, for it to show resizers. return true; diff --git a/testing/web-platform/tests/selection/canvas-click.html b/testing/web-platform/tests/selection/canvas-click.html new file mode 100644 index 000000000000..a058a621a0e2 --- /dev/null +++ b/testing/web-platform/tests/selection/canvas-click.html @@ -0,0 +1,28 @@ + + +Clicking on a text-selectable canvas should not select it + + + + + + + + +Clicking the green square should not select it.
+ +