Changeset 151704 in webkit


Ignore:
Timestamp:
Jun 18, 2013, 3:44:24 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <Joseph Pecoraro> on 2013-06-18
Reviewed by Timothy Hatcher.

  • UserInterface/Geometry.js:
  • UserInterface/Popover.js:

(WebInspector.Popover.prototype._update):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r151688 r151704  
     12013-06-18  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Infrequent uncaught exception with debugger popovers breaks inspector
     4        https://bugs.webkit.org/show_bug.cgi?id=117755
     5
     6        Create the ZERO_SIZE and ZERO_RECT objects after we've setup the Size
     7        and Rect prototypes, so they get the expected methods. We then need to
     8        handle the ZERO_RECT case better, and not attempt to draw a background
     9        in a canvas with a 0 size, which would produce an exception.
     10
     11        Reviewed by Timothy Hatcher.
     12
     13        * UserInterface/Geometry.js:
     14        * UserInterface/Popover.js:
     15        (WebInspector.Popover.prototype._update):
     16
    1172013-06-18  Timothy Hatcher  <timothy@apple.com>
    218
  • trunk/Source/WebInspectorUI/UserInterface/Geometry.js

    r151453 r151704  
    6666};
    6767
    68 WebInspector.Size.ZERO_SIZE = new WebInspector.Size(0, 0);
    69 
    7068WebInspector.Size.prototype = {
    7169    constructor: WebInspector.Size,
     
    8785};
    8886
     87WebInspector.Size.ZERO_SIZE = new WebInspector.Size(0, 0);
     88
     89
    8990WebInspector.Rect = function(x, y, width, height)
    9091{
     
    9293    this.size = new WebInspector.Size(width || 0, height || 0);
    9394};
    94 
    95 WebInspector.Rect.ZERO_RECT = new WebInspector.Rect(0, 0, 0, 0);
    9695
    9796WebInspector.Rect.rectFromClientRect = function(clientRect)
     
    177176};
    178177
     178WebInspector.Rect.ZERO_RECT = new WebInspector.Rect(0, 0, 0, 0);
     179
     180
    179181WebInspector.EdgeInsets = function(top, right, bottom, left)
    180182{
  • trunk/Source/WebInspectorUI/UserInterface/Popover.js

    r151453 r151704  
    218218        var anchorPoint;
    219219        var bestFrame = bestMetrics.frame;
    220         switch (bestEdge) {
    221         case WebInspector.RectEdge.MIN_X: // Displayed on the left of the target, arrow points right.
    222             anchorPoint = new WebInspector.Point(bestFrame.size.width - WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
    223             break;
    224         case WebInspector.RectEdge.MAX_X: // Displayed on the right of the target, arrow points left.
    225             anchorPoint = new WebInspector.Point(WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
    226             break;
    227         case WebInspector.RectEdge.MIN_Y: // Displayed above the target, arrow points down.
    228             anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), bestFrame.size.height - WebInspector.Popover.ShadowPadding);
    229             break;
    230         case WebInspector.RectEdge.MAX_Y: // Displayed below the target, arrow points up.
    231             anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), WebInspector.Popover.ShadowPadding);
    232             break;
    233         }
    234220
    235221        var needsToDrawBackground = !this._frame.size.equals(bestFrame.size) || this._edge !== bestEdge;
     
    238224        this._edge = bestEdge;
    239225
    240         this._element.classList.add(this._cssClassNameForEdge());
    241 
    242         if (needsToDrawBackground)
    243             this._drawBackground(bestEdge, anchorPoint);
    244 
    245         // Make sure content is centered in case either of the dimension is smaller than the minimal bounds.
    246         if (this._preferredSize.width < WebInspector.Popover.MinWidth || this._preferredSize.height < WebInspector.Popover.MinHeight)
    247             this._container.classList.add("center");
    248         else
    249             this._container.classList.remove("center");
    250        
     226        if (this.frame === WebInspector.Rect.ZERO_RECT) {
     227            // The target for the popover is offscreen.
     228            this.dismiss();
     229        } else {
     230            switch (bestEdge) {
     231            case WebInspector.RectEdge.MIN_X: // Displayed on the left of the target, arrow points right.
     232                anchorPoint = new WebInspector.Point(bestFrame.size.width - WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
     233                break;
     234            case WebInspector.RectEdge.MAX_X: // Displayed on the right of the target, arrow points left.
     235                anchorPoint = new WebInspector.Point(WebInspector.Popover.ShadowPadding, targetFrame.midY() - bestFrame.minY());
     236                break;
     237            case WebInspector.RectEdge.MIN_Y: // Displayed above the target, arrow points down.
     238                anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), bestFrame.size.height - WebInspector.Popover.ShadowPadding);
     239                break;
     240            case WebInspector.RectEdge.MAX_Y: // Displayed below the target, arrow points up.
     241                anchorPoint = new WebInspector.Point(targetFrame.midX() - bestFrame.minX(), WebInspector.Popover.ShadowPadding);
     242                break;
     243            }
     244
     245            this._element.classList.add(this._cssClassNameForEdge());
     246
     247            if (needsToDrawBackground)
     248                this._drawBackground(bestEdge, anchorPoint);
     249
     250            // Make sure content is centered in case either of the dimension is smaller than the minimal bounds.
     251            if (this._preferredSize.width < WebInspector.Popover.MinWidth || this._preferredSize.height < WebInspector.Popover.MinHeight)
     252                this._container.classList.add("center");
     253            else
     254                this._container.classList.remove("center");
     255        }
     256
    251257        // Wrap the content in the container so that it's located correctly.
    252258        if (this._contentNeedsUpdate) {
Note: See TracChangeset for help on using the changeset viewer.