Diff
Modified: trunk/LayoutTests/ChangeLog (221307 => 221308)
--- trunk/LayoutTests/ChangeLog 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/LayoutTests/ChangeLog 2017-08-29 19:25:56 UTC (rev 221308)
@@ -1,3 +1,15 @@
+2017-08-29 Nikita Vasilyev <nvasil...@apple.com>
+
+ Web Inspector: Optimize View.prototype.removeSubview
+ https://bugs.webkit.org/show_bug.cgi?id=176041
+
+ Reviewed by Matt Baker.
+
+ Split Array.prototype.remove(value, onlyFirst) into Array.prototype.removeAll(value) and Array.prototype.remove(value).
+
+ * inspector/unit-tests/array-utilities-expected.txt:
+ * inspector/unit-tests/array-utilities.html:
+
2017-08-29 Youenn Fablet <you...@apple.com>
CanvasCaptureMediaStreamTrack clone is not a CanvasCaptureMediaStreamTrack
Modified: trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt (221307 => 221308)
--- trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt 2017-08-29 19:25:56 UTC (rev 221308)
@@ -50,10 +50,13 @@
PASS: lastValue of an empty array should be undefined.
-- Running test case: Array.prototype.remove
-PASS: remove with onlyFirst equal to true should only remove the first matching value.
-PASS: remove with onlyFirst equal to false should remove all matching values.
-PASS: remove with onlyFirst unspecified should remove all matching values.
+PASS: remove should only remove the first matching value.
+PASS: remove should only remove values that strictly match.
+-- Running test case: Array.prototype.removeAll
+PASS: removeAll should remove all matching values.
+PASS: removeAll should only remove values that strictly match.
+
-- Running test case: Array.prototype.toggleIncludes
PASS: toggleIncludes of an existing item with force true should have no effect.
PASS: toggleIncludes of an existing item with force false should remove the item.
Modified: trunk/LayoutTests/inspector/unit-tests/array-utilities.html (221307 => 221308)
--- trunk/LayoutTests/inspector/unit-tests/array-utilities.html 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/LayoutTests/inspector/unit-tests/array-utilities.html 2017-08-29 19:25:56 UTC (rev 221308)
@@ -128,18 +128,30 @@
name: "Array.prototype.remove",
test() {
let arr1 = [1, 2, 3, 1];
- arr1.remove(1, true);
- // Note: Array.prototype.remove starts searching from the end of the array.
- InspectorTest.expectShallowEqual(arr1, [1, 2, 3], "remove with onlyFirst equal to true should only remove the first matching value.");
+ arr1.remove(1);
+ InspectorTest.expectShallowEqual(arr1, [2, 3, 1], "remove should only remove the first matching value.");
- let arr2 = [1, 2, 3, 1];
- arr2.remove(1, false);
- InspectorTest.expectShallowEqual(arr2, [2, 3], "remove with onlyFirst equal to false should remove all matching values.");
+ let arr2 = ["1", "2", 3, 1];
+ arr2.remove("1");
+ arr2.remove(2);
+ InspectorTest.expectShallowEqual(arr2, ["2", 3, 1], "remove should only remove values that strictly match.");
- let arr3 = [1, 2, 3, 1];
- arr3.remove(1);
- InspectorTest.expectShallowEqual(arr3, [2, 3], "remove with onlyFirst unspecified should remove all matching values.");
+ return true;
+ }
+ });
+ suite.addTestCase({
+ name: "Array.prototype.removeAll",
+ test() {
+ let arr1 = [1, 2, 3, 1];
+ arr1.removeAll(1);
+ InspectorTest.expectShallowEqual(arr1, [2, 3], "removeAll should remove all matching values.");
+
+ let arr2 = ["1", "2", 3, 1];
+ arr2.removeAll("1");
+ arr2.removeAll(2);
+ InspectorTest.expectShallowEqual(arr2, ["2", 3, 1], "removeAll should only remove values that strictly match.");
+
return true;
}
});
Modified: trunk/Source/WebInspectorUI/ChangeLog (221307 => 221308)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-08-29 19:25:56 UTC (rev 221308)
@@ -1,3 +1,26 @@
+2017-08-29 Nikita Vasilyev <nvasil...@apple.com>
+
+ Web Inspector: Optimize View.prototype.removeSubview
+ https://bugs.webkit.org/show_bug.cgi?id=176041
+
+ Reviewed by Matt Baker.
+
+ Look up a subview in an array only once, not twice.
+
+ * UserInterface/Base/Utilities.js:
+ (Array.prototype.removeAll):
+ (Array.prototype.remove):
+ Split Array.propotype.remove(value, onlyFirst) into Array.propotype.removeAll(value) and
+ Array.propotype.remove(value).
+
+ * UserInterface/Controllers/DebuggerManager.js:
+ (WI.DebuggerManager.prototype._debuggerBreakpointOptions):
+ * UserInterface/Views/ContentViewContainer.js:
+ (WI.ContentViewContainer.prototype._clearTombstonesForContentView):
+ (WI.ContentViewContainer.prototype._disassociateFromContentView):
+ * UserInterface/Views/View.js:
+ (WI.View.prototype.removeSubview):
+
2017-08-28 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: Remove some unused DataGrid code
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (221307 => 221308)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2017-08-29 19:25:56 UTC (rev 221308)
@@ -494,18 +494,28 @@
Object.defineProperty(Array.prototype, "remove",
{
- value: function(value, onlyFirst)
+ value(value)
{
- for (var i = this.length - 1; i >= 0; --i) {
+ for (let i = 0; i < this.length; ++i) {
if (this[i] === value) {
this.splice(i, 1);
- if (onlyFirst)
- return;
+ return;
}
}
}
});
+Object.defineProperty(Array.prototype, "removeAll",
+{
+ value(value)
+ {
+ for (let i = this.length - 1; i >= 0; --i) {
+ if (this[i] === value)
+ this.splice(i, 1);
+ }
+ }
+});
+
Object.defineProperty(Array.prototype, "toggleIncludes",
{
value: function(value, force)
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (221307 => 221308)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2017-08-29 19:25:56 UTC (rev 221308)
@@ -872,9 +872,8 @@
action.type = WI.BreakpointAction.Type.Evaluate;
}
- const _onlyFirst_ = true;
for (let invalidAction of invalidActions)
- options.actions.remove(invalidAction, onlyFirst);
+ options.actions.remove(invalidAction);
return options;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js (221307 => 221308)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js 2017-08-29 19:25:56 UTC (rev 221308)
@@ -385,8 +385,7 @@
console.assert(contentView.parentContainer === this);
let tombstoneContentViewContainers = this._tombstoneContentViewContainersForContentView(contentView);
- const _onlyFirst_ = false;
- tombstoneContentViewContainers.remove(this, onlyFirst);
+ tombstoneContentViewContainers.removeAll(this);
for (let entry of this._backForwardList) {
if (entry.contentView !== contentView)
@@ -403,8 +402,7 @@
// There may be other back/forward entries that need a reference.
if (isTombstone) {
let tombstoneContentViewContainers = this._tombstoneContentViewContainersForContentView(contentView);
- const _onlyFirst_ = true;
- tombstoneContentViewContainers.remove(this, onlyFirst);
+ tombstoneContentViewContainers.remove(this);
return;
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/View.js (221307 => 221308)
--- trunk/Source/WebInspectorUI/UserInterface/Views/View.js 2017-08-29 18:34:38 UTC (rev 221307)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/View.js 2017-08-29 19:25:56 UTC (rev 221308)
@@ -120,12 +120,13 @@
console.assert(view instanceof WI.View);
console.assert(view.element.parentNode === this._element, "Subview DOM element must be a child of the parent view element.");
- if (!this._subviews.includes(view)) {
+ let index = this._subviews.lastIndexOf(view);
+ if (index === -1) {
console.assert(false, "Cannot remove view which isn't a subview.", view);
return;
}
- this._subviews.remove(view, true);
+ this._subviews.splice(index, 1);
this._element.removeChild(view.element);
view.didMoveToParent(null);