From defdabd355003e6e4592f6ab7587ee2c8c6497ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E4=BE=9D=E4=BA=91?= Date: Mon, 20 Nov 2017 00:16:56 +0800 Subject: [PATCH] support for nsPrefBranch::{get,set}StringPref() (#901) Firefox commit: --8<-- Bug 1414096 (attempt 2) - Remove support for nsISupportsString values in nsPrefBranch::{get,set}ComplexValue(). r=florian. Bug 1345294 introduced nsPrefBranch::{get,set}StringPref(), which allowed the getting of utf8 strings from prefs, which previously required using nsISupportsString with {get,set}ComplexValue. That bug also converted most uses. This patch finishes the job. - It removes the nsISupportsString support. - It converts existing code that relied on the nsISupportsString. - It removes the lint that was set up to detect such uses of nsISupportsString. -->8-- --- extension/lib/prefs.coffee | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/extension/lib/prefs.coffee b/extension/lib/prefs.coffee index f41255f..67b14ce 100644 --- a/extension/lib/prefs.coffee +++ b/extension/lib/prefs.coffee @@ -23,7 +23,10 @@ get = (branch, key) -> when branch.PREF_INT branch.getIntPref(key) when branch.PREF_STRING - branch.getComplexValue(key, Ci.nsISupportsString).data + if branch.getStringPref + branch.getStringPref(key) + else + branch.getComplexValue(key, Ci.nsISupportsString).data set = (branch, key, value) -> switch typeof value @@ -32,10 +35,13 @@ set = (branch, key, value) -> when 'number' branch.setIntPref(key, value) # `value` will be `Math.floor`ed. when 'string' - str = Cc['@mozilla.org/supports-string;1'] - .createInstance(Ci.nsISupportsString) - str.data = value - branch.setComplexValue(key, Ci.nsISupportsString, str) + if branch.setStringPref + branch.setStringPref(key, value) + else + str = Cc['@mozilla.org/supports-string;1'] + .createInstance(Ci.nsISupportsString) + str.data = value + branch.setComplexValue(key, Ci.nsISupportsString, str) else if value == null branch.clearUserPref(key) -- 2.39.3