Title: [184996] trunk/Source/WebInspectorUI
- Revision
- 184996
- Author
- [email protected]
- Date
- 2015-05-29 11:45:48 -0700 (Fri, 29 May 2015)
Log Message
Web Inspector: Tabs should have Context Menus
https://bugs.webkit.org/show_bug.cgi?id=144208
Reviewed by Timothy Hatcher.
Give non-pinned tabs "Close Tab" and "Close Other Tabs" context
menu items to affect other non-pinned tabs.
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/TabBarItem.js:
(WebInspector.TabBarItem):
(WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeTab):
(WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeOtherTabs):
(WebInspector.TabBarItem.prototype._handleContextMenuEvent):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (184995 => 184996)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-05-29 18:45:32 UTC (rev 184995)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-05-29 18:45:48 UTC (rev 184996)
@@ -1,3 +1,20 @@
+2015-05-29 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Tabs should have Context Menus
+ https://bugs.webkit.org/show_bug.cgi?id=144208
+
+ Reviewed by Timothy Hatcher.
+
+ Give non-pinned tabs "Close Tab" and "Close Other Tabs" context
+ menu items to affect other non-pinned tabs.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Views/TabBarItem.js:
+ (WebInspector.TabBarItem):
+ (WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeTab):
+ (WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeOtherTabs):
+ (WebInspector.TabBarItem.prototype._handleContextMenuEvent):
+
2015-05-29 Matt Baker <[email protected]>
Web Inspector: Restoring the last selected DOM node fails on reload (DOMAgent: No node with given path found)
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (184995 => 184996)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-05-29 18:45:32 UTC (rev 184995)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2015-05-29 18:45:48 UTC (rev 184996)
@@ -99,6 +99,8 @@
localizedStrings["Clickable"] = "Clickable";
localizedStrings["Close"] = "Close";
localizedStrings["Close %s timeline view"] = "Close %s timeline view";
+localizedStrings["Close Other Tabs"] = "Close Other Tabs";
+localizedStrings["Close Tab"] = "Close Tab";
localizedStrings["Close resource view"] = "Close resource view";
localizedStrings["Closure Variables"] = "Closure Variables";
localizedStrings["Code"] = "Code";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js (184995 => 184996)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js 2015-05-29 18:45:32 UTC (rev 184995)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js 2015-05-29 18:45:48 UTC (rev 184996)
@@ -46,6 +46,8 @@
var flexSpaceElement = document.createElement("div");
flexSpaceElement.classList.add("flex-space");
this._element.appendChild(flexSpaceElement);
+
+ this._element.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this));
}
this._iconElement = document.createElement("img");
@@ -163,6 +165,43 @@
this._element.title = title || "";
}
+
+ // Private
+
+ _handleContextMenuEvent(event)
+ {
+ if (!this._parentTabBar)
+ return;
+
+ var hasOtherNonPinnedTabs = false;
+ for (var item of this._parentTabBar.tabBarItems) {
+ if (item === this || item.pinned)
+ continue;
+ hasOtherNonPinnedTabs = true;
+ break;
+ }
+
+ function closeTab()
+ {
+ this._parentTabBar.removeTabBarItem(this);
+ }
+
+ function closeOtherTabs()
+ {
+ var tabBarItems = this._parentTabBar.tabBarItems;
+ for (var i = tabBarItems.length - 1; i >= 0; --i) {
+ var item = tabBarItems[i];
+ if (item === this || item.pinned)
+ continue;
+ this._parentTabBar.removeTabBarItem(item);
+ }
+ }
+
+ var contextMenu = new WebInspector.ContextMenu(event);
+ contextMenu.appendItem(WebInspector.UIString("Close Tab"), closeTab.bind(this), !hasOtherNonPinnedTabs);
+ contextMenu.appendItem(WebInspector.UIString("Close Other Tabs"), closeOtherTabs.bind(this), !hasOtherNonPinnedTabs);
+ contextMenu.show();
+ }
};
WebInspector.TabBarItem.StyleClassName = "item";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes