Commit 2a6f5934 authored by graouts@apple.com's avatar graouts@apple.com

Web Inspector: add a method to add padding around a WebInspector.Rect

https://bugs.webkit.org/show_bug.cgi?id=125072

Reviewed by Joseph Pecoraro.

Add a new WebInspector.Rect.prototype.pad() method which does not alter
the rectangle it's called and returns a new rect much like .inset(). I've
checked all call sites and there was no reuse of the rectangle that was
padded so this patch won't have any side effects.

* UserInterface/Breakpoint.js:
(WebInspector.Breakpoint.prototype._showEditBreakpointPopover):
* UserInterface/CSSStyleDeclarationTextEditor.js:
* UserInterface/Geometry.js:
(WebInspector.Rect.prototype.pad):
* UserInterface/LayerTreeSidebarPanel.js:
(WebInspector.LayerTreeSidebarPanel.prototype._updatePopoverForSelectedNode):
* UserInterface/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._showPopover):
* UserInterface/TimelineDataGrid.js:
(WebInspector.TimelineDataGrid.prototype._updatePopoverForSelectedNode):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a8e0dce8
2013-12-02 Antoine Quint <graouts@apple.com>
Web Inspector: add a method to add padding around a WebInspector.Rect
https://bugs.webkit.org/show_bug.cgi?id=125072
Reviewed by Joseph Pecoraro.
Add a new WebInspector.Rect.prototype.pad() method which does not alter
the rectangle it's called and returns a new rect much like .inset(). I've
checked all call sites and there was no reuse of the rectangle that was
padded so this patch won't have any side effects.
* UserInterface/Breakpoint.js:
(WebInspector.Breakpoint.prototype._showEditBreakpointPopover):
* UserInterface/CSSStyleDeclarationTextEditor.js:
* UserInterface/Geometry.js:
(WebInspector.Rect.prototype.pad):
* UserInterface/LayerTreeSidebarPanel.js:
(WebInspector.LayerTreeSidebarPanel.prototype._updatePopoverForSelectedNode):
* UserInterface/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._showPopover):
* UserInterface/TimelineDataGrid.js:
(WebInspector.TimelineDataGrid.prototype._updatePopoverForSelectedNode):
2013-11-26 Antoine Quint <graouts@apple.com>
Web Inspector: Allow showing a context menu on all mouse events.
......
......@@ -480,18 +480,12 @@ WebInspector.Breakpoint.prototype = {
_showEditBreakpointPopover: function(boundingClientRect)
{
const padding = 2;
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;
bounds.size.width += padding * 2;
bounds.size.height += padding * 2;
this._popover = this._popover || new WebInspector.Popover(this);
this._popover.content = this._editBreakpointPopoverContentElement();
this._popover.present(bounds, [WebInspector.RectEdge.MAX_Y]);
this._popover.present(bounds.pad(2), [WebInspector.RectEdge.MAX_Y]);
if (!this._keyboardShortcutEsc) {
this._keyboardShortcutEsc = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape);
......
......@@ -750,14 +750,9 @@ WebInspector.CSSStyleDeclarationTextEditor.prototype = {
}.bind(this));
var bounds = WebInspector.Rect.rectFromClientRect(swatch.getBoundingClientRect());
const padding = 2;
bounds.origin.x -= padding;
bounds.origin.y -= padding;
bounds.size.width += padding * 2;
bounds.size.height += padding * 2;
this._colorPickerPopover.content = colorPicker.element;
this._colorPickerPopover.present(bounds, [WebInspector.RectEdge.MIN_X]);
this._colorPickerPopover.present(bounds.pad(2), [WebInspector.RectEdge.MIN_X]);
colorPicker.color = color;
}
......
......@@ -126,6 +126,16 @@ WebInspector.Rect.prototype = {
);
},
pad: function(padding)
{
return new WebInspector.Rect(
this.origin.x - padding,
this.origin.y - padding,
this.size.width + padding * 2,
this.size.height + padding * 2
);
},
minX: function()
{
return this.origin.x;
......
......@@ -337,16 +337,11 @@ WebInspector.LayerTreeSidebarPanel.prototype = {
popover = this._popover = new WebInspector.Popover;
var targetFrame = WebInspector.Rect.rectFromClientRect(dataGridNode.element.getBoundingClientRect());
const padding = 2;
targetFrame.origin.x -= padding;
targetFrame.origin.y -= padding;
targetFrame.size.width += padding * 2;
targetFrame.size.height += padding * 2;
if (content)
popover.content = content;
popover.present(targetFrame, [WebInspector.RectEdge.MIN_X]);
popover.present(targetFrame.pad(2), [WebInspector.RectEdge.MIN_X]);
},
_hidePopover: function()
......
......@@ -1091,15 +1091,9 @@ WebInspector.SourceCodeTextEditor.prototype = {
content.classList.add(WebInspector.SourceCodeTextEditor.PopoverDebuggerContentStyleClassName);
const padding = 5;
bounds.origin.x -= padding;
bounds.origin.y -= padding;
bounds.size.width += padding * 2;
bounds.size.height += padding * 2;
this._popover = this._popover || new WebInspector.Popover(this);
this._popover.content = content;
this._popover.present(bounds, [WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MAX_X]);
this._popover.present(bounds.pad(5), [WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MAX_X]);
this._trackPopoverEvents();
......
......@@ -217,16 +217,10 @@ WebInspector.TimelineDataGrid.prototype = {
delete this._hidePopoverContentClearTimeout;
}
const padding = 2;
targetFrame.origin.x -= padding;
targetFrame.origin.y -= padding;
targetFrame.size.width += padding * 2;
targetFrame.size.height += padding * 2;
if (updateContent)
this._popover.content = this._createPopoverContent();
this._popover.present(targetFrame, [WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_X]);
this._popover.present(targetFrame.pad(2), [WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_X]);
},
_createPopoverContent: function()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment