Bug 599833 Add "Paste and Go" to the context menu of the URLbar. r=Neil sr=Neil

This commit is contained in:
Philip Chee 2010-10-04 00:23:16 +08:00
Родитель ec5a3ceaeb
Коммит ead91bb562
3 изменённых файлов: 70 добавлений и 3 удалений

Просмотреть файл

@ -24,6 +24,10 @@ tabbrowser {
-moz-binding: url("chrome://navigator/content/urlbarBindings.xml#urlbar");
}
#urlbar > .autocomplete-textbox-container > .textbox-input-box {
-moz-binding: url("chrome://navigator/content/urlbarBindings.xml#input-box-paste");
}
panel[for="urlbar"] {
-moz-binding: url("chrome://navigator/content/urlbarBindings.xml#autocomplete-result-popup") !important;
}

Просмотреть файл

@ -1,5 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % textcontextDTD SYSTEM "chrome://communicator/locale/utilityOverlay.dtd">
%textcontextDTD;
]>
<bindings id="urlbarBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -15,9 +20,11 @@
this.updatePref("browser.urlbar.showPopup");
this.updatePref("browser.urlbar.autoFill");
this.updatePref("browser.urlbar.showSearch");
this.inputField.controllers.insertControllerAt(0, this._editItemsController);
]]></constructor>
<destructor><![CDATA[
this.inputField.controllers.removeController(this._editItemsController);
var pbi = this.mPrefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
if (pbi)
pbi.removeObserver("browser.urlbar", this.mPrefObserver);
@ -93,6 +100,38 @@
}
]]></body>
</method>
<field name="_editItemsController"><![CDATA[
({
editor: this.editor,
_fireEvent: this._fireEvent.bind(this),
supportsCommand: function(aCommand) {
switch (aCommand) {
case "cmd_pasteAndGo":
return true;
}
return false;
},
isCommandEnabled: function(aCommand) {
switch (aCommand) {
case "cmd_pasteAndGo":
return document.commandDispatcher
.getControllerForCommand("cmd_paste")
.isCommandEnabled("cmd_paste");
}
},
doCommand: function(aCommand) {
switch (aCommand) {
case "cmd_pasteAndGo":
this.value = "";
goDoCommand("cmd_paste");
this._fireEvent("textentered", "pasting");
break;
}
}.bind(this),
onEvent: function(aEventName) {}
})
]]></field>
</implementation>
</binding>
@ -422,4 +461,26 @@
</handlers>
</binding>
<binding id="input-box-paste" extends="chrome://global/content/bindings/textbox.xml#input-box">
<content context="_child">
<children/>
<xul:menupopup anonid="input-box-contextmenu"
class="textbox-contextmenu"
onpopupshowing="if (document.commandDispatcher.focusedElement != this.parentNode.firstChild)
this.parentNode.firstChild.focus();
this.parentNode._doPopupItemEnabling(this);"
oncommand="var cmd = event.originalTarget.getAttribute('cmd'); if(cmd) { this.parentNode.doCommand(cmd); event.stopPropagation(); }">
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
<xul:menuseparator/>
<xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
<xul:menuitem label="&copyCmd.label;" accesskey="&copyCmd.accesskey;" cmd="cmd_copy"/>
<xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
<xul:menuitem label="&pasteGoCmd.label;" accesskey="&pasteGoCmd.accesskey;" cmd="cmd_pasteAndGo"/>
<xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
<xul:menuseparator/>
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
</xul:menupopup>
</content>
</binding>
</bindings>

Просмотреть файл

@ -36,6 +36,8 @@
<!ENTITY pasteCmd.label "Paste">
<!ENTITY pasteCmd.key "V">
<!ENTITY pasteCmd.accesskey "p">
<!ENTITY pasteGoCmd.label "Paste &amp; Go">
<!ENTITY pasteGoCmd.accesskey "G">
<!ENTITY deleteCmd.label "Delete">
<!ENTITY deleteCmd.accesskey "d">
<!ENTITY selectAllCmd.label "Select All">