Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (188359 => 188360)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-08-12 21:39:49 UTC (rev 188360)
@@ -1,3 +1,23 @@
+2015-08-12 Matt Baker <[email protected]>
+
+ Web Inspector: Remove clamp and adopt Number.constrain
+ https://bugs.webkit.org/show_bug.cgi?id=147952
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Base/Utilities.js:
+ Removed clamp function.
+
+ * UserInterface/Views/BezierEditor.js:
+ (WebInspector.BezierEditor.prototype._updateControlPointsForMouseEvent):
+ * UserInterface/Views/ProfileNodeDataGridNode.js:
+ (WebInspector.ProfileNodeDataGridNode.prototype.updateRangeTimes):
+ * UserInterface/Views/ScriptTimelineDataGridNode.js:
+ (WebInspector.ScriptTimelineDataGridNode.prototype.updateRangeTimes):
+ * UserInterface/Views/TimelineRuler.js:
+ (WebInspector.TimelineRuler.prototype._updateSelection):
+ Replaced instances of clamp with Number.constrain.
+
2015-08-12 Joseph Pecoraro <[email protected]>
Web Inspector: DOM Node should have context menu to scroll it into view on the inspected page
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (188359 => 188360)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2015-08-12 21:39:49 UTC (rev 188360)
@@ -1079,11 +1079,6 @@
return "\"" + str.replace(/"/g, "\\\"") + "\"";
}
-function clamp(min, value, max)
-{
- return Math.min(Math.max(min, value), max);
-}
-
function insertionIndexForObjectInListSortedByFunction(object, list, comparator, insertionIndexAfter)
{
if (insertionIndexAfter) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BezierEditor.js (188359 => 188360)
--- trunk/Source/WebInspectorUI/UserInterface/Views/BezierEditor.js 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BezierEditor.js 2015-08-12 21:39:49 UTC (rev 188360)
@@ -187,7 +187,7 @@
_updateControlPointsForMouseEvent(event, calculateSelectedControlPoint)
{
var point = WebInspector.Point.fromEventInElement(event, this._bezierContainer);
- point.x = clamp(0, point.x - this._controlHandleRadius, this._bezierWidth);
+ point.x = Number.constrain(point.x - this._controlHandleRadius, 0, this._bezierWidth);
point.y -= this._controlHandleRadius + this._padding;
if (calculateSelectedControlPoint) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js (188359 => 188360)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js 2015-08-12 21:39:49 UTC (rev 188360)
@@ -86,10 +86,10 @@
// We only need a refresh if the new range time changes the visible portion of this record.
var profileStart = this._profileNode.startTime;
var profileEnd = this._profileNode.endTime;
- var oldStartBoundary = clamp(profileStart, oldRangeStartTime, profileEnd);
- var oldEndBoundary = clamp(profileStart, oldRangeEndTime, profileEnd);
- var newStartBoundary = clamp(profileStart, startTime, profileEnd);
- var newEndBoundary = clamp(profileStart, endTime, profileEnd);
+ var oldStartBoundary = Number.constrain(oldRangeStartTime, profileStart, profileEnd);
+ var oldEndBoundary = Number.constrain(oldRangeEndTime, profileStart, profileEnd);
+ var newStartBoundary = Number.constrain(startTime, profileStart, profileEnd);
+ var newEndBoundary = Number.constrain(endTime, profileStart, profileEnd);
if (oldStartBoundary !== newStartBoundary || oldEndBoundary !== newEndBoundary)
this.needsRefresh();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js (188359 => 188360)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2015-08-12 21:39:49 UTC (rev 188360)
@@ -99,10 +99,10 @@
// We only need a refresh if the new range time changes the visible portion of this record.
var recordStart = this._record.startTime;
var recordEnd = this._record.startTime + this._record.duration;
- var oldStartBoundary = clamp(recordStart, oldRangeStartTime, recordEnd);
- var oldEndBoundary = clamp(recordStart, oldRangeEndTime, recordEnd);
- var newStartBoundary = clamp(recordStart, startTime, recordEnd);
- var newEndBoundary = clamp(recordStart, endTime, recordEnd);
+ var oldStartBoundary = Number.constrain(oldRangeStartTime, recordStart, recordEnd);
+ var oldEndBoundary = Number.constrain(oldRangeEndTime, recordStart, recordEnd);
+ var newStartBoundary = Number.constrain(startTime, recordStart, recordEnd);
+ var newEndBoundary = Number.constrain(endTime, recordStart, recordEnd);
if (oldStartBoundary !== newStartBoundary || oldEndBoundary !== newEndBoundary)
this.needsRefresh();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js (188359 => 188360)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js 2015-08-12 21:10:25 UTC (rev 188359)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js 2015-08-12 21:39:49 UTC (rev 188360)
@@ -595,7 +595,7 @@
let formattedStartTimeText = this._formatDividerLabelText(this._selectionStartTime);
let formattedEndTimeText = this._formatDividerLabelText(this._selectionEndTime);
- let newLeftPosition = clamp(0, (this._selectionStartTime - this._startTime) / duration, 1);
+ let newLeftPosition = Number.constrain((this._selectionStartTime - this._startTime) / duration, 0, 1);
this._updatePositionOfElement(this._leftShadedAreaElement, newLeftPosition, visibleWidth, "width");
this._updatePositionOfElement(this._leftSelectionHandleElement, newLeftPosition, visibleWidth, "left");
this._updatePositionOfElement(this._selectionDragElement, newLeftPosition, visibleWidth, "left");
@@ -604,7 +604,7 @@
this._leftSelectionHandleElement.classList.toggle("hidden", startTimeClamped && endTimeClamped && this._selectionStartTime < this._startTime);
this._leftSelectionHandleElement.title = formattedStartTimeText;
- let newRightPosition = 1 - clamp(0, (this._selectionEndTime - this._startTime) / duration, 1);
+ let newRightPosition = 1 - Number.constrain((this._selectionEndTime - this._startTime) / duration, 0, 1);
this._updatePositionOfElement(this._rightShadedAreaElement, newRightPosition, visibleWidth, "width");
this._updatePositionOfElement(this._rightSelectionHandleElement, newRightPosition, visibleWidth, "right");
this._updatePositionOfElement(this._selectionDragElement, newRightPosition, visibleWidth, "right");