From 33aee368ad66f84f3189f49e098a5e8d2ddcdebf Mon Sep 17 00:00:00 2001 From: Frank Yan Date: Tue, 24 May 2011 17:57:31 -0700 Subject: [PATCH 01/15] Bug 654079 - Reposition app tabs when leaving private browsing mode. r=dao --- browser/base/content/tabbrowser.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 47381b3c28b..c1e2d4b9b60 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2948,8 +2948,7 @@ 0 && - numPinned < this.tabbrowser.visibleTabs.length; + numPinned > 0; if (doPosition) { this.setAttribute("positionpinnedtabs", "true"); From 9dc94992351e72c7cdddbb21ee711993ccd4c794 Mon Sep 17 00:00:00 2001 From: Frank Yan Date: Tue, 24 May 2011 17:57:42 -0700 Subject: [PATCH 02/15] Bug 626903 - Indicate onscreen tabs in List All Tabs menu. r=dolske ui-r=faaborg --- browser/themes/gnomestripe/browser/browser.css | 5 +++++ browser/themes/pinstripe/browser/browser.css | 5 +++++ browser/themes/winstripe/browser/browser.css | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/browser/themes/gnomestripe/browser/browser.css b/browser/themes/gnomestripe/browser/browser.css index 5eec576b939..64fe0f0c6da 100644 --- a/browser/themes/gnomestripe/browser/browser.css +++ b/browser/themes/gnomestripe/browser/browser.css @@ -1697,6 +1697,11 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- list-style-image: url("chrome://global/skin/icons/loading_16.png"); } +.alltabs-item[tabIsVisible] { + /* box-shadow instead of background-color to work around native styling */ + box-shadow: inset 0 0 0 2em hsla(0,0%,50%,.15); +} + /* Sidebar */ #sidebar-header > .tabs-closebutton { margin-bottom: 0px !important; diff --git a/browser/themes/pinstripe/browser/browser.css b/browser/themes/pinstripe/browser/browser.css index a29dda41d24..9c71e660b7f 100644 --- a/browser/themes/pinstripe/browser/browser.css +++ b/browser/themes/pinstripe/browser/browser.css @@ -2006,6 +2006,11 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { list-style-image: url("chrome://global/skin/icons/loading_16.png") !important; } +.alltabs-item[tabIsVisible] { + /* box-shadow instead of background-color to work around native styling */ + box-shadow: inset 0 0 0 2em hsla(0,0%,50%,.15); +} + /* Tabstrip close button */ .tabs-closebutton { -moz-padding-end: 4px; diff --git a/browser/themes/winstripe/browser/browser.css b/browser/themes/winstripe/browser/browser.css index 39f7d72a6e1..256832d7e1f 100644 --- a/browser/themes/winstripe/browser/browser.css +++ b/browser/themes/winstripe/browser/browser.css @@ -1881,6 +1881,11 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- list-style-image: url("chrome://global/skin/icons/loading_16.png"); } +.alltabs-item[tabIsVisible] { + /* box-shadow instead of background-color to work around native styling */ + box-shadow: inset 0 0 0 2em hsla(0,0%,50%,.15); +} + /* Tabstrip close button */ .tabs-closebutton { -moz-appearance: none; From 9f81080a38a8f7963c26f1c0f37e17fac462e2d3 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Tue, 24 May 2011 18:05:54 -0700 Subject: [PATCH 03/15] Bug 654154 - GPSD not being used for Geolocation. r=blassey --- dom/system/GPSDGeolocationProvider.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/system/GPSDGeolocationProvider.manifest b/dom/system/GPSDGeolocationProvider.manifest index 7e503cd7476..b9dd19f10f7 100644 --- a/dom/system/GPSDGeolocationProvider.manifest +++ b/dom/system/GPSDGeolocationProvider.manifest @@ -1,3 +1,3 @@ -component {0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D} GPSDGeolocationProvider.manifest +component {0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D} GPSDGeolocationProvider.js contract @mozilla.org/geolocation/gpsd/provider;1 {0A3BE523-0F2A-32CC-CCD8-1E5986D5A79D} category geolocation-provider GPSDProvider @mozilla.org/geolocation/gpsd/provider;1 From d399113e9b8b202edbfd7c45b4e9d1b4cedd325a Mon Sep 17 00:00:00 2001 From: Shawn Gong Date: Mon, 23 May 2011 18:09:28 -0700 Subject: [PATCH 04/15] Bug 658683: Make xhr.response not create a new ArrayBuffer every time it is accessed. r=sicking. Additional fixes by sicking, r=peterv --- content/base/src/nsXMLHttpRequest.cpp | 49 ++++++++++++++--------- content/base/src/nsXMLHttpRequest.h | 10 +++-- content/base/test/test_XHR.html | 10 +++++ xpcom/glue/nsCycleCollectionParticipant.h | 14 +++++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 5b8395f1721..77e7d4b8fb9 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -426,7 +426,8 @@ nsXMLHttpRequest::nsXMLHttpRequest() mErrorLoad(PR_FALSE), mTimerIsActive(PR_FALSE), mProgressEventWasDelayed(PR_FALSE), mLoadLengthComputable(PR_FALSE), mLoadTotal(0), - mFirstStartRequestSeen(PR_FALSE) + mFirstStartRequestSeen(PR_FALSE), + mResultArrayBuffer(nsnull) { mResponseBodyUnicode.SetIsVoid(PR_TRUE); nsLayoutStatics::AddRef(); @@ -450,6 +451,12 @@ nsXMLHttpRequest::~nsXMLHttpRequest() nsLayoutStatics::Release(); } +void +nsXMLHttpRequest::RootResultArrayBuffer() +{ + nsContentUtils::PreserveWrapper(static_cast(this), this); +} + /** * This Init method is called from the factory constructor. */ @@ -572,9 +579,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest, nsIXMLHttpRequestUpload) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, nsXHREventTarget) + tmp->mResultArrayBuffer = nsnull; NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest) @@ -592,6 +599,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mUpload) NS_IMPL_CYCLE_COLLECTION_UNLINK_END +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsXMLHttpRequest, + nsXHREventTarget) + if(tmp->mResultArrayBuffer) { + NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer, + "mResultArrayBuffer") + } +NS_IMPL_CYCLE_COLLECTION_TRACE_END + DOMCI_DATA(XMLHttpRequest, nsXMLHttpRequest) // QueryInterface implementation for nsXMLHttpRequest @@ -839,27 +854,20 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText) return rv; } -nsresult nsXMLHttpRequest::GetResponseArrayBuffer(jsval *aResult) +nsresult nsXMLHttpRequest::CreateResponseArrayBuffer(JSContext *aCx) { - JSContext *cx = nsContentUtils::GetCurrentJSContext(); - if (!cx) + if (!aCx) return NS_ERROR_FAILURE; - if (!(mState & (XML_HTTP_REQUEST_DONE | - XML_HTTP_REQUEST_LOADING))) { - *aResult = JSVAL_NULL; - return NS_OK; - } - PRInt32 dataLen = mResponseBody.Length(); - JSObject *obj = js_CreateArrayBuffer(cx, dataLen); - if (!obj) + RootResultArrayBuffer(); + mResultArrayBuffer = js_CreateArrayBuffer(aCx, dataLen); + if (!mResultArrayBuffer) { return NS_ERROR_FAILURE; - - *aResult = OBJECT_TO_JSVAL(obj); + } if (dataLen > 0) { - js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(obj); + js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(mResultArrayBuffer); NS_ASSERTION(abuf, "What happened?"); memcpy(abuf->data, mResponseBody.BeginReading(), dataLen); } @@ -954,7 +962,11 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult) case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER: if (mState & XML_HTTP_REQUEST_DONE) { - rv = GetResponseArrayBuffer(aResult); + if (!mResultArrayBuffer) { + rv = CreateResponseArrayBuffer(aCx); + NS_ENSURE_SUCCESS(rv, rv); + } + *aResult = OBJECT_TO_JSVAL(mResultArrayBuffer); } else { *aResult = JSVAL_NULL; } @@ -1073,7 +1085,8 @@ nsXMLHttpRequest::Abort() mResponseBodyUnicode.SetIsVoid(PR_TRUE); mResponseBlob = nsnull; mState |= XML_HTTP_REQUEST_ABORTED; - + mResultArrayBuffer = nsnull; + if (!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_DONE))) { diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 2ab09881ed2..8ee3039d738 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -208,11 +208,11 @@ public: void SetRequestObserver(nsIRequestObserver* aObserver); - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLHttpRequest, + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest, nsXHREventTarget) - PRBool AllowUploadProgress(); - + void RootResultArrayBuffer(); + protected: friend class nsMultipartProxyListener; @@ -224,7 +224,7 @@ protected: PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount); - nsresult GetResponseArrayBuffer(jsval *aResult); + nsresult CreateResponseArrayBuffer(JSContext* aCx); void CreateResponseBlob(nsIRequest *request); // Change the state of the object with this. The broadcast argument // determines if the onreadystatechange listener should be called. @@ -345,6 +345,8 @@ protected: nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; + + JSObject* mResultArrayBuffer; }; // helper class to expose a progress DOM Event diff --git a/content/base/test/test_XHR.html b/content/base/test/test_XHR.html index 9052729e6b5..4f370b34969 100644 --- a/content/base/test/test_XHR.html +++ b/content/base/test/test_XHR.html @@ -134,6 +134,16 @@ ab = xhr.response; ok(ab != null, "should have a non-null arraybuffer"); arraybuffer_equals_to(ab, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb"); +// test array buffer GetResult returns the same object +xhr = new XMLHttpRequest(); +xhr.open("GET", 'file_XHR_binary1.bin', false); +xhr.responseType = 'arraybuffer'; +xhr.send(null) +is(xhr.status, 200, "wrong status"); +checkResponseTextAccessThrows(xhr); +checkResponseXMLAccessThrows(xhr); +is(xhr.response, xhr.response, "returns the same ArrayBuffer"); + // test response (responseType='blob') var onloadCount = 0; function checkOnloadCount() { diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 22d8308a578..02e1b77fe66 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -436,6 +436,20 @@ public: "not the nsISupports pointer we expect"); \ _class *tmp = Downcast(s); +#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class) \ + void \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ + TraceCallback aCallback, \ + void *aClosure) \ + { \ + nsISupports *s = static_cast(p); \ + NS_ASSERTION(CheckForRightISupports(s), \ + "not the nsISupports pointer we expect"); \ + _class *tmp = static_cast<_class*>(Downcast(s)); \ + NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Trace(s, \ + aCallback, \ + aClosure); + #define NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(_class) \ void \ NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ From e5cc03fd5bb375821f740afb7c976d7eed59566c Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Fri, 20 May 2011 22:21:28 -0700 Subject: [PATCH 05/15] Bug 641333: Kill nsIDOM3Text and move its contents to nsIDOMText. r=ms2ger --- content/base/src/nsGenericDOMDataNode.cpp | 69 +++---------------- content/base/src/nsGenericDOMDataNode.h | 50 +++----------- content/base/src/nsTextNode.cpp | 4 +- content/base/src/nsTextNode.h | 3 +- content/xml/content/src/nsXMLCDATASection.cpp | 6 +- dom/base/nsDOMClassInfo.cpp | 3 - dom/base/nsDOMClassInfoID.h | 11 ++- dom/interfaces/core/Makefile.in | 1 - dom/interfaces/core/nsIDOM3Text.idl | 65 ----------------- dom/interfaces/core/nsIDOMCDATASection.idl | 2 +- dom/interfaces/core/nsIDOMText.idl | 28 +++++++- js/src/xpconnect/src/dom_quickstubs.qsconf | 13 ---- 12 files changed, 56 insertions(+), 199 deletions(-) delete mode 100644 dom/interfaces/core/nsIDOM3Text.idl diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index f4fe5320c6e..5047f14e23e 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -846,52 +846,6 @@ nsGenericDOMDataNode::SplitText(PRUint32 aOffset, nsIDOMText** aReturn) return rv; } -//---------------------------------------------------------------------- - -// Implementation of the nsGenericDOMDataNode nsIDOM3Text tearoff - -NS_IMPL_CYCLE_COLLECTION_CLASS(nsText3Tearoff) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsText3Tearoff) - NS_INTERFACE_MAP_ENTRY(nsIDOM3Text) -NS_INTERFACE_MAP_END_AGGREGATED(mNode) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsText3Tearoff) - NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNode) -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsText3Tearoff) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mNode, nsIContent) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsText3Tearoff) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsText3Tearoff) - -NS_IMETHODIMP -nsText3Tearoff::GetIsElementContentWhitespace(PRBool *aReturn) -{ - *aReturn = mNode->IsElementContentWhitespace(); - return NS_OK; -} - -NS_IMETHODIMP -nsText3Tearoff::GetWholeText(nsAString& aWholeText) -{ - return mNode->GetWholeText(aWholeText); -} - -NS_IMETHODIMP -nsText3Tearoff::ReplaceWholeText(const nsAString& aContent, - nsIDOMText **aReturn) -{ - nsresult rv; - nsIContent* result = mNode->ReplaceWholeText(PromiseFlatString(aContent), - &rv); - return result ? CallQueryInterface(result, aReturn) : rv; -} - -// Implementation of the nsIDOM3Text interface - /* static */ PRInt32 nsGenericDOMDataNode::FirstLogicallyAdjacentTextNode(nsIContent* aParent, PRInt32 aIndex) @@ -918,7 +872,7 @@ nsGenericDOMDataNode::LastLogicallyAdjacentTextNode(nsIContent* aParent, } nsresult -nsGenericTextNode::GetWholeText(nsAString& aWholeText) +nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText) { nsIContent* parent = GetParent(); @@ -949,21 +903,21 @@ nsGenericTextNode::GetWholeText(nsAString& aWholeText) return NS_OK; } -nsIContent* -nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, - nsresult* aResult) +nsresult +nsGenericDOMDataNode::ReplaceWholeText(const nsAString& aContent, + nsIDOMText **aResult) { - *aResult = NS_OK; + *aResult = nsnull; // Handle parent-less nodes nsCOMPtr parent = GetParent(); if (!parent) { if (aContent.IsEmpty()) { - return nsnull; + return NS_OK; } SetNodeValue(aContent); - return this; + return CallQueryInterface(this, aResult); } // We're relying on mozAutoSubtreeModified to keep the doc alive here. @@ -976,8 +930,7 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, if (index < 0) { NS_WARNING("Trying to use .replaceWholeText with an anonymous text node " "child of a binding parent?"); - *aResult = NS_ERROR_DOM_NOT_SUPPORTED_ERR; - return nsnull; + return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } // We don't support entity references or read-only nodes, so remove the @@ -1016,11 +969,11 @@ nsGenericTextNode::ReplaceWholeText(const nsAFlatString& aContent, // Empty string means we removed this node too. if (aContent.IsEmpty()) { - return nsnull; + return NS_OK; } - SetText(aContent.get(), aContent.Length(), PR_TRUE); - return this; + SetText(aContent.BeginReading(), aContent.Length(), PR_TRUE); + return CallQueryInterface(this, aResult); } //---------------------------------------------------------------------- diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 3557ac0511e..e6c0ab9c6c3 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -46,7 +46,6 @@ #include "nsIContent.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventTarget.h" -#include "nsIDOM3Text.h" #include "nsTextFragment.h" #include "nsDOMError.h" #include "nsIEventListenerManager.h" @@ -328,7 +327,15 @@ protected: nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn); - friend class nsText3Tearoff; + nsresult GetWholeText(nsAString& aWholeText); + + nsresult ReplaceWholeText(const nsAString& aContent, nsIDOMText **aReturn); + + nsresult GetIsElementContentWhitespace(PRBool *aReturn) + { + *aReturn = TextIsOnlyWhitespace(); + return NS_OK; + } static PRInt32 FirstLogicallyAdjacentTextNode(nsIContent* aParent, PRInt32 aIndex); @@ -360,45 +367,6 @@ private: already_AddRefed GetCurrentValueAtom(); }; -class nsGenericTextNode : public nsGenericDOMDataNode -{ -public: - nsGenericTextNode(already_AddRefed aNodeInfo) - : nsGenericDOMDataNode(aNodeInfo) - { - } - - PRBool IsElementContentWhitespace() - { - return TextIsOnlyWhitespace(); - } - nsresult GetWholeText(nsAString& aWholeText); - - nsIContent* ReplaceWholeText(const nsAFlatString& aContent, - nsresult *aResult); -}; - -/** Tearoff class for the nsIDOM3Text portion of nsGenericDOMDataNode. */ -class nsText3Tearoff : public nsIDOM3Text -{ -public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - - NS_DECL_NSIDOM3TEXT - - NS_DECL_CYCLE_COLLECTION_CLASS(nsText3Tearoff) - - nsText3Tearoff(nsGenericTextNode *aNode) : mNode(aNode) - { - } - -protected: - virtual ~nsText3Tearoff() {} - -private: - nsRefPtr mNode; -}; - //---------------------------------------------------------------------- /** diff --git a/content/base/src/nsTextNode.cpp b/content/base/src/nsTextNode.cpp index c3dc9be6da1..ed5bb2e2d1d 100644 --- a/content/base/src/nsTextNode.cpp +++ b/content/base/src/nsTextNode.cpp @@ -40,7 +40,6 @@ */ #include "nsTextNode.h" -#include "nsIDOM3Text.h" #include "nsContentUtils.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" @@ -142,7 +141,7 @@ NS_NewTextNode(nsIContent** aInstancePtrResult, } nsTextNode::nsTextNode(already_AddRefed aNodeInfo) - : nsGenericTextNode(aNodeInfo) + : nsGenericDOMDataNode(aNodeInfo) { } @@ -159,7 +158,6 @@ DOMCI_NODE_DATA(Text, nsTextNode) NS_INTERFACE_TABLE_HEAD(nsTextNode) NS_NODE_INTERFACE_TABLE3(nsTextNode, nsIDOMNode, nsIDOMText, nsIDOMCharacterData) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this)) NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsTextNode) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Text) NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) diff --git a/content/base/src/nsTextNode.h b/content/base/src/nsTextNode.h index c68a6f63a57..c37107a9f8e 100644 --- a/content/base/src/nsTextNode.h +++ b/content/base/src/nsTextNode.h @@ -41,7 +41,6 @@ #include "nsGenericDOMDataNode.h" #include "nsIDOMText.h" -#include "nsIDOM3Text.h" #include "nsContentUtils.h" #include "nsIDOMEventListener.h" #include "nsIDOMEventTarget.h" @@ -53,7 +52,7 @@ /** * Class used to implement DOM text nodes */ -class nsTextNode : public nsGenericTextNode, +class nsTextNode : public nsGenericDOMDataNode, public nsIDOMText { public: diff --git a/content/xml/content/src/nsXMLCDATASection.cpp b/content/xml/content/src/nsXMLCDATASection.cpp index 9474070cbce..071b0d8729b 100644 --- a/content/xml/content/src/nsXMLCDATASection.cpp +++ b/content/xml/content/src/nsXMLCDATASection.cpp @@ -36,14 +36,13 @@ * ***** END LICENSE BLOCK ***** */ #include "nsIDOMCDATASection.h" -#include "nsIDOM3Text.h" #include "nsGenericDOMDataNode.h" #include "nsGkAtoms.h" #include "nsIDocument.h" #include "nsContentUtils.h" -class nsXMLCDATASection : public nsGenericTextNode, +class nsXMLCDATASection : public nsGenericDOMDataNode, public nsIDOMCDATASection { public: @@ -99,7 +98,7 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult, } nsXMLCDATASection::nsXMLCDATASection(already_AddRefed aNodeInfo) - : nsGenericTextNode(aNodeInfo) + : nsGenericDOMDataNode(aNodeInfo) { } @@ -114,7 +113,6 @@ DOMCI_NODE_DATA(CDATASection, nsXMLCDATASection) NS_INTERFACE_TABLE_HEAD(nsXMLCDATASection) NS_NODE_INTERFACE_TABLE4(nsXMLCDATASection, nsIDOMNode, nsIDOMCharacterData, nsIDOMText, nsIDOMCDATASection) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this)) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CDATASection) NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index fad93daa418..738439856d0 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -224,7 +224,6 @@ #include "nsIDOMDocumentFragment.h" #include "nsDOMAttribute.h" #include "nsIDOMText.h" -#include "nsIDOM3Text.h" #include "nsIDOMComment.h" #include "nsIDOMCDATASection.h" #include "nsIDOMProcessingInstruction.h" @@ -2547,7 +2546,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) - DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text) DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment) @@ -2562,7 +2560,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) - DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text) DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction) diff --git a/dom/base/nsDOMClassInfoID.h b/dom/base/nsDOMClassInfoID.h index 9bbd4517e59..c02ad3e0ffb 100644 --- a/dom/base/nsDOMClassInfoID.h +++ b/dom/base/nsDOMClassInfoID.h @@ -80,13 +80,12 @@ DOMCI_CASTABLE_INTERFACE(nsIContent, nsIContent, 1, _extra) \ DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 2, _extra) \ DOMCI_CASTABLE_INTERFACE(nsINodeList, nsINodeList, 3, _extra) \ DOMCI_CASTABLE_INTERFACE(nsICSSDeclaration, nsICSSDeclaration, 4, _extra) \ -DOMCI_CASTABLE_INTERFACE(nsGenericTextNode, nsGenericTextNode, 5, _extra) \ -DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 6, _extra) \ -DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 7, \ +DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra) \ +DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 6, \ _extra) \ -DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 8, _extra) \ -DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 9, _extra) \ -DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 10, _extra) +DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra) \ +DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra) \ +DOMCI_CASTABLE_INTERFACE(nsSVGStylableElement, nsIContent, 9, _extra) // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES // have been declared. diff --git a/dom/interfaces/core/Makefile.in b/dom/interfaces/core/Makefile.in index 85c1a0917d2..a2288c26a35 100644 --- a/dom/interfaces/core/Makefile.in +++ b/dom/interfaces/core/Makefile.in @@ -68,7 +68,6 @@ SDK_XPIDLSRCS = \ $(NULL) XPIDLSRCS = \ nsIDOM3Node.idl \ - nsIDOM3Text.idl \ nsIDOM3TypeInfo.idl \ nsIDOM3Attr.idl \ nsIDOMDOMStringList.idl \ diff --git a/dom/interfaces/core/nsIDOM3Text.idl b/dom/interfaces/core/nsIDOM3Text.idl deleted file mode 100644 index c50dad59d84..00000000000 --- a/dom/interfaces/core/nsIDOM3Text.idl +++ /dev/null @@ -1,65 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is DOM 3 Core interface definitions. - * - * The Initial Developer of the Original Code is - * Jeff Walden . - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "domstubs.idl" - -[scriptable, uuid(BCCA052E-46F4-4B8E-8859-A86776C2F1D7)] -interface nsIDOM3Text : nsISupports -{ - /** - * Indicates whether this text node contains element content whitespace. - * A text node is element content whitespace if it contains only XML - * white space characters and is a child of an element whose content - * model allows only child elements optionally separated by white space. - */ - readonly attribute boolean isElementContentWhitespace; - - /** - * The concatenation of all logically adjacent text nodes with this text - * node, where "logically adjacent" consists of all text nodes which can be - * reached by traversing the document tree in either direction without - * passing an element, comment, or processing-instruction boundary. - */ - readonly attribute DOMString wholeText; - - /** - * If content is empty, removes all logically adjacent text nodes (including - * this node) from the DOM tree, returning null; otherwise, replaces the - * contents of this node with aContent and removes all other logically - * adjacent text nodes from the DOM tree, returning this node. - */ - nsIDOMText replaceWholeText(in DOMString content) raises(DOMException); -}; diff --git a/dom/interfaces/core/nsIDOMCDATASection.idl b/dom/interfaces/core/nsIDOMCDATASection.idl index 510810840cd..028c4a022ed 100644 --- a/dom/interfaces/core/nsIDOMCDATASection.idl +++ b/dom/interfaces/core/nsIDOMCDATASection.idl @@ -49,7 +49,7 @@ * http://www.w3.org/TR/DOM-Level-2-Core/ */ -[scriptable, uuid(f8da723d-0d32-4bbc-a11e-898e506cd908)] +[scriptable, uuid(f1eea89d-8af3-4c2a-90df-6c3a75cb5005)] interface nsIDOMCDATASection : nsIDOMText { }; diff --git a/dom/interfaces/core/nsIDOMText.idl b/dom/interfaces/core/nsIDOMText.idl index 2aa2fd8c524..7b55e068d55 100644 --- a/dom/interfaces/core/nsIDOMText.idl +++ b/dom/interfaces/core/nsIDOMText.idl @@ -44,12 +44,36 @@ * the textual content (termed character data in XML) of an Element or Attr. * * For more information on this interface please see - * http://www.w3.org/TR/DOM-Level-2-Core/ + * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html */ -[scriptable, uuid(48642156-d686-46b7-8e96-35edd5b2afa8)] +[scriptable, uuid(04a1ec2b-491f-4a80-8db4-694c37e31a6f)] interface nsIDOMText : nsIDOMCharacterData { nsIDOMText splitText(in unsigned long offset) raises(DOMException); + + /** + * Indicates whether this text node contains element content whitespace. + * A text node is element content whitespace if it contains only XML + * white space characters and is a child of an element whose content + * model allows only child elements optionally separated by white space. + */ + readonly attribute boolean isElementContentWhitespace; + + /** + * The concatenation of all logically adjacent text nodes with this text + * node, where "logically adjacent" consists of all text nodes which can be + * reached by traversing the document tree in either direction without + * passing an element, comment, or processing-instruction boundary. + */ + readonly attribute DOMString wholeText; + + /** + * If content is empty, removes all logically adjacent text nodes (including + * this node) from the DOM tree, returning null; otherwise, replaces the + * contents of this node with aContent and removes all other logically + * adjacent text nodes from the DOM tree, returning this node. + */ + nsIDOMText replaceWholeText(in DOMString content) raises(DOMException); }; diff --git a/js/src/xpconnect/src/dom_quickstubs.qsconf b/js/src/xpconnect/src/dom_quickstubs.qsconf index 71773b2226e..9203d4f2cc0 100644 --- a/js/src/xpconnect/src/dom_quickstubs.qsconf +++ b/js/src/xpconnect/src/dom_quickstubs.qsconf @@ -784,19 +784,6 @@ customMethodCalls = { 'thisType': 'nsGenericElement', 'code': ' PRBool result = self->MozMatchesSelector(arg0, &rv);', }, - 'nsIDOM3Text_': { - 'thisType': 'nsGenericTextNode' - }, - 'nsIDOM3Text_IsElementContentWhitespace': { - 'thisType': 'nsGenericTextNode', - 'code': ' PRBool result = self->IsElementContentWhitespace();', - 'canFail': False - }, - 'nsIDOM3Text_ReplaceWholeText': { - 'thisType': 'nsGenericTextNode', - 'code': ' nsIContent* result = ' - 'self->ReplaceWholeText(PromiseFlatString(arg0), &rv);' - }, 'nsIDOMNodeSelector_QuerySelector': { 'thisType': 'nsINode', 'code': ' nsIContent* result = ' From 060287addd11d8ec1dfb4ac0de6a1aa722f807be Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 25 May 2011 15:31:59 +0900 Subject: [PATCH 06/15] Bug 659533 Replace nsContentUtils::GetBoolPref() with Preferences::GetBool() r=roc --- content/base/public/nsContentUtils.h | 2 -- content/base/src/nsContentUtils.cpp | 23 ++++-------- content/base/src/nsDocument.cpp | 5 ++- content/base/src/nsEventSource.cpp | 5 ++- content/base/src/nsFrameLoader.cpp | 9 ++--- content/base/src/nsPlainTextSerializer.cpp | 13 +++---- content/base/src/nsWebSocket.cpp | 3 +- content/events/src/nsDOMTouchEvent.cpp | 5 ++- content/events/src/nsEventStateManager.cpp | 32 +++++++++-------- .../html/content/src/nsGenericHTMLElement.cpp | 5 ++- .../html/content/src/nsHTMLDNSPrefetch.cpp | 5 ++- .../html/content/src/nsHTMLImageElement.cpp | 4 ++- .../html/content/src/nsHTMLMediaElement.cpp | 16 +++++---- content/html/document/src/nsImageDocument.cpp | 14 ++++---- content/svg/content/src/nsSVGImageElement.cpp | 3 +- .../xml/document/src/nsXMLPrettyPrinter.cpp | 4 ++- .../xul/content/src/nsXULPopupListener.cpp | 5 ++- .../xul/document/src/nsXULPrototypeCache.cpp | 22 ++++++------ dom/base/nsDOMClassInfo.cpp | 6 ++-- dom/base/nsFocusManager.cpp | 17 +++++---- dom/base/nsGlobalWindow.cpp | 29 +++++++++------ dom/base/nsGlobalWindow.h | 5 +-- dom/base/nsGlobalWindowCommands.cpp | 6 ++-- dom/base/nsHistory.cpp | 9 +++-- dom/base/nsJSEnvironment.cpp | 35 ++++++++++--------- dom/indexedDB/CheckPermissionsHelper.cpp | 4 ++- dom/src/geolocation/nsGeolocation.cpp | 15 ++++---- .../notification/nsDesktopNotification.cpp | 9 +++-- dom/src/storage/nsDOMStorage.cpp | 6 +++- layout/base/nsCaret.cpp | 5 ++- layout/base/nsPresContext.cpp | 23 ++++++------ layout/base/nsPresShell.cpp | 9 ++--- layout/forms/nsComboboxControlFrame.cpp | 5 +-- layout/generic/nsFrame.cpp | 8 +++-- layout/generic/nsFrameSetFrame.cpp | 9 ++--- layout/generic/nsHTMLReflowState.cpp | 3 +- layout/generic/nsImageFrame.cpp | 9 +++-- layout/generic/nsSelection.cpp | 5 ++- layout/printing/nsPrintEngine.cpp | 9 ++--- layout/style/nsCSSRuleProcessor.cpp | 6 ++-- layout/style/nsCSSScanner.cpp | 5 ++- layout/svg/base/src/nsSVGUtils.cpp | 7 ++-- layout/xul/base/src/nsBoxFrame.cpp | 6 ++-- layout/xul/base/src/nsMenuBarListener.cpp | 6 ++-- layout/xul/base/src/nsMenuPopupFrame.cpp | 5 ++- layout/xul/base/src/nsSliderFrame.cpp | 5 ++- layout/xul/base/src/nsXULTooltipListener.cpp | 7 ++-- 47 files changed, 265 insertions(+), 183 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index e9700fadc3d..4dd454d55da 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -551,8 +551,6 @@ public: nsIAtom **aTagName, PRInt32 *aNameSpaceID); static nsAdoptingCString GetCharPref(const char *aPref); - static PRPackedBool GetBoolPref(const char *aPref, - PRBool aDefault = PR_FALSE); static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0); static nsAdoptingString GetLocalizedStringPref(const char *aPref); static nsAdoptingString GetStringPref(const char *aPref); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 3c264ce3b4a..0979b4d2e96 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -211,8 +211,11 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID); #endif #include "nsDOMTouchEvent.h" +#include "mozilla/Preferences.h" + using namespace mozilla::dom; using namespace mozilla::layers; +using namespace mozilla; const char kLoadAsData[] = "loadAsData"; @@ -2608,20 +2611,6 @@ nsContentUtils::GetCharPref(const char *aPref) return result; } -// static -PRPackedBool -nsContentUtils::GetBoolPref(const char *aPref, PRBool aDefault) -{ - PRBool result; - - if (!sPrefBranch || - NS_FAILED(sPrefBranch->GetBoolPref(aPref, &result))) { - result = aDefault; - } - - return (PRPackedBool)result; -} - // static PRInt32 nsContentUtils::GetIntPref(const char *aPref, PRInt32 aDefault) @@ -2734,8 +2723,8 @@ BoolVarChanged(const char *aPref, void *aClosure) { PrefCacheData* cache = static_cast(aClosure); *((PRBool*)cache->cacheLocation) = - nsContentUtils::GetBoolPref(aPref, cache->defaultValueBool); - + Preferences::GetBool(aPref, cache->defaultValueBool); + return 0; } @@ -2744,7 +2733,7 @@ nsContentUtils::AddBoolPrefVarCache(const char *aPref, PRBool* aCache, PRBool aDefault) { - *aCache = GetBoolPref(aPref, aDefault); + *aCache = Preferences::GetBool(aPref, aDefault); PrefCacheData* data = new PrefCacheData; data->cacheLocation = aCache; data->defaultValueBool = aDefault; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index d11abcf47cc..86a24e1f48a 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -203,6 +203,9 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID); #include "nsXULAppAPI.h" #include "nsDOMTouchEvent.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; typedef nsTArray LinkArray; @@ -8261,7 +8264,7 @@ nsresult nsDocument::SetImageLockingState(PRBool aLocked) { if (XRE_GetProcessType() == GeckoProcessType_Content && - !nsContentUtils::GetBoolPref("content.image.allow_locking", PR_TRUE)) { + !Preferences::GetBool("content.image.allow_locking", PR_TRUE)) { return NS_OK; } diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index d3112ff3350..10bbd4f586f 100755 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -57,6 +57,9 @@ #include "nsICharsetConverterManager.h" #include "nsIChannelPolicy.h" #include "nsIContentSecurityPolicy.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define REPLACEMENT_CHAR (PRUnichar)0xFFFD #define BOM_CHAR (PRUnichar)0xFEFF @@ -775,7 +778,7 @@ nsEventSource::GetInterface(const nsIID & aIID, PRBool nsEventSource::PrefEnabled() { - return nsContentUtils::GetBoolPref("dom.server-events.enabled", PR_FALSE); + return Preferences::GetBool("dom.server-events.enabled", PR_FALSE); } nsresult diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index 8515337552b..5f3fa94eb08 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -114,6 +114,8 @@ #include "TabParent.h" #include "mozilla/layout/RenderFrameParent.h" +#include "mozilla/Preferences.h" + using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; @@ -1346,8 +1348,8 @@ nsFrameLoader::ShouldUseRemoteProcess() return false; } - PRBool remoteDisabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.disabled", - PR_FALSE); + PRBool remoteDisabled = + Preferences::GetBool("dom.ipc.tabs.disabled", PR_FALSE); if (remoteDisabled) { return false; } @@ -1366,8 +1368,7 @@ nsFrameLoader::ShouldUseRemoteProcess() return true; } - PRBool remoteEnabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.enabled", - PR_FALSE); + PRBool remoteEnabled = Preferences::GetBool("dom.ipc.tabs.enabled", PR_FALSE); return (bool) remoteEnabled; } diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index 6914b94efb3..870f060607e 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -58,7 +58,9 @@ #include "nsCRT.h" #include "nsIParserService.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; #define PREF_STRUCTS "converter.html2txt.structs" @@ -206,28 +208,27 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, if (mFlags & nsIDocumentEncoder::OutputFormatted) { // Get some prefs that controls how we do formatted output - mStructs = nsContentUtils::GetBoolPref(PREF_STRUCTS, mStructs); + mStructs = Preferences::GetBool(PREF_STRUCTS, mStructs); mHeaderStrategy = nsContentUtils::GetIntPref(PREF_HEADER_STRATEGY, mHeaderStrategy); // The quotesPreformatted pref is a temporary measure. See bug 69638. mQuotesPreformatted = - nsContentUtils::GetBoolPref("editor.quotesPreformatted", - mQuotesPreformatted); + Preferences::GetBool("editor.quotesPreformatted", mQuotesPreformatted); // DontWrapAnyQuotes is set according to whether plaintext mail // is wrapping to window width -- see bug 134439. // We'll only want this if we're wrapping and formatted. if (mFlags & nsIDocumentEncoder::OutputWrap || mWrapColumn > 0) { mDontWrapAnyQuotes = - nsContentUtils::GetBoolPref("mail.compose.wrap_to_window_width", - mDontWrapAnyQuotes); + Preferences::GetBool("mail.compose.wrap_to_window_width", + mDontWrapAnyQuotes); } } // XXX We should let the caller pass this in. - if (nsContentUtils::GetBoolPref("browser.frames.enabled")) { + if (Preferences::GetBool("browser.frames.enabled")) { mFlags &= ~nsIDocumentEncoder::OutputNoFramesContent; } else { diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index 9fe8a2fbe9f..dd349278ab9 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -75,6 +75,7 @@ #include "nsIWebSocketProtocol.h" #include "nsILoadGroup.h" #include "nsIRequest.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -902,7 +903,7 @@ nsWebSocket::CreateAndDispatchCloseEvent(PRBool aWasClean) PRBool nsWebSocket::PrefEnabled() { - return nsContentUtils::GetBoolPref("network.websocket.enabled", PR_TRUE); + return Preferences::GetBool("network.websocket.enabled", PR_TRUE); } void diff --git a/content/events/src/nsDOMTouchEvent.cpp b/content/events/src/nsDOMTouchEvent.cpp index 8fbd374a2c3..a1ac1ed1239 100644 --- a/content/events/src/nsDOMTouchEvent.cpp +++ b/content/events/src/nsDOMTouchEvent.cpp @@ -41,6 +41,9 @@ #include "nsIClassInfo.h" #include "nsIXPCScriptable.h" #include "nsContentUtils.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; DOMCI_DATA(Touch, nsDOMTouch) @@ -323,7 +326,7 @@ nsDOMTouchEvent::PrefEnabled() static PRBool sPrefValue = PR_FALSE; if (!sDidCheckPref) { sDidCheckPref = PR_TRUE; - sPrefValue = nsContentUtils::GetBoolPref("dom.w3c_touch_events.enabled", PR_FALSE); + sPrefValue = Preferences::GetBool("dom.w3c_touch_events.enabled", PR_FALSE); if (sPrefValue) { nsContentUtils::InitializeTouchEventTable(); } diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 7855bd56aac..fcb152e9d2c 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -154,10 +154,13 @@ #include "mozilla/Services.h" #include "mozAutoDocUpdate.h" +#include "mozilla/Preferences.h" + #ifdef XP_MACOSX #import #endif +using namespace mozilla; using namespace mozilla::dom; //#define DEBUG_DOCSHELL_FOCUS @@ -584,7 +587,7 @@ nsMouseWheelTransaction::OnFailToScrollTarget() { NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction"); - if (nsContentUtils::GetBoolPref("test.mousescroll", PR_FALSE)) { + if (Preferences::GetBool("test.mousescroll", PR_FALSE)) { // This event is used for automated tests, see bug 442774. nsContentUtils::DispatchTrustedEvent( sTargetFrame->GetContent()->GetOwnerDoc(), @@ -612,7 +615,7 @@ nsMouseWheelTransaction::OnTimeout(nsITimer* aTimer, void* aClosure) // the next DOM event might create strange situation for us. EndTransaction(); - if (nsContentUtils::GetBoolPref("test.mousescroll", PR_FALSE)) { + if (Preferences::GetBool("test.mousescroll", PR_FALSE)) { // This event is used for automated tests, see bug 442774. nsContentUtils::DispatchTrustedEvent( frame->GetContent()->GetOwnerDoc(), @@ -843,8 +846,8 @@ nsEventStateManager::Init() if (prefBranch) { if (sESMInstanceCount == 1) { sLeftClickOnly = - nsContentUtils::GetBoolPref("nglayout.events.dispatchLeftClickOnly", - sLeftClickOnly); + Preferences::GetBool("nglayout.events.dispatchLeftClickOnly", + sLeftClickOnly); sChromeAccessModifier = GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeChrome); sContentAccessModifier = @@ -875,7 +878,7 @@ nsEventStateManager::Init() } mClickHoldContextMenu = - nsContentUtils::GetBoolPref("ui.click_hold_context_menus", PR_FALSE); + Preferences::GetBool("ui.click_hold_context_menus", PR_FALSE); return NS_OK; } @@ -968,12 +971,12 @@ nsEventStateManager::Observe(nsISupports *aSubject, nsDependentString data(someData); if (data.EqualsLiteral("accessibility.accesskeycausesactivation")) { sKeyCausesActivation = - nsContentUtils::GetBoolPref("accessibility.accesskeycausesactivation", - sKeyCausesActivation); + Preferences::GetBool("accessibility.accesskeycausesactivation", + sKeyCausesActivation); } else if (data.EqualsLiteral("nglayout.events.dispatchLeftClickOnly")) { sLeftClickOnly = - nsContentUtils::GetBoolPref("nglayout.events.dispatchLeftClickOnly", - sLeftClickOnly); + Preferences::GetBool("nglayout.events.dispatchLeftClickOnly", + sLeftClickOnly); } else if (data.EqualsLiteral("ui.key.generalAccessKey")) { sChromeAccessModifier = GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeChrome); @@ -987,7 +990,7 @@ nsEventStateManager::Observe(nsISupports *aSubject, GetAccessModifierMaskFromPref(nsIDocShellTreeItem::typeContent); } else if (data.EqualsLiteral("ui.click_hold_context_menus")) { mClickHoldContextMenu = - nsContentUtils::GetBoolPref("ui.click_hold_context_menus", PR_FALSE); + Preferences::GetBool("ui.click_hold_context_menus", PR_FALSE); #if 0 } else if (data.EqualsLiteral("mousewheel.withaltkey.action")) { } else if (data.EqualsLiteral("mousewheel.withaltkey.numlines")) { @@ -2464,10 +2467,11 @@ nsEventStateManager::DoScrollZoom(nsIFrame *aTargetFrame, // positive adjustment to decrease zoom, negative to increase PRInt32 change = (adjustment > 0) ? -1 : 1; - if (nsContentUtils::GetBoolPref("browser.zoom.full")) + if (Preferences::GetBool("browser.zoom.full")) { ChangeFullZoom(change); - else + } else { ChangeTextSize(change); + } } } @@ -2628,7 +2632,7 @@ nsEventStateManager::UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".sysnumlines"); - return nsContentUtils::GetBoolPref(prefName.get()); + return Preferences::GetBool(prefName.get()); } nsresult @@ -3467,7 +3471,7 @@ nsEventStateManager::UpdateCursor(nsPresContext* aPresContext, hotspotY = framecursor.mHotspotY; } - if (nsContentUtils::GetBoolPref("ui.use_activity_cursor", PR_FALSE)) { + if (Preferences::GetBool("ui.use_activity_cursor", PR_FALSE)) { // Check whether or not to show the busy cursor nsCOMPtr pcContainer = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(pcContainer)); diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index c72d0dd1bea..d69f25152f4 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -116,6 +116,9 @@ #include "mozilla/dom/Element.h" #include "nsHTMLFieldSetElement.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; #include "nsThreadUtils.h" @@ -2545,7 +2548,7 @@ nsGenericHTMLFormElement::BindToTree(nsIDocument* aDocument, // the document should not be already loaded and the "browser.autofocus" // preference should be 'true'. if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) && - nsContentUtils::GetBoolPref("browser.autofocus", PR_TRUE)) { + Preferences::GetBool("browser.autofocus", PR_TRUE)) { nsCOMPtr event = new nsAutoFocusEvent(this); rv = NS_DispatchToCurrentThread(event); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/html/content/src/nsHTMLDNSPrefetch.cpp b/content/html/content/src/nsHTMLDNSPrefetch.cpp index 36ee2f26a0f..27912f4c0d9 100644 --- a/content/html/content/src/nsHTMLDNSPrefetch.cpp +++ b/content/html/content/src/nsHTMLDNSPrefetch.cpp @@ -62,6 +62,9 @@ #include "nsIObserverService.h" #include "mozilla/dom/Link.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::net; @@ -99,7 +102,7 @@ nsHTMLDNSPrefetch::Initialize() // Default is false, so we need an explicit call to prime the cache. sDisablePrefetchHTTPSPref = - nsContentUtils::GetBoolPref("network.dns.disablePrefetchFromHTTPS", PR_TRUE); + Preferences::GetBool("network.dns.disablePrefetchFromHTTPS", PR_TRUE); NS_IF_RELEASE(sDNSService); nsresult rv; diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index 841f3b0e983..e0903fcec62 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -75,7 +75,9 @@ #include "nsEventDispatcher.h" #include "nsLayoutUtils.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; // XXX nav attrs: suppress @@ -500,7 +502,7 @@ nsHTMLImageElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, // If caller is not chrome and dom.disable_image_src_set is true, // prevent setting image.src by exiting early - if (nsContentUtils::GetBoolPref("dom.disable_image_src_set") && + if (Preferences::GetBool("dom.disable_image_src_set") && !nsContentUtils::IsCallerChrome()) { return NS_OK; } diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 4f35b8e00dc..9d54d27f8ec 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -119,6 +119,9 @@ static PRLogModuleInfo* gMediaElementEventsLog; #include "nsIChannelPolicy.h" #include "nsChannelPolicy.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; @@ -838,7 +841,7 @@ void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction) static PRBool IsAutoplayEnabled() { - return nsContentUtils::GetBoolPref("media.autoplay.enabled"); + return Preferences::GetBool("media.autoplay.enabled"); } void nsHTMLMediaElement::UpdatePreloadAction() @@ -1536,7 +1539,7 @@ static const char* gRawCodecs[] = { static PRBool IsRawEnabled() { - return nsContentUtils::GetBoolPref("media.raw.enabled"); + return Preferences::GetBool("media.raw.enabled"); } static PRBool IsRawType(const nsACString& aType) @@ -1568,7 +1571,7 @@ char const *const nsHTMLMediaElement::gOggCodecs[3] = { bool nsHTMLMediaElement::IsOggEnabled() { - return nsContentUtils::GetBoolPref("media.ogg.enabled"); + return Preferences::GetBool("media.ogg.enabled"); } bool @@ -1603,7 +1606,7 @@ char const *const nsHTMLMediaElement::gWaveCodecs[2] = { bool nsHTMLMediaElement::IsWaveEnabled() { - return nsContentUtils::GetBoolPref("media.wave.enabled"); + return Preferences::GetBool("media.wave.enabled"); } bool @@ -1635,7 +1638,7 @@ char const *const nsHTMLMediaElement::gWebMCodecs[4] = { bool nsHTMLMediaElement::IsWebMEnabled() { - return nsContentUtils::GetBoolPref("media.webm.enabled"); + return Preferences::GetBool("media.webm.enabled"); } bool @@ -2083,8 +2086,7 @@ void nsHTMLMediaElement::DownloadStalled() PRBool nsHTMLMediaElement::ShouldCheckAllowOrigin() { - return nsContentUtils::GetBoolPref("media.enforce_same_site_origin", - PR_TRUE); + return Preferences::GetBool("media.enforce_same_site_origin", PR_TRUE); } void nsHTMLMediaElement::UpdateReadyStateForData(NextFrameStatus aNextFrame) diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index a7cf5976cec..e16c42bcfdd 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -74,7 +74,9 @@ #include "nsThreadUtils.h" #include "nsIScrollableFrame.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; #define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing" @@ -288,10 +290,8 @@ nsImageDocument::Init() nsresult rv = nsMediaDocument::Init(); NS_ENSURE_SUCCESS(rv, rv); - mResizeImageByDefault = - nsContentUtils::GetBoolPref(AUTOMATIC_IMAGE_RESIZING_PREF); - mClickResizingEnabled = - nsContentUtils::GetBoolPref(CLICK_IMAGE_RESIZING_PREF); + mResizeImageByDefault = Preferences::GetBool(AUTOMATIC_IMAGE_RESIZING_PREF); + mClickResizingEnabled = Preferences::GetBool(CLICK_IMAGE_RESIZING_PREF); mShouldResize = mResizeImageByDefault; mFirstResize = PR_TRUE; @@ -316,8 +316,7 @@ nsImageDocument::StartDocumentLoad(const char* aCommand, } mOriginalZoomLevel = - nsContentUtils::GetBoolPref(SITE_SPECIFIC_ZOOM, PR_FALSE) ? - 1.0 : GetZoomLevel(); + Preferences::GetBool(SITE_SPECIFIC_ZOOM, PR_FALSE) ? 1.0 : GetZoomLevel(); NS_ASSERTION(aDocListener, "null aDocListener"); *aDocListener = new ImageListener(this); @@ -398,8 +397,7 @@ nsImageDocument::OnPageShow(PRBool aPersisted, { if (aPersisted) { mOriginalZoomLevel = - nsContentUtils::GetBoolPref(SITE_SPECIFIC_ZOOM, PR_FALSE) ? - 1.0 : GetZoomLevel(); + Preferences::GetBool(SITE_SPECIFIC_ZOOM, PR_FALSE) ? 1.0 : GetZoomLevel(); } nsMediaDocument::OnPageShow(aPersisted, aDispatchStartTarget); } diff --git a/content/svg/content/src/nsSVGImageElement.cpp b/content/svg/content/src/nsSVGImageElement.cpp index e4e4932bcaf..fa029f3b76b 100644 --- a/content/svg/content/src/nsSVGImageElement.cpp +++ b/content/svg/content/src/nsSVGImageElement.cpp @@ -43,6 +43,7 @@ #include "imgIContainer.h" #include "imgIDecoderObserver.h" #include "gfxContext.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -170,7 +171,7 @@ nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) { // If caller is not chrome and dom.disable_image_src_set is true, // prevent setting image.src by exiting early - if (nsContentUtils::GetBoolPref("dom.disable_image_src_set") && + if (Preferences::GetBool("dom.disable_image_src_set") && !nsContentUtils::IsCallerChrome()) { return NS_OK; } diff --git a/content/xml/document/src/nsXMLPrettyPrinter.cpp b/content/xml/document/src/nsXMLPrettyPrinter.cpp index 504db4af51d..7bd17de872f 100644 --- a/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -52,7 +52,9 @@ #include "nsIDOMDocumentFragment.h" #include "nsBindingManager.h" #include "nsIScriptSecurityManager.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; NS_IMPL_ISUPPORTS2(nsXMLPrettyPrinter, @@ -114,7 +116,7 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument, } // check the pref - if (!nsContentUtils::GetBoolPref("layout.xml.prettyprint", PR_TRUE)) { + if (!Preferences::GetBool("layout.xml.prettyprint", PR_TRUE)) { return NS_OK; } diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 736f06ce3af..c6b7aaba01b 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -70,6 +70,7 @@ #include "nsFrameManager.h" #include "nsHTMLReflowState.h" #include "nsIObjectLoadingContent.h" +#include "mozilla/Preferences.h" // for event firing in context menus #include "nsPresContext.h" @@ -80,6 +81,8 @@ #include "nsDOMError.h" #include "nsIMenuFrame.h" +using namespace mozilla; + // on win32 and os/2, context menus come up on mouse up. On other platforms, // they appear on mouse down. Certain bits of code care about this difference. #if !defined(XP_WIN) && !defined(XP_OS2) @@ -175,7 +178,7 @@ nsXULPopupListener::PreLaunchPopup(nsIDOMEvent* aMouseEvent) // Someone called preventDefault on a context menu. // Let's make sure they are allowed to do so. PRBool eventEnabled = - nsContentUtils::GetBoolPref("dom.event.contextmenu.enabled", PR_TRUE); + Preferences::GetBool("dom.event.contextmenu.enabled", PR_TRUE); if (!eventEnabled) { // If the target node is for plug-in, we should not open XUL context // menu on windowless plug-ins. diff --git a/content/xul/document/src/nsXULPrototypeCache.cpp b/content/xul/document/src/nsXULPrototypeCache.cpp index b71fdd2518e..854badba7cc 100644 --- a/content/xul/document/src/nsXULPrototypeCache.cpp +++ b/content/xul/document/src/nsXULPrototypeCache.cpp @@ -63,6 +63,10 @@ #include "jsxdrapi.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; + static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID); static PRBool gDisableXULCache = PR_FALSE; // enabled by default @@ -74,7 +78,7 @@ static int DisableXULCacheChangedCallback(const char* aPref, void* aClosure) { gDisableXULCache = - nsContentUtils::GetBoolPref(kDisableXULCachePref, gDisableXULCache); + Preferences::GetBool(kDisableXULCachePref, gDisableXULCache); // Flush the cache, regardless nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance(); @@ -132,7 +136,7 @@ NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult) // XXX Ignore return values. gDisableXULCache = - nsContentUtils::GetBoolPref(kDisableXULCachePref, gDisableXULCache); + Preferences::GetBool(kDisableXULCachePref, gDisableXULCache); nsContentUtils::RegisterPrefCallback(kDisableXULCachePref, DisableXULCacheChangedCallback, nsnull); @@ -596,8 +600,7 @@ FastLoadPrefChangedCallback(const char* aPref, void* aClosure) { PRBool wasEnabled = !gDisableXULFastLoad; gDisableXULFastLoad = - nsContentUtils::GetBoolPref(kDisableXULFastLoadPref, - gDisableXULFastLoad); + Preferences::GetBool(kDisableXULFastLoadPref, gDisableXULFastLoad); if (wasEnabled && gDisableXULFastLoad) { static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID); @@ -609,8 +612,8 @@ FastLoadPrefChangedCallback(const char* aPref, void* aClosure) } gChecksumXULFastLoadFile = - nsContentUtils::GetBoolPref(kChecksumXULFastLoadFilePref, - gChecksumXULFastLoadFile); + Preferences::GetBool(kChecksumXULFastLoadFilePref, + gChecksumXULFastLoadFile); return 0; } @@ -725,11 +728,10 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI) return NS_ERROR_FAILURE; gDisableXULFastLoad = - nsContentUtils::GetBoolPref(kDisableXULFastLoadPref, - gDisableXULFastLoad); + Preferences::GetBool(kDisableXULFastLoadPref, gDisableXULFastLoad); gChecksumXULFastLoadFile = - nsContentUtils::GetBoolPref(kChecksumXULFastLoadFilePref, - gChecksumXULFastLoadFile); + Preferences::GetBool(kChecksumXULFastLoadFilePref, + gChecksumXULFastLoadFile); nsContentUtils::RegisterPrefCallback(kDisableXULFastLoadPref, FastLoadPrefChangedCallback, nsnull); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 738439856d0..b10f6d50ccd 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -93,6 +93,7 @@ #include "nsContentUtils.h" #include "nsDOMWindowUtils.h" #include "nsIDOMGlobalPropertyInitializer.h" +#include "mozilla/Preferences.h" // Window scriptable helper includes #include "nsIDocShell.h" @@ -516,6 +517,7 @@ #include "nsDOMTouchEvent.h" #include "nsIDOMCustomEvent.h" +using namespace mozilla; using namespace mozilla::dom; static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); @@ -4432,10 +4434,10 @@ nsDOMClassInfo::Init() RegisterExternalClasses(); sDisableDocumentAllSupport = - nsContentUtils::GetBoolPref("browser.dom.document.all.disabled"); + Preferences::GetBool("browser.dom.document.all.disabled"); sDisableGlobalScopePollutionSupport = - nsContentUtils::GetBoolPref("browser.dom.global_scope_pollution.disabled"); + Preferences::GetBool("browser.dom.global_scope_pollution.disabled"); sIsInitialized = PR_TRUE; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 43f972e49af..67475203047 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -85,12 +85,14 @@ #include "nsIPrincipal.h" #include "mozilla/dom/Element.h" #include "mozAutoDocUpdate.h" +#include "mozilla/Preferences.h" #ifdef MOZ_XUL #include "nsIDOMXULTextboxElement.h" #include "nsIDOMXULMenuListElement.h" #endif +using namespace mozilla; using namespace mozilla::dom; //#define DEBUG_FOCUS 1 @@ -188,11 +190,11 @@ nsFocusManager::Init() sInstance = fm; nsIContent::sTabFocusModelAppliesToXUL = - nsContentUtils::GetBoolPref("accessibility.tabfocus_applies_to_xul", - nsIContent::sTabFocusModelAppliesToXUL); + Preferences::GetBool("accessibility.tabfocus_applies_to_xul", + nsIContent::sTabFocusModelAppliesToXUL); sMouseFocusesFormControl = - nsContentUtils::GetBoolPref("accessibility.mouse_focuses_formcontrol", PR_FALSE); + Preferences::GetBool("accessibility.mouse_focuses_formcontrol", PR_FALSE); nsIPrefBranch2* prefBranch = nsContentUtils::GetPrefBranch(); if (prefBranch) { @@ -228,12 +230,13 @@ nsFocusManager::Observe(nsISupports *aSubject, } else if (data.EqualsLiteral("accessibility.tabfocus_applies_to_xul")) { nsIContent::sTabFocusModelAppliesToXUL = - nsContentUtils::GetBoolPref("accessibility.tabfocus_applies_to_xul", - nsIContent::sTabFocusModelAppliesToXUL); + Preferences::GetBool("accessibility.tabfocus_applies_to_xul", + nsIContent::sTabFocusModelAppliesToXUL); } else if (data.EqualsLiteral("accessibility.mouse_focuses_formcontrol")) { sMouseFocusesFormControl = - nsContentUtils::GetBoolPref("accessibility.mouse_focuses_formcontrol", PR_FALSE); + Preferences::GetBool("accessibility.mouse_focuses_formcontrol", + PR_FALSE); } } else if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) { mActiveWindow = nsnull; @@ -1955,7 +1958,7 @@ nsFocusManager::UpdateCaret(PRBool aMoveCaretToFocus, return; // Never browse with caret in chrome PRPackedBool browseWithCaret = - nsContentUtils::GetBoolPref("accessibility.browsewithcaret"); + Preferences::GetBool("accessibility.browsewithcaret"); nsCOMPtr presShell; focusedDocShell->GetPresShell(getter_AddRefs(presShell)); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 563305f00b7..e99d2e7c431 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -69,6 +69,7 @@ #include "nsJSEnvironment.h" #include "nsCharSeparatedTokenizer.h" // for Accept-Language parsing #include "nsUnicharUtils.h" +#include "mozilla/Preferences.h" // Other Classes #include "nsIEventListenerManager.h" @@ -244,6 +245,7 @@ static PRLogModuleInfo* gDOMLeakPRLog; static const char kStorageEnabled[] = "dom.storage.enabled"; +using namespace mozilla; using namespace mozilla::dom; using mozilla::TimeStamp; using mozilla::TimeDuration; @@ -5077,7 +5079,7 @@ nsGlobalWindow::Print() nsCOMPtr printSettings; if (printSettingsService) { PRBool printSettingsAreGlobal = - nsContentUtils::GetBoolPref("print.use_global_printsettings", PR_FALSE); + Preferences::GetBool("print.use_global_printsettings", PR_FALSE); if (printSettingsAreGlobal) { printSettingsService->GetGlobalPrintSettings(getter_AddRefs(printSettings)); @@ -5101,7 +5103,7 @@ nsGlobalWindow::Print() LeaveModalState(callerWin); PRBool savePrintSettings = - nsContentUtils::GetBoolPref("print.save_print_settings", PR_FALSE); + Preferences::GetBool("print.save_print_settings", PR_FALSE); if (printSettingsAreGlobal && savePrintSettings) { printSettingsService-> SavePrintSettingsToPrefs(printSettings, @@ -5551,7 +5553,7 @@ nsGlobalWindow::CanSetProperty(const char *aPrefName) // If the pref is set to true, we can not set the property // and vice versa. - return !nsContentUtils::GetBoolPref(aPrefName, PR_TRUE); + return !Preferences::GetBool(aPrefName, PR_TRUE); } PRBool @@ -6187,8 +6189,7 @@ nsGlobalWindow::Close() // that were not opened by script if (!mHadOriginalOpener && !nsContentUtils::IsCallerTrustedForWrite()) { PRBool allowClose = - nsContentUtils::GetBoolPref("dom.allow_scripts_to_close_windows", - PR_TRUE); + Preferences::GetBool("dom.allow_scripts_to_close_windows", PR_TRUE); if (!allowClose) { // We're blocking the close operation // report localized error msg in JS console @@ -7844,8 +7845,9 @@ nsGlobalWindow::DispatchSyncPopState() "Must be safe to run script here."); // Check that PopState hasn't been pref'ed off. - if (!nsContentUtils::GetBoolPref(sPopStatePrefStr, PR_FALSE)) + if (!Preferences::GetBool(sPopStatePrefStr, PR_FALSE)) { return NS_OK; + } nsresult rv = NS_OK; @@ -8022,7 +8024,7 @@ nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage) return NS_OK; } - if (!nsContentUtils::GetBoolPref(kStorageEnabled)) { + if (!Preferences::GetBool(kStorageEnabled)) { *aSessionStorage = nsnull; return NS_OK; } @@ -8086,7 +8088,7 @@ nsGlobalWindow::GetGlobalStorage(nsIDOMStorageList ** aGlobalStorage) NS_ENSURE_ARG_POINTER(aGlobalStorage); #ifdef MOZ_STORAGE - if (!nsContentUtils::GetBoolPref(kStorageEnabled)) { + if (!Preferences::GetBool(kStorageEnabled)) { *aGlobalStorage = nsnull; return NS_OK; } @@ -8112,7 +8114,7 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage) NS_ENSURE_ARG(aLocalStorage); - if (!nsContentUtils::GetBoolPref(kStorageEnabled)) { + if (!Preferences::GetBool(kStorageEnabled)) { *aLocalStorage = nsnull; return NS_OK; } @@ -10067,6 +10069,13 @@ nsGlobalWindow::GetURL(nsIDOMMozURLProperty** aURL) return NS_OK; } +// static +bool +nsGlobalWindow::HasIndexedDBSupport() +{ + return Preferences::GetBool("indexedDB.feature.enabled", PR_TRUE); +} + // nsGlobalChromeWindow implementation NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow) @@ -10975,7 +10984,7 @@ nsNavigator::RefreshMIMEArray() bool nsNavigator::HasDesktopNotificationSupport() { - return nsContentUtils::GetBoolPref("notification.feature.enabled", PR_FALSE); + return Preferences::GetBool("notification.feature.enabled", PR_FALSE); } //***************************************************************************** diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 360d0c445d3..9233d18295e 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -109,7 +109,6 @@ #include "nsIIDBFactory.h" #include "nsFrameMessageManager.h" #include "mozilla/TimeStamp.h" -#include "nsContentUtils.h" // JS includes #include "jsapi.h" @@ -568,9 +567,7 @@ public: return sOuterWindowsById ? sOuterWindowsById->Get(aWindowID) : nsnull; } - static bool HasIndexedDBSupport() { - return nsContentUtils::GetBoolPref("indexedDB.feature.enabled", PR_TRUE); - } + static bool HasIndexedDBSupport(); private: // Enable updates for the accelerometer. diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp index f6f6c1b0738..770dd742752 100644 --- a/dom/base/nsGlobalWindowCommands.cpp +++ b/dom/base/nsGlobalWindowCommands.cpp @@ -44,7 +44,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsCRT.h" #include "nsString.h" -#include "nsContentUtils.h" +#include "mozilla/Preferences.h" #include "nsIControllerCommandTable.h" #include "nsICommandParams.h" @@ -64,6 +64,8 @@ #include "nsIClipboardDragDropHooks.h" #include "nsIClipboardDragDropHookList.h" +using namespace mozilla; + const char * const sSelectAllString = "cmd_selectAll"; const char * const sSelectNoneString = "cmd_selectNone"; const char * const sCopyImageLocationString = "cmd_copyImageLocation"; @@ -246,7 +248,7 @@ nsSelectMoveScrollCommand::DoSelectCommand(const char *aCommandName, nsIDOMWindo PRBool caretOn = PR_FALSE; selCont->GetCaretEnabled(&caretOn); if (!caretOn) { - caretOn = nsContentUtils::GetBoolPref("accessibility.browsewithcaret"); + caretOn = Preferences::GetBool("accessibility.browsewithcaret"); if (caretOn) { nsCOMPtr piWindow = do_QueryInterface(aWindow); if (piWindow) { diff --git a/dom/base/nsHistory.cpp b/dom/base/nsHistory.cpp index 356ebe183dc..96eed059fc6 100644 --- a/dom/base/nsHistory.cpp +++ b/dom/base/nsHistory.cpp @@ -60,6 +60,9 @@ #include "nsContentUtils.h" #include "nsIDOMNSDocument.h" #include "nsISHistoryInternal.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; static const char* sAllowPushStatePrefStr = "browser.history.allowPushState"; @@ -287,8 +290,9 @@ nsHistory::PushState(nsIVariant *aData, const nsAString& aTitle, const nsAString& aURL, JSContext* aCx) { // Check that PushState hasn't been pref'ed off. - if (!nsContentUtils::GetBoolPref(sAllowPushStatePrefStr, PR_FALSE)) + if (!Preferences::GetBool(sAllowPushStatePrefStr, PR_FALSE)) { return NS_OK; + } nsCOMPtr win(do_QueryReferent(mInnerWindow)); if (!win) @@ -316,8 +320,9 @@ nsHistory::ReplaceState(nsIVariant *aData, const nsAString& aTitle, const nsAString& aURL, JSContext* aCx) { // Check that ReplaceState hasn't been pref'ed off - if (!nsContentUtils::GetBoolPref(sAllowReplaceStatePrefStr, PR_FALSE)) + if (!Preferences::GetBool(sAllowReplaceStatePrefStr, PR_FALSE)) { return NS_OK; + } nsCOMPtr win(do_QueryReferent(mInnerWindow)); if (!win) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index e5f36d140ab..674906619b6 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -116,6 +116,7 @@ #include "prthread.h" #include "mozilla/FunctionTimer.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -926,9 +927,9 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) PRUint32 oldDefaultJSOptions = context->mDefaultJSOptions; PRUint32 newDefaultJSOptions = oldDefaultJSOptions; - sPostGCEventsToConsole = nsContentUtils::GetBoolPref(js_memlog_option_str); + sPostGCEventsToConsole = Preferences::GetBool(js_memlog_option_str); - PRBool strict = nsContentUtils::GetBoolPref(js_strict_option_str); + PRBool strict = Preferences::GetBool(js_strict_option_str); if (strict) newDefaultJSOptions |= JSOPTION_STRICT; else @@ -939,16 +940,16 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) // XXX components be covered by the chrome pref instead of the content one? nsCOMPtr chromeWindow(do_QueryInterface(global)); - PRBool useTraceJIT = nsContentUtils::GetBoolPref(chromeWindow ? - js_tracejit_chrome_str : - js_tracejit_content_str); - PRBool useMethodJIT = nsContentUtils::GetBoolPref(chromeWindow ? - js_methodjit_chrome_str : - js_methodjit_content_str); - PRBool useProfiling = nsContentUtils::GetBoolPref(chromeWindow ? - js_profiling_chrome_str : - js_profiling_content_str); - PRBool useMethodJITAlways = nsContentUtils::GetBoolPref(js_methodjit_always_str); + PRBool useTraceJIT = Preferences::GetBool(chromeWindow ? + js_tracejit_chrome_str : + js_tracejit_content_str); + PRBool useMethodJIT = Preferences::GetBool(chromeWindow ? + js_methodjit_chrome_str : + js_methodjit_content_str); + PRBool useProfiling = Preferences::GetBool(chromeWindow ? + js_profiling_chrome_str : + js_profiling_content_str); + PRBool useMethodJITAlways = Preferences::GetBool(js_methodjit_always_str); nsCOMPtr xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID); if (xr) { PRBool safeMode = PR_FALSE; @@ -984,7 +985,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) #ifdef DEBUG // In debug builds, warnings are enabled in chrome context if // javascript.options.strict.debug is true - PRBool strictDebug = nsContentUtils::GetBoolPref(js_strict_debug_option_str); + PRBool strictDebug = Preferences::GetBool(js_strict_debug_option_str); // Note this callback is also called from context's InitClasses thus we don't // need to enable this directly from InitContext if (strictDebug && (newDefaultJSOptions & JSOPTION_STRICT) == 0) { @@ -993,13 +994,13 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) } #endif - PRBool werror = nsContentUtils::GetBoolPref(js_werror_option_str); + PRBool werror = Preferences::GetBool(js_werror_option_str); if (werror) newDefaultJSOptions |= JSOPTION_WERROR; else newDefaultJSOptions &= ~JSOPTION_WERROR; - PRBool relimit = nsContentUtils::GetBoolPref(js_relimit_option_str); + PRBool relimit = Preferences::GetBool(js_relimit_option_str); if (relimit) newDefaultJSOptions |= JSOPTION_RELIMIT; else @@ -3629,7 +3630,7 @@ MaxScriptRunTimePrefChangedCallback(const char *aPrefName, void *aClosure) static int ReportAllJSExceptionsPrefChangedCallback(const char* aPrefName, void* aClosure) { - PRBool reportAll = nsContentUtils::GetBoolPref(aPrefName, PR_FALSE); + PRBool reportAll = Preferences::GetBool(aPrefName, PR_FALSE); nsContentUtils::XPConnect()->SetReportAllJSExceptions(reportAll); return 0; } @@ -3657,7 +3658,7 @@ SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure) static int SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure) { - PRBool enableCompartmentGC = nsContentUtils::GetBoolPref(aPrefName); + PRBool enableCompartmentGC = Preferences::GetBool(aPrefName); JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MODE, enableCompartmentGC ? JSGC_MODE_COMPARTMENT : JSGC_MODE_GLOBAL); diff --git a/dom/indexedDB/CheckPermissionsHelper.cpp b/dom/indexedDB/CheckPermissionsHelper.cpp index f6490e84c4c..f46d9c38550 100644 --- a/dom/indexedDB/CheckPermissionsHelper.cpp +++ b/dom/indexedDB/CheckPermissionsHelper.cpp @@ -51,6 +51,7 @@ #include "nsNetUtil.h" #include "nsThreadUtils.h" #include "mozilla/Services.h" +#include "mozilla/Preferences.h" #include "IndexedDatabaseManager.h" @@ -59,6 +60,7 @@ #define TOPIC_PERMISSIONS_PROMPT "indexedDB-permissions-prompt" #define TOPIC_PERMISSIONS_RESPONSE "indexedDB-permissions-response" +using namespace mozilla; USING_INDEXEDDB_NAMESPACE using namespace mozilla::services; @@ -71,7 +73,7 @@ GetIndexedDBPermissions(const nsACString& aASCIIOrigin, { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - if (!nsContentUtils::GetBoolPref(PREF_INDEXEDDB_ENABLED)) { + if (!Preferences::GetBool(PREF_INDEXEDDB_ENABLED)) { return nsIPermissionManager::DENY_ACTION; } diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 82a4b8ca89a..f769b8c4476 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -72,6 +72,7 @@ #include "nsThreadUtils.h" #include "mozilla/Services.h" #include "mozilla/unused.h" +#include "mozilla/Preferences.h" #include @@ -91,6 +92,7 @@ #define MAX_GEO_REQUESTS_PER_WINDOW 1500 using mozilla::unused; // +using namespace mozilla; using namespace mozilla::dom; class RequestPromptEvent : public nsRunnable @@ -499,15 +501,15 @@ static PRBool sGeoIgnoreLocationFilter = PR_FALSE; static int GeoEnabledChangedCallback(const char *aPrefName, void *aClosure) { - sGeoEnabled = nsContentUtils::GetBoolPref("geo.enabled", PR_TRUE); + sGeoEnabled = Preferences::GetBool("geo.enabled", PR_TRUE); return 0; } static int GeoIgnoreLocationFilterChangedCallback(const char *aPrefName, void *aClosure) { - sGeoIgnoreLocationFilter = nsContentUtils::GetBoolPref("geo.ignore.location_filter", - PR_TRUE); + sGeoIgnoreLocationFilter = + Preferences::GetBool("geo.ignore.location_filter", PR_TRUE); return 0; } @@ -1053,9 +1055,10 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) return true; } - if (nsContentUtils::GetBoolPref("geo.prompt.testing", PR_FALSE)) - { - nsCOMPtr ev = new RequestAllowEvent(nsContentUtils::GetBoolPref("geo.prompt.testing.allow", PR_FALSE), request); + if (Preferences::GetBool("geo.prompt.testing", PR_FALSE)) { + nsCOMPtr ev = + new RequestAllowEvent(Preferences::GetBool("geo.prompt.testing.allow", + PR_FALSE), request); NS_DispatchToMainThread(ev); return true; } diff --git a/dom/src/notification/nsDesktopNotification.cpp b/dom/src/notification/nsDesktopNotification.cpp index 92f90e9e1e1..581cff6d330 100644 --- a/dom/src/notification/nsDesktopNotification.cpp +++ b/dom/src/notification/nsDesktopNotification.cpp @@ -41,7 +41,9 @@ #include "mozilla/dom/PBrowserChild.h" #include "TabChild.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; /* ------------------------------------------------------------------------ */ @@ -109,13 +111,14 @@ nsDOMDesktopNotification::nsDOMDesktopNotification(const nsAString & title, mOwner = aWindow; mScriptContext = aScriptContext; - if (nsContentUtils::GetBoolPref("notification.disabled", PR_FALSE)) + if (Preferences::GetBool("notification.disabled", PR_FALSE)) { return; + } // If we are in testing mode (running mochitests, for example) // and we are suppose to allow requests, then just post an allow event. - if (nsContentUtils::GetBoolPref("notification.prompt.testing", PR_FALSE) && - nsContentUtils::GetBoolPref("notification.prompt.testing.allow", PR_TRUE)) { + if (Preferences::GetBool("notification.prompt.testing", PR_FALSE) && + Preferences::GetBool("notification.prompt.testing.allow", PR_TRUE)) { mAllow = PR_TRUE; return; } diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index b34a41a86c9..2998dc454d8 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -71,6 +71,9 @@ using mozilla::dom::StorageChild; #include "nsDOMString.h" #include "nsNetCID.h" #include "nsIProxyObjectManager.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; static const PRUint32 ASK_BEFORE_ACCEPT = 1; static const PRUint32 ACCEPT_SESSION = 2; @@ -1459,8 +1462,9 @@ nsDOMStorage::CanUseStorage(PRPackedBool* aSessionOnly) NS_ASSERTION(aSessionOnly, "null session flag"); *aSessionOnly = PR_FALSE; - if (!nsContentUtils::GetBoolPref(kStorageEnabled)) + if (!Preferences::GetBool(kStorageEnabled)) { return PR_FALSE; + } // chrome can always use storage regardless of permission preferences if (nsContentUtils::IsCallerChrome()) diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 04023e9200b..b73ac3f9a77 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -68,6 +68,7 @@ #include "nsMenuPopupFrame.h" #include "nsTextFragment.h" #include "nsThemeConstants.h" +#include "mozilla/Preferences.h" // The bidi indicator hangs off the caret to one side, to show which // direction the typing is in. It needs to be at least 2x2 to avoid looking like @@ -79,6 +80,8 @@ static const PRInt32 kMinBidiIndicatorPixels = 2; #include "nsContentUtils.h" #endif //IBMBIDI +using namespace mozilla; + /** * Find the first frame in an in-order traversal of the frame subtree rooted * at aFrame which is either a text frame logically at the end of a line, @@ -225,7 +228,7 @@ nsresult nsCaret::Init(nsIPresShell *inPresShell) StartBlinking(); } #ifdef IBMBIDI - mBidiUI = nsContentUtils::GetBoolPref("bidi.browser.ui"); + mBidiUI = Preferences::GetBool("bidi.browser.ui"); #endif return NS_OK; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 57fcfb1d2a5..ff9a1ad94c8 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -112,6 +112,7 @@ #include "nsContentUtils.h" #include "nsPIWindowRoot.h" +#include "mozilla/Preferences.h" // Needed for Start/Stop of Image Animation #include "imgIContainer.h" @@ -603,8 +604,7 @@ nsPresContext::GetDocumentColorPreferences() } if (usePrefColors) { usePrefColors = - !nsContentUtils::GetBoolPref("browser.display.use_system_colors", - PR_FALSE); + !Preferences::GetBool("browser.display.use_system_colors", PR_FALSE); } if (usePrefColors) { @@ -637,8 +637,8 @@ nsPresContext::GetDocumentColorPreferences() mBackgroundColor); mUseDocumentColors = !useAccessibilityTheme && - nsContentUtils::GetBoolPref("browser.display.use_document_colors", - mUseDocumentColors); + Preferences::GetBool("browser.display.use_document_colors", + mUseDocumentColors); } void @@ -662,12 +662,12 @@ nsPresContext::GetUserPreferences() GetDocumentColorPreferences(); mSendAfterPaintToContent = - nsContentUtils::GetBoolPref("dom.send_after_paint_to_content", - mSendAfterPaintToContent); + Preferences::GetBool("dom.send_after_paint_to_content", + mSendAfterPaintToContent); // * link colors mUnderlineLinks = - nsContentUtils::GetBoolPref("browser.underline_anchors", mUnderlineLinks); + Preferences::GetBool("browser.underline_anchors", mUnderlineLinks); nsAdoptingCString colorStr = nsContentUtils::GetCharPref("browser.anchor_color"); @@ -690,8 +690,7 @@ nsPresContext::GetUserPreferences() } mUseFocusColors = - nsContentUtils::GetBoolPref("browser.display.use_focus_colors", - mUseFocusColors); + Preferences::GetBool("browser.display.use_focus_colors", mUseFocusColors); mFocusTextColor = mDefaultColor; mFocusBackgroundColor = mBackgroundColor; @@ -714,8 +713,8 @@ nsPresContext::GetUserPreferences() mFocusRingWidth); mFocusRingOnAnything = - nsContentUtils::GetBoolPref("browser.display.focus_ring_on_anything", - mFocusRingOnAnything); + Preferences::GetBool("browser.display.focus_ring_on_anything", + mFocusRingOnAnything); mFocusRingStyle = nsContentUtils::GetIntPref("browser.display.focus_ring_style", @@ -726,7 +725,7 @@ nsPresContext::GetUserPreferences() // * replace backslashes with Yen signs? (bug 245770) mEnableJapaneseTransform = - nsContentUtils::GetBoolPref("layout.enable_japanese_specific_transform"); + Preferences::GetBool("layout.enable_japanese_specific_transform"); mPrefScrollbarSide = nsContentUtils::GetIntPref("layout.scrollbar.side"); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 9430492e46a..8b156dc8bf1 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -209,6 +209,7 @@ #include "gfxPlatform.h" #include "mozilla/FunctionTimer.h" +#include "mozilla/Preferences.h" #include "Layers.h" @@ -1885,13 +1886,13 @@ PresShell::Init(nsIDocument* aDocument, #ifdef MOZ_REFLOW_PERF if (mReflowCountMgr) { PRBool paintFrameCounts = - nsContentUtils::GetBoolPref("layout.reflow.showframecounts"); + Preferences::GetBool("layout.reflow.showframecounts"); PRBool dumpFrameCounts = - nsContentUtils::GetBoolPref("layout.reflow.dumpframecounts"); + Preferences::GetBool("layout.reflow.dumpframecounts"); PRBool dumpFrameByFrameCounts = - nsContentUtils::GetBoolPref("layout.reflow.dumpframebyframecounts"); + Preferences::GetBool("layout.reflow.dumpframebyframecounts"); mReflowCountMgr->SetDumpFrameCounts(dumpFrameCounts); mReflowCountMgr->SetDumpFrameByFrameCounts(dumpFrameByFrameCounts); @@ -3920,7 +3921,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) // Should we select the target? This action is controlled by a // preference: the default is to not select. - PRBool selectAnchor = nsContentUtils::GetBoolPref("layout.selectanchor"); + PRBool selectAnchor = Preferences::GetBool("layout.selectanchor"); // Even if select anchor pref is false, we must still move the // caret there. That way tabbing will start from the new diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index f405d91b0e1..bdd526e3151 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -90,8 +90,9 @@ #include "nsThemeConstants.h" #include "nsPLDOMEvent.h" #include "nsRenderingContext.h" +#include "mozilla/Preferences.h" -namespace dom = mozilla::dom; +using namespace mozilla; NS_IMETHODIMP nsComboboxControlFrame::RedisplayTextEvent::Run() @@ -1518,6 +1519,6 @@ nsComboboxControlFrame::RestoreState(nsPresState* aState) PRBool nsComboboxControlFrame::ToolkitHasNativePopup() { - return nsContentUtils::GetBoolPref("ui.use_native_popup_windows"); + return Preferences::GetBool("ui.use_native_popup_windows"); } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 67cfd9beedb..6c502bcd9ae 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -130,6 +130,8 @@ #include "CSSCalc.h" #include "nsAbsoluteContainingBlock.h" +#include "mozilla/Preferences.h" + using namespace mozilla; using namespace mozilla::layers; @@ -2354,7 +2356,7 @@ nsFrame::HandleMultiplePress(nsPresContext* aPresContext, if (me->clickCount == 4) { beginAmount = endAmount = eSelectParagraph; } else if (me->clickCount == 3) { - if (nsContentUtils::GetBoolPref("browser.triple_click_selects_paragraph")) { + if (Preferences::GetBool("browser.triple_click_selects_paragraph")) { beginAmount = endAmount = eSelectParagraph; } else { beginAmount = eSelectBeginLine; @@ -5650,7 +5652,7 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) // This pref only affects whether moving forward by word should go to the end of this word or start of the next word. // When going backwards, the start of the word is always used, on every operating system. wordSelectEatSpace = aPos->mDirection == eDirNext && - nsContentUtils::GetBoolPref("layout.word_select.eat_space_to_next_word"); + Preferences::GetBool("layout.word_select.eat_space_to_next_word"); } // mSawBeforeType means "we already saw characters of the type @@ -5958,7 +5960,7 @@ nsFrame::BreakWordBetweenPunctuation(const PeekWordState* aState, // We always stop between whitespace and punctuation return PR_TRUE; } - if (!nsContentUtils::GetBoolPref("layout.word_select.stop_at_punctuation")) { + if (!Preferences::GetBool("layout.word_select.stop_at_punctuation")) { // When this pref is false, we never stop at a punctuation boundary unless // it's after whitespace return PR_FALSE; diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index fbbe9db6af2..f0f5cd75f67 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -73,6 +73,9 @@ #include "nsDisplayList.h" #include "nsNodeUtils.h" #include "mozAutoDocUpdate.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; // masks for mEdgeVisibility #define LEFT_VIS 0x0001 @@ -263,8 +266,7 @@ nsHTMLFramesetFrame::FrameResizePrefCallback(const char* aPref, void* aClosure) } frame->mForceFrameResizability = - nsContentUtils::GetBoolPref(kFrameResizePref, - frame->mForceFrameResizability); + Preferences::GetBool(kFrameResizePref, frame->mForceFrameResizability); frame->RecalculateBorderResize(); if (doc) { @@ -974,8 +976,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext, if (firstTime) { nsContentUtils::RegisterPrefCallback(kFrameResizePref, FrameResizePrefCallback, this); - mForceFrameResizability = - nsContentUtils::GetBoolPref(kFrameResizePref); + mForceFrameResizability = Preferences::GetBool(kFrameResizePref); } // subtract out the width of all of the potential borders. There are diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 6bc0f1b6df7..f12bba4a09c 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -56,6 +56,7 @@ #include "nsIPercentHeightObserver.h" #include "nsContentUtils.h" #include "nsLayoutUtils.h" +#include "mozilla/Preferences.h" #ifdef IBMBIDI #include "nsBidiUtils.h" #endif @@ -1613,7 +1614,7 @@ static int PrefsChanged(const char *aPrefName, void *instance) { sBlinkIsAllowed = - nsContentUtils::GetBoolPref("browser.blink_allowed", sBlinkIsAllowed); + Preferences::GetBool("browser.blink_allowed", sBlinkIsAllowed); return 0; /* PREF_OK */ } diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 2bd64634b67..e565c56a8a7 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -103,6 +103,10 @@ #include "gfxRect.h" #include "ImageLayers.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; + // sizes (pixels) for image icon, padding and border frame #define ICON_SIZE (16) #define ICON_PADDING (3) @@ -1916,11 +1920,10 @@ nsImageFrame::IconLoad::Observe(nsISupports *aSubject, const char* aTopic, void nsImageFrame::IconLoad::GetPrefs() { mPrefForceInlineAltText = - nsContentUtils::GetBoolPref("browser.display.force_inline_alttext"); + Preferences::GetBool("browser.display.force_inline_alttext"); mPrefShowPlaceholders = - nsContentUtils::GetBoolPref("browser.display.show_image_placeholders", - PR_TRUE); + Preferences::GetBool("browser.display.show_image_placeholders", PR_TRUE); } diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 8b9f5af1ee3..a6fe5c57140 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -87,6 +87,7 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsContentUtils.h" #include "nsThreadUtils.h" +#include "mozilla/Preferences.h" //included for desired x position; #include "nsPresContext.h" @@ -113,6 +114,8 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID); #include "nsDOMError.h" +using namespace mozilla; + //#define DEBUG_TABLE 1 static NS_DEFINE_IID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); @@ -730,7 +733,7 @@ nsFrameSelection::nsFrameSelection() // Check to see if the autocopy pref is enabled // and add the autocopy listener if it is - if (nsContentUtils::GetBoolPref("clipboard.autocopy")) { + if (Preferences::GetBool("clipboard.autocopy")) { nsAutoCopyListener *autoCopy = nsAutoCopyListener::GetInstance(); if (autoCopy) { diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index abcea28ed5b..125aa7fd46c 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -123,6 +123,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsContentUtils.h" #include "nsIPresShell.h" #include "nsLayoutUtils.h" +#include "mozilla/Preferences.h" #include "nsViewsCID.h" #include "nsWidgetsCID.h" @@ -165,6 +166,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsIURIFixup.h" #include "mozilla/dom/Element.h" +using namespace mozilla; using namespace mozilla::dom; //----------------------------------------------------- @@ -597,8 +599,8 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview, mPrt->mPrintSettings->GetPrintSilent(&printSilently); // Check prefs for a default setting as to whether we should print silently - printSilently = nsContentUtils::GetBoolPref("print.always_print_silent", - printSilently); + printSilently = + Preferences::GetBool("print.always_print_silent", printSilently); // Ask dialog to be Print Shown via the Plugable Printing Dialog Service // This service is for the Print Dialog and the Print Progress Dialog @@ -1012,8 +1014,7 @@ nsPrintEngine::ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify) // if it is already being shown then don't bother to find out if it should be // so skip this and leave mShowProgressDialog set to FALSE if (!mProgressDialogIsShown) { - showProgresssDialog = - nsContentUtils::GetBoolPref("print.show_print_progress"); + showProgresssDialog = Preferences::GetBool("print.show_print_progress"); } // Turning off the showing of Print Progress in Prefs overrides diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 2a21bcdb52c..4fc65fbb520 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -94,9 +94,10 @@ #include "mozilla/dom/Element.h" #include "nsGenericElement.h" #include "nsNthIndexCache.h" +#include "mozilla/Preferences.h" +using namespace mozilla; using namespace mozilla::dom; -namespace css = mozilla::css; #define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled" @@ -964,8 +965,7 @@ nsCSSRuleProcessor::Startup() nsContentUtils::AddBoolPrefVarCache(VISITED_PSEUDO_PREF, &gSupportVisitedPseudo); // We want to default to true, not false as AddBoolPrefVarCache does. - gSupportVisitedPseudo = - nsContentUtils::GetBoolPref(VISITED_PSEUDO_PREF, PR_TRUE); + gSupportVisitedPseudo = Preferences::GetBool(VISITED_PSEUDO_PREF, PR_TRUE); gPrivateBrowsingObserver = new nsPrivateBrowsingObserver(); NS_ENSURE_TRUE(gPrivateBrowsingObserver, NS_ERROR_OUT_OF_MEMORY); diff --git a/layout/style/nsCSSScanner.cpp b/layout/style/nsCSSScanner.cpp index 5124967e571..60ab7776747 100644 --- a/layout/style/nsCSSScanner.cpp +++ b/layout/style/nsCSSScanner.cpp @@ -60,6 +60,9 @@ #include "mozilla/Services.h" #include "mozilla/css/Loader.h" #include "nsCSSStyleSheet.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #ifdef CSS_REPORT_PARSE_ERRORS static PRBool gReportErrors = PR_TRUE; @@ -325,7 +328,7 @@ nsCSSScanner::SetLowLevelError(nsresult aErrorCode) static int CSSErrorsPrefChanged(const char *aPref, void *aClosure) { - gReportErrors = nsContentUtils::GetBoolPref(CSS_ERRORS_PREF, PR_TRUE); + gReportErrors = Preferences::GetBool(CSS_ERRORS_PREF, PR_TRUE); return NS_OK; } #endif diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index fc2e392f78a..e061d20e995 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -88,6 +88,7 @@ #include "prdtoa.h" #include "mozilla/dom/Element.h" #include "gfxUtils.h" +#include "mozilla/Preferences.h" using namespace mozilla; using namespace mozilla::dom; @@ -175,7 +176,7 @@ static const char SMIL_PREF_STR[] = "svg.smil.enabled"; static int SMILPrefChanged(const char *aPref, void *aClosure) { - PRBool prefVal = nsContentUtils::GetBoolPref(SMIL_PREF_STR); + PRBool prefVal = Preferences::GetBool(SMIL_PREF_STR); gSMILEnabled = prefVal; return 0; } @@ -187,7 +188,7 @@ NS_SMILEnabled() if (!sInitialized) { /* check and register ourselves with the pref */ - gSMILEnabled = nsContentUtils::GetBoolPref(SMIL_PREF_STR); + gSMILEnabled = Preferences::GetBool(SMIL_PREF_STR); nsContentUtils::RegisterPrefCallback(SMIL_PREF_STR, SMILPrefChanged, nsnull); sInitialized = PR_TRUE; @@ -1299,7 +1300,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame) if (svg) { // It is possible to apply a gradient, pattern, clipping path, mask or // filter to text. When one of these facilities is applied to text - // the bounding box is the entire ‘text’ element in all + // the bounding box is the entire text element in all // cases. nsSVGTextContainerFrame* metrics = do_QueryFrame( GetFirstNonAAncestorFrame(aFrame)); diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 133ff3d60f4..10cfe9aff82 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -93,13 +93,15 @@ #include "nsEventDispatcher.h" #include "nsIDOMEvent.h" #include "nsIPrivateDOMEvent.h" -#include "nsContentUtils.h" #include "nsDisplayList.h" +#include "mozilla/Preferences.h" // Needed for Print Preview #include "nsIDocument.h" #include "nsIURI.h" +using namespace mozilla; + //define DEBUG_REDRAW #define DEBUG_SPRING_SIZE 8 @@ -1246,7 +1248,7 @@ nsBoxFrame::AttributeChanged(PRInt32 aNameSpaceID, void nsBoxFrame::GetDebugPref(nsPresContext* aPresContext) { - gDebug = nsContentUtils::GetBoolPref("xul.debug.box"); + gDebug = Preferences::GetBool("xul.debug.box"); } class nsDisplayXULDebug : public nsDisplayItem { diff --git a/layout/xul/base/src/nsMenuBarListener.cpp b/layout/xul/base/src/nsMenuBarListener.cpp index d49db84cb70..f2c3a365528 100644 --- a/layout/xul/base/src/nsMenuBarListener.cpp +++ b/layout/xul/base/src/nsMenuBarListener.cpp @@ -58,6 +58,9 @@ #include "nsIDOMElement.h" #include "nsContentUtils.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; /* * nsMenuBarListener implementation @@ -130,8 +133,7 @@ void nsMenuBarListener::InitAccessKey() else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_META) mAccessKeyMask = MODIFIER_META; - mAccessKeyFocuses = - nsContentUtils::GetBoolPref("ui.key.menuAccessKeyFocuses"); + mAccessKeyFocuses = Preferences::GetBool("ui.key.menuAccessKeyFocuses"); } void diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 82b93d4ef7c..0f80c51a480 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -86,6 +86,9 @@ #include "nsIScreenManager.h" #include "nsIServiceManager.h" #include "nsThemeConstants.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; PRInt8 nsMenuPopupFrame::sDefaultLevelIsTop = -1; @@ -130,7 +133,7 @@ nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContex if (sDefaultLevelIsTop >= 0) return; sDefaultLevelIsTop = - nsContentUtils::GetBoolPref("ui.panel.default_level_parent", PR_FALSE); + Preferences::GetBool("ui.panel.default_level_parent", PR_FALSE); } // ctor diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index d36b4a5cf98..0fe901dd749 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -70,6 +70,9 @@ #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; PRBool nsSliderFrame::gMiddlePref = PR_FALSE; PRInt32 nsSliderFrame::gSnapMultiplier; @@ -117,7 +120,7 @@ nsSliderFrame::Init(nsIContent* aContent, if (!gotPrefs) { gotPrefs = PR_TRUE; - gMiddlePref = nsContentUtils::GetBoolPref("middlemouse.scrollbarPosition"); + gMiddlePref = Preferences::GetBool("middlemouse.scrollbarPosition"); gSnapMultiplier = nsContentUtils::GetIntPref("slider.snapMultiplier"); } diff --git a/layout/xul/base/src/nsXULTooltipListener.cpp b/layout/xul/base/src/nsXULTooltipListener.cpp index cf82c5486e9..3520a793a62 100644 --- a/layout/xul/base/src/nsXULTooltipListener.cpp +++ b/layout/xul/base/src/nsXULTooltipListener.cpp @@ -62,6 +62,9 @@ #endif #include "nsIRootBox.h" #include "nsEventDispatcher.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; nsXULTooltipListener* nsXULTooltipListener::mInstance = nsnull; @@ -323,8 +326,8 @@ int nsXULTooltipListener::ToolbarTipsPrefChanged(const char *aPref, void *aClosure) { - sShowTooltips = nsContentUtils::GetBoolPref("browser.chrome.toolbar_tips", - sShowTooltips); + sShowTooltips = + Preferences::GetBool("browser.chrome.toolbar_tips", sShowTooltips); return 0; } From 2c22152882f5f1cecdfe9bea0771ffbfe7be18ba Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 25 May 2011 15:31:59 +0900 Subject: [PATCH 07/15] Bug 659536 part.1 Implement Preferences::GetUint() r=roc --- modules/libpref/public/Preferences.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/libpref/public/Preferences.h b/modules/libpref/public/Preferences.h index cfada7ff482..8ced5254b45 100644 --- a/modules/libpref/public/Preferences.h +++ b/modules/libpref/public/Preferences.h @@ -119,6 +119,13 @@ public: return result; } + static PRUint32 GetUint(const char* aPref, PRUint32 aDefault = 0) + { + PRUint32 result = aDefault; + GetUint(aPref, &result); + return result; + } + /** * Gets int or bool type pref value with raw return value of nsIPrefBranch. * @@ -128,6 +135,15 @@ public: */ static nsresult GetBool(const char* aPref, PRBool* aResult); static nsresult GetInt(const char* aPref, PRInt32* aResult); + static nsresult GetUint(const char* aPref, PRUint32* aResult) + { + PRInt32 result; + nsresult rv = GetInt(aPref, &result); + if (NS_SUCCEEDED(rv)) { + *aResult = static_cast(result); + } + return rv; + } /** * Gets string type pref value with raw return value of nsIPrefBranch. @@ -145,6 +161,10 @@ public: */ static nsresult SetBool(const char* aPref, PRBool aValue); static nsresult SetInt(const char* aPref, PRInt32 aValue); + static nsresult SetUint(const char* aPref, PRUint32 aValue) + { + return SetInt(aPref, static_cast(aValue)); + } static nsresult SetChar(const char* aPref, const char* aValue); static nsresult SetChar(const char* aPref, const nsCString &aValue); static nsresult SetChar(const char* aPref, const PRUnichar* aValue); From 49814a538d7ed9b5735c9bd413b9abb4e0be63e4 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 25 May 2011 15:32:00 +0900 Subject: [PATCH 08/15] Bug 659536 part.2 Replace nsContentUtils::GetIntPref() with Preferences::GetInt() or Preferences::GetUint() r=roc --- content/base/public/nsContentUtils.h | 1 - content/base/src/nsContentUtils.cpp | 18 ++-------- content/base/src/nsEventSource.cpp | 4 +-- content/base/src/nsPlainTextSerializer.cpp | 2 +- content/events/src/nsEventStateManager.cpp | 30 ++++++++-------- .../html/content/src/nsGenericHTMLElement.cpp | 3 +- .../html/content/src/nsHTMLMediaElement.cpp | 10 +++--- .../html/document/src/nsHTMLContentSink.cpp | 4 ++- content/media/nsMediaCache.cpp | 4 +-- content/xbl/src/nsXBLPrototypeHandler.cpp | 7 ++-- dom/base/nsGlobalWindow.cpp | 13 ++++--- dom/base/nsJSEnvironment.cpp | 8 ++--- dom/plugins/ipc/PluginModuleParent.cpp | 6 ++-- dom/src/geolocation/nsGeolocation.cpp | 2 +- dom/src/offline/nsDOMOfflineResourceList.cpp | 7 ++-- dom/src/storage/nsDOMStorage.cpp | 15 ++++---- dom/src/threads/nsDOMThreadService.cpp | 3 +- editor/libeditor/text/nsPlaintextEditor.cpp | 10 ++++-- layout/base/nsPresContext.cpp | 36 +++++++++---------- layout/base/nsPresShell.cpp | 7 ++-- layout/base/nsRefreshDriver.cpp | 5 ++- layout/generic/nsFrame.cpp | 2 +- layout/generic/nsHTMLReflowState.cpp | 7 ++-- layout/generic/nsObjectFrame.cpp | 3 +- layout/generic/nsSelection.cpp | 6 ++-- layout/generic/nsSimplePageSequence.cpp | 5 ++- layout/xul/base/src/nsMenuBarListener.cpp | 2 +- layout/xul/base/src/nsMenuFrame.cpp | 5 ++- layout/xul/base/src/nsSliderFrame.cpp | 2 +- 29 files changed, 116 insertions(+), 111 deletions(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 4dd454d55da..cd8f5016a13 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -551,7 +551,6 @@ public: nsIAtom **aTagName, PRInt32 *aNameSpaceID); static nsAdoptingCString GetCharPref(const char *aPref); - static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0); static nsAdoptingString GetLocalizedStringPref(const char *aPref); static nsAdoptingString GetStringPref(const char *aPref); static void RegisterPrefCallback(const char *aPref, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 0979b4d2e96..65bfab89be0 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -2611,20 +2611,6 @@ nsContentUtils::GetCharPref(const char *aPref) return result; } -// static -PRInt32 -nsContentUtils::GetIntPref(const char *aPref, PRInt32 aDefault) -{ - PRInt32 result; - - if (!sPrefBranch || - NS_FAILED(sPrefBranch->GetIntPref(aPref, &result))) { - result = aDefault; - } - - return result; -} - // static nsAdoptingString nsContentUtils::GetLocalizedStringPref(const char *aPref) @@ -2746,7 +2732,7 @@ IntVarChanged(const char *aPref, void *aClosure) { PrefCacheData* cache = static_cast(aClosure); *((PRInt32*)cache->cacheLocation) = - nsContentUtils::GetIntPref(aPref, cache->defaultValueInt); + Preferences::GetInt(aPref, cache->defaultValueInt); return 0; } @@ -2756,7 +2742,7 @@ nsContentUtils::AddIntPrefVarCache(const char *aPref, PRInt32* aCache, PRInt32 aDefault) { - *aCache = GetIntPref(aPref, aDefault); + *aCache = Preferences::GetInt(aPref, aDefault); PrefCacheData* data = new PrefCacheData; data->cacheLocation = aCache; data->defaultValueInt = aDefault; diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index 10bbd4f586f..ee29db88cd1 100755 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -299,8 +299,8 @@ nsEventSource::Init(nsIPrincipal* aPrincipal, mOrigin = origin; mReconnectionTime = - nsContentUtils::GetIntPref("dom.server-events.default-reconnection-time", - DEFAULT_RECONNECTION_TIME_VALUE); + Preferences::GetInt("dom.server-events.default-reconnection-time", + DEFAULT_RECONNECTION_TIME_VALUE); nsCOMPtr convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index 870f060607e..2adeab9ba7e 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -211,7 +211,7 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, mStructs = Preferences::GetBool(PREF_STRUCTS, mStructs); mHeaderStrategy = - nsContentUtils::GetIntPref(PREF_HEADER_STRATEGY, mHeaderStrategy); + Preferences::GetInt(PREF_HEADER_STRATEGY, mHeaderStrategy); // The quotesPreformatted pref is a temporary measure. See bug 69638. mQuotesPreformatted = diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index fcb152e9d2c..1aac19c60e3 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -328,7 +328,7 @@ GetDocumentFromWindow(nsIDOMWindow *aWindow) static PRInt32 GetAccessModifierMaskFromPref(PRInt32 aItemType) { - PRInt32 accessKey = nsContentUtils::GetIntPref("ui.key.generalAccessKey", -1); + PRInt32 accessKey = Preferences::GetInt("ui.key.generalAccessKey", -1); switch (accessKey) { case -1: break; // use the individual prefs case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT; @@ -340,9 +340,9 @@ GetAccessModifierMaskFromPref(PRInt32 aItemType) switch (aItemType) { case nsIDocShellTreeItem::typeChrome: - return nsContentUtils::GetIntPref("ui.key.chromeAccess", 0); + return Preferences::GetInt("ui.key.chromeAccess", 0); case nsIDocShellTreeItem::typeContent: - return nsContentUtils::GetIntPref("ui.key.contentAccess", 0); + return Preferences::GetInt("ui.key.contentAccess", 0); default: return 0; } @@ -654,15 +654,13 @@ nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent) PRUint32 nsMouseWheelTransaction::GetTimeoutTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.timeout", 1500); + return Preferences::GetUint("mousewheel.transaction.timeout", 1500); } PRUint32 nsMouseWheelTransaction::GetIgnoreMoveDelayTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.ignoremovedelay", 100); + return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100); } PRBool @@ -711,13 +709,13 @@ nsMouseWheelTransaction::ComputeAcceleratedWheelDelta(PRInt32 aDelta, PRInt32 nsMouseWheelTransaction::GetAccelerationStart() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.start", -1); + return Preferences::GetInt("mousewheel.acceleration.start", -1); } PRInt32 nsMouseWheelTransaction::GetAccelerationFactor() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.factor", -1); + return Preferences::GetInt("mousewheel.acceleration.factor", -1); } PRInt32 @@ -1723,7 +1721,7 @@ nsEventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext, mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mClickHoldTimer) { PRInt32 clickHoldDelay = - nsContentUtils::GetIntPref("ui.click_hold_context_menus.delay", 500); + Preferences::GetInt("ui.click_hold_context_menus.delay", 500); mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, clickHoldDelay, nsITimer::TYPE_ONE_SHOT); @@ -2404,8 +2402,8 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float textzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetTextZoom(&textzoom); textzoom += ((float)change) / 10; if (textzoom < zoomMin) @@ -2425,8 +2423,8 @@ nsEventStateManager::ChangeFullZoom(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float fullzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetFullZoom(&fullzoom); fullzoom += ((float)change) / 10; if (fullzoom < zoomMin) @@ -2612,7 +2610,7 @@ nsEventStateManager::GetWheelActionFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".action"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRInt32 @@ -2623,7 +2621,7 @@ nsEventStateManager::GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".numlines"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRBool diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d69f25152f4..d06ead8c478 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -899,8 +899,7 @@ nsGenericHTMLElement::GetSpellcheck(PRBool* aSpellcheck) // NOTE: Do not reflect a pref value of 0 back to the DOM getter. // The web page should not know if the user has disabled spellchecking. // We'll catch this in the editor itself. - PRInt32 spellcheckLevel = - nsContentUtils::GetIntPref("layout.spellcheckDefault", 1); + PRInt32 spellcheckLevel = Preferences::GetInt("layout.spellcheckDefault", 1); if (spellcheckLevel == 2) { // "Spellcheck multi- and single-line" *aSpellcheck = PR_TRUE; // Spellchecked by default } diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 9d54d27f8ec..4f262fd98df 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -857,10 +857,12 @@ void nsHTMLMediaElement::UpdatePreloadAction() // Find the appropriate preload action by looking at the attribute. const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsGkAtoms::preload, kNameSpaceID_None); - PRUint32 preloadDefault = nsContentUtils::GetIntPref("media.preload.default", - nsHTMLMediaElement::PRELOAD_ATTR_METADATA); - PRUint32 preloadAuto = nsContentUtils::GetIntPref("media.preload.auto", - nsHTMLMediaElement::PRELOAD_ENOUGH); + PRUint32 preloadDefault = + Preferences::GetInt("media.preload.default", + nsHTMLMediaElement::PRELOAD_ATTR_METADATA); + PRUint32 preloadAuto = + Preferences::GetInt("media.preload.auto", + nsHTMLMediaElement::PRELOAD_ENOUGH); if (!val) { // Attribute is not set. Use the preload action specified by the // media.preload.default pref, or just preload metadata if not present. diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 3054d7d740c..95ea94ae48e 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -63,6 +63,7 @@ #include "nsNodeUtils.h" #include "nsIContent.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" #include "nsGenericHTMLElement.h" @@ -122,6 +123,7 @@ #include "nsContentCreatorFunctions.h" #include "mozAutoDocUpdate.h" +using namespace mozilla; using namespace mozilla::dom; #ifdef NS_DEBUG @@ -1597,7 +1599,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, // Changed from 8192 to greatly improve page loading performance on // large pages. See bugzilla bug 77540. - mMaxTextRun = nsContentUtils::GetIntPref("content.maxtextrun", 8191); + mMaxTextRun = Preferences::GetInt("content.maxtextrun", 8191); nsCOMPtr nodeInfo; nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull, diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index 1c01cf4155b..023f90180ad 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -40,7 +40,6 @@ #include "mozilla/XPCOM.h" #include "nsMediaCache.h" -#include "nsContentUtils.h" #include "nsDirectoryServiceUtils.h" #include "nsDirectoryServiceDefs.h" #include "nsNetUtil.h" @@ -50,6 +49,7 @@ #include "nsMathUtils.h" #include "prlog.h" #include "nsIPrivateBrowsingService.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -739,7 +739,7 @@ static PRInt32 GetMaxBlocks() // We look up the cache size every time. This means dynamic changes // to the pref are applied. // Cache size is in KB - PRInt32 cacheSize = nsContentUtils::GetIntPref("media.cache_size", 500*1024); + PRInt32 cacheSize = Preferences::GetInt("media.cache_size", 500*1024); PRInt64 maxBlocks = static_cast(cacheSize)*1024/nsMediaCache::BLOCK_SIZE; maxBlocks = PR_MAX(maxBlocks, 1); return PRInt32(PR_MIN(maxBlocks, PR_INT32_MAX)); diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index 88f78ca28cc..b4b8f3aceee 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -80,6 +80,9 @@ #include "nsCRT.h" #include "nsXBLEventHandler.h" #include "nsEventDispatcher.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); @@ -206,8 +209,8 @@ nsXBLPrototypeHandler::InitAccessKeys() // Get the menu access key value from prefs, overriding the default: kMenuAccessKey = - nsContentUtils::GetIntPref("ui.key.menuAccessKey", kMenuAccessKey); - kAccelKey = nsContentUtils::GetIntPref("ui.key.accelKey", kAccelKey); + Preferences::GetInt("ui.key.menuAccessKey", kMenuAccessKey); + kAccelKey = Preferences::GetInt("ui.key.accelKey", kAccelKey); } nsresult diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index e99d2e7c431..0ce1fcbf816 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2580,8 +2580,8 @@ nsGlobalWindow::DialogOpenAttempted() topWindow->mLastDialogQuitTime); if (dialogDuration.ToSeconds() < - nsContentUtils::GetIntPref("dom.successive_dialog_time_limit", - SUCCESSIVE_DIALOG_TIME_LIMIT)) { + Preferences::GetInt("dom.successive_dialog_time_limit", + SUCCESSIVE_DIALOG_TIME_LIMIT)) { topWindow->mDialogAbuseCount++; return (topWindow->GetPopupControlState() > openAllowed || @@ -5611,7 +5611,7 @@ nsGlobalWindow::RevisePopupAbuseLevel(PopupControlState aControl) // limit the number of simultaneously open popups if (abuse == openAbused || abuse == openControlled) { - PRInt32 popupMax = nsContentUtils::GetIntPref("dom.popup_maximum", -1); + PRInt32 popupMax = Preferences::GetInt("dom.popup_maximum", -1); if (popupMax >= 0 && gOpenPopupSpamCount >= popupMax) abuse = openOverridden; } @@ -8956,7 +8956,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, // "dom.disable_open_click_delay" is set to (in ms). PRInt32 delay = - nsContentUtils::GetIntPref("dom.disable_open_click_delay"); + Preferences::GetInt("dom.disable_open_click_delay"); // This is checking |interval|, not realInterval, on purpose, // because our lower bound for |realInterval| could be pretty high @@ -10859,9 +10859,8 @@ NS_IMETHODIMP nsNavigator::GetCookieEnabled(PRBool *aCookieEnabled) { *aCookieEnabled = - (nsContentUtils::GetIntPref("network.cookie.cookieBehavior", - COOKIE_BEHAVIOR_REJECT) != - COOKIE_BEHAVIOR_REJECT); + (Preferences::GetInt("network.cookie.cookieBehavior", + COOKIE_BEHAVIOR_REJECT) != COOKIE_BEHAVIOR_REJECT); return NS_OK; } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 674906619b6..b45bb02edbd 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1012,7 +1012,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) context->mDefaultJSOptions = newDefaultJSOptions; #ifdef JS_GC_ZEAL - PRInt32 zeal = nsContentUtils::GetIntPref(js_zeal_option_str, -1); + PRInt32 zeal = Preferences::GetInt(js_zeal_option_str, -1); if (zeal >= 0) ::JS_SetGCZeal(context->mContext, (PRUint8)zeal); #endif @@ -3608,7 +3608,7 @@ MaxScriptRunTimePrefChangedCallback(const char *aPrefName, void *aClosure) // scripts run forever. PRBool isChromePref = strcmp(aPrefName, "dom.max_chrome_script_run_time") == 0; - PRInt32 time = nsContentUtils::GetIntPref(aPrefName, isChromePref ? 20 : 10); + PRInt32 time = Preferences::GetInt(aPrefName, isChromePref ? 20 : 10); PRTime t; if (time <= 0) { @@ -3638,7 +3638,7 @@ ReportAllJSExceptionsPrefChangedCallback(const char* aPrefName, void* aClosure) static int SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure) { - PRInt32 highwatermark = nsContentUtils::GetIntPref(aPrefName, 128); + PRInt32 highwatermark = Preferences::GetInt(aPrefName, 128); JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_MALLOC_BYTES, highwatermark * 1024L * 1024L); @@ -3648,7 +3648,7 @@ SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure) static int SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure) { - PRInt32 pref = nsContentUtils::GetIntPref(aPrefName, -1); + PRInt32 pref = Preferences::GetInt(aPrefName, -1); // handle overflow and negative pref values PRUint32 max = (pref <= 0 || pref >= 0x1000) ? -1 : (PRUint32)pref * 1024 * 1024; JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES, max); diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index c67dfaa04de..7646bb64fd8 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -51,6 +51,7 @@ #include "base/process_util.h" +#include "mozilla/Preferences.h" #include "mozilla/unused.h" #include "mozilla/ipc/SyncChannel.h" #include "mozilla/plugins/PluginModuleParent.h" @@ -71,6 +72,7 @@ using base::KillProcess; using mozilla::PluginLibrary; using mozilla::ipc::SyncChannel; +using namespace mozilla; using namespace mozilla::plugins; static const char kTimeoutPref[] = "dom.ipc.plugins.timeoutSecs"; @@ -90,7 +92,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) { PLUGIN_LOG_DEBUG_FUNCTION; - PRInt32 prefSecs = nsContentUtils::GetIntPref(kLaunchTimeoutPref, 0); + PRInt32 prefSecs = Preferences::GetInt(kLaunchTimeoutPref, 0); // Block on the child process being launched and initialized. nsAutoPtr parent(new PluginModuleParent(aFilePath)); @@ -223,7 +225,7 @@ PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule) NS_ABORT_IF_FALSE(!strcmp(aPref, kTimeoutPref), "unexpected pref callback"); - PRInt32 timeoutSecs = nsContentUtils::GetIntPref(kTimeoutPref, 0); + PRInt32 timeoutSecs = Preferences::GetInt(kTimeoutPref, 0); int32 timeoutMs = (timeoutSecs > 0) ? (1000 * timeoutSecs) : SyncChannel::kNoTimeout; diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index f769b8c4476..79c97cbae42 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -516,7 +516,7 @@ GeoIgnoreLocationFilterChangedCallback(const char *aPrefName, void *aClosure) nsresult nsGeolocationService::Init() { - mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000); + mTimeout = Preferences::GetInt("geo.timeout", 6000); nsContentUtils::RegisterPrefCallback("geo.ignore.location_filter", GeoIgnoreLocationFilterChangedCallback, diff --git a/dom/src/offline/nsDOMOfflineResourceList.cpp b/dom/src/offline/nsDOMOfflineResourceList.cpp index 381d95c4485..fdb7332e440 100644 --- a/dom/src/offline/nsDOMOfflineResourceList.cpp +++ b/dom/src/offline/nsDOMOfflineResourceList.cpp @@ -56,11 +56,14 @@ #include "nsIObserverService.h" #include "nsIScriptGlobalObject.h" #include "nsIWebNavigation.h" +#include "mozilla/Preferences.h" #include "nsXULAppAPI.h" #define IS_CHILD_PROCESS() \ (GeckoProcessType_Default != XRE_GetProcessType()) +using namespace mozilla; + // Event names #define CHECKING_STR "checking" @@ -392,8 +395,8 @@ nsDOMOfflineResourceList::MozAdd(const nsAString& aURI) PRUint32 length; rv = GetMozLength(&length); NS_ENSURE_SUCCESS(rv, rv); - PRUint32 maxEntries = nsContentUtils::GetIntPref(kMaxEntriesPref, - DEFAULT_MAX_ENTRIES); + PRUint32 maxEntries = + Preferences::GetUint(kMaxEntriesPref, DEFAULT_MAX_ENTRIES); if (length > maxEntries) return NS_ERROR_NOT_AVAILABLE; diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 2998dc454d8..78b985ab927 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -205,22 +205,21 @@ GetQuota(const nsACString &aDomain, PRInt32 *aQuota, PRInt32 *aWarnQuota, PRUint32 perm = GetOfflinePermission(aDomain); if (IS_PERMISSION_ALLOWED(perm) || aOverrideQuota) { // This is an offline app, give more space by default. - *aQuota = ((PRInt32)nsContentUtils::GetIntPref(kOfflineAppQuota, - DEFAULT_OFFLINE_APP_QUOTA) * 1024); + *aQuota = Preferences::GetInt(kOfflineAppQuota, + DEFAULT_OFFLINE_APP_QUOTA) * 1024; if (perm == nsIOfflineCacheUpdateService::ALLOW_NO_WARN || aOverrideQuota) { *aWarnQuota = -1; } else { - *aWarnQuota = ((PRInt32)nsContentUtils::GetIntPref(kOfflineAppWarnQuota, - DEFAULT_OFFLINE_WARN_QUOTA) * 1024); + *aWarnQuota = Preferences::GetInt(kOfflineAppWarnQuota, + DEFAULT_OFFLINE_WARN_QUOTA) * 1024; } return perm; } // FIXME: per-domain quotas? - *aQuota = ((PRInt32)nsContentUtils::GetIntPref(kDefaultQuota, - DEFAULT_QUOTA) * 1024); + *aQuota = Preferences::GetInt(kDefaultQuota, DEFAULT_QUOTA) * 1024; *aWarnQuota = -1; return perm; @@ -1504,8 +1503,8 @@ nsDOMStorage::CanUseStorage(PRPackedBool* aSessionOnly) *aSessionOnly = PR_TRUE; } else if (perm != nsIPermissionManager::ALLOW_ACTION) { - PRUint32 cookieBehavior = nsContentUtils::GetIntPref(kCookiesBehavior); - PRUint32 lifetimePolicy = nsContentUtils::GetIntPref(kCookiesLifetimePolicy); + PRUint32 cookieBehavior = Preferences::GetUint(kCookiesBehavior); + PRUint32 lifetimePolicy = Preferences::GetUint(kCookiesLifetimePolicy); // Treat "ask every time" as "reject always". // Chrome persistent pages can bypass this check. diff --git a/dom/src/threads/nsDOMThreadService.cpp b/dom/src/threads/nsDOMThreadService.cpp index 80c599982a1..0211a283ba7 100644 --- a/dom/src/threads/nsDOMThreadService.cpp +++ b/dom/src/threads/nsDOMThreadService.cpp @@ -71,6 +71,7 @@ #include "nsXPCOMCIDInternal.h" #include "pratom.h" #include "prthread.h" +#include "mozilla/Preferences.h" // DOMWorker includes #include "nsDOMWorker.h" @@ -1593,7 +1594,7 @@ nsDOMThreadService::PrefCallback(const char* aPrefName, // some wacky platform then the worst that could happen is that the close // handler will run for a slightly different amount of time. PRUint32 timeoutMS = - nsContentUtils::GetIntPref(aPrefName, gWorkerCloseHandlerTimeoutMS); + Preferences::GetUint(aPrefName, gWorkerCloseHandlerTimeoutMS); // We must have a timeout value, 0 is not ok. If the pref is set to 0 then // fall back to our default. diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index e413f0a4e3e..fd20305ba58 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -79,6 +79,7 @@ #include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsDebug.h" +#include "mozilla/Preferences.h" // Drag & Drop, Clipboard #include "nsIClipboard.h" @@ -87,6 +88,8 @@ #include "mozilla/FunctionTimer.h" +using namespace mozilla; + nsPlaintextEditor::nsPlaintextEditor() : nsEditor() , mIgnoreSpuriousDragEvent(PR_FALSE) @@ -171,10 +174,11 @@ static int EditorPrefsChangedCallback(const char *aPrefName, void *) { if (nsCRT::strcmp(aPrefName, "editor.singleLine.pasteNewlines") == 0) { - sNewlineHandlingPref = nsContentUtils::GetIntPref("editor.singleLine.pasteNewlines", - nsIPlaintextEditor::eNewlinesPasteToFirst); + sNewlineHandlingPref = + Preferences::GetInt("editor.singleLine.pasteNewlines", + nsIPlaintextEditor::eNewlinesPasteToFirst); } else if (nsCRT::strcmp(aPrefName, "layout.selection.caret_style") == 0) { - sCaretStylePref = nsContentUtils::GetIntPref("layout.selection.caret_style", + sCaretStylePref = Preferences::GetInt("layout.selection.caret_style", #ifdef XP_WIN 1); if (sCaretStylePref == 0) diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index ff9a1ad94c8..330a1c5e9da 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -491,7 +491,7 @@ nsPresContext::GetFontPreferences() pref.Assign("font.minimum-size."); pref.Append(langGroup); - PRInt32 size = nsContentUtils::GetIntPref(pref.get()); + PRInt32 size = Preferences::GetInt(pref.get()); if (unit == eUnit_px) { mMinimumFontSizePref = CSSPixelsToAppUnits(size); } @@ -557,7 +557,7 @@ nsPresContext::GetFontPreferences() // get font.size.[generic].[langGroup] // size=0 means 'Auto', i.e., generic fonts retain the size of the variable font MAKE_FONT_PREF_KEY(pref, "font.size", generic_dot_langGroup); - size = nsContentUtils::GetIntPref(pref.get()); + size = Preferences::GetInt(pref.get()); if (size > 0) { if (unit == eUnit_px) { font->size = CSSPixelsToAppUnits(size); @@ -651,12 +651,11 @@ nsPresContext::GetUserPreferences() } mFontScaler = - nsContentUtils::GetIntPref("browser.display.base_font_scaler", - mFontScaler); + Preferences::GetInt("browser.display.base_font_scaler", mFontScaler); mAutoQualityMinFontSizePixelsPref = - nsContentUtils::GetIntPref("browser.display.auto_quality_min_font_size"); + Preferences::GetInt("browser.display.auto_quality_min_font_size"); // * document colors GetDocumentColorPreferences(); @@ -709,26 +708,23 @@ nsPresContext::GetUserPreferences() } mFocusRingWidth = - nsContentUtils::GetIntPref("browser.display.focus_ring_width", - mFocusRingWidth); + Preferences::GetInt("browser.display.focus_ring_width", mFocusRingWidth); mFocusRingOnAnything = Preferences::GetBool("browser.display.focus_ring_on_anything", mFocusRingOnAnything); mFocusRingStyle = - nsContentUtils::GetIntPref("browser.display.focus_ring_style", - mFocusRingStyle); + Preferences::GetInt("browser.display.focus_ring_style", mFocusRingStyle); // * use fonts? mUseDocumentFonts = - nsContentUtils::GetIntPref("browser.display.use_document_fonts") != 0; + Preferences::GetInt("browser.display.use_document_fonts") != 0; // * replace backslashes with Yen signs? (bug 245770) mEnableJapaneseTransform = Preferences::GetBool("layout.enable_japanese_specific_transform"); - mPrefScrollbarSide = - nsContentUtils::GetIntPref("layout.scrollbar.side"); + mPrefScrollbarSide = Preferences::GetInt("layout.scrollbar.side"); GetFontPreferences(); @@ -747,24 +743,24 @@ nsPresContext::GetUserPreferences() PRUint32 bidiOptions = GetBidi(); PRInt32 prefInt = - nsContentUtils::GetIntPref(IBMBIDI_TEXTDIRECTION_STR, - GET_BIDI_OPTION_DIRECTION(bidiOptions)); + Preferences::GetInt(IBMBIDI_TEXTDIRECTION_STR, + GET_BIDI_OPTION_DIRECTION(bidiOptions)); SET_BIDI_OPTION_DIRECTION(bidiOptions, prefInt); mPrefBidiDirection = prefInt; prefInt = - nsContentUtils::GetIntPref(IBMBIDI_TEXTTYPE_STR, - GET_BIDI_OPTION_TEXTTYPE(bidiOptions)); + Preferences::GetInt(IBMBIDI_TEXTTYPE_STR, + GET_BIDI_OPTION_TEXTTYPE(bidiOptions)); SET_BIDI_OPTION_TEXTTYPE(bidiOptions, prefInt); prefInt = - nsContentUtils::GetIntPref(IBMBIDI_NUMERAL_STR, - GET_BIDI_OPTION_NUMERAL(bidiOptions)); + Preferences::GetInt(IBMBIDI_NUMERAL_STR, + GET_BIDI_OPTION_NUMERAL(bidiOptions)); SET_BIDI_OPTION_NUMERAL(bidiOptions, prefInt); prefInt = - nsContentUtils::GetIntPref(IBMBIDI_SUPPORTMODE_STR, - GET_BIDI_OPTION_SUPPORT(bidiOptions)); + Preferences::GetInt(IBMBIDI_SUPPORTMODE_STR, + GET_BIDI_OPTION_SUPPORT(bidiOptions)); SET_BIDI_OPTION_SUPPORT(bidiOptions, prefInt); // We don't need to force reflow: either we are initializing a new diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8b156dc8bf1..f001cb57917 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1860,8 +1860,7 @@ PresShell::Init(nsIDocument* aDocument, if (gMaxRCProcessingTime == -1) { gMaxRCProcessingTime = - nsContentUtils::GetIntPref("layout.reflow.timeslice", - NS_MAX_REFLOW_TIME); + Preferences::GetInt("layout.reflow.timeslice", NS_MAX_REFLOW_TIME); } { @@ -2817,8 +2816,8 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) // Default to PAINTLOCK_EVENT_DELAY if we can't get the pref value. PRInt32 delay = - nsContentUtils::GetIntPref("nglayout.initialpaint.delay", - PAINTLOCK_EVENT_DELAY); + Preferences::GetInt("nglayout.initialpaint.delay", + PAINTLOCK_EVENT_DELAY); mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback, this, delay, diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 6cf4643fed6..3714973e790 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -52,10 +52,13 @@ #include "nsEventDispatcher.h" #include "jsapi.h" #include "nsContentUtils.h" +#include "mozilla/Preferences.h" using mozilla::TimeStamp; using mozilla::TimeDuration; +using namespace mozilla; + #define DEFAULT_FRAME_RATE 60 #define DEFAULT_THROTTLED_FRAME_RATE 1 @@ -75,7 +78,7 @@ nsRefreshDriver::GetRefreshTimerInterval() const { const char* prefName = mThrottled ? "layout.throttled_frame_rate" : "layout.frame_rate"; - PRInt32 rate = nsContentUtils::GetIntPref(prefName, -1); + PRInt32 rate = Preferences::GetInt(prefName, -1); if (rate <= 0) { // TODO: get the rate from the platform rate = mThrottled ? DEFAULT_THROTTLED_FRAME_RATE : DEFAULT_FRAME_RATE; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 6c502bcd9ae..2a86be325db 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2926,7 +2926,7 @@ static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame, // up with a line or the beginning or end of the frame; 0 on Windows, // 1 on other platforms by default at the writing of this code PRInt32 dragOutOfFrame = - nsContentUtils::GetIntPref("browser.drag_out_of_frame_style"); + Preferences::GetInt("browser.drag_out_of_frame_style"); if (prevLine == end) { if (dragOutOfFrame == 1 || nextLine == end) diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index f12bba4a09c..5111ccb7d0a 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -1639,9 +1639,10 @@ static eNormalLineHeightControl GetNormalLineHeightCalcControl(void) if (sNormalLineHeightControl == eUninitialized) { // browser.display.normal_lineheight_calc_control is not user // changeable, so no need to register callback for it. - sNormalLineHeightControl = - static_cast - (nsContentUtils::GetIntPref("browser.display.normal_lineheight_calc_control", eNoExternalLeading)); + PRInt32 val = + Preferences::GetInt("browser.display.normal_lineheight_calc_control", + eNoExternalLeading); + sNormalLineHeightControl = static_cast(val); } return sNormalLineHeightControl; } diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 14630d99ec3..62247b8ccc0 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -133,6 +133,7 @@ enum { XKeyPress = KeyPress }; #include "nsComponentManagerUtils.h" #include "nsIObserverService.h" #include "nsIScrollableFrame.h" +#include "mozilla/Preferences.h" // headers for plugin scriptability #include "nsIScriptGlobalObject.h" @@ -3373,7 +3374,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, } PRInt32 blockPopups = - nsContentUtils::GetIntPref("privacy.popups.disable_from_plugins"); + Preferences::GetInt("privacy.popups.disable_from_plugins"); nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups); rv = lh->OnLinkClick(mContent, uri, unitarget.get(), diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index a6fe5c57140..7bf82fb0508 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1084,7 +1084,8 @@ nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) mMouseDownState = PR_FALSE; mDesiredXSet = PR_FALSE; mLimiter = aLimiter; - mCaretMovementStyle = nsContentUtils::GetIntPref("bidi.edit.caret_movement_style", 2); + mCaretMovementStyle = + Preferences::GetInt("bidi.edit.caret_movement_style", 2); } nsresult @@ -1143,7 +1144,8 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode, SetDesiredX(desiredX); } - PRInt32 caretStyle = nsContentUtils::GetIntPref("layout.selection.caret_style", 0); + PRInt32 caretStyle = + Preferences::GetInt("layout.selection.caret_style", 0); #ifdef XP_MACOSX if (caretStyle == 0) { caretStyle = 2; // put caret at the selection edge in the |aKeycode| direction diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index e9edcb20774..ba485049709 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -49,6 +49,7 @@ #include "nsCSSFrameConstructor.h" #include "nsContentUtils.h" #include "nsDisplayList.h" +#include "mozilla/Preferences.h" // DateTime Includes #include "nsDateTimeFormatCID.h" @@ -61,6 +62,8 @@ #include "nsGfxCIID.h" #include "nsIServiceManager.h" +using namespace mozilla; + static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1"; // @@ -226,7 +229,7 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext, // Compute the size of each page and the x coordinate that each page will // be placed at nscoord extraThreshold = NS_MAX(pageSize.width, pageSize.height)/10; - PRInt32 gapInTwips = nsContentUtils::GetIntPref("print.print_extra_margin"); + PRInt32 gapInTwips = Preferences::GetInt("print.print_extra_margin"); gapInTwips = NS_MAX(0, gapInTwips); nscoord extraGap = aPresContext->CSSTwipsToAppUnits(gapInTwips); diff --git a/layout/xul/base/src/nsMenuBarListener.cpp b/layout/xul/base/src/nsMenuBarListener.cpp index f2c3a365528..2a080a215da 100644 --- a/layout/xul/base/src/nsMenuBarListener.cpp +++ b/layout/xul/base/src/nsMenuBarListener.cpp @@ -123,7 +123,7 @@ void nsMenuBarListener::InitAccessKey() #endif // Get the menu access key value from prefs, overriding the default: - mAccessKey = nsContentUtils::GetIntPref("ui.key.menuAccessKey", mAccessKey); + mAccessKey = Preferences::GetInt("ui.key.menuAccessKey", mAccessKey); if (mAccessKey == nsIDOMKeyEvent::DOM_VK_SHIFT) mAccessKeyMask = MODIFIER_SHIFT; else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_CONTROL) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 8727a305ef4..b14950bfd9c 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -83,6 +83,9 @@ #include "nsEventStateManager.h" #include "nsIDOMXULMenuListElement.h" #include "mozilla/Services.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define NS_MENU_POPUP_LIST_INDEX 0 @@ -1118,7 +1121,7 @@ nsMenuFrame::BuildAcceleratorText(PRBool aNotify) #endif // Get the accelerator key value from prefs, overriding the default: - accelKey = nsContentUtils::GetIntPref("ui.key.accelKey", accelKey); + accelKey = Preferences::GetInt("ui.key.accelKey", accelKey); } nsAutoString modifiers; diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 0fe901dd749..591c5a7a1d5 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -121,7 +121,7 @@ nsSliderFrame::Init(nsIContent* aContent, gotPrefs = PR_TRUE; gMiddlePref = Preferences::GetBool("middlemouse.scrollbarPosition"); - gSnapMultiplier = nsContentUtils::GetIntPref("slider.snapMultiplier"); + gSnapMultiplier = Preferences::GetInt("slider.snapMultiplier"); } mCurPos = GetCurrentPosition(aContent); From 279ca0316c5f69de9b952a6a09ae738d074a139a Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Wed, 25 May 2011 08:46:56 +0200 Subject: [PATCH 09/15] Bug 543154 - Uninitialised value use in nsNativeThemeWin::ClassicDrawWidgetBackground. r=roc --- widget/src/windows/nsNativeThemeWin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 7975db48082..435777c2849 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -2660,6 +2660,7 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsRenderingContext* aContext, nsIF nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, PRInt32& aPart, PRInt32& aState, PRBool& aFocused) { + aFocused = PR_FALSE; switch (aWidgetType) { case NS_THEME_BUTTON: { nsEventStates contentState; From 1fc2b406e5979218b086873c5fdd86a9f4a0ce2d Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Tue, 24 May 2011 10:34:30 -0400 Subject: [PATCH 10/15] Bug 657961 - Use async API to get favicons for site permissions page. r=sdwilsh --- .../preferences/aboutPermissions.js | 31 ++++++++++--------- .../browser/preferences/aboutPermissions.css | 5 +++ .../browser/preferences/aboutPermissions.css | 5 +++ .../browser/preferences/aboutPermissions.css | 5 +++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/browser/components/preferences/aboutPermissions.js b/browser/components/preferences/aboutPermissions.js index 745be4c0968..83825bafd72 100644 --- a/browser/components/preferences/aboutPermissions.js +++ b/browser/components/preferences/aboutPermissions.js @@ -81,29 +81,29 @@ function Site(host) { this.httpURI = NetUtil.newURI("http://" + this.host); this.httpsURI = NetUtil.newURI("https://" + this.host); - - this._favicon = ""; } Site.prototype = { /** - * Gets the favicon to use for the site. This will return the default favicon - * if there is no favicon stored for the site. + * Gets the favicon to use for the site. The callback only gets called if + * a favicon is found for either the http URI or the https URI. * - * @return A favicon image URL. + * @param aCallback + * A callback function that takes a favicon image URL as a parameter. */ - get favicon() { - if (!this._favicon) { - // TODO: Bug 657961: Make this async when bug 655270 is fixed. + getFavicon: function Site_getFavicon(aCallback) { + function faviconDataCallback(aURI, aDataLen, aData, aMimeType) { try { - // First try to see if a favicon is stored for the http URI. - this._favicon = gFaviconService.getFaviconForPage(this.httpURI).spec; + aCallback(aURI.spec); } catch (e) { - // getFaviconImageForPage returns the default favicon if no stored favicon is found. - this._favicon = gFaviconService.getFaviconImageForPage(this.httpsURI).spec; + Cu.reportError("AboutPermissions: " + e); } } - return this._favicon; + + // Try to find favicion for both URIs. Callback will only be called if a + // favicon URI is found, so this means we'll always prefer the https favicon. + gFaviconService.getFaviconURLForPage(this.httpURI, faviconDataCallback); + gFaviconService.getFaviconURLForPage(this.httpsURI, faviconDataCallback); }, /** @@ -542,7 +542,10 @@ let AboutPermissions = { let item = document.createElement("richlistitem"); item.setAttribute("class", "site"); item.setAttribute("value", aSite.host); - item.setAttribute("favicon", aSite.favicon); + + aSite.getFavicon(function(aURL) { + item.setAttribute("favicon", aURL); + }); aSite.listitem = item; this.sitesList.appendChild(item); diff --git a/browser/themes/gnomestripe/browser/preferences/aboutPermissions.css b/browser/themes/gnomestripe/browser/preferences/aboutPermissions.css index 445f9f11fcb..8a0d98ad076 100644 --- a/browser/themes/gnomestripe/browser/preferences/aboutPermissions.css +++ b/browser/themes/gnomestripe/browser/preferences/aboutPermissions.css @@ -32,6 +32,11 @@ height: 16px; width: 16px; -moz-margin-end: 4px; + list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png"); +} + +#all-sites-item > .site-container > .site-favicon { + list-style-image: none; } .site-domain { diff --git a/browser/themes/pinstripe/browser/preferences/aboutPermissions.css b/browser/themes/pinstripe/browser/preferences/aboutPermissions.css index 7a99df82924..ba1db4999ce 100644 --- a/browser/themes/pinstripe/browser/preferences/aboutPermissions.css +++ b/browser/themes/pinstripe/browser/preferences/aboutPermissions.css @@ -34,6 +34,11 @@ height: 16px; width: 16px; -moz-margin-end: 4px; + list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png"); +} + +#all-sites-item > .site-container > .site-favicon { + list-style-image: none; } .site-domain { diff --git a/browser/themes/winstripe/browser/preferences/aboutPermissions.css b/browser/themes/winstripe/browser/preferences/aboutPermissions.css index 82aaf43cd2c..e3f8451e0f2 100644 --- a/browser/themes/winstripe/browser/preferences/aboutPermissions.css +++ b/browser/themes/winstripe/browser/preferences/aboutPermissions.css @@ -37,6 +37,11 @@ height: 16px; width: 16px; -moz-margin-end: 4px; + list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png"); +} + +#all-sites-item > .site-container > .site-favicon { + list-style-image: none; } .site-domain { From da07d8c5a725c00f3c1d6ea49cd3a74bf07d83ee Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Mon, 23 May 2011 22:14:21 +0200 Subject: [PATCH 11/15] bug 600244 - Some cleanups in search and sidebar code found by SeaMonkey's OpenSearch work, r=gavin --- browser/base/content/browser.js | 4 +- browser/components/sidebar/src/nsSidebar.js | 60 ++++++--------------- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 4a242623411..40438adb7c7 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3346,7 +3346,7 @@ const BrowserSearch = { var win = getTopWin(); if (win) { // If there's an open browser window, it should handle this command - win.focus() + win.focus(); win.BrowserSearch.webSearch(); } else { // If there are no open browser windows, open a new one @@ -3356,7 +3356,7 @@ const BrowserSearch = { Services.obs.removeObserver(observer, "browser-delayed-startup-finished"); } } - win = window.openDialog("chrome://browser/content/", "_blank", + win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", "about:blank"); Services.obs.addObserver(observer, "browser-delayed-startup-finished", false); } diff --git a/browser/components/sidebar/src/nsSidebar.js b/browser/components/sidebar/src/nsSidebar.js index 1484c2654b1..b2654cb73a3 100644 --- a/browser/components/sidebar/src/nsSidebar.js +++ b/browser/components/sidebar/src/nsSidebar.js @@ -41,6 +41,7 @@ # # ***** END LICENSE BLOCK ***** +Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); const DEBUG = false; /* set to false to suppress debug messages */ @@ -56,15 +57,6 @@ const SHERLOCK_FILE_EXT_REGEXP = /\.src$/i; function nsSidebar() { - const PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1"; - const nsIPromptService = Components.interfaces.nsIPromptService; - this.promptService = - Components.classes[PROMPTSERVICE_CONTRACTID].getService(nsIPromptService); - - const SEARCHSERVICE_CONTRACTID = "@mozilla.org/browser/search-service;1"; - const nsIBrowserSearchService = Components.interfaces.nsIBrowserSearchService; - this.searchService = - Components.classes[SEARCHSERVICE_CONTRACTID].getService(nsIBrowserSearchService); } nsSidebar.prototype.classID = SIDEBAR_CID; @@ -102,20 +94,15 @@ function(aTitle, aContentURL, aCustomizeURL) nsSidebar.prototype.addPanelInternal = function (aTitle, aContentURL, aCustomizeURL, aPersist) { - var WINMEDSVC = Components.classes['@mozilla.org/appshell/window-mediator;1'] - .getService(Components.interfaces.nsIWindowMediator); - // XXX Bug 620418: We shouldn't do this anymore. Instead, we should find the // global object for our caller and use it. - var win = WINMEDSVC.getMostRecentWindow( "navigator:browser" ); + var win = Services.wm.getMostRecentWindow("navigator:browser"); if (!sidebarURLSecurityCheck(aContentURL)) return; var uri = null; - var ioService = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); try { - uri = ioService.newURI(aContentURL, null, null); + uri = Services.io.newURI(aContentURL, null, null); } catch(ex) { return; } @@ -141,7 +128,7 @@ function (engineURL, iconURL) if (!isWeb.test(engineURL)) throw "Unsupported search engine URL"; - + if (iconURL && !isWeb.test(iconURL)) throw "Unsupported search icon URL."; } @@ -149,19 +136,17 @@ function (engineURL, iconURL) { debug(ex); Components.utils.reportError("Invalid argument passed to window.sidebar.addSearchEngine: " + ex); - - var searchBundle = srGetStrBundle("chrome://global/locale/search/search.properties"); - var brandBundle = srGetStrBundle("chrome://branding/locale/brand.properties"); + + var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties"); + var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); var brandName = brandBundle.GetStringFromName("brandShortName"); var title = searchBundle.GetStringFromName("error_invalid_engine_title"); var msg = searchBundle.formatStringFromName("error_invalid_engine_msg", [brandName], 1); - var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]. - getService(Components.interfaces.nsIWindowWatcher); - ww.getNewPrompter(null).alert(title, msg); + Services.ww.getNewPrompter(null).alert(title, msg); return false; } - + return true; } @@ -185,7 +170,7 @@ function (engineURL, iconURL, suggestedTitle, suggestedCategory) else dataType = Components.interfaces.nsISearchEngine.DATA_XML; - this.searchService.addEngine(engineURL, dataType, iconURL, true); + Services.search.addEngine(engineURL, dataType, iconURL, true); } // This function exists largely to implement window.external.AddSearchProvider(), @@ -198,23 +183,21 @@ function (aDescriptionURL) // page since we don't have easy access to the active document. Most search // engines will override this with an icon specified in the OpenSearch // description anyway. - var WINMEDSVC = Components.classes['@mozilla.org/appshell/window-mediator;1'] - .getService(Components.interfaces.nsIWindowMediator); - var win = WINMEDSVC.getMostRecentWindow("navigator:browser"); - var browser = win.document.getElementById("content"); + var win = Services.wm.getMostRecentWindow("navigator:browser"); + var browser = win.gBrowser; var iconURL = ""; // Use documentURIObject in the check for shouldLoadFavIcon so that we // do the right thing with about:-style error pages. Bug 453442 if (browser.shouldLoadFavIcon(browser.selectedBrowser .contentDocument .documentURIObject)) - iconURL = win.gBrowser.getIcon(); - + iconURL = browser.getIcon(); + if (!this.validateSearchEngine(aDescriptionURL, iconURL)) return; const typeXML = Components.interfaces.nsISearchEngine.DATA_XML; - this.searchService.addEngine(aDescriptionURL, typeXML, iconURL, true); + Services.search.addEngine(aDescriptionURL, typeXML, iconURL, true); } // This function exists to implement window.external.IsSearchProviderInstalled(), @@ -265,16 +248,3 @@ if (DEBUG) debug = function (s) { dump("-*- sidebar component: " + s + "\n"); } else debug = function (s) {} - -// String bundle service -var gStrBundleService = null; - -function srGetStrBundle(path) -{ - if (!gStrBundleService) - gStrBundleService = - Components.classes["@mozilla.org/intl/stringbundle;1"] - .getService(Components.interfaces.nsIStringBundleService); - - return gStrBundleService.createBundle(path); -} From 10a9af98432bada3a645bdffda0d0a21e45d6f6c Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Wed, 25 May 2011 08:49:29 +0200 Subject: [PATCH 12/15] Bug 588027 - Clean up places library code. r=mak --- browser/components/places/content/places.xul | 248 +++++++++--------- .../gnomestripe/browser/places/organizer.css | 31 +-- .../pinstripe/browser/places/organizer.css | 29 +- .../browser/places/organizer-aero.css | 2 +- .../winstripe/browser/places/organizer.css | 34 +-- 5 files changed, 134 insertions(+), 210 deletions(-) diff --git a/browser/components/places/content/places.xul b/browser/components/places/content/places.xul index 0c89b0f1d5e..e89121c2046 100644 --- a/browser/components/places/content/places.xul +++ b/browser/components/places/content/places.xul @@ -221,6 +221,19 @@ accesskey="&cmd.new_separator.accesskey;"/> #ifndef XP_MACOSX + + + + + - - + - + + +#ifdef XP_MACOSX -#ifndef XP_MACOSX +#else - - -