Web Inspector: Edit Breakpoint popover sometimes appears misplaced in top left
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 00:55:42 +0000 (00:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 00:55:42 +0000 (00:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120804

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2013-09-05
Reviewed by Timothy Hatcher.

Grab the bounding rect immediately, instead of grabbing it from the element
after the user has selected the "Edit Breakpoint" context menu item. When
the popover was misplaced it was when using an element had been removed or
replaced in the DOM, and caused a bogus bounding client rect.

* UserInterface/Breakpoint.js:
(WebInspector.Breakpoint.prototype.editBreakpoint):
(WebInspector.Breakpoint.prototype._showEditBreakpointPopover):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155165 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Breakpoint.js

index ea1d33b1f08430e65a22f04fb125f70977768ea9..45350d2685ba616c75220a7203779fd3679e4267 100644 (file)
@@ -1,3 +1,19 @@
+2013-09-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Edit Breakpoint popover sometimes appears misplaced in top left
+        https://bugs.webkit.org/show_bug.cgi?id=120804
+
+        Reviewed by Timothy Hatcher.
+
+        Grab the bounding rect immediately, instead of grabbing it from the element
+        after the user has selected the "Edit Breakpoint" context menu item. When
+        the popover was misplaced it was when using an element had been removed or
+        replaced in the DOM, and caused a bogus bounding client rect.
+
+        * UserInterface/Breakpoint.js:
+        (WebInspector.Breakpoint.prototype.editBreakpoint):
+        (WebInspector.Breakpoint.prototype._showEditBreakpointPopover):
+
 2013-09-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Remove harmless assert, triggered hitting breakpoint in auto prettyprinted code on reload
index 42a42e8c8b6707b4a1bb3bc029a16c4e0edcdc6e..1eff6c50e62481872a4669dbcbb7f4f62308628d 100644 (file)
@@ -199,9 +199,13 @@ WebInspector.Breakpoint.prototype = {
 
     appendContextMenuItems: function(contextMenu, breakpointDisplayElement)
     {
+        console.assert(document.body.contains(breakpointDisplayElement), "breakpoint popover display element must be in the DOM");
+
+        var boundingClientRect = breakpointDisplayElement.getBoundingClientRect();
+
         function editBreakpoint()
         {
-            this._showEditBreakpointPopover(breakpointDisplayElement);
+            this._showEditBreakpointPopover(boundingClientRect);
         }
 
         function removeBreakpoint()
@@ -474,10 +478,11 @@ WebInspector.Breakpoint.prototype = {
         delete this._popover;
     },
 
-    _showEditBreakpointPopover: function(element)
+    _showEditBreakpointPopover: function(boundingClientRect)
     {
         const padding = 2;
-        var bounds = WebInspector.Rect.rectFromClientRect(element.getBoundingClientRect());
+        var bounds = WebInspector.Rect.rectFromClientRect(boundingClientRect);
+
         bounds.origin.x -= 1; // Move the anchor left one pixel so it looks more centered.
         bounds.origin.x -= padding;
         bounds.origin.y -= padding;