зеркало из https://github.com/mozilla/gecko-dev.git
Bug 365171 - Bug context menu delete of personal toolbar bookmark can delete history item if focused. r=sspitzer.
This commit is contained in:
Родитель
be4ac0f3b8
Коммит
bad3378cc1
|
@ -36,7 +36,7 @@
|
|||
|
||||
<commandset id="placesCommands"
|
||||
commandupdater="true"
|
||||
events="places-select"
|
||||
events="focus"
|
||||
oncommandupdate="goUpdatePlacesCommands();">>
|
||||
<command id="placesCmd_open"
|
||||
label="&cmd.open.label;"
|
||||
|
|
|
@ -39,8 +39,9 @@
|
|||
and browser/components/places for the effect to appear in both the toolbar/
|
||||
menu and the places organizer. -->
|
||||
<popup id="placesContext"
|
||||
onpopupshowing="PlacesUtils.getViewForNode(document.popupNode)
|
||||
.buildContextMenu(this);">
|
||||
onpopupshowing="this._view = PlacesUtils.getViewForNode(document.popupNode);
|
||||
this._view.buildContextMenu(this);"
|
||||
onpopuphiding="this._view.destroyContextMenu();">
|
||||
<!-- the rules defined in the selection attribute control whether or not
|
||||
the menu item is _visible_ regardless of whether or not the command
|
||||
is enabled. -->
|
||||
|
|
|
@ -181,33 +181,28 @@ PlacesController.prototype = {
|
|||
isCommandEnabled: function PC_isCommandEnabled(command) {
|
||||
switch (command) {
|
||||
case "cmd_undo":
|
||||
return this._view.enableEditCommands && PlacesUtils.tm.numberOfUndoItems > 0;
|
||||
return PlacesUtils.tm.numberOfUndoItems > 0;
|
||||
case "cmd_redo":
|
||||
return this._view.enableEditCommands && PlacesUtils.tm.numberOfRedoItems > 0;
|
||||
return PlacesUtils.tm.numberOfRedoItems > 0;
|
||||
case "cmd_cut":
|
||||
case "cmd_delete":
|
||||
return this._view.enableEditCommands &&
|
||||
!this._rootNodeIsSelected() &&
|
||||
return !this._rootNodeIsSelected() &&
|
||||
!this._selectionOverlapsSystemArea() &&
|
||||
this._hasRemovableSelection();
|
||||
case "cmd_copy":
|
||||
return this._view.enableEditCommands &&
|
||||
!this._selectionOverlapsSystemArea() &&
|
||||
return !this._selectionOverlapsSystemArea() &&
|
||||
this._view.hasSelection;
|
||||
case "cmd_paste":
|
||||
return this._view.enableEditCommands &&
|
||||
!this._selectionOverlapsSystemArea() &&
|
||||
return !this._selectionOverlapsSystemArea() &&
|
||||
this._canInsert() &&
|
||||
this._hasClipboardData() && this._canPaste();
|
||||
case "cmd_selectAll":
|
||||
if (this._view.enableEditCommands) {
|
||||
if (this._view.selType != "single") {
|
||||
var result = this._view.getResult();
|
||||
if (result) {
|
||||
var container = asContainer(result.root);
|
||||
if (container.childCount > 0);
|
||||
return true;
|
||||
}
|
||||
if (this._view.selType != "single") {
|
||||
var result = this._view.getResult();
|
||||
if (result) {
|
||||
var container = asContainer(result.root);
|
||||
if (container.childCount > 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -67,10 +67,7 @@
|
|||
<method name="_init">
|
||||
<body><![CDATA[
|
||||
this._controller = new PlacesController(this);
|
||||
top.controllers.appendController(this._controller);
|
||||
|
||||
if (!this.hasAttribute("place"))
|
||||
return;
|
||||
this.controllers.appendController(this._controller);
|
||||
|
||||
// This function should only be called for top-level menus like the bookmarks menu.
|
||||
// Submenus get their _result and _resultNode from their parents.
|
||||
|
@ -715,30 +712,29 @@
|
|||
</method>
|
||||
|
||||
<property name="selType" onget="return 'single';"/>
|
||||
|
||||
<!-- Edit commands are only enabled when the menu is open -->
|
||||
<field name="_enableEditCommands">false</field>
|
||||
<property name="enableEditCommands"
|
||||
readonly="true"
|
||||
onget="return this._enableEditCommands;"/>
|
||||
|
||||
<method name="buildContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
// When right clicking an item in a bookmarks menu the places commands
|
||||
// need to be updated for the context menu to appear correctly.
|
||||
PlacesUtils.updateAllCommands();
|
||||
this.focus();
|
||||
this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="destroyContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (window.content)
|
||||
window.content.focus();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="popupshowing">
|
||||
if (event.target == this) {
|
||||
this._enableEditCommands = true;
|
||||
PlacesUtils.updateAllCommands();
|
||||
if (event.target == this)
|
||||
this.onPopupShowing();
|
||||
}
|
||||
</handler>
|
||||
<handler event="popuphidden">
|
||||
if (event.target == this) {
|
||||
|
@ -750,8 +746,6 @@
|
|||
// automatically opened when dragged over. Turn off this attribute
|
||||
// when the folder closes because it is no longer applicable.
|
||||
this.removeAttribute("autoopened");
|
||||
this._enableEditCommands = false;
|
||||
PlacesUtils.updateAllCommands();
|
||||
}
|
||||
</handler>
|
||||
<!-- Set selected node/active view on mousedown/DOMMenuItemActive events
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
<implementation implements="nsIDOMEventListener">
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
// Support an asyncinit attribute that causes the view to populate
|
||||
// itself only after the window has been shown. This is to ensure we
|
||||
|
@ -114,7 +114,7 @@
|
|||
<method name="_init">
|
||||
<body><![CDATA[
|
||||
this._controller = new PlacesController(this);
|
||||
top.controllers.appendController(this._controller);
|
||||
this.controllers.appendController(this._controller);
|
||||
|
||||
PlacesUtils.bookmarks.addObserver(this._observer, false);
|
||||
var t = this;
|
||||
|
@ -882,33 +882,22 @@
|
|||
|
||||
<property name="selType" onget="return 'single';"/>
|
||||
|
||||
<!-- Edit commands are only enabled when the context menu is oepn -->
|
||||
<field name="_enableEditCommands">false</field>
|
||||
<property name="enableEditCommands"
|
||||
readonly="true"
|
||||
onget="return this._enableEditCommands;"/>
|
||||
|
||||
<method name="buildContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
this._enableEditCommands = true;
|
||||
PlacesUtils.updateAllCommands();
|
||||
aPopup.addEventListener("popuphiding", this, true);
|
||||
this.focus();
|
||||
this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIDOMEventListener -->
|
||||
<method name="handleEvent">
|
||||
<parameter name="aEvent"/>
|
||||
<body><![CDATA[
|
||||
if (aEvent.type == "popuphiding" &&
|
||||
aEvent.eventPhase == Event.AT_TARGET) {
|
||||
this._enableEditCommands = false;
|
||||
PlacesUtils.updateAllCommands();
|
||||
aEvent.target.removeEventListener("popuphiding", this, true);
|
||||
}
|
||||
]]></body>
|
||||
<method name="destroyContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (window.content)
|
||||
window.content.focus();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
|
@ -920,8 +909,6 @@
|
|||
this._selection = event.target.node;
|
||||
else
|
||||
this._selection = this.getResult().root;
|
||||
|
||||
window.updateCommands("places-select");
|
||||
]]></handler>
|
||||
<handler event="draggesture"><![CDATA[
|
||||
if (event.target.localName == "toolbarbutton")
|
||||
|
|
|
@ -980,14 +980,14 @@
|
|||
this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="destroyContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body/>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<!-- Edit commands are updated by the global focus command updater
|
||||
in editMenuOverlay -->
|
||||
<handler event="focus" action="window.updateCommands('places-select')"/>
|
||||
<handler event="blur" action="window.updateCommands('places-select')"/>
|
||||
|
||||
<handler event="select" action="PlacesUtils.updateAllCommands();"/>
|
||||
<handler event="select" action="window.updateCommands('focus');"/>
|
||||
<handler event="draggesture"><![CDATA[
|
||||
// XXXben ew.
|
||||
if (event.target.localName == "treechildren")
|
||||
|
|
|
@ -644,13 +644,5 @@ var PlacesUtils = {
|
|||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update both edit and places-specific commands
|
||||
*/
|
||||
updateAllCommands: function() {
|
||||
window.updateCommands("select");
|
||||
window.updateCommands("places-select");
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче