Bug 1436605 - Replace remaining Components.interface/Components.utils uses with Ci/Cu in mail, chat, common and mailnews. r=jorgk

This commit is contained in:
aceman 2018-03-12 16:32:00 +01:00
Родитель c2129703f2
Коммит 5df6a3cdd4
18 изменённых файлов: 45 добавлений и 277 удалений

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

@ -100,7 +100,7 @@
<field name="_webNavigation">null</field>
<property name="webNavigation"
onget="return this._webNavigation || (this._webNavigation = this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation));"
onget="return this._webNavigation || (this._webNavigation = this.docShell.QueryInterface(Ci.nsIWebNavigation));"
readonly="true"/>
<field name="_finder">null</field>
@ -144,13 +144,13 @@
<property name="webProgress"
readonly="true"
onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
onget="return this.docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress);"/>
<field name="_contentWindow">null</field>
<property name="contentWindow"
readonly="true"
onget="return this._contentWindow || (this._contentWindow = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow));"/>
onget="return this._contentWindow || (this._contentWindow = this.docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow));"/>
<property name="contentWindowAsCPOW"
readonly="true"
@ -1303,10 +1303,10 @@
</handler>
<handler event="keypress" modifiers="shift" keycode="VK_PAGE_UP"
action="this.docShell.QueryInterface(Components.interfaces.nsITextScroll).scrollByPages(-1);"/>
action="this.docShell.QueryInterface(Ci.nsITextScroll).scrollByPages(-1);"/>
<handler event="keypress" modifiers="shift" keycode="VK_PAGE_DOWN"
action="this.docShell.QueryInterface(Components.interfaces.nsITextScroll).scrollByPages(1);"/>
action="this.docShell.QueryInterface(Ci.nsITextScroll).scrollByPages(1);"/>
<handler event="keypress" modifiers="alt" keycode="VK_PAGE_UP"
action="this.scrollToPreviousSection();"/>

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

@ -82,19 +82,16 @@
</method>
<field name="service">
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
</field>
<field name="rootBranch">
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
</field>
<field name="defaultBranch">
this.service.getDefaultBranch("");
</field>
<field name="rootBranchInternal">
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
</field>
<property name="type" readonly="true">
<getter>

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

