Title: [151704] trunk/Source/WebInspectorUI
Revision
151704
Author
[email protected]
Date
2013-06-18 15:44:24 -0700 (Tue, 18 Jun 2013)

Log Message

Web Inspector: Infrequent uncaught exception with debugger popovers breaks inspector
https://bugs.webkit.org/show_bug.cgi?id=117755

Create the ZERO_SIZE and ZERO_RECT objects after we've setup the Size
and Rect prototypes, so they get the expected methods. We then need to
handle the ZERO_RECT case better, and not attempt to draw a background
in a canvas with a 0 size, which would produce an exception.

Patch by Joseph Pecoraro <[email protected]> on 2013-06-18
Reviewed by Timothy Hatcher.

* UserInterface/Geometry.js:
* UserInterface/Popover.js:
(WebInspector.Popover.prototype._update):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (151703 => 151704)


--- trunk/Source/WebInspectorUI/ChangeLog	2013-06-18 22:31:57 UTC (rev 151703)
+++ trunk/Source/WebInspectorUI/ChangeLog	2013-06-18 22:44:24 UTC (rev 151704)
@@ -1,3 +1,19 @@
+2013-06-18  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Infrequent uncaught exception with debugger popovers breaks inspector
+        https://bugs.webkit.org/show_bug.cgi?id=117755
+
+        Create the ZERO_SIZE and ZERO_RECT objects after we've setup the Size
+        and Rect prototypes, so they get the expected methods. We then need to
+        handle the ZERO_RECT case better, and not attempt to draw a background
+        in a canvas with a 0 size, which would produce an exception.
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Geometry.js:
+        * UserInterface/Popover.js:
+        (WebInspector.Popover.prototype._update):
+
 2013-06-18  Timothy Hatcher  <[email protected]>
 
         If the tree outline is processing a selection currently, then don't change the selection.

Modified: trunk/Source/WebInspectorUI/UserInterface/Geometry.js (151703 => 151704)


--- trunk/Source/WebInspectorUI/UserInterface/Geometry.js	2013-06-18 22:31:57 UTC (rev 151703)
+++ trunk/Source/WebInspectorUI/UserInterface/Geometry.js	2013-06-18 22:44:24 UTC (rev 151704)
@@ -65,8 +65,6 @@
     this.height = height || 0;
 };
 
-WebInspector.Size.ZERO_SIZE = new WebInspector.Size(0, 0);
-
 WebInspector.Size.prototype = {
     constructor: WebInspector.Size,
 
@@ -86,14 +84,15 @@
     }
 };
 
+WebInspector.Size.ZERO_SIZE = new WebInspector.Size(0, 0);
+
+
 WebInspector.Rect = function(x, y, width, height)
 {
     this.origin = new WebInspector.Point(x || 0, y || 0);
     this.size = new WebInspector.Size(width || 0, height || 0);
 };
 
-WebInspector.Rect.ZERO_RECT = new WebInspector.Rect(0, 0, 0, 0);
-
 WebInspector.Rect.rectFromClientRect = function(clientRect)
 {
     return new WebInspector.Rect(clientRect.left, clientRect.top, clientRect.width, clientRect.height);
@@ -176,6 +175,9 @@
     }
 };
 
+WebInspector.Rect.ZERO_RECT = new WebInspector.Rect(0, 0, 0, 0);
+
+
 WebInspector.EdgeInsets = function(top, right, bottom, left)
 {
     console.assert(arguments.length === 1 || arguments.length === 4);

Modified: trunk/Source/WebInspectorUI/UserInterface/Popover.js (151703 => 151704)


--- trunk/Source/WebInspectorUI/UserInterface/Popover.js	2013-06-18 22:31:57 UTC (rev 151703)
+++ trunk/Source/WebInspectorUI/UserInterface/Popover.js	2013-06-18 22:44:24 UTC (rev 151704)
@@ -217,37 +217,43 @@
 
         var anchorPoint;
         var bestFrame = bestMetrics.frame;
-        switch (bestEdge) {
-        case WebInspector.RectEdge.MIN_X: // Displayed on the left of the target, arrow points right.
-            anchorPoint = new WebInspector.Point(bestFrame.size.width - WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
-            break;
-        case WebInspector.RectEdge.MAX_X: // Displayed on the right of the target, arrow points left.
-            anchorPoint = new WebInspector.Point(WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
-            break;
-        case WebInspector.RectEdge.MIN_Y: // Displayed above the target, arrow points down.
-            anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), bestFrame.size.height - WebInspector.Popover.ShadowPadding);
-            break;
-        case WebInspector.RectEdge.MAX_Y: // Displayed below the target, arrow points up.
-            anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), WebInspector.Popover.ShadowPadding);
-            break;
-        }
 
         var needsToDrawBackground = !this._frame.size.equals(bestFrame.size) || this._edge !== bestEdge;
 
         this.frame = bestFrame;
         this._edge = bestEdge;
 
-        this._element.classList.add(this._cssClassNameForEdge());
+        if (this.frame === WebInspector.Rect.ZERO_RECT) {
+            // The target for the popover is offscreen.
+            this.dismiss();
+        } else {
+            switch (bestEdge) {
+            case WebInspector.RectEdge.MIN_X: // Displayed on the left of the target, arrow points right.
+                anchorPoint = new WebInspector.Point(bestFrame.size.width - WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
+                break;
+            case WebInspector.RectEdge.MAX_X: // Displayed on the right of the target, arrow points left.
+                anchorPoint = new WebInspector.Point(WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
+                break;
+            case WebInspector.RectEdge.MIN_Y: // Displayed above the target, arrow points down.
+                anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), bestFrame.size.height - WebInspector.Popover.ShadowPadding);
+                break;
+            case WebInspector.RectEdge.MAX_Y: // Displayed below the target, arrow points up.
+                anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), WebInspector.Popover.ShadowPadding);
+                break;
+            }
 
-        if (needsToDrawBackground)
-            this._drawBackground(bestEdge, anchorPoint);
+            this._element.classList.add(this._cssClassNameForEdge());
 
-        // Make sure content is centered in case either of the dimension is smaller than the minimal bounds.
-        if (this._preferredSize.width < WebInspector.Popover.MinWidth || this._preferredSize.height < WebInspector.Popover.MinHeight)
-            this._container.classList.add("center");
-        else
-            this._container.classList.remove("center");
-        
+            if (needsToDrawBackground)
+                this._drawBackground(bestEdge, anchorPoint);
+
+            // Make sure content is centered in case either of the dimension is smaller than the minimal bounds.
+            if (this._preferredSize.width < WebInspector.Popover.MinWidth || this._preferredSize.height < WebInspector.Popover.MinHeight)
+                this._container.classList.add("center");
+            else
+                this._container.classList.remove("center");
+        }
+
         // Wrap the content in the container so that it's located correctly.
         if (this._contentNeedsUpdate) {
             this._container.textContent = "";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to