Bug 1532397 - Fix multiple highlight issues in debugger r=jlast
☠☠ backed out by ab3ace7e5b1a ☠ ☠
authorDavid Walsh <dwalsh@mozilla.com>
Tue, 05 Mar 2019 00:33:08 +0000
changeset 520270 ed389b1ea7dae6afc927cdf665bf872fece3acb2
parent 520269 c151282e48a26172d4b162276b792a736b21de8d
child 520271 9fca85ee3084599c0119d126840eb2062f65003d
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1532397
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532397 - Fix multiple highlight issues in debugger r=jlast https://github.com/firefox-devtools/debugger/issues/7954 Differential Revision: https://phabricator.services.mozilla.com/D21989
devtools/client/debugger/new/src/components/Editor/Preview/index.js
--- a/devtools/client/debugger/new/src/components/Editor/Preview/index.js
+++ b/devtools/client/debugger/new/src/components/Editor/Preview/index.js
@@ -45,20 +45,24 @@ function inPopup(e) {
     relatedTarget.closest(".popover") ||
     relatedTarget.classList.contains("debug-expression");
 
   return pop;
 }
 
 function getElementFromPos(pos: DOMRect) {
   // $FlowIgnore
-  return document.elementFromPoint(
+  // We need to use element*s*AtPoint because the tooltip overlays
+  // the token and thus an undesirable element may be returned
+  const elementsAtPoint = [...document.elementsFromPoint(
     pos.x + pos.width / 2,
     pos.y + pos.height / 2
-  );
+  )];
+
+  return elementsAtPoint.find(el => el.className.startsWith("cm-"));
 }
 
 class Preview extends PureComponent<Props, State> {
   target = null;
   constructor(props) {
     super(props);
     this.state = { selecting: false };
   }