@ -1677,7 +1677,7 @@
<binding id="searchoperator" name="searchOperator"
extends="chrome://messenger/content/mailWidgets.xml#search-menulist-abstract">
<implementation>
<field name="searchAttribute">Components.interfaces.nsMsgSearchAttrib.Default</field>
<field name="searchAttribute">Ci.nsMsgSearchAttrib.Default</field>
<field name="stringBundle">
<![CDATA[
this.Services.strings.createBundle("chrome://messenger/locale/search-operators.properties")

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

@ -2281,9 +2281,9 @@
label="&copyCmd.label;"
accesskey="&copyCmd.accesskey;"
tooltiptext="&copyCmd.label;"
oncommand="Components.classes['@mozilla.org/widget/clipboardhelper;1']
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(window.getSelection().isCollapsed ?
oncommand="Cc['@mozilla.org/widget/clipboardhelper;1']
.getService(Ci.nsIClipboardHelper)
.copyString(window.getSelection().isCollapsed ?
document.popupNode.textContent :
window.getSelection().toString());"/>
<menuitem id="createFilterFromMenuItem" label="&CreateFilterFrom.label;"

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

@ -68,7 +68,7 @@
this.glodaCompleter =
Cc["@mozilla.org/autocomplete/search;1?name=gloda"]
.getService()
.getService(Ci.nsIAutoCompleteSearch)
.wrappedJSObject;
Services.obs.addObserver(this, "autocomplete-did-enter-text");
@ -101,7 +101,7 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
if (topic == "nsPref:changed") {
subject.QueryInterface(Components.interfaces.nsIPrefBranch);
subject.QueryInterface(Ci.nsIPrefBranch);
switch (data) {
case "mailnews.database.global.indexer.enabled":
this.inputSearch.glodaEnabled =
@ -115,10 +115,9 @@
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIObserver) ||
aIID.equals(Components.interfaces.nsISupports))
if (aIID.equals(Ci.nsIObserver) || aIID.equals(Ci.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
throw Cr.NS_NOINTERFACE;
}
});
</field>

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

@ -1808,13 +1808,14 @@
document.getElementById(this.getAttribute("collapsetoolbar"));
</field>
<field name="_prefObserver">({
<field name="_prefObserver"><![CDATA[
({
tabbox: this,
observe: function(subject, topic, data)
{
if (topic == "nsPref:changed") {
subject.QueryInterface(Components.interfaces.nsIPrefBranch);
subject.QueryInterface(Ci.nsIPrefBranch);
switch (data) {
case "mail.tabs.closeButtons":
this.tabbox.mCloseButtons = subject.getIntPref("mail.tabs.closeButtons");
@ -1829,18 +1830,17 @@
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIObserver) ||
aIID.equals(Components.interfaces.nsISupports))
if (aIID.equals(Ci.nsIObserver) || aIID.equals(Ci.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
throw Cr.NS_NOINTERFACE;
}
});
]]>
</field>
<field name="_tabDropIndicator">
document.getAnonymousElementByAttribute(
this,
"anonid", "tab-drop-indicator");
document.getAnonymousElementByAttribute(this, "anonid",
"tab-drop-indicator");
</field>
<field name="_dragOverDelay">350</field>

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

@ -82,7 +82,7 @@ interface nsIMsgCloudFileProvider : nsISupports {
* with an http status. Generally, status between 200 and 300 is OK,
* otherwise, an error occurred which is * probably specific to the provider.
* If the request fails completely, onStopRequest will get called with
* Components.results.NS_ERROR_FAILURE
* Cr.NS_ERROR_FAILURE
* @throws nsIMsgCloudFileProvider.offlineErr if we are offline.
*/
void createNewAccount(in ACString aEmailAddress, in ACString aPassword,

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

@ -5501,7 +5501,7 @@ nsAttachmentOpener.prototype =
request.URI = request.URI.mutate().setQuery(newQuery).finalize();
}
let newHandler = Cc["@mozilla.org/uriloader/content-handler;1?type=application/x-message-display"]
.createInstance(Components.interfaces.nsIContentHandler);
.createInstance(Ci.nsIContentHandler);
newHandler.handleContent("application/x-message-display", this, request);
return true;
},

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

@ -40,8 +40,8 @@ httpRequestObserver.prototype = {
return;
if (!(aSubject instanceof Ci.nsIHttpChannel)) {
Component.utils.reportError("Failed to get a nsIHttpChannel when "
+ "observing http-on-examine-response");
Cu.reportError("Failed to get a nsIHttpChannel when "
+ "observing http-on-examine-response");
return;
}

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

@ -58,7 +58,7 @@ MockObjectRegisterer.prototype = {
* created every time createInstance is called. This object must
* implement QueryInterface and provide the XPCOM interfaces required by
* the specified ContractID (for example
* Components.interfaces.nsIFilePicker).
* Ci.nsIFilePicker).
*/
function MockObjectReplacer(aContractID, aReplacementCtor) {

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

@ -52,7 +52,7 @@ settings_env = 'JSBRIDGE_SETTINGS_FILE'
parent = os.path.abspath(os.path.dirname(__file__))
extension_path = os.path.join(parent, 'extension')
window_string = "Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('')"
window_string = "Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator).getMostRecentWindow('')"
wait_to_create_timeout = 60
@ -176,11 +176,4 @@ def cli():
CLI().run()
def getBrowserWindow(bridge):
return JSObject(bridge, "Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('')")
return JSObject(bridge, "Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator).getMostRecentWindow('')")

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

@ -282,8 +282,7 @@ RecorderConnector.prototype.on = function() {
}
var observerService =
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
//Attach the new window open listener
observerService.addObserver(this.observer, "toplevel-window-ready", false);
@ -309,8 +308,7 @@ RecorderConnector.prototype.off = function() {
currentRecorderArray = [];
//remove new window listener
var observerService =
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
try { observerService.removeObserver(this.observer, "toplevel-window-ready"); }
catch(err){}
};

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

@ -1,218 +0,0 @@
diff --git a/mozmill/mozmill/extension/resource/stdlib/EventUtils.js b/mozmill/mozmill/extension/resource/stdlib/EventUtils.js
index 27fbbc7..0329d47 100644
--- a/mozmill/mozmill/extension/resource/stdlib/EventUtils.js
+++ b/mozmill/mozmill/extension/resource/stdlib/EventUtils.js
@@ -1,3 +1,24 @@
+// Export all available functions for Mozmill
+var EXPORTED_SYMBOLS = ["sendMouseEvent", "sendChar", "sendString", "sendKey",
+ "__doEventDispatch", "_parseModifiers", "synthesizeMouse",
+ "synthesizeMouseScroll", "synthesizeKey", "_expectEvent",
+ "_checkExpectedEvent", "synthesizeMouseExpectEvent",
+ "synthesizeDragStart", "synthesizeDrop",
+ "disableNonTestMouseEvents", "_getDOMWindowUtils",
+ "synthesizeComposition", "synthesizeText",
+ "synthesizeQuerySelectedText", "synthesizeQueryTextContent",
+ "synthesizeQueryCaretRect", "synthesizeQueryTextRect",
+ "synthesizeQueryEditorRect", "synthesizeCharAtPoint",
+ "synthesizeSelectionSet"];
+
+/**
+ * Get the array with available key events
+ */
+function getKeyEvent(aWindow) {
+ var win = aWindow.wrappedJSObject ? aWindow.wrappedJSObject : aWindow;
+ return win.KeyEvent;
+}
+
/**
* EventUtils provides some utility methods for creating and sending DOM events.
* Current methods:
@@ -29,9 +50,6 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
aTarget = aWindow.document.getElementById(aTarget);
}
- // For events to trigger the UA's default actions they need to be "trusted"
- netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
-
var event = aWindow.document.createEvent('MouseEvent');
var typeArg = aEvent.type;
@@ -107,14 +125,17 @@ function sendString(aStr, aTarget) {
* Returns true if the keypress event was accepted (no calls to preventDefault
* or anything like that), false otherwise.
*/
-function sendKey(aKey, aTarget) {
+function sendKey(aKey, aTarget, aWindow) {
+ if (!aWindow)
+ aWindow = window;
+
keyName = "DOM_VK_" + aKey.toUpperCase();
- if (!KeyEvent[keyName]) {
+ if (!getKeyEvent(aWindow)[keyName]) {
throw "Unknown key: " + keyName;
}
- return __doEventDispatch(aTarget, 0, KeyEvent[keyName], false);
+ return __doEventDispatch(aTarget, 0, getKeyEvent(aWindow)[keyName], false);
}
/**
@@ -130,9 +151,6 @@ function __doEventDispatch(aTarget, aCharCode, aKeyCode, aHasShift) {
aTarget = "target";
}
- // Make our events trusted
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
var event = document.createEvent("KeyEvents");
event.initKeyEvent("keydown", true, true, document.defaultView,
false, false, aHasShift, false,
@@ -171,6 +189,10 @@ function __doEventDispatch(aTarget, aCharCode, aKeyCode, aHasShift) {
*/
function _parseModifiers(aEvent)
{
+ var hwindow = Components.classes["@mozilla.org/appshell/appShellService;1"]
+ .getService(Components.interfaces.nsIAppShellService)
+ .hiddenDOMWindow;
+
const masks = Components.interfaces.nsIDOMNSEvent;
var mval = 0;
if (aEvent.shiftKey)
@@ -182,8 +204,8 @@ function _parseModifiers(aEvent)
if (aEvent.metaKey)
mval |= masks.META_MASK;
if (aEvent.accelKey)
- mval |= (navigator.platform.indexOf("Mac") >= 0) ? masks.META_MASK :
- masks.CONTROL_MASK;
+ mval |= (hwindow.navigator.platform.indexOf("Mac") >= 0) ? masks.META_MASK :
+ masks.CONTROL_MASK;
return mval;
}
@@ -203,8 +225,6 @@ function _parseModifiers(aEvent)
*/
function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
if (!aWindow)
aWindow = window;
@@ -253,8 +273,6 @@ function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
*/
function synthesizeMouseScroll(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
if (!aWindow)
aWindow = window;
@@ -302,8 +320,6 @@ function synthesizeMouseScroll(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
*/
function synthesizeKey(aKey, aEvent, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
if (!aWindow)
aWindow = window;
@@ -312,7 +328,7 @@ function synthesizeKey(aKey, aEvent, aWindow)
if (utils) {
var keyCode = 0, charCode = 0;
if (aKey.indexOf("VK_") == 0)
- keyCode = KeyEvent["DOM_" + aKey];
+ keyCode = getKeyEvent(aWindow)["DOM_" + aKey];
else
charCode = aKey.charCodeAt(0);
@@ -555,8 +571,6 @@ function synthesizeDrop(srcElement, destElement, dragData, dropEffect, aWindow)
function disableNonTestMouseEvents(aDisable)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
@@ -582,8 +596,6 @@ function _getDOMWindowUtils(aWindow)
*/
function synthesizeComposition(aIsCompositionStart, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return;
@@ -635,8 +647,6 @@ function synthesizeComposition(aIsCompositionStart, aWindow)
*/
function synthesizeText(aEvent, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return;
@@ -685,8 +695,6 @@ function synthesizeText(aEvent, aWindow)
*/
function synthesizeQuerySelectedText(aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -707,8 +715,6 @@ function synthesizeQuerySelectedText(aWindow)
*/
function synthesizeQueryTextContent(aOffset, aLength, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -728,8 +734,6 @@ function synthesizeQueryTextContent(aOffset, aLength, aWindow)
*/
function synthesizeQueryCaretRect(aOffset, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -751,8 +755,6 @@ function synthesizeQueryCaretRect(aOffset, aWindow)
*/
function synthesizeQueryTextRect(aOffset, aLength, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -770,8 +772,6 @@ function synthesizeQueryTextRect(aOffset, aLength, aWindow)
*/
function synthesizeQueryEditorRect(aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -789,8 +789,6 @@ function synthesizeQueryEditorRect(aWindow)
*/
function synthesizeCharAtPoint(aX, aY, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return nullptr;
@@ -813,8 +811,6 @@ function synthesizeCharAtPoint(aX, aY, aWindow)
*/
function synthesizeSelectionSet(aOffset, aLength, aReverse, aWindow)
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
var utils = _getDOMWindowUtils(aWindow);
if (!utils) {
return false;

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

@ -170,8 +170,7 @@ var abDirTreeObserver = {
//
// If target directory is a mailing list, then only allow copies.
// if (targetDirectory.isMailList &&
// dragSession.dragAction != Components.interfaces.
// nsIDragService.DRAGDROP_ACTION_COPY)
// dragSession.dragAction != Ci.nsIDragService.DRAGDROP_ACTION_COPY)
//return false;
var srcDirectory = GetDirectoryFromURI(srcURI);

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

@ -293,7 +293,7 @@ function initializeFilterTypeSelector()
/**
* Returns the currently set filter type (checkboxes) in terms
* of a Components.interfaces.nsMsgFilterType value.
* of a Ci.nsMsgFilterType value.
*/
getType: function()
{
@ -328,7 +328,7 @@ function initializeFilterTypeSelector()
* Sets the checkboxes to represent the filter type passed in.
*
* @param aType the filter type to set in terms
* of Components.interfaces.nsMsgFilterType values.
* of Ci.nsMsgFilterType values.
*/
setType: function(aType)
{

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

@ -29,18 +29,18 @@
var trimmedSearchString = controller.searchString.trim();
// Unescape the URI spec for showing as an entry in the popup
let url = Cc["@mozilla.org/intl/texttosuburi;1"].
getService(Ci.nsITextToSubURI).
unEscapeURIForUI("UTF-8", controller.getValueAt(this._currentIndex));
let url = Cc["@mozilla.org/intl/texttosuburi;1"]
.getService(Ci.nsITextToSubURI)
.unEscapeURIForUI("UTF-8", controller.getValueAt(this._currentIndex));
// Unlike our superclass, we create nodes every time because we have
// heterogeneous results and we cannot rely on the XBL bindings to
// to change fast enough.
item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
var glodaCompleter = Cc["@mozilla.org/autocomplete/search;1?name=gloda"].
getService(). //Components.interfaces.nsIAutoCompleteSearch)
wrappedJSObject;
let glodaCompleter = Cc["@mozilla.org/autocomplete/search;1?name=gloda"]
.getService(Ci.nsIAutoCompleteSearch)
.wrappedJSObject;
var result = glodaCompleter.curResult;
// set these attributes before we set the class
@ -62,7 +62,7 @@
// yield after each batch of items so that typing the url bar is responsive
setTimeout(() => this._appendCurrentResult(), 0);
]]>
]]>
</body>
</method>
<method name="_invalidate">

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

@ -32,7 +32,7 @@ ChromeUtils.import("resource:///modules/gloda/indexer.js");
ChromeUtils.import("resource:///modules/gloda/mimemsg.js");
// Components.results does not have mailnews error codes!
// Cr does not have mailnews error codes!
var NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE = 0x80550005;
var GLODA_MESSAGE_ID_PROPERTY = "gloda-id";

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

@ -673,7 +673,7 @@ function ConsoleAppender(formatter) {
ConsoleAppender.prototype = {
__proto__: Appender.prototype,
// override to send Error and higher level messages to Components.utils.reportError()
// override to send Error and higher level messages to Cu.reportError()
append: function CApp_append(message) {
let stringMessage = this._formatter.format(message);
if (message.level > Log4Moz.Level.Warn) {