From 39be3999c27589505c349b186bf895f10320c9c6 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Wed, 5 Mar 2008 11:09:52 -0800 Subject: [PATCH 001/248] bug 415918 - fix version info on mozcrt19.dll. r=bsmedberg --- memory/jemalloc/crtsp1.diff | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/memory/jemalloc/crtsp1.diff b/memory/jemalloc/crtsp1.diff index e5449d6710c7..ac2c2950d8f5 100755 --- a/memory/jemalloc/crtsp1.diff +++ b/memory/jemalloc/crtsp1.diff @@ -17,6 +17,26 @@ diff -re crt/src/crt0.c crt-sp1/src/crt0.c 101a extern BOOL malloc_init_hard(void); . +diff -re crt/src/_sample_.rc crt-sp1/src/_sample_.rc +41c + VALUE "ProductName", "Mozilla Custom C Runtime" +. +39c + VALUE "OriginalFilename", "MOZCRT19.DLL" +. +37c + VALUE "OriginalFilename", "MOZCRT19D.DLL" +. +33c + VALUE "InternalName", "MOZCRT19.DLL" +. +31c + VALUE "InternalName", "MOZCRT19D.DLL" +. +27c + VALUE "CompanyName", "Mozilla Foundation" +. + diff -re crt/src/crt0dat.c crt-sp1/src/crt0dat.c 789d 778d From f7d646647b49278ea464311b7bb3a6a2dcd7b372 Mon Sep 17 00:00:00 2001 From: "blizzard@mozilla.com" Date: Wed, 5 Mar 2008 11:10:34 -0800 Subject: [PATCH 002/248] bug 419918 - Add the ability to fire the memory pressure observers from the embedding test app. Taken from Stuart's ramback extension and made available here for testing. r=dougt, sr=pavlov, a=beltzner --- embedding/browser/gtk/tests/TestGtkEmbed.cpp | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/embedding/browser/gtk/tests/TestGtkEmbed.cpp b/embedding/browser/gtk/tests/TestGtkEmbed.cpp index 910d7f0de3fe..3c7223d37e51 100644 --- a/embedding/browser/gtk/tests/TestGtkEmbed.cpp +++ b/embedding/browser/gtk/tests/TestGtkEmbed.cpp @@ -46,6 +46,11 @@ #include "nsIDOMMouseEvent.h" #include "nsIDOMUIEvent.h" +#include "nsCOMPtr.h" +#include "nsISupportsUtils.h" +#include "nsServiceManagerUtils.h" +#include "nsIObserverService.h" + #include "nsStringAPI.h" #include "gtkmozembed_glue.cpp" @@ -57,6 +62,7 @@ typedef struct _TestGtkBrowser { GtkWidget *fileMenu; GtkWidget *fileOpenNewBrowser; GtkWidget *fileStream; + GtkWidget *fileMemory; GtkWidget *fileClose; GtkWidget *fileQuit; GtkWidget *toolbarHBox; @@ -107,6 +113,8 @@ static void menu_open_new_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser); static void menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser); +static void menu_memory_cb (GtkMenuItem *menuitem, + TestGtkBrowser *browser); static void menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser); static void menu_quit_cb (GtkMenuItem *menuitem, @@ -328,6 +336,11 @@ new_gtk_browser(guint32 chromeMask) gtk_menu_append(GTK_MENU(browser->fileMenu), browser->fileStream); + browser->fileMemory = + gtk_menu_item_new_with_label("Release Memory"); + gtk_menu_append(GTK_MENU(browser->fileMenu), + browser->fileMemory); + browser->fileClose = gtk_menu_item_new_with_label("Close"); gtk_menu_append(GTK_MENU(browser->fileMenu), @@ -465,6 +478,9 @@ new_gtk_browser(guint32 chromeMask) // hook up to the stream test gtk_signal_connect(GTK_OBJECT(browser->fileStream), "activate", GTK_SIGNAL_FUNC(menu_stream_cb), browser); + // hook up the memory pressure release function + gtk_signal_connect(GTK_OBJECT(browser->fileMemory), "activate", + GTK_SIGNAL_FUNC(menu_memory_cb), browser); // close this window gtk_signal_connect(GTK_OBJECT(browser->fileClose), "activate", GTK_SIGNAL_FUNC(menu_close_cb), browser); @@ -672,6 +688,21 @@ menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser) gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed)); } +void +menu_memory_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser) +{ + g_print("menu_memory_cb\n"); + nsCOMPtr os = do_GetService("@mozilla.org/observer-service;1"); + if (!os) + return; + + // Compact like you mean it. We do this three times to give the + // cycle collector a chance to try and reclaim as much as we can. + os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get()); + os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get()); + os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get()); +} + void menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser) { From 19b228e5aeb568e7845aa3882b4c40974bf9a6ce Mon Sep 17 00:00:00 2001 From: "crowder@fiverocks.com" Date: Wed, 5 Mar 2008 11:11:54 -0800 Subject: [PATCH 003/248] Bug 324161 - Optimize parseInt for integer values, if radix is 10, r=brendan, blocking1.9=dsicore --- js/src/jsnum.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/src/jsnum.c b/js/src/jsnum.c index bf4ba043eac4..94018b1daf7b 100644 --- a/js/src/jsnum.c +++ b/js/src/jsnum.c @@ -128,6 +128,11 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp) return JS_TRUE; } + if (JSVAL_IS_INT(vp[2]) && (radix == 0 || radix == 10)) { + *vp = vp[2]; + return JS_TRUE; + } + str = js_ValueToString(cx, vp[2]); if (!str) return JS_FALSE; From 0069a6f866b3f47c9a9dabcdea9e988515fbb241 Mon Sep 17 00:00:00 2001 From: "dougt@meer.net" Date: Wed, 5 Mar 2008 11:23:44 -0800 Subject: [PATCH 004/248] XRE build changes for windows mobile. b=420240, r=bsmedberg, a=beltzner --- toolkit/library/Makefile.in | 8 ++++++++ toolkit/library/libxul-rules.mk | 2 ++ toolkit/xre/Makefile.in | 8 ++++++-- toolkit/xre/nsAppRunner.cpp | 7 ++++++- toolkit/xre/nsWindowsRestart.cpp | 5 ++++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index d6e8c49d2d73..12e18269f39e 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -74,6 +74,10 @@ ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) CPPSRCS += dlldeps-xul.cpp endif +ifeq ($(OS_ARCH),WINCE) +CPPSRCS += dlldeps-xul.cpp +endif + ifeq ($(OS_ARCH),OS2) CPPSRCS += dlldeps-xul.cpp endif @@ -228,6 +232,10 @@ ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)) EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME,imagehlp) endif endif # WINNT +ifeq ($(OS_ARCH),WINCE) +EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME, aygshell cellcore uuid ole32 oleaut32 ) +endif + ifdef MOZ_JPROF EXTRA_DSO_LDOPTS += -ljprof diff --git a/toolkit/library/libxul-rules.mk b/toolkit/library/libxul-rules.mk index 9e3a0ade1692..2fbdc3157fb0 100644 --- a/toolkit/library/libxul-rules.mk +++ b/toolkit/library/libxul-rules.mk @@ -74,8 +74,10 @@ DEFINES += \ $(NULL) ifeq ($(MOZ_WIDGET_TOOLKIT),windows) +ifneq ($(OS_ARCH),WINCE) OS_LIBS += $(call EXPAND_LIBNAME,usp10) endif +endif ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa)) EXTRA_DSO_LDOPTS += -lcups ifdef MOZ_ENABLE_GLITZ diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index 0c050c77bb3e..11a22d56bdd9 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -92,7 +92,7 @@ XPIDLSRCS = \ nsIXULRuntime.idl \ $(NULL) -ifeq ($(OS_ARCH),WINNT) +ifneq (,$(filter WINCE WINNT,$(OS_ARCH))) XPIDLSRCS += nsIWinAppHelper.idl endif @@ -126,7 +126,11 @@ DEFINES += -DMOZ_UPDATER endif ifeq ($(MOZ_WIDGET_TOOLKIT),windows) +ifdef WINCE +CPPSRCS += nsNativeAppSupportDefault.cpp +else CPPSRCS += nsNativeAppSupportWin.cpp +endif DEFINES += -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE else ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) @@ -164,7 +168,7 @@ SHAREDCPPSRCS += nsSigHandlers.cpp endif GARBAGE += $(SHAREDCPPSRCS) $(wildcard *.$(OBJ_SUFFIX)) -ifeq ($(OS_ARCH),WINNT) +ifneq (,$(filter WINCE WINNT,$(OS_ARCH))) GARBAGE += $(addprefix $(srcdir)/,$(SHAREDCPPSRCS)) endif diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 9a81f64d9457..affc067746ad 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -790,6 +790,10 @@ typedef enum NS_IMETHODIMP nsXULAppInfo::GetUserCanElevate(PRBool *aUserCanElevate) { +#ifdef WINCE + *aUserCanElevate = PR_FALSE; + return NS_OK; +#else HANDLE hToken; VISTA_TOKEN_ELEVATION_TYPE elevationType; @@ -817,6 +821,7 @@ nsXULAppInfo::GetUserCanElevate(PRBool *aUserCanElevate) CloseHandle(hToken); return NS_OK; +#endif // WINCE } #endif @@ -2400,7 +2405,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) NS_BREAK(); #endif -#ifdef XP_WIN32 +#if defined (XP_WIN32) && !defined (WINCE) // Suppress the "DLL Foo could not be found" dialog, such that if dependent // libraries (such as GDI+) are not preset, we gracefully fail to load those // XPCOM components, instead of being ungraceful. diff --git a/toolkit/xre/nsWindowsRestart.cpp b/toolkit/xre/nsWindowsRestart.cpp index 2fa6ae7a54ee..34969eddae17 100755 --- a/toolkit/xre/nsWindowsRestart.cpp +++ b/toolkit/xre/nsWindowsRestart.cpp @@ -145,6 +145,9 @@ MakeCommandLine(int argc, PRUnichar **argv) static BOOL LaunchAsNormalUser(const PRUnichar *exePath, PRUnichar *cl) { +#ifdef WINCE + return PR_FALSE; +#else if (!pCreateProcessWithTokenW) { // IsUserAnAdmin is not present on Win9x and not exported by name on Win2k *(FARPROC *)&pIsUserAnAdmin = @@ -218,8 +221,8 @@ LaunchAsNormalUser(const PRUnichar *exePath, PRUnichar *cl) CloseHandle(pi.hThread); return TRUE; +#endif } - /** * Convert UTF8 to UTF16 without using the normal XPCOM goop, which we * can't link to updater.exe. From fa4e17f0c51490b5c58eef91cc5eedf31f8c750b Mon Sep 17 00:00:00 2001 From: "masayuki@d-toybox.com" Date: Wed, 5 Mar 2008 11:24:44 -0800 Subject: [PATCH 005/248] Bug 405308 [text-decoration] Link underline disappears (or is misaligned 1px) when scrolling r+sr=roc, a1.9=beltzner --- layout/base/nsCSSRendering.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 4b50ba4ab5c8..7bb50d7d9d75 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -4596,7 +4596,7 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt, const PRUint8 aStyle) { gfxRect r; - r.pos.x = NS_round(aPt.x); + r.pos.x = NS_floor(aPt.x + 0.5); r.size.width = NS_round(aLineSize.width); gfxFloat basesize = NS_round(aLineSize.height); @@ -4610,24 +4610,24 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt, r.size.height = basesize; } - gfxFloat baseline = NS_round(aPt.y + aAscent); + gfxFloat baseline = NS_floor(aPt.y + aAscent + 0.5); gfxFloat offset = 0; switch (aDecoration) { case NS_STYLE_TEXT_DECORATION_UNDERLINE: - offset = NS_round(aOffset); + offset = aOffset; break; case NS_STYLE_TEXT_DECORATION_OVERLINE: - offset = NS_round(aOffset - basesize + r.Height()); + offset = aOffset - basesize + r.Height(); break; case NS_STYLE_TEXT_DECORATION_LINE_THROUGH: { - gfxFloat extra = NS_round(r.Height() / 2.0); + gfxFloat extra = NS_floor(r.Height() / 2.0 + 0.5); extra = PR_MAX(extra, basesize); - offset = NS_round(aOffset - basesize + extra); + offset = aOffset - basesize + extra; break; } default: NS_ERROR("Invalid decoration value!"); } - r.pos.y = baseline - NS_round(offset); + r.pos.y = baseline - NS_floor(offset + 0.5); return r; } From b97376dfa82d40f5aaa8583a304f472a303a92ef Mon Sep 17 00:00:00 2001 From: "masayuki@d-toybox.com" Date: Wed, 5 Mar 2008 11:27:54 -0800 Subject: [PATCH 006/248] Bug 419359 Compile warning about NS_TargetUnfocusedEventToLastFocusedContent r+sr=roc, a1.9=beltzner --- widget/public/nsGUIEvent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index 678e3822791c..81ae90c3b158 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -1244,7 +1244,7 @@ enum nsDragDropEventStatus { #define NS_TEXTRANGE_CONVERTEDTEXT 0x04 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05 -static PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent) +inline PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent) { #if defined(MOZ_X11) || defined(XP_MACOSX) // bug 52416 (MOZ_X11) From a41d6a883dd393a2b51981e668c638f5e18d27f2 Mon Sep 17 00:00:00 2001 From: "sayrer@gmail.com" Date: Wed, 5 Mar 2008 12:07:55 -0800 Subject: [PATCH 007/248] Bug 383939. RDF datasources must implement cycle collection. r/sr=bsmedberg --- content/xul/document/src/nsXULDocument.cpp | 3 +- rdf/datasource/src/nsFileSystemDataSource.cpp | 7 +- rdf/datasource/src/nsFileSystemDataSource.h | 4 +- rdf/datasource/src/nsLocalStore.cpp | 70 ++++++------------- 4 files changed, 32 insertions(+), 52 deletions(-) diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 0f56c33d1f37..f2a29c6e04c2 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -345,8 +345,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULDocument, nsXMLDocument) for (i = 0; i < count; ++i) { cb.NoteXPCOMChild(static_cast(tmp->mPrototypes[i])); } - + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTooltipNode) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLocalStore) if (tmp->mOverlayLoadObservers.IsInitialized()) tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb); diff --git a/rdf/datasource/src/nsFileSystemDataSource.cpp b/rdf/datasource/src/nsFileSystemDataSource.cpp index 6ade67d8fe52..cd1bf5eb8fc1 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -251,7 +251,12 @@ FileSystemDataSource::Create(nsISupports* aOuter, const nsIID& aIID, void **aRes return self->QueryInterface(aIID, aResult); } -NS_IMPL_ISUPPORTS1(FileSystemDataSource, nsIRDFDataSource) +NS_IMPL_CYCLE_COLLECTION_0(FileSystemDataSource) +NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemDataSource) +NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemDataSource) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemDataSource) + NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource) +NS_INTERFACE_MAP_END NS_IMETHODIMP FileSystemDataSource::GetURI(char **uri) diff --git a/rdf/datasource/src/nsFileSystemDataSource.h b/rdf/datasource/src/nsFileSystemDataSource.h index 5b6125d37e4f..11d1c56b2be3 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.h +++ b/rdf/datasource/src/nsFileSystemDataSource.h @@ -46,6 +46,7 @@ #include "nsISupportsArray.h" #include "nsCOMPtr.h" #include "nsString.h" +#include "nsCycleCollectionParticipant.h" #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN) || defined(XP_BEOS) #define USE_NC_EXTENSION @@ -54,7 +55,8 @@ class FileSystemDataSource : public nsIRDFDataSource { public: - NS_DECL_ISUPPORTS + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(FileSystemDataSource) NS_DECL_NSIRDFDATASOURCE static NS_METHOD Create(nsISupports* aOuter, diff --git a/rdf/datasource/src/nsLocalStore.cpp b/rdf/datasource/src/nsLocalStore.cpp index 9ff8eae5fa23..67e78717065c 100644 --- a/rdf/datasource/src/nsLocalStore.cpp +++ b/rdf/datasource/src/nsLocalStore.cpp @@ -66,6 +66,7 @@ #include "nsCRTGlue.h" #include "nsCRT.h" #include "nsEnumeratorUtils.h" +#include "nsCycleCollectionParticipant.h" //////////////////////////////////////////////////////////////////////// @@ -91,7 +92,8 @@ protected: public: // nsISupports interface - NS_DECL_ISUPPORTS + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(LocalStoreImpl, nsILocalStore) // nsILocalStore interface @@ -213,13 +215,13 @@ public: } NS_IMETHOD GetLoaded(PRBool* _result); - NS_IMETHOD Init(const char *uri); - NS_IMETHOD Flush(); - NS_IMETHOD FlushTo(const char *aURI); - NS_IMETHOD Refresh(PRBool sync); - - // nsIObserver - NS_DECL_NSIOBSERVER + NS_IMETHOD Init(const char *uri); + NS_IMETHOD Flush(); + NS_IMETHOD FlushTo(const char *aURI); + NS_IMETHOD Refresh(PRBool sync); + + // nsIObserver + NS_DECL_NSIOBSERVER }; //////////////////////////////////////////////////////////////////////// @@ -264,51 +266,21 @@ NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult) return rv; } +NS_IMPL_CYCLE_COLLECTION_1(LocalStoreImpl, mInner) +NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(LocalStoreImpl, nsILocalStore) +NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(LocalStoreImpl, nsILocalStore) -// nsISupports interface - -NS_IMPL_ADDREF(LocalStoreImpl) -NS_IMPL_RELEASE(LocalStoreImpl) - -NS_IMETHODIMP -LocalStoreImpl::QueryInterface(REFNSIID aIID, void** aResult) -{ -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - - NS_PRECONDITION(aResult != nsnull, "null ptr"); - if (! aResult) - return NS_ERROR_NULL_POINTER; - - if (aIID.Equals(kISupportsIID) || - aIID.Equals(NS_GET_IID(nsILocalStore))) { - *aResult = static_cast(this); - } - else if (aIID.Equals(NS_GET_IID(nsIRDFDataSource))) { - *aResult = static_cast(this); - } - else if (aIID.Equals(NS_GET_IID(nsIRDFRemoteDataSource))) { - *aResult = static_cast(this); - } - else if (aIID.Equals(NS_GET_IID(nsIObserver))) { - *aResult = static_cast(this); - } - else if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference))) { - *aResult = static_cast(this); - } - else { - *aResult = nsnull; - return NS_NOINTERFACE; - } - - NS_ADDREF(this); - return NS_OK; -} - +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalStoreImpl) + NS_INTERFACE_MAP_ENTRY(nsILocalStore) + NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource) + NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource) + NS_INTERFACE_MAP_ENTRY(nsIObserver) + NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILocalStore) +NS_INTERFACE_MAP_END // nsILocalStore interface - - // nsIRDFDataSource interface NS_IMETHODIMP From bdc9c64b8a515fd7684c2563af53193ce6d47702 Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Wed, 5 Mar 2008 12:18:52 -0800 Subject: [PATCH 008/248] bug=355258 r=brendan a1.9=beltzner --- js/src/jsinterp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 3a7c1a8e1dd0..cd98b14fb521 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -884,8 +884,8 @@ JSBool js_OnUnknownMethod(JSContext *cx, jsval *vp) { JSObject *obj; - JSTempValueRooter tvr; jsid id; + JSTempValueRooter tvr; JSBool ok; JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp[1])); @@ -915,6 +915,16 @@ js_OnUnknownMethod(JSContext *cx, jsval *vp) if (JSVAL_IS_PRIMITIVE(tvr.u.value)) { vp[0] = tvr.u.value; } else { +#if JS_HAS_XML_SUPPORT + /* Extract the function name from function::name qname. */ + if (!JSVAL_IS_PRIMITIVE(vp[0])) { + obj = JSVAL_TO_OBJECT(vp[0]); + if (!js_IsFunctionQName(cx, obj, &id)) + return JS_FALSE; + if (id != 0) + vp[0] = ID_TO_VALUE(id); + } +#endif obj = js_NewObject(cx, &js_NoSuchMethodClass, NULL, NULL); if (!obj) { ok = JS_FALSE; From 2015c98075aa18a0a4295ffe15ae89b541b5852a Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Wed, 5 Mar 2008 12:26:06 -0800 Subject: [PATCH 009/248] bug=418641 r=brendan a1.9=dsicore Avoiding code bloat on slow paths in the interpreter. --- js/src/jsemit.c | 25 +-- js/src/jsinterp.c | 388 +++++++++++++++++++++++--------------------- js/src/jsinterp.h | 9 + js/src/jsopcode.h | 6 +- js/src/jsopcode.tbl | 34 ++-- 5 files changed, 243 insertions(+), 219 deletions(-) diff --git a/js/src/jsemit.c b/js/src/jsemit.c index efe0477bee5d..a6c8cd21f67f 100644 --- a/js/src/jsemit.c +++ b/js/src/jsemit.c @@ -151,14 +151,17 @@ UpdateDepth(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t target) jsbytecode *pc; JSOp op; const JSCodeSpec *cs; + uintN depth; intN nuses; pc = CG_CODE(cg, target); op = (JSOp) *pc; cs = &js_CodeSpec[op]; - if ((cs->format & JOF_TMPSLOT) && - (uintN)cg->stackDepth >= cg->maxStackDepth) { - cg->maxStackDepth = cg->stackDepth + 1; + if (cs->format & JOF_TMPSLOT_MASK) { + depth = (uintN) cg->stackDepth + + ((cs->format & JOF_TMPSLOT_MASK) >> JOF_TMPSLOT_SHIFT); + if (depth > cg->maxStackDepth) + cg->maxStackDepth = depth; } nuses = cs->nuses; if (nuses < 0) { @@ -5672,7 +5675,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) JS_ASSERT(pn2->pn_type != TOK_RP); op = PN_OP(pn); switch (pn2->pn_type) { - case TOK_NAME: + default: + JS_ASSERT(pn2->pn_type == TOK_NAME); pn2->pn_op = op; if (!BindNameToSlot(cx, cg, pn2, 0)) return JS_FALSE; @@ -5722,20 +5726,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return JS_FALSE; break; #endif - default: - JS_ASSERT(0); } - - /* - * Post-increments require an extra slot for GC protection in case - * the initial value being post-incremented or -decremented is not a - * number, but converts to a jsdouble. In the TOK_NAME cases, op has - * 0 operand uses and 1 definition, so we don't need an extra stack - * slot -- we can use the one allocated for the def. - */ - JS_ASSERT(((js_CodeSpec[op].format >> JOF_TMPSLOT_SHIFT) & 1) == - ((js_CodeSpec[op].format & JOF_POST) && - pn2->pn_type != TOK_NAME)); break; case TOK_DELETE: diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index cd98b14fb521..873e91fdde04 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -2029,6 +2029,35 @@ js_UnwindScope(JSContext *cx, JSStackFrame *fp, jsint stackDepth, return normalUnwind; } +JSBool +js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, jsval *vp, jsval *vp2) +{ + jsval v; + jsdouble d; + + v = *vp; + if (JSVAL_IS_DOUBLE(v)) { + d = *JSVAL_TO_DOUBLE(v); + } else if (JSVAL_IS_INT(v)) { + d = JSVAL_TO_INT(v); + } else { + if (!js_ValueToNumber(cx, v, &d)) + return JS_FALSE; + + /* Store the result of v conversion back in vp for post increments. */ + if ((cs->format & JOF_POST) && !js_NewNumberValue(cx, d, vp)) + return JS_FALSE; + } + + (cs->format & JOF_INC) ? d++ : d--; + if (!js_NewNumberValue(cx, d, vp2)) + return JS_FALSE; + + if (!(cs->format & JOF_POST)) + *vp = *vp2; + return JS_TRUE; +} + #ifdef JS_OPMETER # include @@ -2342,6 +2371,20 @@ js_DumpOpMeters() v = sp[n]; \ JS_END_MACRO +/* + * Quickly test if v is an int from the [-2**29, 2**29) range, that is, when + * the lowest bit of v is 1 and the bits 30 and 31 are both either 0 or 1. For + * such v we can do increment or decrement via adding or subtracting two + * without checking that the result overflows JSVAL_INT_MIN or JSVAL_INT_MAX. + */ +#define CAN_DO_FAST_INC_DEC(v) (((((v) << 1) ^ v) & 0x80000001) == 1) + +JS_STATIC_ASSERT(JSVAL_INT == 1); +JS_STATIC_ASSERT(JSVAL_INT & JSVAL_VOID); +JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(JSVAL_VOID)); +JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL(JSVAL_INT_MIN))); +JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL(JSVAL_INT_MAX))); + /* * Conditional assert to detect failure to clear a pending exception that is * suppressed (or unintentional suppression of a wanted exception). @@ -3023,6 +3066,7 @@ interrupt: } else { \ if (!js_InternNonIntElementId(cx, obj, idval_, &id)) \ goto error; \ + sp[n] = ID_TO_VALUE(id); \ } \ JS_END_MACRO @@ -3874,187 +3918,192 @@ interrupt: goto error; if (!prop) goto atom_not_defined; - OBJ_DROP_PROPERTY(cx, obj2, prop); - lval = OBJECT_TO_JSVAL(obj); - i = 0; do_incop: { const JSCodeSpec *cs; + jsval v; - /* The operand must contain a number. */ - if (!OBJ_GET_PROPERTY(cx, obj, id, &rval)) + /* + * We need a root to store the value to leave on the stack until + * we have done with OBJ_SET_PROPERTY. + */ + PUSH_OPND(JSVAL_NULL); + SAVE_SP(fp); + if (!OBJ_GET_PROPERTY(cx, obj, id, &sp[-1])) goto error; - /* Preload for use in the if/else immediately below. */ cs = &js_CodeSpec[op]; + JS_ASSERT(cs->ndefs == 1); + JS_ASSERT((cs->format & JOF_TMPSLOT_MASK) == JOF_TMPSLOT2); + v = sp[-1]; + if (JS_LIKELY(CAN_DO_FAST_INC_DEC(v))) { + jsval incr; - /* The expression result goes in rtmp, the updated value in rval. */ - if (JSVAL_IS_INT(rval) && - rval != INT_TO_JSVAL(JSVAL_INT_MIN) && - rval != INT_TO_JSVAL(JSVAL_INT_MAX)) { + incr = (cs->format & JOF_INC) ? 2 : -2; if (cs->format & JOF_POST) { - rtmp = rval; - (cs->format & JOF_INC) ? (rval += 2) : (rval -= 2); + sp[-1] = v + incr; } else { - (cs->format & JOF_INC) ? (rval += 2) : (rval -= 2); - rtmp = rval; + v += incr; + sp[-1] = v; } + fp->flags |= JSFRAME_ASSIGNING; + ok = OBJ_SET_PROPERTY(cx, obj, id, &sp[-1]); + fp->flags &= ~JSFRAME_ASSIGNING; + if (!ok) + goto error; + + /* + * We must set sp[-1] to v for both post and pre increments + * as the setter overwrites sp[-1]. + */ + sp[-1] = v; } else { - -/* - * Initially, rval contains the value to increment or decrement, which is not - * yet converted. As above, the expression result goes in rtmp, the updated - * value goes in rval. Our caller must set vp to point at a GC-rooted jsval - * in which we home rtmp, to protect it from GC in case the unconverted rval - * is not a number. - */ -#define NONINT_INCREMENT_OP_MIDDLE() \ - JS_BEGIN_MACRO \ - VALUE_TO_NUMBER(cx, rval, d); \ - if (cs->format & JOF_POST) { \ - rtmp = rval; \ - if (!JSVAL_IS_NUMBER(rtmp) && !js_NewNumberValue(cx, d, &rtmp)) \ - goto error; \ - *vp = rtmp; \ - (cs->format & JOF_INC) ? d++ : d--; \ - if (!js_NewNumberValue(cx, d, &rval)) \ - goto error; \ - } else { \ - (cs->format & JOF_INC) ? ++d : --d; \ - if (!js_NewNumberValue(cx, d, &rval)) \ - goto error; \ - rtmp = rval; \ - } \ - JS_END_MACRO - - if (cs->format & JOF_POST) { - /* - * We must push early to protect the postfix increment - * or decrement result, if converted to a jsdouble from - * a non-number value, from GC nesting in the setter. - */ - vp = sp; - PUSH(JSVAL_VOID); - SAVE_SP(fp); - --i; - } -#ifdef __GNUC__ - else vp = NULL; /* suppress bogus gcc warnings */ -#endif - - NONINT_INCREMENT_OP_MIDDLE(); + /* We need an extra root for the result. */ + PUSH_OPND(JSVAL_NULL); + SAVE_SP(fp); + if (!js_DoIncDec(cx, cs, &sp[-2], &sp[-1])) + goto error; + fp->flags |= JSFRAME_ASSIGNING; + ok = OBJ_SET_PROPERTY(cx, obj, id, &sp[-1]); + fp->flags &= ~JSFRAME_ASSIGNING; + if (!ok) + goto error; + sp--; } - fp->flags |= JSFRAME_ASSIGNING; - ok = OBJ_SET_PROPERTY(cx, obj, id, &rval); - fp->flags &= ~JSFRAME_ASSIGNING; - if (!ok) - goto error; - sp += i; - PUSH_OPND(rtmp); - len = js_CodeSpec[op].length; - DO_NEXT_OP(len); - } - -/* NB: This macro doesn't use JS_BEGIN_MACRO/JS_END_MACRO around its body. */ -#define FAST_INCREMENT_OP(SLOT,COUNT,BASE,PRE,OPEQ,MINMAX) \ - slot = SLOT; \ - JS_ASSERT(slot < fp->fun->COUNT); \ - METER_SLOT_OP(op, slot); \ - vp = fp->BASE + slot; \ - rval = *vp; \ - if (!JSVAL_IS_INT(rval) || rval == INT_TO_JSVAL(JSVAL_INT_##MINMAX)) \ - goto do_nonint_fast_incop; \ - PRE = rval; \ - rval OPEQ 2; \ - *vp = rval; \ - PUSH_OPND(PRE); \ - goto end_nonint_fast_incop - - BEGIN_CASE(JSOP_INCARG) - FAST_INCREMENT_OP(GET_ARGNO(pc), nargs, argv, rval, +=, MAX); - BEGIN_CASE(JSOP_DECARG) - FAST_INCREMENT_OP(GET_ARGNO(pc), nargs, argv, rval, -=, MIN); - BEGIN_CASE(JSOP_ARGINC) - FAST_INCREMENT_OP(GET_ARGNO(pc), nargs, argv, rtmp, +=, MAX); - BEGIN_CASE(JSOP_ARGDEC) - FAST_INCREMENT_OP(GET_ARGNO(pc), nargs, argv, rtmp, -=, MIN); - - BEGIN_CASE(JSOP_INCVAR) - FAST_INCREMENT_OP(GET_VARNO(pc), u.i.nvars, vars, rval, +=, MAX); - BEGIN_CASE(JSOP_DECVAR) - FAST_INCREMENT_OP(GET_VARNO(pc), u.i.nvars, vars, rval, -=, MIN); - BEGIN_CASE(JSOP_VARINC) - FAST_INCREMENT_OP(GET_VARNO(pc), u.i.nvars, vars, rtmp, +=, MAX); - BEGIN_CASE(JSOP_VARDEC) - FAST_INCREMENT_OP(GET_VARNO(pc), u.i.nvars, vars, rtmp, -=, MIN); - - end_nonint_fast_incop: - len = JSOP_INCARG_LENGTH; /* all fast incops are same length */ - DO_NEXT_OP(len); - -#undef FAST_INCREMENT_OP - - do_nonint_fast_incop: - { - const JSCodeSpec *cs = &js_CodeSpec[op]; - - NONINT_INCREMENT_OP_MIDDLE(); - *vp = rval; - PUSH_OPND(rtmp); + if (cs->nuses == 0) { + /* sp[-1] already contains the result of name increment. */ + } else { + rtmp = sp[-1]; + sp -= cs->nuses; + sp[-1] = rtmp; + } len = cs->length; DO_NEXT_OP(len); } -/* NB: This macro doesn't use JS_BEGIN_MACRO/JS_END_MACRO around its body. */ -#define FAST_GLOBAL_INCREMENT_OP(SLOWOP,PRE,OPEQ,MINMAX) \ - slot = GET_VARNO(pc); \ - JS_ASSERT(slot < fp->nvars); \ - METER_SLOT_OP(op, slot); \ - lval = fp->vars[slot]; \ - if (JSVAL_IS_NULL(lval)) { \ - op = SLOWOP; \ - DO_OP(); \ - } \ - slot = JSVAL_TO_INT(lval); \ - obj = fp->varobj; \ - rval = OBJ_GET_SLOT(cx, obj, slot); \ - if (!JSVAL_IS_INT(rval) || rval == INT_TO_JSVAL(JSVAL_INT_##MINMAX)) \ - goto do_nonint_fast_global_incop; \ - PRE = rval; \ - rval OPEQ 2; \ - OBJ_SET_SLOT(cx, obj, slot, rval); \ - PUSH_OPND(PRE); \ - goto end_nonint_fast_global_incop + { + jsval incr, incr2; - BEGIN_CASE(JSOP_INCGVAR) - FAST_GLOBAL_INCREMENT_OP(JSOP_INCNAME, rval, +=, MAX); - BEGIN_CASE(JSOP_DECGVAR) - FAST_GLOBAL_INCREMENT_OP(JSOP_DECNAME, rval, -=, MIN); - BEGIN_CASE(JSOP_GVARINC) - FAST_GLOBAL_INCREMENT_OP(JSOP_NAMEINC, rtmp, +=, MAX); - BEGIN_CASE(JSOP_GVARDEC) - FAST_GLOBAL_INCREMENT_OP(JSOP_NAMEDEC, rtmp, -=, MIN); + /* Position cases so the most frequent i++ does not need a jump. */ + BEGIN_CASE(JSOP_DECARG) + incr = -2; incr2 = -2; goto do_arg_incop; + BEGIN_CASE(JSOP_ARGDEC) + incr = -2; incr2 = 0; goto do_arg_incop; + BEGIN_CASE(JSOP_INCARG) + incr = 2; incr2 = 2; goto do_arg_incop; + BEGIN_CASE(JSOP_ARGINC) + incr = 2; incr2 = 0; - end_nonint_fast_global_incop: - len = JSOP_INCGVAR_LENGTH; /* all gvar incops are same length */ + do_arg_incop: + slot = GET_ARGNO(pc); + JS_ASSERT(slot < fp->fun->nargs); + METER_SLOT_OP(op, slot); + vp = fp->argv + slot; + goto do_int_fast_incop; + + BEGIN_CASE(JSOP_DECLOCAL) + incr = -2; incr2 = -2; goto do_local_incop; + BEGIN_CASE(JSOP_LOCALDEC) + incr = -2; incr2 = 0; goto do_local_incop; + BEGIN_CASE(JSOP_INCLOCAL) + incr = 2; incr2 = 2; goto do_local_incop; + BEGIN_CASE(JSOP_LOCALINC) + incr = 2; incr2 = 0; + + do_local_incop: + slot = GET_UINT16(pc); + JS_ASSERT(slot < script->depth); + vp = fp->spbase + slot; + goto do_int_fast_incop; + + BEGIN_CASE(JSOP_DECVAR) + incr = -2; incr2 = -2; goto do_var_incop; + BEGIN_CASE(JSOP_VARDEC) + incr = -2; incr2 = 0; goto do_var_incop; + BEGIN_CASE(JSOP_INCVAR) + incr = 2; incr2 = 2; goto do_var_incop; + BEGIN_CASE(JSOP_VARINC) + incr = 2; incr2 = 0; + + /* + * do_var_incop comes right before do_int_fast_incop as we want to + * avoid an extra jump for variable cases as var++ is more frequent + * than arg++ or local++; + */ + do_var_incop: + slot = GET_VARNO(pc); + JS_ASSERT(slot < fp->fun->u.i.nvars); + METER_SLOT_OP(op, slot); + vp = fp->vars + slot; + + do_int_fast_incop: + rval = *vp; + if (JS_LIKELY(CAN_DO_FAST_INC_DEC(rval))) { + *vp = rval + incr; + PUSH_OPND(rval + incr2); + } else { + PUSH_OPND(rval); + SAVE_SP_AND_PC(fp); + if (!js_DoIncDec(cx, &js_CodeSpec[op], &sp[-1], vp)) + goto error; + } + len = JSOP_INCARG_LENGTH; JS_ASSERT(len == js_CodeSpec[op].length); DO_NEXT_OP(len); + } + +/* NB: This macro doesn't use JS_BEGIN_MACRO/JS_END_MACRO around its body. */ +#define FAST_GLOBAL_INCREMENT_OP(SLOWOP,INCR,INCR2) \ + op2 = SLOWOP; \ + incr = INCR; \ + incr2 = INCR2; \ + goto do_global_incop + + { + jsval incr, incr2; + + BEGIN_CASE(JSOP_DECGVAR) + FAST_GLOBAL_INCREMENT_OP(JSOP_DECNAME, -2, -2); + BEGIN_CASE(JSOP_GVARDEC) + FAST_GLOBAL_INCREMENT_OP(JSOP_NAMEDEC, -2, 0); + BEGIN_CASE(JSOP_INCGVAR) + FAST_GLOBAL_INCREMENT_OP(JSOP_INCNAME, 2, 2); + BEGIN_CASE(JSOP_GVARINC) + FAST_GLOBAL_INCREMENT_OP(JSOP_NAMEINC, 2, 0); #undef FAST_GLOBAL_INCREMENT_OP - do_nonint_fast_global_incop: - { - const JSCodeSpec *cs = &js_CodeSpec[op]; - - vp = sp++; - SAVE_SP(fp); - NONINT_INCREMENT_OP_MIDDLE(); - OBJ_SET_SLOT(cx, obj, slot, rval); - STORE_OPND(-1, rtmp); - len = cs->length; + do_global_incop: + JS_ASSERT((js_CodeSpec[op].format & JOF_TMPSLOT_MASK) == + JOF_TMPSLOT2); + slot = GET_VARNO(pc); + JS_ASSERT(slot < fp->nvars); + METER_SLOT_OP(op, slot); + lval = fp->vars[slot]; + if (JSVAL_IS_NULL(lval)) { + op = op2; + DO_OP(); + } + slot = JSVAL_TO_INT(lval); + rval = OBJ_GET_SLOT(cx, fp->varobj, slot); + if (JS_LIKELY(CAN_DO_FAST_INC_DEC(rval))) { + PUSH_OPND(rval + incr2); + rval += incr; + } else { + PUSH_OPND(rval); + PUSH_OPND(JSVAL_NULL); /* Extra root */ + SAVE_SP_AND_PC(fp); + if (!js_DoIncDec(cx, &js_CodeSpec[op], &sp[-2], &sp[-1])) + goto error; + rval = sp[-1]; + --sp; + } + OBJ_SET_SLOT(cx, fp->varobj, slot, rval); + len = JSOP_INCGVAR_LENGTH; /* all gvar incops are same length */ + JS_ASSERT(len == js_CodeSpec[op].length); DO_NEXT_OP(len); } @@ -6616,37 +6665,6 @@ interrupt: *vp = FETCH_OPND(-1); END_CASE(JSOP_SETLOCAL) -/* NB: This macro doesn't use JS_BEGIN_MACRO/JS_END_MACRO around its body. */ -#define FAST_LOCAL_INCREMENT_OP(PRE,OPEQ,MINMAX) \ - slot = GET_UINT16(pc); \ - JS_ASSERT(slot < script->depth); \ - vp = fp->spbase + slot; \ - rval = *vp; \ - if (!JSVAL_IS_INT(rval) || rval == INT_TO_JSVAL(JSVAL_INT_##MINMAX)) \ - goto do_nonint_fast_incop; \ - PRE = rval; \ - rval OPEQ 2; \ - *vp = rval; \ - PUSH_OPND(PRE) - - BEGIN_CASE(JSOP_INCLOCAL) - FAST_LOCAL_INCREMENT_OP(rval, +=, MAX); - END_CASE(JSOP_INCLOCAL) - - BEGIN_CASE(JSOP_DECLOCAL) - FAST_LOCAL_INCREMENT_OP(rval, -=, MIN); - END_CASE(JSOP_DECLOCAL) - - BEGIN_CASE(JSOP_LOCALINC) - FAST_LOCAL_INCREMENT_OP(rtmp, +=, MAX); - END_CASE(JSOP_LOCALINC) - - BEGIN_CASE(JSOP_LOCALDEC) - FAST_LOCAL_INCREMENT_OP(rtmp, -=, MIN); - END_CASE(JSOP_LOCALDEC) - -#undef FAST_LOCAL_INCREMENT_OP - BEGIN_CASE(JSOP_ENDITER) /* * Decrease the stack pointer even when !ok, see comments in the diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index b4bcc4c8d906..80981c6aaebf 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -495,6 +495,15 @@ js_ImportProperty(JSContext *cx, JSObject *obj, jsid id); extern JSBool js_OnUnknownMethod(JSContext *cx, jsval *vp); +/* + * Find the results of incrementing or decrementing *vp. For pre-increments, + * both *vp and *vp2 will contain the result on return. For post-increments, + * vp will contain the original value converted to a number and vp2 will get + * the result. Both vp and vp2 must be roots. + */ +extern JSBool +js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, jsval *vp, jsval *vp2); + /* * JS_OPMETER helper functions. */ diff --git a/js/src/jsopcode.h b/js/src/jsopcode.h index b726d3c7fa0d..6072dc638748 100644 --- a/js/src/jsopcode.h +++ b/js/src/jsopcode.h @@ -121,8 +121,12 @@ typedef enum JSOpLength { parenthesized statement head */ #define JOF_INVOKE (1U<<22) /* JSOP_CALL, JSOP_NEW, JSOP_EVAL */ #define JOF_TMPSLOT (1U<<23) /* interpreter uses extra temporary slot - to root intermediate objects */ + to root intermediate objects besides + the slots opcode uses */ +#define JOF_TMPSLOT2 (2U<<23) /* interpreter uses extra 2 temporary slot + besides the slots opcode uses */ #define JOF_TMPSLOT_SHIFT 23 +#define JOF_TMPSLOT_MASK (JS_BITMASK(2) << JOF_TMPSLOT_SHIFT) /* Shorthands for type from format and type from opcode. */ #define JOF_TYPE(fmt) ((fmt) & JOF_TYPEMASK) diff --git a/js/src/jsopcode.tbl b/js/src/jsopcode.tbl index c568c793d64c..92bb92d8d539 100644 --- a/js/src/jsopcode.tbl +++ b/js/src/jsopcode.tbl @@ -144,18 +144,20 @@ OPDEF(JSOP_DELPROP, 37, "delprop", NULL, 3, 1, 1, 17, JOF_ATOM|J OPDEF(JSOP_DELELEM, 38, "delelem", NULL, 1, 2, 1, 17, JOF_BYTE |JOF_ELEM|JOF_DEL) OPDEF(JSOP_TYPEOF, 39, js_typeof_str,NULL, 1, 1, 1, 15, JOF_BYTE|JOF_DETECTING) OPDEF(JSOP_VOID, 40, js_void_str, NULL, 1, 1, 1, 15, JOF_BYTE) -OPDEF(JSOP_INCNAME, 41, "incname", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC) -OPDEF(JSOP_INCPROP, 42, "incprop", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_INC) -OPDEF(JSOP_INCELEM, 43, "incelem", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_INC) -OPDEF(JSOP_DECNAME, 44, "decname", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC) -OPDEF(JSOP_DECPROP, 45, "decprop", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_DEC) -OPDEF(JSOP_DECELEM, 46, "decelem", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_DEC) -OPDEF(JSOP_NAMEINC, 47, "nameinc", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_POST) -OPDEF(JSOP_PROPINC, 48, "propinc", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_INC|JOF_POST|JOF_TMPSLOT) -OPDEF(JSOP_ELEMINC, 49, "eleminc", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_INC|JOF_POST|JOF_TMPSLOT) -OPDEF(JSOP_NAMEDEC, 50, "namedec", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_POST) -OPDEF(JSOP_PROPDEC, 51, "propdec", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_DEC|JOF_POST|JOF_TMPSLOT) -OPDEF(JSOP_ELEMDEC, 52, "elemdec", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_DEC|JOF_POST|JOF_TMPSLOT) + +OPDEF(JSOP_INCNAME, 41, "incname", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_TMPSLOT2) +OPDEF(JSOP_INCPROP, 42, "incprop", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_INC|JOF_TMPSLOT2) +OPDEF(JSOP_INCELEM, 43, "incelem", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_INC|JOF_TMPSLOT2) +OPDEF(JSOP_DECNAME, 44, "decname", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_TMPSLOT2) +OPDEF(JSOP_DECPROP, 45, "decprop", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_DEC|JOF_TMPSLOT2) +OPDEF(JSOP_DECELEM, 46, "decelem", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_DEC|JOF_TMPSLOT2) +OPDEF(JSOP_NAMEINC, 47, "nameinc", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_PROPINC, 48, "propinc", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_INC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_ELEMINC, 49, "eleminc", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_INC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_NAMEDEC, 50, "namedec", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_PROPDEC, 51, "propdec", NULL, 3, 1, 1, 15, JOF_ATOM|JOF_PROP|JOF_DEC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_ELEMDEC, 52, "elemdec", NULL, 1, 2, 1, 15, JOF_BYTE |JOF_ELEM|JOF_DEC|JOF_POST|JOF_TMPSLOT2) + OPDEF(JSOP_GETPROP, 53, "getprop", NULL, 3, 1, 1, 18, JOF_ATOM|JOF_PROP) OPDEF(JSOP_SETPROP, 54, "setprop", NULL, 3, 2, 1, 3, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING) OPDEF(JSOP_GETELEM, 55, "getelem", NULL, 1, 2, 1, 18, JOF_BYTE |JOF_ELEM|JOF_LEFTASSOC) @@ -374,10 +376,10 @@ OPDEF(JSOP_RETRVAL, 153,"retrval", NULL, 1, 0, 0, 0, JOF_BYTE) /* Optimized global variable ops (we don't bother doing a JSOP_FORGVAR op). */ OPDEF(JSOP_GETGVAR, 154,"getgvar", NULL, 3, 0, 1, 19, JOF_ATOM|JOF_NAME) OPDEF(JSOP_SETGVAR, 155,"setgvar", NULL, 3, 1, 1, 3, JOF_ATOM|JOF_NAME|JOF_SET|JOF_DETECTING) -OPDEF(JSOP_INCGVAR, 156,"incgvar", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC) -OPDEF(JSOP_DECGVAR, 157,"decgvar", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC) -OPDEF(JSOP_GVARINC, 158,"gvarinc", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_POST) -OPDEF(JSOP_GVARDEC, 159,"gvardec", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_POST) +OPDEF(JSOP_INCGVAR, 156,"incgvar", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_TMPSLOT2) +OPDEF(JSOP_DECGVAR, 157,"decgvar", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_TMPSLOT2) +OPDEF(JSOP_GVARINC, 158,"gvarinc", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_INC|JOF_POST|JOF_TMPSLOT2) +OPDEF(JSOP_GVARDEC, 159,"gvardec", NULL, 3, 0, 1, 15, JOF_ATOM|JOF_NAME|JOF_DEC|JOF_POST|JOF_TMPSLOT2) /* Regular expression literal requiring special "fork on exec" handling. */ OPDEF(JSOP_REGEXP, 160,"regexp", NULL, 3, 0, 1, 19, JOF_REGEXP) From 57cb5b5b2fa8c6488b2e277f07271b1b9188a487 Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Wed, 5 Mar 2008 12:41:27 -0800 Subject: [PATCH 010/248] Don't leave an exception hanging on the JS context when we return ok. Bug 418133, r=jst, sr=brendan, a=beltzner. --- content/xbl/src/nsXBLProtoImplField.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content/xbl/src/nsXBLProtoImplField.cpp b/content/xbl/src/nsXBLProtoImplField.cpp index ce9e1d4d8fbf..2adf6063b832 100644 --- a/content/xbl/src/nsXBLProtoImplField.cpp +++ b/content/xbl/src/nsXBLProtoImplField.cpp @@ -119,6 +119,10 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext, nsCAutoString uriSpec; aBindingDocURI->GetSpec(uriSpec); + JSContext* cx = (JSContext*) aContext->GetNativeContext(); + NS_ASSERTION(!::JS_IsExceptionPending(cx), + "Shouldn't get here when an exception is pending!"); + // compile the literal string // XXX Could we produce a better principal here? Should be able // to, really! @@ -133,13 +137,19 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext, if (NS_FAILED(rv)) return rv; + // If EvaluateStringWithValue() threw an exception, just report it now. + // Failure to evaluate a field should stop neither the get of the field value + // nor an enumeration attempt. + if (::JS_IsExceptionPending(cx)) { + ::JS_ReportPendingException(cx); + } + if (undefined) { result = JSVAL_VOID; } // Define the evaluated result as a JS property nsDependentString name(mName); - JSContext* cx = (JSContext*) aContext->GetNativeContext(); JSAutoRequest ar(cx); if (!::JS_DefineUCProperty(cx, aBoundNode, reinterpret_cast(mName), From e31ee13acfdbdce17541b01880bb93bdb31eb39a Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Wed, 5 Mar 2008 12:44:27 -0800 Subject: [PATCH 011/248] Init the selected panel to the right value to prevent window size flicker. Bug 405390, r=enn, a=beltzner --- toolkit/content/widgets/tabbox.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/content/widgets/tabbox.xml b/toolkit/content/widgets/tabbox.xml index b823137bd536..4aa704f78587 100644 --- a/toolkit/content/widgets/tabbox.xml +++ b/toolkit/content/widgets/tabbox.xml @@ -552,7 +552,7 @@ extends="chrome://global/content/bindings/tabbox.xml#tab-base"> - null + this.childNodes.item(this.selectedIndex) From ed92494ec4b83b1d06792ff22a1e1af585e99afe Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Wed, 5 Mar 2008 12:46:21 -0800 Subject: [PATCH 012/248] Revert the change to RequiresBody. In particular, an needs to not require it, for now... Bug 418464, r+sr=mrbkap, a=jonas --- parser/htmlparser/src/CNavDTD.cpp | 51 +++++++++++++++++-- parser/htmlparser/tests/mochitest/Makefile.in | 1 + .../tests/mochitest/regressions.txt | 12 +++++ .../tests/mochitest/test_bug418464.html | 43 ++++++++++++++++ 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 parser/htmlparser/tests/mochitest/test_bug418464.html diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 9f4ef63f964f..eb173a798150 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -479,6 +479,52 @@ CNavDTD::GetType() return NS_IPARSER_FLAG_HTML; } +/** + * Text and some tags require a body when they're added, this function returns + * true for those tags. + * + * @param aToken The current token that we care about. + * @param aTokenizer A tokenizer that we can get the tags attributes off of. + * @return PR_TRUE if aToken does indeed force the body to open. + */ +static PRBool +DoesRequireBody(CToken* aToken, nsITokenizer* aTokenizer) +{ + PRBool result = PR_FALSE; + + if (aToken) { + eHTMLTags theTag = (eHTMLTags)aToken->GetTypeID(); + if (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody)) { + if (theTag == eHTMLTag_input) { + // IE & Nav4x opens up a body for type=text - Bug 66985 + // XXXbz but we don't want to open one for with no + // type attribute? That's pretty whack. + PRInt32 ac = aToken->GetAttributeCount(); + for(PRInt32 i = 0; i < ac; ++i) { + CAttributeToken* attr = static_cast + (aTokenizer->GetTokenAt(i)); + const nsSubstring& name = attr->GetKey(); + const nsAString& value = attr->GetValue(); + // XXXbz note that this stupid case-sensitive comparison is + // actually depended on by sites... + if ((name.EqualsLiteral("type") || + name.EqualsLiteral("TYPE")) + && + !(value.EqualsLiteral("hidden") || + value.EqualsLiteral("HIDDEN"))) { + result = PR_TRUE; + break; + } + } + } else { + result = PR_TRUE; + } + } + } + + return result; +} + static PRBool ValueIsHidden(const nsAString& aValue) { @@ -690,10 +736,7 @@ CNavDTD::HandleToken(CToken* aToken, nsIParser* aParser) // end tag. } - if (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody) && - (theTag != eHTMLTag_input || - theType != eToken_start || - !IsHiddenInput(aToken, mTokenizer))) { + if (DoesRequireBody(aToken, mTokenizer)) { CToken* theBodyToken = mTokenAllocator->CreateTokenOfType(eToken_start, eHTMLTag_body, diff --git a/parser/htmlparser/tests/mochitest/Makefile.in b/parser/htmlparser/tests/mochitest/Makefile.in index be30af566961..817a72efbbe6 100644 --- a/parser/htmlparser/tests/mochitest/Makefile.in +++ b/parser/htmlparser/tests/mochitest/Makefile.in @@ -54,6 +54,7 @@ _TEST_FILES = parser_datreader.js \ test_bug339350.xhtml \ test_bug358797.html \ test_bug396568.html \ + test_bug418464.html \ test_compatmode.html \ regressions.txt \ $(NULL) diff --git a/parser/htmlparser/tests/mochitest/regressions.txt b/parser/htmlparser/tests/mochitest/regressions.txt index bc1ff381a355..9b4265eabe7c 100644 --- a/parser/htmlparser/tests/mochitest/regressions.txt +++ b/parser/htmlparser/tests/mochitest/regressions.txt @@ -343,9 +343,21 @@ x { content:" | | +| +| rows="*" +| + +#data +
+#errors +#document +| +| +| | |
| +| type="text" #data
diff --git a/parser/htmlparser/tests/mochitest/test_bug418464.html b/parser/htmlparser/tests/mochitest/test_bug418464.html new file mode 100644 index 000000000000..d19d3ef88ee0 --- /dev/null +++ b/parser/htmlparser/tests/mochitest/test_bug418464.html @@ -0,0 +1,43 @@ +
+ +
+ +
+ +
+ + + + + + + Test for Bug 418464 + + + + + +Mozilla Bug 418464 +

+ +
+
+
+ + + From 4dc91524a43b05668c3e8d9cfb8bc8aa9815ba02 Mon Sep 17 00:00:00 2001 From: "timeless@mozdev.org" Date: Wed, 5 Mar 2008 13:10:01 -0800 Subject: [PATCH 013/248] Bug 282660 Crash [@ jsds_NotifyPendingDeadScripts] ds->script is null r=jst a=beltzner --- js/jsd/jsd_xpc.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index ad42210af664..8aa25d72d51a 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -476,14 +476,20 @@ jsds_NotifyPendingDeadScripts (JSContext *cx) nsCOMPtr hook = 0; gJsds->GetScriptHook (getter_AddRefs(hook)); - DeadScript *ds; #ifdef CAUTIOUS_SCRIPTHOOK JSRuntime *rt = JS_GetRuntime(cx); #endif gJsds->Pause(nsnull); - while (gDeadScripts) { - ds = gDeadScripts; - + DeadScript *deadScripts = gDeadScripts; + gDeadScripts = nsnull; + while (deadScripts) { + DeadScript *ds = deadScripts; + /* get next deleted script */ + deadScripts = reinterpret_cast + (PR_NEXT_LINK(&ds->links)); + if (deadScripts == ds) + deadScripts = nsnull; + if (hook) { /* tell the user this script has been destroyed */ @@ -495,16 +501,10 @@ jsds_NotifyPendingDeadScripts (JSContext *cx) JS_KEEP_ATOMS(rt); #endif } - /* get next deleted script */ - gDeadScripts = reinterpret_cast - (PR_NEXT_LINK(&ds->links)); - if (gDeadScripts == ds) { - /* last script in the list */ - gDeadScripts = nsnull; - } - - /* take ourselves out of the circular list */ + + /* take it out of the circular list */ PR_REMOVE_LINK(&ds->links); + /* addref came from the FromPtr call in jsds_ScriptHookProc */ NS_RELEASE(ds->script); /* free the struct! */ @@ -517,13 +517,17 @@ jsds_NotifyPendingDeadScripts (JSContext *cx) JS_STATIC_DLL_CALLBACK (JSBool) jsds_GCCallbackProc (JSContext *cx, JSGCStatus status) { - gGCStatus = status; #ifdef DEBUG_verbose printf ("new gc status is %i\n", status); #endif - if (status == JSGC_END && gDeadScripts) - jsds_NotifyPendingDeadScripts (cx); - + if (status == JSGC_END) { + /* just to guard against reentering. */ + gGCStatus = JSGC_BEGIN; + while (gDeadScripts) + jsds_NotifyPendingDeadScripts (cx); + } + + gGCStatus = status; if (gLastGCProc) return gLastGCProc (cx, status); From 636dd26f2eaa1f47ec6557aa1faf06783f361059 Mon Sep 17 00:00:00 2001 From: "enndeakin@sympatico.ca" Date: Wed, 5 Mar 2008 13:18:14 -0800 Subject: [PATCH 014/248] Bug 403217 - cannot drag text containing certain characters, r+sr=jst --- content/base/src/nsContentAreaDragDrop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/base/src/nsContentAreaDragDrop.cpp b/content/base/src/nsContentAreaDragDrop.cpp index 7722b6c047cc..feba79b000fd 100644 --- a/content/base/src/nsContentAreaDragDrop.cpp +++ b/content/base/src/nsContentAreaDragDrop.cpp @@ -1714,7 +1714,7 @@ nsTransferableFactory::SerializeNodeOrSelection(nsIDOMWindow* inWindow, NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE); PRUint32 flags = nsIDocumentEncoder::OutputAbsoluteLinks | - nsIDocumentEncoder::OutputEncodeW3CEntities; + nsIDocumentEncoder::OutputEncodeHTMLEntities; nsCOMPtr range; nsCOMPtr selection; if (inNode) { From d2084e7a6802594acd691ecebeab969a0c9f5551 Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Wed, 5 Mar 2008 13:30:28 -0800 Subject: [PATCH 015/248] Bug 410637: Mac UB XULRunner SDK packages have empty bin directory. p=matthew@allpeers.com, r=bsmedberg, a=beltzner --- toolkit/mozapps/installer/packager.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index cacd8beec4f9..84cba980a3f8 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -340,7 +340,11 @@ ifeq ($(MOZ_PKG_FORMAT),DMG) # If UNIVERSAL_BINARY, the package will be made from an already-prepared # STAGEPATH ifndef UNIVERSAL_BINARY +ifndef STAGE_SDK @cd $(DIST) && rsync -auv --copy-unsafe-links $(_APPNAME) $(MOZ_PKG_APPNAME) +else + @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_APPNAME); tar -xf -) +endif endif else @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_APPNAME); tar -xf -) @@ -434,11 +438,12 @@ ifdef INSTALL_SDK # Here comes the hard part ln -s $(idldir)/unstable $(DESTDIR)$(sdkdir)/idl endif # INSTALL_SDK -make-sdk:: stage-package +make-sdk: + $(MAKE) stage-package STAGE_SDK=1 MOZ_PKG_APPNAME=sdk-stage @echo "Packaging SDK..." $(RM) -rf $(DIST)/$(MOZ_APP_NAME)-sdk $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/bin - (cd $(DIST)/$(MOZ_PKG_APPNAME) && tar $(TAR_CREATE_FLAGS) - .) | \ + (cd $(DIST)/sdk-stage && tar $(TAR_CREATE_FLAGS) - .) | \ (cd $(DIST)/$(MOZ_APP_NAME)-sdk/bin && tar -xf -) $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/sdk (cd $(DIST)/sdk && tar $(TAR_CREATE_FLAGS) - .) | \ From 110a35e15bcc30fee160c6fc7748c5a8b16f06f2 Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Wed, 5 Mar 2008 13:32:27 -0800 Subject: [PATCH 016/248] Fire dynamic overlay load observers in more cases b=419452 r+sr=jst a=beltzner --- content/xul/document/src/nsXULDocument.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index f2a29c6e04c2..5f4f76421baf 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -2762,6 +2762,7 @@ nsXULDocument::ResumeWalk() // ) can be properly re-loaded if the // cached copy of the document becomes stale. nsresult rv; + nsCOMPtr overlayURI = mCurrentPrototype->GetURI(); while (1) { // Begin (or resume) walking the current prototype. @@ -2950,8 +2951,6 @@ nsXULDocument::ResumeWalk() const PRUnichar* params[] = { piProto->mTarget.get() }; - nsCOMPtr overlayURI = mCurrentPrototype->GetURI(); - nsContentUtils::ReportToConsole( nsContentUtils::eXUL_PROPERTIES, "PINotInProlog", @@ -3006,8 +3005,21 @@ nsXULDocument::ResumeWalk() continue; if (NS_FAILED(rv)) return rv; + if (mOverlayLoadObservers.IsInitialized()) { + nsIObserver *obs = mOverlayLoadObservers.GetWeak(overlayURI); + if (obs) { + // This overlay has an unloaded overlay, so it will never + // notify. The best we can do is to notify for the unloaded + // overlay instead, assuming nobody is already notifiable + // for it. Note that this will confuse the observer. + if (!mOverlayLoadObservers.GetWeak(uri)) + mOverlayLoadObservers.Put(uri, obs); + mOverlayLoadObservers.Remove(overlayURI); + } + } if (shouldReturn) return NS_OK; + overlayURI.swap(uri); } // If we get here, there is nothing left for us to walk. The content From f20e0ba61e4ac6751e2e13c3ef494d1d62be9477 Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Wed, 5 Mar 2008 13:35:38 -0800 Subject: [PATCH 017/248] clears its mIconURL inappropriately b=418213 r=Mano a=beltzner --- toolkit/content/widgets/browser.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 7ff8434bf838..b32b9a5355d0 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -181,7 +181,6 @@ catch (e) { } } - this.mIconURL = null; try { this.userTypedClear++; this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, aPostData, null); From dfd26f92ec79bacfe4726ee77329a0a8f8e8e387 Mon Sep 17 00:00:00 2001 From: "blassey@mozilla.com" Date: Wed, 5 Mar 2008 13:39:29 -0800 Subject: [PATCH 018/248] switching windows narrow char system calls to wide char b=418703 r=bsmedberg a=beltzner --- accessible/src/msaa/nsAccessNodeWrap.cpp | 2 +- accessible/src/msaa/nsAccessibleWrap.cpp | 2 +- browser/app/nsBrowserApp.cpp | 8 +- .../migration/src/nsIEProfileMigrator.cpp | 13 +- .../shell/src/nsWindowsShellService.cpp | 8 +- db/mork/src/morkFile.cpp | 10 - .../activex/src/plugin/LegacyPlugin.cpp | 3 +- .../activex/src/plugin/XPCDocument.cpp | 2 +- .../browser/activex/src/plugin/XPConnect.cpp | 2 +- extensions/auth/nsAuthSSPI.cpp | 34 ++- gfx/src/thebes/nsSystemFontsWin.cpp | 10 +- gfx/src/thebes/nsSystemFontsWin.h | 3 +- gfx/src/windows/nsDeviceContextWin.cpp | 2 +- gfx/src/windows/nsDeviceContextWin.h | 3 +- gfx/src/windows/nsFontMetricsWin.cpp | 31 --- gfx/thebes/src/gfxWindowsFonts.cpp | 4 +- gfx/thebes/src/gfxWindowsSurface.cpp | 34 +-- intl/uconv/src/nsWinCharset.cpp | 6 +- ipc/ipcd/client/src/ipcConnectionWin.cpp | 2 +- .../decoders/icon/win/nsIconChannel.cpp | 34 +-- .../libpr0n/decoders/icon/win/nsIconChannel.h | 2 +- modules/oji/src/scd.cpp | 2 +- .../base/src/nsPluginDirServiceProvider.cpp | 229 +++++++++--------- modules/plugin/base/src/nsPluginHostImpl.cpp | 12 +- .../base/src/nsPluginNativeWindowWin.cpp | 10 +- modules/plugin/base/src/nsPluginsDirWin.cpp | 67 +++-- .../samples/default/windows/dialogs.cpp | 45 ++-- .../samples/default/windows/npshell.cpp | 14 +- .../plugin/samples/default/windows/plugin.cpp | 105 ++++---- .../plugin/samples/default/windows/plugin.h | 6 +- .../plugin/samples/default/windows/utils.cpp | 65 ++--- .../plugin/samples/default/windows/utils.h | 2 +- .../sdk/samples/basic/windows/plugin.cpp | 4 +- .../sdk/samples/scriptable/windows/plugin.cpp | 4 +- rdf/datasource/src/nsFileSystemDataSource.cpp | 7 +- .../components/startup/src/nsUserInfoWin.cpp | 9 +- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 14 +- .../exthandler/win/nsOSHelperAppService.cpp | 4 +- widget/src/windows/nsAppShell.cpp | 14 +- widget/src/windows/nsBidiKeyboard.cpp | 31 +-- widget/src/windows/nsBidiKeyboard.h | 6 +- widget/src/windows/nsClipboard.cpp | 8 +- widget/src/windows/nsDataObj.h | 8 +- widget/src/windows/nsFilePicker.cpp | 8 +- widget/src/windows/nsLookAndFeel.cpp | 8 +- widget/src/windows/nsNativeThemeWin.cpp | 4 +- widget/src/windows/nsSound.cpp | 10 +- widget/src/windows/nsToolkit.cpp | 6 +- widget/src/windows/nsWindow.cpp | 34 +-- widget/src/windows/nsWindow.h | 7 + xpcom/base/nsDebugImpl.cpp | 27 ++- xpcom/base/nsStackWalk.cpp | 4 +- xpcom/io/SpecialSystemDirectory.cpp | 2 +- xpcom/io/nsLocalFileWin.cpp | 9 +- xpcom/threads/nsProcessCommon.cpp | 39 +-- xpcom/windbgdlg/Makefile.in | 2 + xpcom/windbgdlg/windbgdlg.cpp | 20 +- xpfe/bootstrap/showOSAlert.cpp | 14 +- 58 files changed, 525 insertions(+), 550 deletions(-) diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index 575a26485b85..96ebfdb0696b 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -576,7 +576,7 @@ void nsAccessNodeWrap::InitAccessibility() } if (!gmUserLib) { - gmUserLib =::LoadLibrary("USER32.DLL"); + gmUserLib =::LoadLibraryW(L"USER32.DLL"); } if (gmUserLib) { diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index ee3adfbb40d2..8e45c5feed43 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -156,7 +156,7 @@ STDMETHODIMP nsAccessibleWrap::AccessibleObjectFromWindow(HWND hwnd, { // open the dll dynamically if (!gmAccLib) - gmAccLib =::LoadLibrary("OLEACC.DLL"); + gmAccLib =::LoadLibraryW(L"OLEACC.DLL"); if (gmAccLib) { if (!gmAccessibleObjectFromWindow) diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index 0c867f701ffc..6e7c518b366c 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -64,11 +64,9 @@ static void Output(const char *fmt, ... ) va_start(ap, fmt); #if defined(XP_WIN) && !MOZ_WINCONSOLE - char msg[2048]; - - _vsnprintf(msg, sizeof(msg), fmt, ap); - - MessageBox(NULL, msg, "XULRunner", MB_OK | MB_ICONERROR); + PRUnichar msg[2048]; + _vsnwprintf(msg, sizeof(msg), NS_ConvertUTF8toUTF16(fmt).get(), ap); + MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR); #else vfprintf(stderr, fmt, ap); #endif diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp index 500d66caeaf9..9cb7ef0102ab 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -867,7 +867,7 @@ nsIEProfileMigrator::CopyPasswords(PRBool aReplace) nsresult rv; nsVoidArray signonsFound; - HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll"); + HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll"); if (!pstoreDLL) { // XXXben TODO // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read @@ -1177,7 +1177,7 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace) { HRESULT hr; - HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll"); + HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll"); if (!pstoreDLL) { // XXXben TODO // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read @@ -1410,20 +1410,19 @@ nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL) { HRESULT result; - IUniformResourceLocator* urlLink = nsnull; + IUniformResourceLocatorW* urlLink = nsnull; result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, - IID_IUniformResourceLocator, (void**)&urlLink); + IID_IUniformResourceLocatorW, (void**)&urlLink); if (SUCCEEDED(result) && urlLink) { IPersistFile* urlFile = nsnull; result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile); if (SUCCEEDED(result) && urlFile) { result = urlFile->Load(aFileName.get(), STGM_READ); if (SUCCEEDED(result) ) { - LPSTR lpTemp = nsnull; + LPWSTR lpTemp = nsnull; result = urlLink->GetURL(&lpTemp); if (SUCCEEDED(result) && lpTemp) { - *aOutURL = PL_strdup(lpTemp); - + *aOutURL = *aOutURL = (char*)ToNewUTF8String(nsDependentString(lpTemp)); // free the string that GetURL alloc'd ::CoTaskMemFree(lpTemp); } diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 65b58570062b..30c716af3b0b 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -396,8 +396,8 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs rv = appHelper->AppendNative(NS_LITERAL_CSTRING("helper.exe")); NS_ENSURE_SUCCESS(rv, rv); - nsCAutoString appHelperPath; - rv = appHelper->GetNativePath(appHelperPath); + nsAutoString appHelperPath; + rv = appHelper->GetPath(appHelperPath); NS_ENSURE_SUCCESS(rv, rv); if (aForAllUsers) { @@ -406,10 +406,10 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs appHelperPath.AppendLiteral(" /SetAsDefaultAppUser"); } - STARTUPINFO si = {sizeof(si), 0}; + STARTUPINFOW si = {sizeof(si), 0}; PROCESS_INFORMATION pi = {0}; - BOOL ok = CreateProcess(NULL, (LPSTR)appHelperPath.get(), NULL, NULL, + BOOL ok = CreateProcessW(NULL, (LPWSTR)appHelperPath.get(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); if (!ok) diff --git a/db/mork/src/morkFile.cpp b/db/mork/src/morkFile.cpp index 011056fa81ba..a3167afa0952 100644 --- a/db/mork/src/morkFile.cpp +++ b/db/mork/src/morkFile.cpp @@ -929,16 +929,6 @@ morkStdioFile::Steal(nsIMdbEnv* ev, nsIMdbFile* ioThief) void mork_fileflush(FILE * file) { fflush(file); -#ifndef WINCE - OSVERSIONINFOA vi = { sizeof(OSVERSIONINFOA) }; - if ((GetVersionExA(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)) - { - // Win9x/ME - int fd = fileno(file); - HANDLE fh = (HANDLE)_get_osfhandle(fd); - FlushFileBuffers(fh); - } -#endif } #endif /*MORK_WIN*/ diff --git a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp index 8ab3fe738dc5..f0044c2217c4 100644 --- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp +++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp @@ -303,8 +303,7 @@ ShowError(MozAxPluginErrors errorCode, const CLSID &clsid) LPOLESTR szClsid; StringFromCLSID(clsid, &szClsid); _sntprintf(szBuffer, kBufSize - 1, - _T("Could not create the control %s. Check that it has been installed on your computer " - "and that this page correctly references it."), OLE2T(szClsid)); + _T("Could not create the control %s. Check that it has been installed on your computer and that this page correctly references it."), OLE2T(szClsid)); CoTaskMemFree(szClsid); szMsg = szBuffer; } diff --git a/embedding/browser/activex/src/plugin/XPCDocument.cpp b/embedding/browser/activex/src/plugin/XPCDocument.cpp index 1c6a9235ae02..60f9c86a6b61 100644 --- a/embedding/browser/activex/src/plugin/XPCDocument.cpp +++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp @@ -1915,7 +1915,7 @@ END_COM_MAP() NS_SUCCEEDED(baseURI->GetSpec(spec))) { USES_CONVERSION; - if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker))) + if (FAILED(CreateURLMoniker(NULL, A2CW(spec.get()), &baseURLMoniker))) return E_UNEXPECTED; } } diff --git a/embedding/browser/activex/src/plugin/XPConnect.cpp b/embedding/browser/activex/src/plugin/XPConnect.cpp index c5dc232d4672..0620194ed363 100644 --- a/embedding/browser/activex/src/plugin/XPConnect.cpp +++ b/embedding/browser/activex/src/plugin/XPConnect.cpp @@ -372,7 +372,7 @@ nsScriptablePeer::ConvertVariants(VARIANT *aIn, nsIVariant **aOut) { // do_CreateInstance macro is broken so load the component manager by // hand and get it to create the component. - HMODULE hlib = ::LoadLibrary("xpcom.dll"); + HMODULE hlib = ::LoadLibraryW(L"xpcom.dll"); if (hlib) { nsIComponentManager *pManager = nsnull; // A frozen interface, even in 1.0.x diff --git a/extensions/auth/nsAuthSSPI.cpp b/extensions/auth/nsAuthSSPI.cpp index ca70729e7c5d..353d3b8219c5 100644 --- a/extensions/auth/nsAuthSSPI.cpp +++ b/extensions/auth/nsAuthSSPI.cpp @@ -52,6 +52,8 @@ #include "nsNetCID.h" #include "nsCOMPtr.h" +#include + #define SEC_SUCCESS(Status) ((Status) >= 0) #ifndef KERB_WRAP_NO_ENCRYPT @@ -103,25 +105,25 @@ static const char *MapErrorCode(int rc) //----------------------------------------------------------------------------- static HINSTANCE sspi_lib; -static PSecurityFunctionTable sspi; +static PSecurityFunctionTableW sspi; static nsresult InitSSPI() { - PSecurityFunctionTable (*initFun)(void); + PSecurityFunctionTableW (*initFun)(void); LOG((" InitSSPI\n")); - sspi_lib = LoadLibrary("secur32.dll"); + sspi_lib = LoadLibraryW(L"secur32.dll"); if (!sspi_lib) { - sspi_lib = LoadLibrary("security.dll"); + sspi_lib = LoadLibraryW(L"security.dll"); if (!sspi_lib) { LOG(("SSPI library not found")); return NS_ERROR_UNEXPECTED; } } - initFun = (PSecurityFunctionTable (*)(void)) + initFun = (PSecurityFunctionTableW (*)(void)) GetProcAddress(sspi_lib, "InitSecurityInterfaceA"); if (!initFun) { LOG(("InitSecurityInterfaceA not found")); @@ -242,11 +244,9 @@ nsAuthSSPI::Init(const char *serviceName, if (NS_FAILED(rv)) return rv; } + SEC_WCHAR *package; - SEC_CHAR *package; - - package = (SEC_CHAR *) pTypeName[(int)mPackage]; - + package = (SEC_WCHAR *) pTypeName[(int)mPackage]; if (mPackage != PACKAGE_TYPE_NTLM) { rv = MakeSN(serviceName, mServiceName); @@ -257,8 +257,8 @@ nsAuthSSPI::Init(const char *serviceName, SECURITY_STATUS rc; - PSecPkgInfo pinfo; - rc = (sspi->QuerySecurityPackageInfo)(package, &pinfo); + PSecPkgInfoW pinfo; + rc = (sspi->QuerySecurityPackageInfoW)(package, &pinfo); if (rc != SEC_E_OK) { LOG(("%s package not found\n", package)); return NS_ERROR_UNEXPECTED; @@ -268,7 +268,7 @@ nsAuthSSPI::Init(const char *serviceName, TimeStamp useBefore; - rc = (sspi->AcquireCredentialsHandle)(NULL, + rc = (sspi->AcquireCredentialsHandleW)(NULL, package, SECPKG_CRED_OUTBOUND, NULL, @@ -336,15 +336,13 @@ nsAuthSSPI::GetNextToken(const void *inToken, if (!ob.pvBuffer) return NS_ERROR_OUT_OF_MEMORY; memset(ob.pvBuffer, 0, ob.cbBuffer); - - SEC_CHAR *sn; - + SEC_WCHAR *sn; if (mPackage == PACKAGE_TYPE_NTLM) sn = NULL; else - sn = (SEC_CHAR *) mServiceName.get(); + sn = (SEC_WCHAR *) mServiceName.get(); - rc = (sspi->InitializeSecurityContext)(&mCred, + rc = (sspi->InitializeSecurityContextW)(&mCred, ctxIn, sn, ctxReq, @@ -461,7 +459,7 @@ nsAuthSSPI::Wrap(const void *inToken, secBuffers bufs; SecPkgContext_Sizes sizes; - rc = (sspi->QueryContextAttributes)( + rc = (sspi->QueryContextAttributesW)( &mCtxt, SECPKG_ATTR_SIZES, &sizes); diff --git a/gfx/src/thebes/nsSystemFontsWin.cpp b/gfx/src/thebes/nsSystemFontsWin.cpp index f53f06ae1028..f84f184ca427 100644 --- a/gfx/src/thebes/nsSystemFontsWin.cpp +++ b/gfx/src/thebes/nsSystemFontsWin.cpp @@ -44,18 +44,12 @@ nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsString *aFontName, - gfxFontStyle *aFontStyle, - PRBool aIsWide) const + nsString *aFontName, + gfxFontStyle *aFontStyle) const { PRUnichar name[LF_FACESIZE]; name[0] = 0; - if (aIsWide) memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2); - else { - MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName, - strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0])); - } *aFontName = name; // Do Style diff --git a/gfx/src/thebes/nsSystemFontsWin.h b/gfx/src/thebes/nsSystemFontsWin.h index a8a047e0ed42..2d98724b9bd4 100644 --- a/gfx/src/thebes/nsSystemFontsWin.h +++ b/gfx/src/thebes/nsSystemFontsWin.h @@ -51,8 +51,7 @@ public: gfxFontStyle *aFontStyle) const; private: nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsString *aFontName, gfxFontStyle *aFontStyle, - PRBool aIsWide = PR_FALSE) const; + nsString *aFontName, gfxFontStyle *aFontStyle) const; nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsString *aFontName, gfxFontStyle *aFontStyle) const; diff --git a/gfx/src/windows/nsDeviceContextWin.cpp b/gfx/src/windows/nsDeviceContextWin.cpp index 28e157363609..2afffa42daee 100644 --- a/gfx/src/windows/nsDeviceContextWin.cpp +++ b/gfx/src/windows/nsDeviceContextWin.cpp @@ -310,7 +310,7 @@ NS_IMETHODIMP nsDeviceContextWin :: SetCanonicalPixelScale(float aScale) nsresult nsDeviceContextWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsFont* aFont, PRBool aIsWide) const + nsFont* aFont) const { PRUnichar name[LF_FACESIZE]; name[0] = 0; diff --git a/gfx/src/windows/nsDeviceContextWin.h b/gfx/src/windows/nsDeviceContextWin.h index 6a02af01b934..291e6a6c25a9 100644 --- a/gfx/src/windows/nsDeviceContextWin.h +++ b/gfx/src/windows/nsDeviceContextWin.h @@ -101,8 +101,7 @@ protected: void ComputeFullAreaUsingScreen ( nsRect* outRect ) ; nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const; - nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont, - PRBool aIsWide = PR_FALSE) const; + nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont) const; PRBool mCachedClientRect; PRBool mCachedFullRect; diff --git a/gfx/src/windows/nsFontMetricsWin.cpp b/gfx/src/windows/nsFontMetricsWin.cpp index d6fbf78a31e4..a066ddc67f74 100644 --- a/gfx/src/windows/nsFontMetricsWin.cpp +++ b/gfx/src/windows/nsFontMetricsWin.cpp @@ -2121,40 +2121,9 @@ nsGlyphAgent::GetGlyphMetrics(HDC aDC, GLYPHMETRICS* aGlyphMetrics) { memset(aGlyphMetrics, 0, sizeof(GLYPHMETRICS)); // UMR: bug 46438 - if (eGlyphAgent_UNKNOWN == mState) { // first time we have been in this function - // see if this platform implements GetGlyphOutlineW() - DWORD len = GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat); - if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - // next time, we won't bother trying GetGlyphOutlineW() - mState = eGlyphAgent_ANSI; - } - else { - // all is well with GetGlyphOutlineW(), we will be using it from now on mState = eGlyphAgent_UNICODE; - return len; - } - } - - if (eGlyphAgent_UNICODE == mState) { return GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat); - } - // Otherwise, we are on a platform that doesn't implement GetGlyphOutlineW() - // (see Q241358: The GetGlyphOutlineW Function Fails on Windows 95 & 98 - // http://support.microsoft.com/support/kb/articles/Q241/3/58.ASP) - // we will use glyph indices as a work around. - if (0 == aGlyphIndex) { // caller doesn't know the glyph index, so find it - nsAutoChar16Buffer buf; - if (NS_SUCCEEDED(GetGlyphIndices(aDC, nsnull, &aChar, 1, buf))) - aGlyphIndex = *(buf.Elements()); - } - if (0 < aGlyphIndex) { - return GetGlyphOutlineA(aDC, aGlyphIndex, GGO_METRICS | GGO_GLYPH_INDEX, aGlyphMetrics, 0, nsnull, &mMat); - } - - // if we ever reach here, something went wrong in GetGlyphIndices() above - // because the current font in aDC wasn't a Unicode font - return GDI_ERROR; } // the global glyph agent that we will be using diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index c20abc171041..63e3837cfe2b 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -340,13 +340,13 @@ gfxWindowsFont::ComputeMetrics() // Cache the width of a single space. SIZE size; - GetTextExtentPoint32(dc, " ", 1, &size); + GetTextExtentPoint32W(dc, L" ", 1, &size); mMetrics->spaceWidth = ROUND(size.cx); mSpaceGlyph = 0; if (metrics.tmPitchAndFamily & TMPF_TRUETYPE) { WORD glyph; - DWORD ret = GetGlyphIndicesA(dc, " ", 1, &glyph, + DWORD ret = GetGlyphIndicesW(dc, L" ", 1, &glyph, GGI_MARK_NONEXISTING_GLYPHS); if (ret != GDI_ERROR && glyph != 0xFFFF) { mSpaceGlyph = glyph; diff --git a/gfx/thebes/src/gfxWindowsSurface.cpp b/gfx/thebes/src/gfxWindowsSurface.cpp index a2a7c8a636ae..83cf0ff9533f 100644 --- a/gfx/thebes/src/gfxWindowsSurface.cpp +++ b/gfx/thebes/src/gfxWindowsSurface.cpp @@ -168,27 +168,11 @@ gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat return raw; } -static char* -GetACPString(const nsAString& aStr) -{ - int acplen = aStr.Length() * 2 + 1; - char * acp = new char[acplen]; - if(acp) { - int outlen = ::WideCharToMultiByte(CP_ACP, 0, - PromiseFlatString(aStr).get(), - aStr.Length(), - acp, acplen, NULL, NULL); - if (outlen > 0) - acp[outlen] = '\0'; // null terminate - } - return acp; -} - nsresult gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName) { #define DOC_TITLE_LENGTH 30 - DOCINFO docinfo; + DOCINFOW docinfo; nsString titleStr; titleStr = aTitle; @@ -196,23 +180,21 @@ nsresult gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, titleStr.SetLength(DOC_TITLE_LENGTH-3); titleStr.AppendLiteral("..."); } - char *title = GetACPString(titleStr); - - char *docName = nsnull; + nsPromiseFlatString flatTitleStr(titleStr); + const PRUnichar *title = (const PRUnichar*)(flatTitleStr.get()); + const PRUnichar *docName = nsnull; + nsPromiseFlatString printToFileNameStr(aPrintToFileName); if (!aPrintToFileName.IsEmpty()) { - docName = ToNewCString(aPrintToFileName); + docName = (const PRUnichar*)(printToFileNameStr.get()); } - docinfo.cbSize = sizeof(docinfo); - docinfo.lpszDocName = title ? title : "Mozilla Document"; + docinfo.lpszDocName = title ? title : L"Mozilla Document"; docinfo.lpszOutput = docName; docinfo.lpszDatatype = NULL; docinfo.fwType = 0; - ::StartDoc(mDC, &docinfo); + ::StartDocW(mDC, &docinfo); - delete [] title; - if (docName != nsnull) nsMemory::Free(docName); return NS_OK; } diff --git a/intl/uconv/src/nsWinCharset.cpp b/intl/uconv/src/nsWinCharset.cpp index c3eae316a334..3fdb83dced4a 100644 --- a/intl/uconv/src/nsWinCharset.cpp +++ b/intl/uconv/src/nsWinCharset.cpp @@ -133,7 +133,7 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS { nsCOMPtr winLocale; LCID localeAsLCID; - char acp_name[6]; + PRUnichar acp_name[6]; // // convert locale name to a code page (through the LCID) @@ -147,11 +147,11 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID); if (NS_FAILED(rv)) { return rv; } - if (GetLocaleInfo(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { + if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { return NS_ERROR_FAILURE; } nsAutoString acp_key(NS_LITERAL_STRING("acp.")); - acp_key.AppendWithConversion(acp_name); + acp_key.Append(acp_name); return MapToCharset(acp_key, oResult); } diff --git a/ipc/ipcd/client/src/ipcConnectionWin.cpp b/ipc/ipcd/client/src/ipcConnectionWin.cpp index 9a99c1956b5c..b6ac516ff176 100644 --- a/ipc/ipcd/client/src/ipcConnectionWin.cpp +++ b/ipc/ipcd/client/src/ipcConnectionWin.cpp @@ -112,7 +112,7 @@ ipcThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) cd.dwData = GetCurrentProcessId(); cd.cbData = (DWORD) msg->MsgLen(); cd.lpData = (PVOID) msg->MsgBuf(); - SendMessageA(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd); + SendMessage(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd); LOG((" done.\n")); delete msg; } diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index e0e896a57d17..5e1bc11c6eab 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -63,6 +63,7 @@ #include #include #include +#include struct ICONFILEHEADER { PRUint16 ifhReserved; @@ -189,7 +190,7 @@ nsIconChannel::Open(nsIInputStream **_retval) return MakeInputStream(_retval, PR_FALSE); } -nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension) +nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension) { nsresult rv = NS_OK; nsCOMPtr iconURI (do_QueryInterface(mUrl, &rv)); @@ -236,29 +237,28 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports return rv; } -static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFO* aSFI, UINT aInfoFlags) +static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI, UINT aInfoFlags) { DWORD shellResult = 0; if (!aFile) return shellResult; - char fileNativePath[MAX_PATH]; - nsCAutoString fileNativePathStr; - aFile->GetNativePath(fileNativePathStr); - ::GetShortPathName(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath)); + PRUnichar fileNativePath[MAX_PATH]; + nsAutoString fileNativePathStr; + aFile->GetPath(fileNativePathStr); + ::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath)); LPITEMIDLIST idList; HRESULT hr = ::SHGetSpecialFolderLocation(NULL, aFolder, &idList); if (SUCCEEDED(hr)) { - char specialNativePath[MAX_PATH]; - ::SHGetPathFromIDList(idList, specialNativePath); - ::GetShortPathName(specialNativePath, specialNativePath, sizeof(specialNativePath)); - - if (nsDependentCString(fileNativePath).EqualsIgnoreCase(specialNativePath)) { + PRUnichar specialNativePath[MAX_PATH]; + ::SHGetPathFromIDListW(idList, specialNativePath); + ::GetShortPathNameW(specialNativePath, specialNativePath, sizeof(specialNativePath)); + if (!wcsicmp(fileNativePath,specialNativePath)) { aInfoFlags |= (SHGFI_PIDL | SHGFI_SYSICONINDEX); - shellResult = ::SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)idList, 0, aSFI, - sizeof(SHFILEINFO), aInfoFlags); + shellResult = ::SHGetFileInfoW((LPCWSTR)(LPCITEMIDLIST)idList, 0, aSFI, + sizeof(SHFILEINFOW), aInfoFlags); IMalloc* pMalloc; hr = ::SHGetMalloc(&pMalloc); if (SUCCEEDED(hr)) { @@ -273,14 +273,14 @@ static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFO* aSFI, nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking) { nsXPIDLCString contentType; - nsCAutoString filePath; + nsCString filePath; nsCOMPtr localFile; // file we want an icon for PRUint32 desiredImageSize; nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, contentType, filePath); NS_ENSURE_SUCCESS(rv, rv); // if the file exists, we are going to use it's real attributes...otherwise we only want to use it for it's extension... - SHFILEINFO sfi; + SHFILEINFOW sfi; UINT infoFlags = SHGFI_ICON; PRBool fileExists = PR_FALSE; @@ -342,7 +342,9 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc // Not a special folder, or something else failed above. if (!shellResult) - shellResult = ::SHGetFileInfo(filePath.get(), FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags); + shellResult = ::SHGetFileInfoW( + NS_ConvertUTF8toUTF16(filePath).get(), + FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags); if (shellResult && sfi.hIcon) { diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.h b/modules/libpr0n/decoders/icon/win/nsIconChannel.h index bf59799ae8b7..a69ea61c0d87 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.h +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.h @@ -77,7 +77,7 @@ protected: nsCOMPtr mPump; nsCOMPtr mListener; - nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension); + nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension); nsresult MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking); }; diff --git a/modules/oji/src/scd.cpp b/modules/oji/src/scd.cpp index 34e9925318f7..6b49e7058fae 100644 --- a/modules/oji/src/scd.cpp +++ b/modules/oji/src/scd.cpp @@ -100,7 +100,7 @@ nsSymantecDebugManager::SetDebugAgentPassword(PRInt32 pwd) // ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError())); /* continue so that we try to wake up the DebugManager */ } - sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger"); + sem = OpenSemaphoreW(SEMAPHORE_MODIFY_STATE, FALSE, L"Netscape-Symantec Debugger"); if (sem) { ReleaseSemaphore(sem, 1, NULL); CloseHandle(sem); diff --git a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp index db6e4c56bc0b..893100776321 100644 --- a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp +++ b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp @@ -66,14 +66,14 @@ ClearVersion(verBlock *ver) } static BOOL -FileExists(LPCSTR szFile) +FileExists(wchar_t* szFile) { - return GetFileAttributes(szFile) != 0xFFFFFFFF; + return GetFileAttributesW(szFile) != 0xFFFFFFFF; } // Get file version information from a file static BOOL -GetFileVersion(LPSTR szFile, verBlock *vbVersion) +GetFileVersion(wchar_t* szFile, verBlock *vbVersion) { UINT uLen; UINT dwLen; @@ -86,12 +86,12 @@ GetFileVersion(LPSTR szFile, verBlock *vbVersion) ClearVersion(vbVersion); if (FileExists(szFile)) { bRv = TRUE; - dwLen = GetFileVersionInfoSize(szFile, &dwHandle); + dwLen = GetFileVersionInfoSizeW(szFile, &dwHandle); lpData = (LPVOID)malloc(dwLen); uLen = 0; - if (lpData && GetFileVersionInfo(szFile, dwHandle, dwLen, lpData) != 0) { - if (VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0) { + if (lpData && GetFileVersionInfoW(szFile, dwHandle, dwLen, lpData) != 0) { + if (VerQueryValueW(lpData, L"\\", &lpBuffer, &uLen) != 0) { lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer; vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS); @@ -124,15 +124,15 @@ CopyVersion(verBlock *ver1, verBlock *ver2) static void TranslateVersionStr(const char* szVersion, verBlock *vbVersion) { - LPSTR szNum1 = NULL; - LPSTR szNum2 = NULL; - LPSTR szNum3 = NULL; - LPSTR szNum4 = NULL; - LPSTR szJavaBuild = NULL; + char* szNum1 = NULL; + char* szNum2 = NULL; + char* szNum3 = NULL; + char* szNum4 = NULL; + char* szJavaBuild = NULL; - char *strVer = nsnull; + char* strVer = nsnull; if (szVersion) { - strVer = PL_strdup(szVersion); + strVer = strdup(szVersion); } if (!strVer) { @@ -157,7 +157,7 @@ TranslateVersionStr(const char* szVersion, verBlock *vbVersion) vbVersion->wRelease = szNum3 ? atoi(szNum3) : 0; vbVersion->wBuild = szNum4 ? atoi(szNum4) : 0; - PL_strfree(strVer); + free(strVer); } // Compare two version struct, return zero if the same @@ -195,26 +195,28 @@ CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) // Indicate whether we should try to use the new NPRuntime-based Java // Plug-In if it's available static PRBool -TryToUseNPRuntimeJavaPlugIn(const char* javaVersion) +TryToUseNPRuntimeJavaPlugIn(const wchar_t* javaVersion) { HKEY javaKey = NULL; - char keyName[_MAX_PATH]; - keyName[0] = 0; - PL_strcat(keyName, "Software\\JavaSoft\\Java Plug-in\\"); - PL_strcat(keyName, javaVersion); + wchar_t keyName[_MAX_PATH]; + + wcsncpy(keyName, L"Software\\JavaSoft\\Java Plug-in\\", wcslen(L"Software\\JavaSoft\\Java Plug-in\\")); + wcscpy(keyName, javaVersion); + DWORD val; DWORD valSize = sizeof(DWORD); - if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, + if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &javaKey)) { return FALSE; } // Look for "UseNewJavaPlugin" - if (ERROR_SUCCESS != ::RegQueryValueEx(javaKey, "UseNewJavaPlugin", - NULL, NULL, - (LPBYTE) &val, - &valSize)) { + if (ERROR_SUCCESS != ::RegQueryValueExW(javaKey, + L"UseNewJavaPlugin", + NULL, NULL, + (LPBYTE) &val, + &valSize)) { val = 0; } @@ -262,7 +264,7 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, return rv; } - if (nsCRT::strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) { + if (strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) { // Check our prefs to see if scanning the 4.x folder has been // explictly overriden failure to get the pref is okay, we'll do // what we've been doing -- a filtered scan @@ -277,38 +279,38 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, HKEY keyloc; long result; DWORD type; - char szKey[_MAX_PATH] = "Software\\Netscape\\Netscape Navigator"; - char path[_MAX_PATH]; + wchar_t szKey[_MAX_PATH] = L"Software\\Netscape\\Netscape Navigator"; + wchar_t path[_MAX_PATH]; - result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); + result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { - char current_version[80]; + wchar_t current_version[80]; DWORD length = sizeof(current_version); - result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, + result = ::RegQueryValueExW(keyloc, L"CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length); ::RegCloseKey(keyloc); - PL_strcat(szKey, "\\"); - PL_strcat(szKey, current_version); - PL_strcat(szKey, "\\Main"); - result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); + wcscat(szKey, L"\\"); + wcscat(szKey, current_version); + wcscat(szKey, L"\\Main"); + result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { DWORD pathlen = sizeof(path); - result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, + result = ::RegQueryValueExW(keyloc, L"Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen); if (result == ERROR_SUCCESS) { - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, + getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } } - } else if (nsCRT::strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) { + } else if (strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) { nsXPIDLCString strVer; #ifdef OJI if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) @@ -328,24 +330,25 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); - char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Runtime Environment"; - char path[_MAX_PATH]; + wchar_t curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment"; + wchar_t path[_MAX_PATH]; + // Add + 15 to prevent buffer overrun when adding \bin (+ optionally // \new_plugin) #define JAVA_PATH_SIZE _MAX_PATH + 15 - char newestPath[JAVA_PATH_SIZE]; - const char mozPath[_MAX_PATH] = "Software\\mozilla.org\\Mozilla"; - char browserJavaVersion[_MAX_PATH]; + wchar_t newestPath[JAVA_PATH_SIZE]; + const wchar_t mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla"; + wchar_t browserJavaVersion[_MAX_PATH]; PRBool tryNPRuntimeJavaPlugIn = PR_FALSE; newestPath[0] = 0; - LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, + LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); if (ERROR_SUCCESS != result) return NS_ERROR_FAILURE; // Look for "BrowserJavaVersion" - if (ERROR_SUCCESS != ::RegQueryValueEx(baseloc, "BrowserJavaVersion", NULL, + if (ERROR_SUCCESS != ::RegQueryValueExW(baseloc, L"BrowserJavaVersion", NULL, NULL, (LPBYTE)&browserJavaVersion, &numChars)) browserJavaVersion[0] = 0; @@ -356,13 +359,13 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, path[0] = 0; numChars = _MAX_PATH; pathlen = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, + result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; // Skip major.minor as it always points to latest in its family numChars = 0; - for (char *p = curKey; *p; p++) { + for (wchar_t *p = curKey; *p; p++) { // can I do this with wchar_t xxx? if (*p == '.') { numChars++; } @@ -371,24 +374,24 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, continue; if (ERROR_SUCCESS == result) { - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, + if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) { verBlock curVer; - TranslateVersionStr(curKey, &curVer); + TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer); if (CompareVersion(curVer, minVer) >= 0) { - if (!strncmp(browserJavaVersion, curKey, _MAX_PATH)) { - PL_strcpy(newestPath, path); + if (!wcsncmp(browserJavaVersion, curKey, _MAX_PATH)) { + wcscpy(newestPath, path); tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey); ::RegCloseKey(keyloc); break; } if (CompareVersion(curVer, maxVer) >= 0) { - PL_strcpy(newestPath, path); + wcscpy(newestPath, path); CopyVersion(&maxVer, &curVer); tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey); } @@ -404,20 +407,20 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // If nothing is found, then don't add \bin dir and don't set // CurrentVersion for Mozilla if (newestPath[0] != 0) { - if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, mozPath, 0, + if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE|KEY_QUERY_VALUE, NULL, &entryloc, NULL)) { - if (ERROR_SUCCESS != ::RegQueryValueEx(entryloc, "CurrentVersion", 0, + if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0, NULL, NULL, NULL)) { - ::RegSetValueEx(entryloc, "CurrentVersion", 0, REG_SZ, + ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ, (const BYTE*)MOZILLA_VERSION, sizeof(MOZILLA_VERSION)); } ::RegCloseKey(entryloc); } - PL_strcat(newestPath,"\\bin"); + wcscat(newestPath,L"\\bin"); // See whether we should use the new NPRuntime-based Java Plug-In: // - If tryNPRuntimeJavaPlugIn is true, and @@ -427,13 +430,13 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // one any more. if (tryNPRuntimeJavaPlugIn) { // See whether the "new_plugin" directory exists - char tmpPath[JAVA_PATH_SIZE]; - PL_strcpy(tmpPath, newestPath); - PL_strcat(tmpPath, "\\new_plugin"); + wchar_t tmpPath[JAVA_PATH_SIZE]; + wcscpy(tmpPath, newestPath); + wcscat(tmpPath, L"\\new_plugin"); nsCOMPtr tmpFile; - if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(tmpPath), - PR_TRUE, - getter_AddRefs(tmpFile))) && + if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(tmpPath), + PR_TRUE, + getter_AddRefs(tmpFile))) && tmpFile) { PRBool exists = PR_FALSE; PRBool isDir = PR_FALSE; @@ -442,15 +445,15 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // Assume we're supposed to use this as the search // directory for the Java Plug-In instead of the normal // one - PL_strcpy(newestPath, tmpPath); + wcscpy(newestPath, tmpPath); } } } - rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } - } else if (nsCRT::strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { + } else if (strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) return NS_ERROR_FAILURE; @@ -463,33 +466,33 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD type; verBlock qtVer; ClearVersion(&qtVer); - char path[_MAX_PATH]; + wchar_t path[_MAX_PATH]; DWORD pathlen = sizeof(path); // First we need to check the version of Quicktime via checking // the EXE's version table - if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, - (LPBYTE)&path, &pathlen)) { - GetFileVersion((char*)path, &qtVer); + if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { + GetFileVersion(path, &qtVer); } ::RegCloseKey(keyloc); } if (CompareVersion(qtVer, minVer) < 0) return rv; - if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { DWORD pathlen = sizeof(path); - result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type, + result = ::RegQueryValueExW(keyloc, L"InstallDir", NULL, &type, (LPBYTE)&path, &pathlen); - PL_strcat(path, "\\Plugins"); + wcscat(path, L"\\Plugins"); if (result == ERROR_SUCCESS) - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, + getter_AddRefs(localFile)); ::RegCloseKey(keyloc); } - } else if (nsCRT::strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) { + } else if (strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) return NS_ERROR_FAILURE; @@ -501,33 +504,33 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD type; verBlock wmpVer; ClearVersion(&wmpVer); - char path[_MAX_PATH]; + wchar_t path[_MAX_PATH]; DWORD pathlen = sizeof(path); // First we need to check the version of WMP - if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, - (LPBYTE)&path, &pathlen)) { - GetFileVersion((char*)path, &wmpVer); + if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { + GetFileVersion(path, &wmpVer); } ::RegCloseKey(keyloc); } if (CompareVersion(wmpVer, minVer) < 0) return rv; - if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "software\\Microsoft\\MediaPlayer", 0, + if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"software\\Microsoft\\MediaPlayer", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory", + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Installation Directory", NULL, &type, (LPBYTE)&path, &pathlen)) { - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, + getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } - } else if (nsCRT::strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) { + } else if (strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) { return NS_ERROR_FAILURE; @@ -546,16 +549,16 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); - char curKey[_MAX_PATH] = "software\\Adobe\\Acrobat Reader"; - char path[_MAX_PATH]; + wchar_t curKey[_MAX_PATH] = L"software\\Adobe\\Acrobat Reader"; + wchar_t path[_MAX_PATH]; // Add + 8 to prevent buffer overrun when adding \browser - char newestPath[_MAX_PATH + 8]; + wchar_t newestPath[_MAX_PATH + 8]; newestPath[0] = 0; - if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, + if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { - PL_strcpy(curKey, "software\\Adobe\\Adobe Acrobat"); - if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, + wcscpy(curKey, L"software\\Adobe\\Adobe Acrobat"); + if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { return NS_ERROR_FAILURE; } @@ -568,22 +571,22 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, path[0] = 0; numChars = _MAX_PATH; pathlen = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, + result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; if (ERROR_SUCCESS == result) { verBlock curVer; - TranslateVersionStr(curKey, &curVer); - PL_strcat(curKey, "\\InstallPath"); - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, + TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer); + wcscat(curKey, L"\\InstallPath"); + if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { if (CompareVersion(curVer, maxVer) >= 0 && CompareVersion(curVer, minVer) >= 0) { - PL_strcpy(newestPath, path); + wcscpy(newestPath, path); CopyVersion(&maxVer, &curVer); } } @@ -596,9 +599,9 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, ::RegCloseKey(baseloc); if (newestPath[0] != 0) { - PL_strcat(newestPath,"\\browser"); - rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, - getter_AddRefs(localFile)); + wcscat(newestPath, L"\\browser"); + rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } } @@ -626,32 +629,32 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator nsresult nsPluginDirServiceProvider::GetPLIDDirectoriesWithHKEY(HKEY aKey, nsCOMArray &aDirs) { - char subkey[_MAX_PATH] = "Software\\MozillaPlugins"; + wchar_t subkey[_MAX_PATH] = L"Software\\MozillaPlugins"; HKEY baseloc; - if (ERROR_SUCCESS != ::RegOpenKeyEx(aKey, subkey, 0, KEY_READ, &baseloc)) + if (ERROR_SUCCESS != ::RegOpenKeyExW(aKey, subkey, 0, KEY_READ, &baseloc)) return NS_ERROR_FAILURE; DWORD index = 0; DWORD subkeylen = _MAX_PATH; FILETIME modTime; - while (ERROR_SUCCESS == ::RegEnumKeyEx(baseloc, index++, subkey, &subkeylen, + while (ERROR_SUCCESS == ::RegEnumKeyExW(baseloc, index++, subkey, &subkeylen, NULL, NULL, NULL, &modTime)) { subkeylen = _MAX_PATH; HKEY keyloc; - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, subkey, 0, KEY_QUERY_VALUE, + if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, subkey, 0, KEY_QUERY_VALUE, &keyloc)) { DWORD type; - char path[_MAX_PATH]; + wchar_t path[_MAX_PATH]; DWORD pathlen = sizeof(path); - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Path", NULL, &type, + if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Path", NULL, &type, (LPBYTE)&path, &pathlen)) { nsCOMPtr localFile; - if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(path), - PR_TRUE, - getter_AddRefs(localFile))) && + if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(path), + PR_TRUE, + getter_AddRefs(localFile))) && localFile) { // Some vendors use a path directly to the DLL so chop off // the filename diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 68b03a9ccf81..370f40ff0d00 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -4017,18 +4017,18 @@ nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType, #ifdef XP_WIN static BOOL firstJavaPlugin = FALSE; BOOL restoreOrigDir = FALSE; - char origDir[_MAX_PATH]; + PRUnichar origDir[_MAX_PATH]; if (isJavaPlugin && !firstJavaPlugin) { - DWORD dw = ::GetCurrentDirectory(_MAX_PATH, origDir); + DWORD dw = ::GetCurrentDirectoryW(_MAX_PATH, origDir); NS_ASSERTION(dw <= _MAX_PATH, "Falied to obtain the current directory, which may leads to incorrect class laoding"); nsCOMPtr binDirectory; result = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(binDirectory)); if (NS_SUCCEEDED(result)) { - nsCAutoString path; - binDirectory->GetNativePath(path); - restoreOrigDir = ::SetCurrentDirectory(path.get()); + nsAutoString path; + binDirectory->GetPath(path); + restoreOrigDir = ::SetCurrentDirectoryW(path.get()); } } #endif @@ -4036,7 +4036,7 @@ nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType, #ifdef XP_WIN if (!firstJavaPlugin && restoreOrigDir) { - BOOL bCheck = ::SetCurrentDirectory(origDir); + BOOL bCheck = ::SetCurrentDirectoryW(origDir); NS_ASSERTION(bCheck, " Error restoring driectoy"); firstJavaPlugin = TRUE; } diff --git a/modules/plugin/base/src/nsPluginNativeWindowWin.cpp b/modules/plugin/base/src/nsPluginNativeWindowWin.cpp index 27b74b160d01..fc702c791081 100644 --- a/modules/plugin/base/src/nsPluginNativeWindowWin.cpp +++ b/modules/plugin/base/src/nsPluginNativeWindowWin.cpp @@ -62,7 +62,7 @@ static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID); // needed for NS_TRY_SAFE_CALL -#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION "MozillaPluginWindowPropertyAssociation" +#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION L"MozillaPluginWindowPropertyAssociation" typedef nsTWeakRef PluginWindowWeakRef; @@ -203,7 +203,7 @@ NS_IMETHODIMP nsDelayedPopupsEnabledEvent::Run() */ static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); if (!win) return TRUE; @@ -526,10 +526,10 @@ nsresult nsPluginNativeWindowWin::SubclassAndAssociateWindow() if (!mPluginWinProc) return NS_ERROR_FAILURE; - nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); NS_ASSERTION(!win || (win == this), "plugin window already has property and this is not us"); - if (!::SetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this)) + if (!::SetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this)) return NS_ERROR_FAILURE; return NS_OK; @@ -543,7 +543,7 @@ nsresult nsPluginNativeWindowWin::UndoSubclassAndAssociateWindow() // remove window property HWND hWnd = (HWND)window; if (IsWindow(hWnd)) - ::RemoveProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + ::RemovePropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); // restore the original win proc // but only do this if this were us last time diff --git a/modules/plugin/base/src/nsPluginsDirWin.cpp b/modules/plugin/base/src/nsPluginsDirWin.cpp index 35d07f9eaa00..97b31f2d2de4 100644 --- a/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -58,25 +58,18 @@ /* Local helper functions */ -static char* GetKeyValue(char* verbuf, char* key) +static char* GetKeyValue(wchar_t* verbuf, wchar_t* key) { - char *buf = NULL; + wchar_t *buf = NULL; UINT blen; - ::VerQueryValue(verbuf, - TEXT(key), + ::VerQueryValueW(verbuf, + key, (void **)&buf, &blen); if(buf != NULL) { -#ifdef WINCE - // On windows CE, the verbuf is wide and the shunt - // layer can't do much about it. So, here we - // convert the wide string. - return PL_strdup(NS_ConvertUTF16toUTF8((PRUnichar*)buf).get()); -#else - return PL_strdup(buf); -#endif + return strdup(NS_ConvertUTF16toUTF8(buf).get()); } return nsnull; @@ -216,35 +209,35 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) if (!mPlugin) return NS_ERROR_NULL_POINTER; - nsCAutoString temp; - mPlugin->GetNativePath(temp); + nsAutoString temp; + mPlugin->GetPath(temp); - char* index; - char* pluginFolderPath = PL_strdup(temp.get()); + PRUnichar* index; + PRUnichar* pluginFolderPath = _wcsdup(temp.get()); - index = PL_strrchr(pluginFolderPath, '\\'); + index = wcsrchr(pluginFolderPath, '\\'); *index = 0; BOOL restoreOrigDir = FALSE; - char aOrigDir[MAX_PATH + 1]; - DWORD dwCheck = ::GetCurrentDirectory(sizeof(aOrigDir), aOrigDir); + PRUnichar aOrigDir[MAX_PATH + 1]; + DWORD dwCheck = ::GetCurrentDirectoryW(sizeof(aOrigDir), aOrigDir); NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin"); if (dwCheck <= MAX_PATH + 1) { - restoreOrigDir = ::SetCurrentDirectory(pluginFolderPath); + restoreOrigDir = ::SetCurrentDirectoryW(pluginFolderPath); NS_ASSERTION(restoreOrigDir, "Error in Loading plugin"); } - outLibrary = PR_LoadLibrary(temp.get()); + outLibrary = PR_LoadLibrary(NS_ConvertUTF16toUTF8(temp).get()); if (restoreOrigDir) { - BOOL bCheck = ::SetCurrentDirectory(aOrigDir); + BOOL bCheck = ::SetCurrentDirectoryW(aOrigDir); NS_ASSERTION(bCheck, "Error in Loading plugin"); } - PL_strfree(pluginFolderPath); + free(pluginFolderPath); return NS_OK; } @@ -256,37 +249,39 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) { nsresult res = NS_OK; DWORD zerome, versionsize; - char* verbuf = nsnull; + PRUnichar* verbuf = nsnull; - const char* path; + const PRUnichar* path; if (!mPlugin) return NS_ERROR_NULL_POINTER; - nsCAutoString temp; - mPlugin->GetNativePath(temp); + nsAutoString temp; + mPlugin->GetPath(temp); path = temp.get(); - versionsize = ::GetFileVersionInfoSize((char*)path, &zerome); + versionsize = ::GetFileVersionInfoSizeW(path, &zerome); if (versionsize > 0) - verbuf = (char *)PR_Malloc(versionsize); + verbuf = (wchar_t *)PR_Malloc(versionsize); if(!verbuf) return NS_ERROR_OUT_OF_MEMORY; - if(::GetFileVersionInfo((char*)path, NULL, versionsize, verbuf)) + if(::GetFileVersionInfoW(path, NULL, versionsize, verbuf)) { - info.fName = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\ProductName"); - info.fDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileDescription"); + info.fName = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\ProductName"); + info.fDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileDescription"); - char *mimeType = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType"); - char *mimeDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileOpenName"); - char *extensions = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileExtents"); + char *mimeType = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\MIMEType"); + char *mimeDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileOpenName"); + char *extensions = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileExtents"); info.fVariantCount = CalculateVariantCount(mimeType); info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType); info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription); info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions); - info.fFileName = PL_strdup(path); + + // fFileName is narrow. fix? + info.fFileName = PL_strdup(NS_ConvertUTF16toUTF8(path).get()); PL_strfree(mimeType); PL_strfree(mimeDescription); diff --git a/modules/plugin/samples/default/windows/dialogs.cpp b/modules/plugin/samples/default/windows/dialogs.cpp index eae460d2dcb2..4c8efb03f73c 100644 --- a/modules/plugin/samples/default/windows/dialogs.cpp +++ b/modules/plugin/samples/default/windows/dialogs.cpp @@ -79,17 +79,18 @@ static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) pPlugin->m_hWndDialog = hWnd; - char szString[512]; - LoadString(hInst, IDS_TITLE, szString, sizeof(szString)); - SetWindowText(hWnd, szString); + wchar_t szString[512]; + LoadStringW(hInst, IDS_TITLE, szString, sizeof(szString)); + SetWindowTextW(hWnd, szString); - LoadString(hInst, IDS_INFO, szString, sizeof(szString)); - SetDlgItemText(hWnd, IDC_STATIC_INFO, szString); + LoadStringW(hInst, IDS_INFO, szString, sizeof(szString)); + SetDlgItemTextW(hWnd, IDC_STATIC_INFO, szString); - SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType); + // convert m_pNPMIMEType dougt + SetDlgItemTextA(hWnd, IDC_STATIC_INFOTYPE, pPlugin->m_pNPMIMEType); - LoadString(hInst, IDS_LOCATION, szString, sizeof(szString)); - SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString); + LoadStringW(hInst, IDS_LOCATION, szString, sizeof(szString)); + SetDlgItemTextW(hWnd, IDC_STATIC_LOCATION, szString); char contentTypeIsJava = 0; @@ -99,30 +100,36 @@ static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) } if(pPlugin->m_szPageURL == NULL || contentTypeIsJava) - LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString)); + LoadStringW(hInst, IDS_FINDER_PAGE, szString, sizeof(szString)); else - strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738 - + { + MultiByteToWideChar( CP_ACP, 0, + pPlugin->m_szPageURL, + strlen(pPlugin->m_szPageURL)+1, + szString, + 511 ); // defect #362738 + } + SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString); - LoadString(hInst, IDS_QUESTION, szString, sizeof(szString)); - SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString); + LoadStringW(hInst, IDS_QUESTION, szString, sizeof(szString)); + SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, szString); - SetDlgItemText(hWnd, IDC_STATIC_WARNING, ""); + SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, L""); if(!pPlugin->m_bOnline) { EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE); - LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString)); - SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString); - SetDlgItemText(hWnd, IDC_STATIC_QUESTION, ""); + LoadStringW(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString)); + SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString); + SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, L""); return TRUE; } if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate)) { - LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString)); - SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString); + LoadStringW(hInst, IDS_WARNING_JS, szString, sizeof(szString)); + SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString); return TRUE; } diff --git a/modules/plugin/samples/default/windows/npshell.cpp b/modules/plugin/samples/default/windows/npshell.cpp index b7d2683d4a1b..1525b84cc96a 100644 --- a/modules/plugin/samples/default/windows/npshell.cpp +++ b/modules/plugin/samples/default/windows/npshell.cpp @@ -86,18 +86,18 @@ NPError NP_LOADDS NPP_New(NPMIMEType pluginType, for(int i = 0; i < argc; i++) { - if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL) + if(strcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL) szPageURL = (char *)argv[i]; - else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL) + else if(strcmpi(argn[i],"codebase") == 0 && argv[i] != NULL) szPageURL = (char *)argv[i]; - else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL) + else if(strcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL) szFileURL = (char *)argv[i]; - else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL) + else if(strcmpi(argn[i],"classid") == 0 && argv[i] != NULL) szFileURL = (char *)argv[i]; - else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL) + else if(strcmpi(argn[i],"SRC") == 0 && argv[i] != NULL) buf = (char *)argv[i]; - else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL) - bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0); + else if(strcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL) + bHidden = (strcmp((char *)argv[i], "TRUE") == 0); } /* some post-processing on the filename to attempt to extract the extension: */ diff --git a/modules/plugin/samples/default/windows/plugin.cpp b/modules/plugin/samples/default/windows/plugin.cpp index c22de1023b4c..2b5fac54d40e 100644 --- a/modules/plugin/samples/default/windows/plugin.cpp +++ b/modules/plugin/samples/default/windows/plugin.cpp @@ -51,7 +51,7 @@ nsIServiceManager * gServiceManager = NULL; -static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN; +static wchar_t szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN; static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM); @@ -66,7 +66,7 @@ BOOL RegisterNullPluginWindowClass() { assert(hInst != NULL); - WNDCLASS wc; + WNDCLASSW wc; memset(&wc, 0, sizeof(wc)); @@ -78,14 +78,14 @@ BOOL RegisterNullPluginWindowClass() wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1); wc.lpszClassName = szNullPluginWindowClassName; - ATOM aRet = RegisterClass(&wc); + ATOM aRet = RegisterClassW(&wc); return (aRet != NULL); } void UnregisterNullPluginWindowClass() { assert(hInst != NULL); - UnregisterClass(szNullPluginWindowClassName, hInst); + UnregisterClassW(szNullPluginWindowClassName, hInst); } /*********************************************/ @@ -129,41 +129,41 @@ CPlugin::CPlugin(HINSTANCE hInst, if(pluginType && *pluginType) { - m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1]; + m_pNPMIMEType = (NPMIMEType) new char[strlen(pluginType) + 1]; if(m_pNPMIMEType != NULL) - lstrcpy((LPSTR)m_pNPMIMEType, pluginType); + strcpy(m_pNPMIMEType, pluginType); } if(szPageURL && *szPageURL) { - m_szPageURL = new char[lstrlen(szPageURL) + 1]; + m_szPageURL = new char[strlen(szPageURL) + 1]; if(m_szPageURL != NULL) - lstrcpy(m_szPageURL, szPageURL); + strcpy(m_szPageURL, szPageURL); } if(szFileURL && *szFileURL) { - m_szFileURL = new char[lstrlen(szFileURL) + 1]; + m_szFileURL = new char[strlen(szFileURL) + 1]; if(m_szFileURL != NULL) - lstrcpy(m_szFileURL, szFileURL); + strcpy(m_szFileURL, szFileURL); } if(szFileExtension && *szFileExtension) { - m_szFileExtension = new char[lstrlen(szFileExtension) + 1]; + m_szFileExtension = new char[strlen(szFileExtension) + 1]; if(m_szFileExtension != NULL) - lstrcpy(m_szFileExtension, szFileExtension); + strcpy(m_szFileExtension, szFileExtension); } m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON)); - char szString[1024] = {'\0'}; - LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString)); + wchar_t szString[1024] = {'\0'}; + LoadStringW(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString)); if(*szString) { - m_szCommandMessage = new char[lstrlen(szString) + 1]; + m_szCommandMessage = new wchar_t[wcslen(szString) + 1]; if(m_szCommandMessage != NULL) - lstrcpy(m_szCommandMessage, szString); + wcscpy(m_szCommandMessage, szString); } } @@ -253,8 +253,8 @@ BOOL CPlugin::init(HWND hWndParent) RECT rcParent; GetClientRect(m_hWndParent, &rcParent); - CreateWindow(szNullPluginWindowClassName, - "NULL Plugin", + CreateWindowW(szNullPluginWindowClassName, + L"NULL Plugin", WS_CHILD, 0,0, rcParent.right, rcParent.bottom, m_hWndParent, @@ -332,10 +332,10 @@ LPSTR CPlugin::createURLString() // check if there is file URL first if(!m_bSmartUpdate && m_szFileURL != NULL) { - m_szURLString = new char[lstrlen(m_szFileURL) + 1]; + m_szURLString = new char[strlen(m_szFileURL) + 1]; if(m_szURLString == NULL) return NULL; - lstrcpy(m_szURLString, m_szFileURL); + strcpy(m_szURLString, m_szFileURL); return m_szURLString; } @@ -351,18 +351,18 @@ LPSTR CPlugin::createURLString() if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava) { - szAddress = new char[lstrlen(m_szPageURL) + 1]; + szAddress = new char[strlen(m_szPageURL) + 1]; if(szAddress == NULL) return NULL; - lstrcpy(szAddress, m_szPageURL); + strcpy(szAddress, m_szPageURL); - m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1]; + m_szURLString = new char[strlen(szAddress) + 1 + strlen(m_pNPMIMEType) + 1]; if(m_szURLString == NULL) return NULL; // Append the MIME type to the URL - wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType); + sprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType); } else // default { @@ -374,20 +374,20 @@ LPSTR CPlugin::createURLString() urlToOpen = szPageUrlForJVM; } - szAddress = new char[lstrlen(urlToOpen) + 1]; + szAddress = new char[strlen(urlToOpen) + 1]; if(szAddress == NULL) return NULL; - lstrcpy(szAddress, urlToOpen); + strcpy(szAddress, urlToOpen); - m_szURLString = new char[lstrlen(szAddress) + 10 + - lstrlen((LPSTR)m_pNPMIMEType) + 1]; + m_szURLString = new char[strlen(szAddress) + 10 + + strlen(m_pNPMIMEType) + 1]; if(m_szURLString == NULL) return NULL; // Append the MIME type to the URL - wsprintf(m_szURLString, "%s?mimetype=%s", - szAddress, (LPSTR)m_pNPMIMEType); + sprintf(m_szURLString, "%s?mimetype=%s", + szAddress, m_pNPMIMEType); } else { @@ -409,14 +409,15 @@ LPSTR CPlugin::createURLString() m_szFileURL[0] = '\0'; } - m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 + - lstrlen((LPSTR)m_pNPMIMEType) + 13 + - lstrlen((LPSTR)m_szPageURL) + 11 + - lstrlen((LPSTR)m_szFileURL) + - lstrlen(szPluginFinderCommandEnd) + 1]; - wsprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s", - szPluginFinderCommandBeginning, urlToOpen, - (LPSTR)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd); + m_szURLString = new char[strlen(szPluginFinderCommandBeginning) + strlen(urlToOpen) + 10 + + strlen((LPSTR)m_pNPMIMEType) + 13 + + strlen((LPSTR)m_szPageURL) + 11 + + strlen((LPSTR)m_szFileURL) + + strlen(szPluginFinderCommandEnd) + 1]; + sprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s", + szPluginFinderCommandBeginning, urlToOpen, + m_pNPMIMEType, m_szPageURL, m_szFileURL, + szPluginFinderCommandEnd); } } @@ -512,13 +513,13 @@ void CPlugin::getPlugin() m_szCommandMessage = NULL; } - char szString[1024] = {'\0'}; - LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); + wchar_t szString[1024] = {'\0'}; + LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); if(*szString) { - m_szCommandMessage = new char[lstrlen(szString) + 1]; + m_szCommandMessage = new wchar_t[wcslen(szString) + 1]; if(m_szCommandMessage != NULL) - lstrcpy(m_szCommandMessage, szString); + wcscpy(m_szCommandMessage, szString); } InvalidateRect(m_hWnd, NULL, TRUE); @@ -548,20 +549,20 @@ void CPlugin::URLNotify(const char * szURL) dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL); NPStream * pStream = NULL; - char buf[256]; + wchar_t buf[256]; assert(m_hInst != NULL); assert(m_pNPInstance != NULL); - int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf)); + int iSize = LoadStringW(m_hInst, IDS_GOING2HTML, buf, sizeof(buf)); NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream); if (rc != NPERR_NO_ERROR) return; - //char buf[] = "\n\n\n

NPN_NewStream / NPN_Write - This seems to work.

\n\n\n"; + //wchar_t buf[] = L"\n\n\n

NPN_NewStream / NPN_Write - This seems to work.

\n\n\n"; - NPN_Write(m_pNPInstance, pStream, iSize, buf); + NPN_Write(m_pNPInstance, pStream, iSize, buf); // buf is unicode now. NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE); } @@ -594,12 +595,12 @@ NPError CPlugin::destroyStream(NPStream *stream, NPError reason) BOOL CPlugin::readyToRefresh() { - char szString[1024] = {'\0'}; - LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); + wchar_t szString[1024] = {'\0'}; + LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); if(m_szCommandMessage == NULL) return FALSE; - return (lstrcmp(m_szCommandMessage, szString) == 0); + return (wcscmp(m_szCommandMessage, szString) == 0); } //*************************** @@ -626,7 +627,7 @@ void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags) NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self"); } -static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc) +static void DrawCommandMessage(HDC hDC, wchar_t* szString, LPRECT lprc) { if(szString == NULL) return; @@ -637,7 +638,7 @@ static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc) HFONT hFontOld = SelectFont(hDC, hFont); SIZE sz; - GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz); + GetTextExtentPoint32W(hDC, szString, wcslen(szString), &sz); POINT pt; pt.x = sz.cx; pt.y = sz.cy; @@ -659,7 +660,7 @@ static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc) int iModeOld = SetBkMode(hDC, TRANSPARENT); COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0)); - DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER); + DrawTextW(hDC, szString, wcslen(szString), &rcText, DT_CENTER|DT_VCENTER); SetTextColor(hDC, crColorOld); SetBkMode(hDC, iModeOld); SelectFont(hDC, hFontOld); diff --git a/modules/plugin/samples/default/windows/plugin.h b/modules/plugin/samples/default/windows/plugin.h index 34961aa4369c..21b6f45c50f0 100644 --- a/modules/plugin/samples/default/windows/plugin.h +++ b/modules/plugin/samples/default/windows/plugin.h @@ -51,7 +51,7 @@ private: HICON m_hIcon; char* m_szURLString; - char* m_szCommandMessage; + wchar_t* m_szCommandMessage; BOOL m_bWaitingStreamFromPFS; NPStream* m_PFSStream; @@ -118,7 +118,7 @@ public: #define JVM_SMARTUPDATE_URL "http://java.com/download" #ifdef WIN32 -#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin" +#define REGISTRY_PLACE L"Software\\Netscape\\Netscape Navigator\\Default Plugin" #else #define GWL_USERDATA 0 #define COLOR_3DSHADOW COLOR_BTNFACE @@ -126,7 +126,7 @@ public: #define COLOR_3DDKSHADOW COLOR_BTNSHADOW #endif -#define CLASS_NULL_PLUGIN "NullPluginClass" +#define CLASS_NULL_PLUGIN L"NullPluginClass" BOOL RegisterNullPluginWindowClass(); void UnregisterNullPluginWindowClass(); diff --git a/modules/plugin/samples/default/windows/utils.cpp b/modules/plugin/samples/default/windows/utils.cpp index 2371e71430c7..01cf1f3928a5 100644 --- a/modules/plugin/samples/default/windows/utils.cpp +++ b/modules/plugin/samples/default/windows/utils.cpp @@ -45,8 +45,8 @@ HKEY openRegistry() { HKEY phkResult; - if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS) - MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK); + if(RegCreateKeyW(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS) + MessageBoxW(0, L"Error creating Default Plugin registry key", L"Default Plugin", MB_OK); return phkResult; } @@ -56,30 +56,37 @@ BOOL IsNewMimeType(LPSTR mime) { HKEY hkey = openRegistry(); DWORD dwType, keysize = 512; - char keybuf[512]; + wchar_t keybuf[512]; + wchar_t wideMime[64]; - if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS) + MultiByteToWideChar(CP_ACP, 0, + mime, + strlen(mime) + 1, + wideMime, + 64); + + if(RegQueryValueExW(hkey, wideMime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS) { // key exists, must have already been here... return FALSE; } else { - if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS) - MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK); + if(RegSetValueExW(hkey, wideMime, 0, REG_SZ, (LPBYTE) L"(none)", 7) != ERROR_SUCCESS) + MessageBoxW(0, L"Error adding MIME type value", L"Default Plugin", MB_OK); return TRUE; } } // string length in pixels for the specific window (selected font) -static int getWindowStringLength(HWND hWnd, LPSTR lpsz) +static int getWindowStringLength(HWND hWnd, wchar_t* lpsz) { SIZE sz; HDC hDC = GetDC(hWnd); HFONT hWindowFont = GetWindowFont(hWnd); HFONT hFontOld = SelectFont(hDC, hWindowFont); - GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz); + GetTextExtentPoint32W(hDC, lpsz, wcslen(lpsz), &sz); POINT pt; pt.x = sz.cx; pt.y = sz.cy; @@ -89,20 +96,20 @@ static int getWindowStringLength(HWND hWnd, LPSTR lpsz) return (int)pt.x; } -/****************************************************************/ -/* */ -/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */ -/* */ -/* helper to wrap long lines in a static control, which do not */ -/* wrap automatically if they do not have space characters */ -/* */ -/****************************************************************/ -void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) +/*******************************************************************/ +/* */ +/* void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) */ +/* */ +/* helper to wrap long lines in a static control, which do not */ +/* wrap automatically if they do not have space characters */ +/* */ +/*******************************************************************/ +void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) { HWND hWndStatic = GetDlgItem(hWnd, iID); - if((szText == NULL) || (lstrlen(szText) == 0)) + if((szText == NULL) || (wcslen(szText) == 0)) { - SetDlgItemText(hWnd, iID, ""); + SetDlgItemTextW(hWnd, iID, L""); return; } @@ -114,7 +121,7 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) if(iStringLength <= iStaticLength) { - SetDlgItemText(hWnd, iID, szText); + SetDlgItemTextW(hWnd, iID, szText); return; } @@ -122,19 +129,19 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) if(iBreaks <= 0) return; - char * pBuf = new char[iStringLength + iBreaks + 1]; + wchar_t * pBuf = new wchar_t[iStringLength + iBreaks + 1]; if(pBuf == NULL) return; - lstrcpy(pBuf, ""); + wcscpy(pBuf, L""); int iStart = 0; int iLines = 0; for(int i = 0; i < iStringLength; i++) { - char * sz = &szText[iStart]; + wchar_t* sz = &szText[iStart]; int iIndex = i - iStart; - char ch = sz[iIndex + 1]; + wchar_t ch = sz[iIndex + 1]; sz[iIndex + 1] = '\0'; @@ -145,7 +152,7 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) sz[iIndex + 1] = ch; if(iLines == iBreaks) { - lstrcat(pBuf, sz); + wcscat(pBuf, sz); break; } continue; @@ -157,15 +164,15 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) ch = sz[iIndex]; sz[iIndex] = '\0'; // terminate string one char shorter - lstrcat(pBuf, sz); // append the string - lstrcat(pBuf, " "); // append space character for successful wrapping + wcscat(pBuf, sz); // append the string + wcscat(pBuf, L" "); // append space character for successful wrapping - iStart += lstrlen(sz);// shift new start position + iStart += wcslen(sz); // shift new start position sz[iIndex] = ch; // restore zeroed element iLines++; // count lines } - SetDlgItemText(hWnd, iID, pBuf); + SetDlgItemTextW(hWnd, iID, pBuf); delete [] pBuf; } diff --git a/modules/plugin/samples/default/windows/utils.h b/modules/plugin/samples/default/windows/utils.h index 1e1691d78287..a4b5a44443ea 100644 --- a/modules/plugin/samples/default/windows/utils.h +++ b/modules/plugin/samples/default/windows/utils.h @@ -40,6 +40,6 @@ HKEY openRegistry(); BOOL IsNewMimeType(LPSTR szMimeType); -void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText); +void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText); #endif // __UTILS_H__ diff --git a/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp b/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp index 8443ce501f06..923f6ef2ea1b 100644 --- a/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp +++ b/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp @@ -146,11 +146,11 @@ static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA); if (plugin) { const char * string = plugin->getVersion(); - DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } else { char string[] = "Error occured"; - DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } EndPaint(hWnd, &ps); diff --git a/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp b/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp index 23d06902ccc0..a2bed6b18021 100644 --- a/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp +++ b/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp @@ -220,10 +220,10 @@ static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM // get our plugin instance object and ask it for the version string nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA); if (plugin) - DrawText(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawTextA(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); else { char string[] = "Error occured"; - DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } EndPaint(hWnd, &ps); diff --git a/rdf/datasource/src/nsFileSystemDataSource.cpp b/rdf/datasource/src/nsFileSystemDataSource.cpp index cd1bf5eb8fc1..d88221b77f26 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -928,14 +928,15 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult) #if defined (XP_WIN) && !defined (WINCE) PRInt32 driveType; - char drive[32]; + PRUnichar drive[32]; PRInt32 volNum; char *url; for (volNum = 0; volNum < 26; volNum++) { - sprintf(drive, "%c:\\", volNum + 'A'); - driveType = GetDriveType(drive); + swprintf( drive, L"%c:\\", volNum + (PRUnichar)'A'); + + driveType = GetDriveTypeW(drive); if (driveType != DRIVE_UNKNOWN && driveType != DRIVE_NO_ROOT_DIR) { if (nsnull != (url = PR_smprintf("file:///%c|/", volNum + 'A'))) diff --git a/toolkit/components/startup/src/nsUserInfoWin.cpp b/toolkit/components/startup/src/nsUserInfoWin.cpp index bbb16c7a099e..4bdc29fa246d 100644 --- a/toolkit/components/startup/src/nsUserInfoWin.cpp +++ b/toolkit/components/startup/src/nsUserInfoWin.cpp @@ -58,14 +58,13 @@ nsUserInfo::GetUsername(char **aUsername) { *aUsername = nsnull; - TCHAR username[256]; + PRUnichar username[256]; DWORD size = 256; - if (!GetUserName(username, &size)) + if (!GetUserNameW(username, &size)) return NS_ERROR_FAILURE; - - *aUsername = nsCRT::strdup(username); - + + *aUsername = ToNewUTF8String(nsDependentString(username)); if (*aUsername) return NS_OK; return NS_ERROR_FAILURE; diff --git a/uriloader/exthandler/win/nsMIMEInfoWin.cpp b/uriloader/exthandler/win/nsMIMEInfoWin.cpp index 2ed61c0e760c..c4e2a59e41ea 100755 --- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp +++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp @@ -266,7 +266,7 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) SFGAOF sfgao; // Bug 394974 - HMODULE hDll = ::LoadLibrary("shell32.dll"); + HMODULE hDll = ::LoadLibraryW(L"shell32.dll"); MySHParseDisplayName pMySHParseDisplayName = NULL; // Version 6.0 and higher if (pMySHParseDisplayName = @@ -274,19 +274,19 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) "SHParseDisplayName")) { if (SUCCEEDED(pMySHParseDisplayName(NS_ConvertUTF8toUTF16(urlSpec).get(), NULL, &pidl, 0, &sfgao))) { - static const char cmdVerb[] = "open"; - SHELLEXECUTEINFO sinfo; + static const PRUnichar cmdVerb[] = L"open"; + SHELLEXECUTEINFOW sinfo; memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO)); sinfo.cbSize = sizeof(SHELLEXECUTEINFO); sinfo.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI | SEE_MASK_INVOKEIDLIST; sinfo.hwnd = NULL; - sinfo.lpVerb = (LPCSTR)&cmdVerb; + sinfo.lpVerb = (LPWSTR)&cmdVerb; sinfo.nShow = SW_SHOWNORMAL; sinfo.lpIDList = pidl; - BOOL result = ShellExecuteEx(&sinfo); + BOOL result = ShellExecuteExW(&sinfo); CoTaskMemFree(pidl); @@ -295,7 +295,9 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) } } else { // Version of shell32.dll < 6.0 - LONG r = (LONG) ::ShellExecute(NULL, "open", urlSpec.get(), NULL, NULL, + LONG r = (LONG) ::ShellExecuteW(NULL, L"open", + NS_ConvertUTF8toUTF16(urlSpec).get(), + NULL, NULL, SW_SHOWNORMAL); if (r < 32) rv = NS_ERROR_FAILURE; diff --git a/uriloader/exthandler/win/nsOSHelperAppService.cpp b/uriloader/exthandler/win/nsOSHelperAppService.cpp index bfe39446ec5b..8d63241533be 100644 --- a/uriloader/exthandler/win/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp @@ -145,11 +145,11 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch if (aProtocolScheme && *aProtocolScheme) { HKEY hKey; - LONG err = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, aProtocolScheme, 0, + LONG err = ::RegOpenKeyExA(HKEY_CLASSES_ROOT, aProtocolScheme, 0, KEY_QUERY_VALUE, &hKey); if (err == ERROR_SUCCESS) { - err = ::RegQueryValueEx(hKey, "URL Protocol", NULL, NULL, NULL, NULL); + err = ::RegQueryValueExW(hKey, L"URL Protocol", NULL, NULL, NULL, NULL); *aHandlerExists = (err == ERROR_SUCCESS); // close the key ::RegCloseKey(hKey); diff --git a/widget/src/windows/nsAppShell.cpp b/widget/src/windows/nsAppShell.cpp index 9b81af7060fe..9dd15f5bfa2e 100644 --- a/widget/src/windows/nsAppShell.cpp +++ b/widget/src/windows/nsAppShell.cpp @@ -93,13 +93,13 @@ nsresult nsAppShell::Init() { if (!sMsgId) - sMsgId = RegisterWindowMessage("nsAppShell:EventID"); + sMsgId = RegisterWindowMessageW(L"nsAppShell:EventID"); - WNDCLASS wc; + WNDCLASSW wc; HINSTANCE module = GetModuleHandle(NULL); - const char *const kWindowClass = "nsAppShell:EventWindowClass"; - if (!GetClassInfo(module, kWindowClass, &wc)) { + const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass"; + if (!GetClassInfoW(module, kWindowClass, &wc)) { wc.style = 0; wc.lpfnWndProc = EventWindowProc; wc.cbClsExtra = 0; @@ -108,12 +108,12 @@ nsAppShell::Init() wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = (HBRUSH) NULL; - wc.lpszMenuName = (LPCSTR) NULL; + wc.lpszMenuName = (LPCWSTR) NULL; wc.lpszClassName = kWindowClass; - RegisterClass(&wc); + RegisterClassW(&wc); } - mEventWnd = CreateWindow(kWindowClass, "nsAppShell:EventWindow", + mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow", 0, 0, 0, 10, 10, NULL, NULL, module, NULL); NS_ENSURE_STATE(mEventWnd); diff --git a/widget/src/windows/nsBidiKeyboard.cpp b/widget/src/windows/nsBidiKeyboard.cpp index 03c7df9c72cc..07afbd6f565f 100644 --- a/widget/src/windows/nsBidiKeyboard.cpp +++ b/widget/src/windows/nsBidiKeyboard.cpp @@ -40,6 +40,7 @@ #include #include "nsBidiKeyboard.h" #include "prmem.h" +#include NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard) @@ -63,8 +64,8 @@ NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel) return result; // call LoadKeyboardLayout() only if the target keyboard layout is different from the current - char currentLocaleName[KL_NAMELENGTH]; - strncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH); + PRUnichar currentLocaleName[KL_NAMELENGTH]; + wcsncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH); currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate NS_ASSERTION(*currentLocaleName, @@ -96,26 +97,26 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL) currentLocale = ::GetKeyboardLayout(0); *aIsRTL = IsRTLLanguage(currentLocale); - if (!::GetKeyboardLayoutName(mCurrentLocaleName)) + if (!::GetKeyboardLayoutNameW(mCurrentLocaleName)) return NS_ERROR_FAILURE; NS_ASSERTION(*mCurrentLocaleName, "GetKeyboardLayoutName return string length == 0"); - NS_ASSERTION((strlen(mCurrentLocaleName) < KL_NAMELENGTH), + NS_ASSERTION((wcslen(mCurrentLocaleName) < KL_NAMELENGTH), "GetKeyboardLayoutName return string length >= KL_NAMELENGTH"); // The language set by the user overrides the default language for that direction if (*aIsRTL) { - strncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH); + wcsncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH); mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } else { - strncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH); + wcsncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH); mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } - NS_ASSERTION((strlen(mRTLKeyboard) < KL_NAMELENGTH), + NS_ASSERTION((wcslen(mRTLKeyboard) < KL_NAMELENGTH), "mLTRKeyboard has string length >= KL_NAMELENGTH"); - NS_ASSERTION((strlen(mLTRKeyboard) < KL_NAMELENGTH), + NS_ASSERTION((wcslen(mLTRKeyboard) < KL_NAMELENGTH), "mRTLKeyboard has string length >= KL_NAMELENGTH"); return NS_OK; } @@ -132,7 +133,7 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() int keyboards; HKL far* buf; HKL locale; - char localeName[KL_NAMELENGTH]; + PRUnichar localeName[KL_NAMELENGTH]; PRBool isLTRKeyboardSet = PR_FALSE; PRBool isRTLKeyboardSet = PR_FALSE; @@ -156,11 +157,11 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() while (keyboards--) { locale = buf[keyboards]; if (IsRTLLanguage(locale)) { - sprintf(mRTLKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); + swprintf(mRTLKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); isRTLKeyboardSet = PR_TRUE; } else { - sprintf(mLTRKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); + swprintf( mLTRKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); isLTRKeyboardSet = PR_TRUE; } } @@ -178,20 +179,20 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() // installed this prevents us from arbitrarily resetting the current // layout (bug 80274) locale = ::GetKeyboardLayout(0); - if (!::GetKeyboardLayoutName(localeName)) + if (!::GetKeyboardLayoutNameW(localeName)) return NS_ERROR_FAILURE; NS_ASSERTION(*localeName, "GetKeyboardLayoutName return string length == 0"); - NS_ASSERTION((strlen(localeName) < KL_NAMELENGTH), + NS_ASSERTION((wcslen(localeName) < KL_NAMELENGTH), "GetKeyboardLayout return string length >= KL_NAMELENGTH"); if (IsRTLLanguage(locale)) { - strncpy(mRTLKeyboard, localeName, KL_NAMELENGTH); + swprintf(mRTLKeyboard, localeName, KL_NAMELENGTH); mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } else { - strncpy(mLTRKeyboard, localeName, KL_NAMELENGTH); + swprintf( mLTRKeyboard, localeName, KL_NAMELENGTH); mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } diff --git a/widget/src/windows/nsBidiKeyboard.h b/widget/src/windows/nsBidiKeyboard.h index 71a9a40962f5..de859f5f6807 100644 --- a/widget/src/windows/nsBidiKeyboard.h +++ b/widget/src/windows/nsBidiKeyboard.h @@ -58,9 +58,9 @@ protected: PRPackedBool mInitialized; PRPackedBool mHaveBidiKeyboards; - char mLTRKeyboard[KL_NAMELENGTH]; - char mRTLKeyboard[KL_NAMELENGTH]; - char mCurrentLocaleName[KL_NAMELENGTH]; + PRUnichar mLTRKeyboard[KL_NAMELENGTH]; + PRUnichar mRTLKeyboard[KL_NAMELENGTH]; + PRUnichar mCurrentLocaleName[KL_NAMELENGTH]; }; diff --git a/widget/src/windows/nsClipboard.cpp b/widget/src/windows/nsClipboard.cpp index 8c54fc79a413..8b515f674c9a 100644 --- a/widget/src/windows/nsClipboard.cpp +++ b/widget/src/windows/nsClipboard.cpp @@ -70,7 +70,7 @@ // oddly, this isn't in the MSVC headers anywhere. -UINT nsClipboard::CF_HTML = ::RegisterClipboardFormat("HTML Format"); +UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format"); //------------------------------------------------------------------------- @@ -111,7 +111,9 @@ UINT nsClipboard::GetFormat(const char* aMimeStr) else if (strcmp(aMimeStr, kNativeHTMLMime) == 0) format = CF_HTML; else - format = ::RegisterClipboardFormat(aMimeStr); + format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get()); + + return format; } @@ -316,7 +318,7 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, PRUint32 * aLe ); // Display the string. - MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION ); + MessageBoxW( NULL, (LPCWSTR)lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION ); // Free the buffer. LocalFree( lpMsgBuf ); diff --git a/widget/src/windows/nsDataObj.h b/widget/src/windows/nsDataObj.h index 95f33d5f44a9..226e3e38f247 100644 --- a/widget/src/windows/nsDataObj.h +++ b/widget/src/windows/nsDataObj.h @@ -82,10 +82,10 @@ IAsyncOperation : public IUnknown * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp */ #ifndef CFSTR_INETURLA -#define CFSTR_INETURLA "UniformResourceLocator" +#define CFSTR_INETURLA L"UniformResourceLocator" #endif #ifndef CFSTR_INETURLW -#define CFSTR_INETURLW "UniformResourceLocatorW" +#define CFSTR_INETURLW L"UniformResourceLocatorW" #endif // For support of MinGW w32api v2.4. @@ -93,10 +93,10 @@ IAsyncOperation : public IUnknown // http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/shlobj.h?cvsroot=src // then that can be made the base required version and this code should be removed. #ifndef CFSTR_FILEDESCRIPTORA -# define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" +# define CFSTR_FILEDESCRIPTORA L"FileGroupDescriptor" #endif #ifndef CFSTR_FILEDESCRIPTORW -# define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW" +# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW" #endif #ifdef __MINGW32__ diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index bd68753e9778..1b1c708c59a3 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -280,10 +280,10 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) #ifndef WINCE } catch(...) { - MessageBox(ofn.hwndOwner, - 0, - "The filepicker was unexpectedly closed by Windows.", - MB_ICONERROR); + MessageBoxW(ofn.hwndOwner, + 0, + L"The filepicker was unexpectedly closed by Windows.", + MB_ICONERROR); result = PR_FALSE; } #endif diff --git a/widget/src/windows/nsLookAndFeel.cpp b/widget/src/windows/nsLookAndFeel.cpp index c07094aa8dcd..43599495ee24 100644 --- a/widget/src/windows/nsLookAndFeel.cpp +++ b/widget/src/windows/nsLookAndFeel.cpp @@ -56,7 +56,7 @@ static CloseThemeDataPtr closeTheme = NULL; static GetThemeColorPtr getThemeColor = NULL; static IsAppThemedPtr isAppThemed = NULL; -static const char kThemeLibraryName[] = "uxtheme.dll"; +static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll"; static HINSTANCE gThemeDLLInst = NULL; static HANDLE gMenuTheme = NULL; @@ -105,13 +105,13 @@ static PRInt32 GetSystemParam(long flag, PRInt32 def) nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel() { #ifndef WINCE - gShell32DLLInst = LoadLibrary("Shell32.dll"); + gShell32DLLInst = LoadLibraryW(L"Shell32.dll"); if (gShell32DLLInst) { gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst, "SHAppBarMessage"); } - gThemeDLLInst = LoadLibrary(kThemeLibraryName); + gThemeDLLInst = LoadLibraryW(kThemeLibraryName); if(gThemeDLLInst) { openTheme = (OpenThemeDataPtr)GetProcAddress(gThemeDLLInst, "OpenThemeData"); @@ -504,7 +504,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) if (gSHAppBarMessage) { // Get task bar window handle - HWND shellWindow = FindWindow("Shell_TrayWnd", NULL); + HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL); if (shellWindow != NULL) { diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 6c53bfd5bd42..a4ba95007c65 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -279,7 +279,7 @@ static GetThemeSysFontPtr getThemeSysFont = NULL; static GetThemeColorPtr getThemeColor = NULL; static GetThemeMarginsPtr getThemeMargins = NULL; -static const char kThemeLibraryName[] = "uxtheme.dll"; +static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll"; static inline bool IsCheckboxWidgetType(PRUint8 aWidgetType) { @@ -318,7 +318,7 @@ nsNativeThemeWin::nsNativeThemeWin() { mHeaderTheme = NULL; mMenuTheme = NULL; - mThemeDLL = ::LoadLibrary(kThemeLibraryName); + mThemeDLL = ::LoadLibraryW(kThemeLibraryName); if (mThemeDLL) { openTheme = (OpenThemeDataPtr)GetProcAddress(mThemeDLL, "OpenThemeData"); closeTheme = (CloseThemeDataPtr)GetProcAddress(mThemeDLL, "CloseThemeData"); diff --git a/widget/src/windows/nsSound.cpp b/widget/src/windows/nsSound.cpp index 552171cb9ff0..403a782d87d5 100644 --- a/widget/src/windows/nsSound.cpp +++ b/widget/src/windows/nsSound.cpp @@ -40,7 +40,7 @@ #include "nscore.h" #include "plstr.h" #include - +#include "nsString.h" #include // mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN @@ -125,7 +125,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, flags |= SND_ASYNC; } - ::PlaySound(reinterpret_cast(data), 0, flags); + ::PlaySoundA(reinterpret_cast(data), 0, flags); } return NS_OK; @@ -166,12 +166,10 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias) PurgeLastSound(); if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) { - ::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC); + ::PlaySoundW(L"MailBeep", nsnull, SND_ALIAS | SND_ASYNC); } else { - nsCAutoString nativeSoundAlias; - NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias); - ::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC); + ::PlaySoundW(PromiseFlatString(aSoundAlias).get(), nsnull, SND_ALIAS | SND_ASYNC); } return NS_OK; diff --git a/widget/src/windows/nsToolkit.cpp b/widget/src/windows/nsToolkit.cpp index dcd196150552..1e62d2941ee4 100644 --- a/widget/src/windows/nsToolkit.cpp +++ b/widget/src/windows/nsToolkit.cpp @@ -264,7 +264,7 @@ nsToolkit::Startup(HMODULE hModule) typedef BOOL (*SetProcessDPIAwareFunc)(VOID); SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc) - GetProcAddress(LoadLibrary("user32.dll"), + GetProcAddress(LoadLibraryW(L"user32.dll"), "SetProcessDPIAware"); if (setDPIAware) @@ -295,8 +295,8 @@ void nsToolkit::CreateInternalWindow(PRThread *aThread) // create the internal window // - mDispatchWnd = ::CreateWindow("nsToolkitClass", - "NetscapeDispatchWnd", + mDispatchWnd = ::CreateWindowW(L"nsToolkitClass", + L"NetscapeDispatchWnd", WS_DISABLED, -50, -50, 10, 10, diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 7e9e96c8a19e..200ad9054c4b 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -150,7 +150,7 @@ #include "prprf.h" #include "prmem.h" -static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump"; +static const PRUnichar kMozHeapDumpMessageString[] = L"MOZ_HeapDump"; #define kWindowPositionSlop 20 @@ -699,7 +699,7 @@ nsWindow::nsWindow() : nsBaseWidget() // Heap dump #ifndef WINCE - nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString); + nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessageW(kMozHeapDumpMessageString); #endif } @@ -1119,26 +1119,26 @@ nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow) return (PRBool) PtInRect(&r, mp); } -static char sPropName[40] = ""; -static char* GetNSWindowPropName() { +static PRUnichar sPropName[40] = L""; +static PRUnichar* GetNSWindowPropName() { if (!*sPropName) { - _snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid()); + _snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p", _getpid()); sPropName[39] = '\0'; } return sPropName; } nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) { - return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName()); + return (nsWindow *) ::GetPropW(aWnd, GetNSWindowPropName()); } BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) { if (ptr == NULL) { - ::RemovePropA(aWnd, GetNSWindowPropName()); + ::RemovePropW(aWnd, GetNSWindowPropName()); return TRUE; } else { - return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr); + return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)ptr); } } @@ -1788,7 +1788,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) { // Play the minimize sound while we're here, since that is also // forgotten when we use SW_SHOWMINIMIZED. - ::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC); + ::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC); } #endif break; @@ -5192,7 +5192,7 @@ LPCWSTR nsWindow::WindowPopupClassW() return className; } -LPCSTR nsWindow::WindowClass() +LPCTSTR nsWindow::WindowClass() { // Call into the wide version to make sure things get // registered properly. @@ -5200,7 +5200,9 @@ LPCSTR nsWindow::WindowClass() // XXX: The class name used here must be kept in sync with // the classname used in WindowClassW(); - +#ifdef UNICODE + return classNameW; +#else if (classNameW == kWClassNameHidden) { return kClassNameHidden; } @@ -5217,17 +5219,21 @@ LPCSTR nsWindow::WindowClass() return kClassNameContentFrame; } return kClassNameGeneral; +#endif } -LPCSTR nsWindow::WindowPopupClass() +LPCTSTR nsWindow::WindowPopupClass() { // Call into the wide version to make sure things get // registered properly. - WindowPopupClassW(); +#ifdef UNICODE + return WindowPopupClassW(); +#else // XXX: The class name used here must be kept in sync with // the classname used in WindowPopupClassW(); return "MozillaDropShadowWindowClass"; +#endif } //------------------------------------------------------------------------- @@ -7718,7 +7724,7 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L { // open the dll dynamically if (!gmAccLib) - gmAccLib =::LoadLibrary("OLEACC.DLL"); + gmAccLib =::LoadLibraryW(L"OLEACC.DLL"); if (gmAccLib) { if (!gmLresultFromObject) diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index ecdaf4b0cf4f..77167963ac71 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -105,6 +105,13 @@ const LPCSTR kClassNameContent = "MozillaContentWindowClass"; const LPCSTR kClassNameContentFrame = "MozillaContentFrameWindowClass"; const LPCSTR kClassNameGeneral = "MozillaWindowClass"; const LPCSTR kClassNameDialog = "MozillaDialogClass"; +const LPCTSTR kTClassNameHidden = TEXT("MozillaHiddenWindowClass"); +const LPCTSTR kTClassNameUI = TEXT("MozillaUIWindowClass"); +const LPCTSTR kTClassNameContent = TEXT("MozillaContentWindowClass"); +const LPCTSTR kTClassNameContentFrame = TEXT("MozillaContentFrameWindowClass"); +const LPCTSTR kTClassNameGeneral = TEXT("MozillaWindowClass"); +const LPCTSTR kTClassNameDialog = TEXT("MozillaDialogClass"); + /** * Native WIN32 window wrapper. diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 6c7a7f3576a2..fe7aa06a37cf 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -66,6 +66,11 @@ #include #endif +#if defined(XP_WIN) +#include +#include "nsString.h" +#endif + static void Abort(const char *aMsg); @@ -97,7 +102,7 @@ PRBool InDebugger() #ifndef WINCE PRBool fReturn = PR_FALSE; LPFNISDEBUGGERPRESENT lpfnIsDebuggerPresent = NULL; - HINSTANCE hKernel = LoadLibrary("Kernel32.dll"); + HINSTANCE hKernel = LoadLibraryW(L"Kernel32.dll"); if(hKernel) { @@ -401,9 +406,9 @@ Break(const char *aMsg) * See http://bugzilla.mozilla.org/show_bug.cgi?id=54792 */ PROCESS_INFORMATION pi; - STARTUPINFO si; - char executable[MAX_PATH]; - char* pName; + STARTUPINFOW si; + PRUnichar executable[MAX_PATH]; + PRUnichar* pName; memset(&pi, 0, sizeof(pi)); @@ -412,13 +417,15 @@ Break(const char *aMsg) si.wShowWindow = SW_SHOW; // 2nd arg of CreateProcess is in/out - char *msgCopy = (char*) _alloca(strlen(aMsg) + 1); - strcpy(msgCopy, aMsg); + PRUnichar *msgCopy = (PRUnichar*) _alloca((strlen(aMsg) + 1)*sizeof(PRUnichar)); + wcscpy(msgCopy , (PRUnichar*)NS_ConvertUTF8toUTF16(aMsg).get()); - if(GetModuleFileName(GetModuleHandle("xpcom.dll"), executable, MAX_PATH) && - NULL != (pName = strrchr(executable, '\\')) && - NULL != strcpy(pName+1, "windbgdlg.exe") && - CreateProcess(executable, msgCopy, NULL, NULL, PR_FALSE, + if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), (LPWCH)executable, MAX_PATH) && + NULL != (pName = wcsrchr(executable, '\\')) && + NULL != + wcscpy((WCHAR*) + pName+1, L"windbgdlg.exe") && + CreateProcessW((LPCWSTR)executable, (LPWSTR)msgCopy, NULL, NULL, PR_FALSE, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { WaitForSingleObject(pi.hProcess, INFINITE); diff --git a/xpcom/base/nsStackWalk.cpp b/xpcom/base/nsStackWalk.cpp index 5a2059e35ebf..3e26d76681e2 100644 --- a/xpcom/base/nsStackWalk.cpp +++ b/xpcom/base/nsStackWalk.cpp @@ -328,9 +328,9 @@ EnsureImageHlpInitialized() ::InitializeCriticalSection(&gDbgHelpCS); - HMODULE module = ::LoadLibrary("DBGHELP.DLL"); + HMODULE module = ::LoadLibraryW(L"DBGHELP.DLL"); if (!module) { - module = ::LoadLibrary("IMAGEHLP.DLL"); + module = ::LoadLibraryW(L"IMAGEHLP.DLL"); if (!module) return PR_FALSE; } diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 5ceea5ed1050..41f7325cccbc 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -127,7 +127,7 @@ NS_COM void StartupSpecialSystemDirectory() #if defined (XP_WIN) && !defined (WINCE) // SHGetKnownFolderPath is only available on Windows Vista // so that we need to use GetProcAddress to get the pointer. - gShell32DLLInst = LoadLibrary("Shell32.dll"); + gShell32DLLInst = LoadLibraryW(L"Shell32.dll"); if(gShell32DLLInst) { gGetKnownFolderPath = (nsGetKnownFolderPath) diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index ce5d35364411..c4554a824e44 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -108,8 +108,8 @@ private: * HasMoreElements reads mLetter. * GetNext advances mLetter. */ - nsCString mDrives; - const char *mLetter; + nsString mDrives; + const PRUnichar *mLetter; }; //---------------------------------------------------------------------------- @@ -2952,7 +2952,7 @@ nsresult nsDriveEnumerator::Init() /* The string is null terminated */ if (!EnsureStringLength(mDrives, length+1)) return NS_ERROR_OUT_OF_MEMORY; - if (!GetLogicalDriveStrings(length, mDrives.BeginWriting())) + if (!GetLogicalDriveStringsW(length, mDrives.BeginWriting())) return NS_ERROR_FAILURE; mLetter = mDrives.get(); return NS_OK; @@ -2982,8 +2982,9 @@ NS_IMETHODIMP nsDriveEnumerator::GetNext(nsISupports **aNext) *aNext = nsnull; return NS_OK; } - NS_ConvertASCIItoUTF16 drive(mLetter); + nsString drive(mDrives); mLetter += drive.Length() + 1; + nsILocalFile *file; nsresult rv = NS_NewLocalFile(drive, PR_FALSE, &file); diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp index 21d45e1698e6..ebf8e02cad0d 100644 --- a/xpcom/threads/nsProcessCommon.cpp +++ b/xpcom/threads/nsProcessCommon.cpp @@ -106,10 +106,11 @@ nsProcess::Init(nsIFile* executable) #if defined(XP_WIN) -static int assembleCmdLine(char *const *argv, char **cmdLine) +static int assembleCmdLine(char *const *argv, PRUnichar **cmdLine) { char *const *arg; - char *p, *q; + PRUnichar *p; + char *q; int cmdLineSize; int numBackslashes; int i; @@ -131,7 +132,7 @@ static int assembleCmdLine(char *const *argv, char **cmdLine) + 2 /* we quote every argument */ + 1; /* space in between, or final null */ } - p = *cmdLine = (char *) PR_MALLOC(cmdLineSize); + p = *cmdLine = (PRUnichar *) PR_MALLOC(cmdLineSize*sizeof(PRUnichar)); if (p == NULL) { return -1; } @@ -237,10 +238,10 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count, my_argv[count+1] = NULL; #if defined(XP_WIN) && !defined (WINCE) /* wince uses nspr */ - STARTUPINFO startupInfo; + STARTUPINFOW startupInfo; PROCESS_INFORMATION procInfo; BOOL retVal; - char *cmdLine; + PRUnichar *cmdLine; if (assembleCmdLine(my_argv, &cmdLine) == -1) { nsMemory::Free(my_argv); @@ -250,20 +251,20 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count, ZeroMemory(&startupInfo, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); - retVal = CreateProcess(NULL, - // const_cast(mTargetPath.get()), - cmdLine, - NULL, /* security attributes for the new - * process */ - NULL, /* security attributes for the primary - * thread in the new process */ - FALSE, /* inherit handles */ - 0, /* creation flags */ - NULL, /* env */ - NULL, /* current drive and directory */ - &startupInfo, - &procInfo - ); + retVal = CreateProcessW(NULL, + // const_cast(mTargetPath.get()), + cmdLine, + NULL, /* security attributes for the new + * process */ + NULL, /* security attributes for the primary + * thread in the new process */ + FALSE, /* inherit handles */ + 0, /* creation flags */ + NULL, /* env */ + NULL, /* current drive and directory */ + &startupInfo, + &procInfo + ); PR_Free( cmdLine ); if (blocking) { diff --git a/xpcom/windbgdlg/Makefile.in b/xpcom/windbgdlg/Makefile.in index da1bcfae4993..b2dcc1ef9d9d 100644 --- a/xpcom/windbgdlg/Makefile.in +++ b/xpcom/windbgdlg/Makefile.in @@ -42,6 +42,8 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +OS_LIBS += shell32.lib + SIMPLE_PROGRAMS = windbgdlg$(BIN_SUFFIX) CPPSRCS = windbgdlg.cpp diff --git a/xpcom/windbgdlg/windbgdlg.cpp b/xpcom/windbgdlg/windbgdlg.cpp index 1a19f0165694..cef47730de49 100644 --- a/xpcom/windbgdlg/windbgdlg.cpp +++ b/xpcom/windbgdlg/windbgdlg.cpp @@ -42,6 +42,7 @@ #include #include +#include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -59,10 +60,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, DWORD regValue = -1; DWORD regLength = sizeof regValue; HKEY hkeyCU, hkeyLM; - RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU); - RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM); - const char * const * argv = __argv; - for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) { + RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU); + RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM); + int argc =0; + LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); + for (int i = argc - 1; regValue == (DWORD)-1 && i; --i) { bool ok = false; if (hkeyCU) ok = RegQueryValueEx(hkeyCU, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS; @@ -77,15 +79,15 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, RegCloseKey(hkeyLM); if (regValue != (DWORD)-1 && regValue != (DWORD)-2) return regValue; - static char msg[4048]; + static PRUnichar msg[4048]; wsprintf(msg, - "%s\n\nClick Abort to exit the Application.\n" - "Click Retry to Debug the Application..\n" - "Click Ignore to continue running the Application.", + L"%s\n\nClick Abort to exit the Application.\n" + L"Click Retry to Debug the Application..\n" + L"Click Ignore to continue running the Application.", lpszCmdLine); - return MessageBox(NULL, msg, "NSGlue_Assertion", + return MessageBoxW(NULL, msg, L"NSGlue_Assertion", MB_ICONSTOP | MB_SYSTEMMODAL| MB_ABORTRETRYIGNORE | MB_DEFBUTTON3); } diff --git a/xpfe/bootstrap/showOSAlert.cpp b/xpfe/bootstrap/showOSAlert.cpp index 7d0d70b02a48..346214fe61f5 100644 --- a/xpfe/bootstrap/showOSAlert.cpp +++ b/xpfe/bootstrap/showOSAlert.cpp @@ -39,6 +39,7 @@ #include #include #include "nscore.h" +#include "nsString.h" //defines and includes for previous installation cleanup process #if defined (XP_WIN) @@ -63,15 +64,18 @@ printf("\n****Inside ShowOSAlert ***\n"); #endif const PRInt32 max_len = 255; - char message_copy[max_len+1] = { 0 }; PRInt32 input_len = strlen(aMessage); PRInt32 copy_len = (input_len > max_len) ? max_len : input_len; +#if defined (XP_WIN) + NS_ConvertUTF8toUTF16 msg_str(aMessage, copy_len); + PRUnichar* message_copy = (PRUnichar*)msg_str.get(); + MessageBoxW(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND ); +#else + char message_copy[max_len+1] = { 0 }; strncpy(message_copy, aMessage, copy_len); message_copy[copy_len] = 0; - -#if defined (XP_WIN) - MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND ); -#elif (XP_MAC) +#endif +#if (XP_MAC) short buttonClicked; StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked); #elif defined (XP_OS2) From 75d375bd083cb7f41c800e538ea395c94b73c451 Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Wed, 5 Mar 2008 13:44:29 -0800 Subject: [PATCH 019/248] Bug 419865 Port scripts pane to use r=Mano,IanN sr=jag a=beltzner --- toolkit/content/widgets/preferences.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/content/widgets/preferences.xml b/toolkit/content/widgets/preferences.xml index a6859800bb58..2d4d55863f8d 100644 --- a/toolkit/content/widgets/preferences.xml +++ b/toolkit/content/widgets/preferences.xml @@ -396,7 +396,8 @@ else element.setAttribute(attribute, value); } - if (aElement.localName == "checkbox") + if (aElement.localName == "checkbox" || + aElement.localName == "listitem") setValue(aElement, "checked", val); else if (aElement.localName == "colorpicker") setValue(aElement, "color", val); @@ -444,7 +445,8 @@ return element[attribute]; return element.getAttribute(attribute); } - if (aElement.localName == "checkbox") + if (aElement.localName == "checkbox" || + aElement.localName == "listitem") var value = getValue(aElement, "checked"); else if (aElement.localName == "colorpicker") value = getValue(aElement, "color"); From 7b3cc60dbc75f2c891bcd0da78fa8ca72ddc5858 Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Wed, 5 Mar 2008 14:08:20 -0800 Subject: [PATCH 020/248] Bug 419111: unfrozen interfaces listed in SDK_XPIDLSRCS, r=kaie, sr=bzbarsky --- security/manager/boot/src/Makefile.in | 1 + security/manager/ssl/public/Makefile.in | 6 +++--- toolkit/components/build/Makefile.in | 1 + toolkit/components/url-classifier/src/Makefile.in | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/security/manager/boot/src/Makefile.in b/security/manager/boot/src/Makefile.in index 6c4d9e8cf25c..9eda9b0d8252 100644 --- a/security/manager/boot/src/Makefile.in +++ b/security/manager/boot/src/Makefile.in @@ -75,6 +75,7 @@ REQUIRES = nspr \ content \ caps \ pref \ + pipnss \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/security/manager/ssl/public/Makefile.in b/security/manager/ssl/public/Makefile.in index 0f864bf9413d..b3b4795c3253 100644 --- a/security/manager/ssl/public/Makefile.in +++ b/security/manager/ssl/public/Makefile.in @@ -51,17 +51,17 @@ GRE_MODULE = 1 SDK_XPIDLSRCS = \ nsIASN1Object.idl \ nsIASN1Sequence.idl \ - nsIBadCertListener2.idl \ - nsISSLErrorListener.idl \ nsICertificateDialogs.idl \ nsICRLInfo.idl \ nsIX509Cert.idl \ nsIX509CertDB.idl \ nsIX509CertValidity.idl \ - nsIIdentityInfo.idl \ $(NULL) XPIDLSRCS = \ + nsIBadCertListener2.idl \ + nsISSLErrorListener.idl \ + nsIIdentityInfo.idl \ nsICertOverrideService.idl \ nsIRecentBadCertsService.idl \ nsIFormSigningDialog.idl \ diff --git a/toolkit/components/build/Makefile.in b/toolkit/components/build/Makefile.in index 4a4b6ff386fd..736dddbdbc93 100644 --- a/toolkit/components/build/Makefile.in +++ b/toolkit/components/build/Makefile.in @@ -81,6 +81,7 @@ REQUIRES = \ xuldoc \ feeds \ storage \ + pipnss \ $(NULL) ifdef ALERTS_SERVICE diff --git a/toolkit/components/url-classifier/src/Makefile.in b/toolkit/components/url-classifier/src/Makefile.in index b342853e937c..1887795cd5b9 100644 --- a/toolkit/components/url-classifier/src/Makefile.in +++ b/toolkit/components/url-classifier/src/Makefile.in @@ -18,6 +18,7 @@ REQUIRES = docshell \ string \ uriloader \ xpcom \ + pipnss \ $(ZLIB_REQUIRES) \ $(NULL) From 28d29b3c84a1b6cc184a19f2c54fd95b5efd5af1 Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Wed, 5 Mar 2008 14:11:45 -0800 Subject: [PATCH 021/248] Bug 420328: don't trigger keyword matches if the keyword doesn't take a parameter and one was provided, r=rflint --- browser/base/content/browser.js | 7 +- browser/base/content/test/Makefile.in | 1 + .../content/test/browser_getshortcutoruri.js | 139 ++++++++++++++++++ 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 browser/base/content/test/browser_getshortcutoruri.js diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index d0c1b3be9ee4..fb9f19ebcc5a 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1736,9 +1736,14 @@ function getShortcutOrURI(aURL, aPostDataRef) { aPostDataRef.value = getPostDataStream(postData, param, encodedParam, "application/x-www-form-urlencoded"); } - else + else if (param) { + // This keyword doesn't take a parameter, but one was provided. Just return + // the original URL. aPostDataRef.value = null; + return aURL; + } + return shortcutURL; } diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 31ed5ce22cbd..cd0047826021 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -55,6 +55,7 @@ _BROWSER_FILES = browser_bug321000.js \ browser_autodiscovery.js \ autodiscovery.html \ moz.png \ + browser_getshortcutoruri.js \ $(NULL) libs:: $(_TEST_FILES) diff --git a/browser/base/content/test/browser_getshortcutoruri.js b/browser/base/content/test/browser_getshortcutoruri.js new file mode 100644 index 000000000000..a6d9a7e55103 --- /dev/null +++ b/browser/base/content/test/browser_getshortcutoruri.js @@ -0,0 +1,139 @@ +function makeURI(aURL, aOriginCharset, aBaseURI) { + var ioService = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + return ioService.newURI(aURL, aOriginCharset, aBaseURI); +} + +function getPostDataString(aIS) { + if (!aIS) + return null; + + var sis = Cc["@mozilla.org/scriptableinputstream;1"]. + createInstance(Ci.nsIScriptableInputStream); + sis.init(aIS); + var dataLines = sis.read(aIS.available()).split("\n"); + + // only want the last line + return dataLines[dataLines.length-1]; +} + +function keywordResult(aURL, aPostData) { + this.url = aURL; + this.postData = aPostData; +} + +function keyWordData() {} +keyWordData.prototype = { + init: function(aKeyWord, aURL, aPostData, aSearchWord) { + this.keyword = aKeyWord; + this.uri = makeURI(aURL); + this.postData = aPostData; + this.searchWord = aSearchWord; + + this.method = (this.postData ? "POST" : "GET"); + } +} + +function bmKeywordData(aKeyWord, aURL, aPostData, aSearchWord) { + this.init(aKeyWord, aURL, aPostData, aSearchWord); +} +bmKeywordData.prototype = new keyWordData(); + +function searchKeywordData(aKeyWord, aURL, aPostData, aSearchWord) { + this.init(aKeyWord, aURL, aPostData, aSearchWord); +} +searchKeywordData.prototype = new keyWordData(); + +var testData = [ + [new bmKeywordData("bmget", "http://bmget/search=%s", null, "foo"), + new keywordResult("http://bmget/search=foo", null)], + + [new bmKeywordData("bmpost", "http://bmpost/", "search=%s", "foo2"), + new keywordResult("http://bmpost/", "search=foo2")], + + [new bmKeywordData("bmpostget", "http://bmpostget/search1=%s", "search2=%s", "foo3"), + new keywordResult("http://bmpostget/search1=foo3", "search2=foo3")], + + [new bmKeywordData("bmget-nosearch", "http://bmget-nosearch/", null, ""), + new keywordResult("http://bmget-nosearch/", null)], + + [new searchKeywordData("searchget", "http://searchget/?search={searchTerms}", null, "foo4"), + new keywordResult("http://searchget/?search=foo4", null)], + + [new searchKeywordData("searchpost", "http://searchpost/", "search={searchTerms}", "foo5"), + new keywordResult("http://searchpost/", "search=foo5")], + + [new searchKeywordData("searchpostget", "http://searchpostget/?search1={searchTerms}", "search2={searchTerms}", "foo6"), + new keywordResult("http://searchpostget/?search1=foo6", "search2=foo6")], + + // Bookmark keywords that don't take parameters should not be activated if a + // parameter is passed (bug 420328). + [new bmKeywordData("bmget-noparam", "http://bmget-noparam/", null, "foo7"), + new keywordResult(null, null)], + [new bmKeywordData("bmpost-noparam", "http://bmpost-noparam/", "not_a=param", "foo8"), + new keywordResult(null, null)], + + // Test escaping (%s = escaped, %S = raw) + // UTF-8 default + [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "foé"), + new keywordResult("http://bmget/?esc=fo%C3%A9&raw=foé", null)], + // Explicitly-defined ISO-8859-1 + [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"), + new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)], +]; + +function test() { + setupKeywords(); + + for each (var item in testData) { + var [data, result] = item; + + var postData = {}; + var query = data.keyword; + if (data.searchWord) + query += " " + data.searchWord; + var url = getShortcutOrURI(query, postData); + + // null result.url means we should expect the same query we sent in + var expected = result.url || query; + is(url, expected, "got correct URL for " + data.keyword); + is(getPostDataString(postData.value), result.postData, "got correct postData for " + data.keyword); + } + + cleanupKeywords(); +} + +var gBMFolder = null; +var gAddedEngines = []; +function setupKeywords() { + var searchService = Cc["@mozilla.org/browser/search-service;1"]. + getService(Ci.nsIBrowserSearchService); + gBMFolder = Application.bookmarks.addFolder("keyword-test"); + for each (var item in testData) { + var data = item[0]; + if (data instanceof bmKeywordData) { + var bm = gBMFolder.addBookmark(data.keyword, data.uri); + bm.keyword = data.keyword; + if (data.postData) + bm.annotations.set("bookmarkProperties/POSTData", data.postData, Ci.nsIAnnotationService.EXPIRE_SESSION); + } + + if (data instanceof searchKeywordData) { + searchService.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec); + var addedEngine = searchService.getEngineByName(data.keyword); + if (data.postData) { + var [paramName, paramValue] = data.postData.split("="); + addedEngine.addParam(paramName, paramValue, null); + } + + gAddedEngines.push(addedEngine); + } + } +} + +function cleanupKeywords() { + var searchService = Cc["@mozilla.org/browser/search-service;1"]. + getService(Ci.nsIBrowserSearchService); + gBMFolder.remove(); + gAddedEngines.map(searchService.removeEngine); +} From 21f2f90b8b7e9357170609402e192a4aa7cd483a Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Wed, 5 Mar 2008 14:13:41 -0800 Subject: [PATCH 022/248] Bug 420549: don't ASSERT when removing an engine shortly after adding it, r=mano, a=beltzner --- browser/components/search/nsSearchService.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/browser/components/search/nsSearchService.js b/browser/components/search/nsSearchService.js index 70309fa7bad0..b6bf6c5349dc 100755 --- a/browser/components/search/nsSearchService.js +++ b/browser/components/search/nsSearchService.js @@ -2754,6 +2754,12 @@ SearchService.prototype = { engineToRemove.hidden = true; engineToRemove.alias = null; } else { + // Cancel the lazy serialization timer if it's running + if (engineToRemove._serializeTimer) { + engineToRemove._serializeTimer.cancel(); + engineToRemove._serializeTimer = null; + } + // Remove the engine file from disk (this might throw) engineToRemove._remove(); engineToRemove._file = null; From c1b3fd34a20de3cc149f3d8c556cf4abf4cd81c3 Mon Sep 17 00:00:00 2001 From: "myk@mozilla.org" Date: Wed, 5 Mar 2008 14:26:13 -0800 Subject: [PATCH 023/248] bug 420556: give sidebar header a non-transparent background in gnomestripe; r=gavin, a=beltzner --- toolkit/themes/gnomestripe/global/global.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/toolkit/themes/gnomestripe/global/global.css b/toolkit/themes/gnomestripe/global/global.css index 12d524f2f5da..3c23f6edb2a1 100644 --- a/toolkit/themes/gnomestripe/global/global.css +++ b/toolkit/themes/gnomestripe/global/global.css @@ -174,11 +174,8 @@ resizer[dir="bottomright"] { /* XXXBlake yeah, shoot me -- these don't belong here. I'll move them later. */ sidebarheader { - -moz-appearance: toolbox; height: 25px; background-color: -moz-Dialog; - border-bottom: 1px solid ThreeDShadow; - border-top: 1px solid ThreeDHighlight; } sidebarheader > label { From 212762193f1788ba0e52e93251ee73a2dfdef9c0 Mon Sep 17 00:00:00 2001 From: "myk@mozilla.org" Date: Wed, 5 Mar 2008 14:34:54 -0800 Subject: [PATCH 024/248] bug 376222: a javascript exception thrown by an extension's (or core code's) web progress listener shouldn't interfere with the normal operation of tabbed browsing (i.e. other progress listeners); Patch by John P. Baker; r=gavin, a=beltzner --- browser/base/content/tabbrowser.xml | 94 ++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 27 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 2efac86817a5..cae3012c231e 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -297,9 +297,13 @@ for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; if (p) - p.onProgressChange(aWebProgress, aRequest, - aCurSelfProgress, aMaxSelfProgress, - aCurTotalProgress, aMaxTotalProgress); + try { + p.onProgressChange(aWebProgress, aRequest, + aCurSelfProgress, aMaxSelfProgress, + aCurTotalProgress, aMaxTotalProgress); + } catch (e) { + // don't inhibit other listeners or following code + } } } @@ -398,11 +402,16 @@ if (this.mTabBrowser.mCurrentTab == this.mTab) { for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; - if (p && !oldBlank) - p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus); - // make sure that the visible status of new blank tabs is correctly set - else if (p && "onUpdateCurrentBrowser" in p) - p.onUpdateCurrentBrowser(aStateFlags, aStatus, "", 0); + if (p) + try { + if (!oldBlank) + p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus); + // make sure that the visible status of new blank tabs is correctly set + else if ("onUpdateCurrentBrowser" in p) + p.onUpdateCurrentBrowser(aStateFlags, aStatus, "", 0); + } catch (e) { + // don't inhibit other listeners or following code + } } } @@ -433,7 +442,11 @@ for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; if (p) - p.onLocationChange(aWebProgress, aRequest, aLocation); + try { + p.onLocationChange(aWebProgress, aRequest, aLocation); + } catch (e) { + // don't inhibit other listeners + } } } }, @@ -447,7 +460,11 @@ for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; if (p) - p.onStatusChange(aWebProgress, aRequest, aStatus, aMessage); + try { + p.onStatusChange(aWebProgress, aRequest, aStatus, aMessage); + } catch (e) { + // don't inhibit other listeners or following code + } } } @@ -460,7 +477,11 @@ for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; if (p) - p.onSecurityChange(aWebProgress, aRequest, aState); + try { + p.onSecurityChange(aWebProgress, aRequest, aState); + } catch (e) { + // don't inhibit other listeners + } } } }, @@ -471,8 +492,12 @@ for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) { var p = this.mTabBrowser.mProgressListeners[i]; if (p && "onRefreshAttempted" in p) { - if (!p.onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI)) - allowRefresh = false; + try { + if (!p.onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI)) + allowRefresh = false; + } catch (e) { + // don't inhibit other listeners or following code + } } } return allowRefresh; @@ -515,7 +540,11 @@ for (var i = 0; i < this.mProgressListeners.length; i++) { var p = this.mProgressListeners[i]; if ('onLinkIconAvailable' in p) - p.onLinkIconAvailable(browser); + try { + p.onLinkIconAvailable(browser); + } catch (e) { + // don't inhibit other listeners + } } ]]> @@ -737,19 +766,22 @@ var i, p; for (i = 0; i < this.mProgressListeners.length; i++) { p = this.mProgressListeners[i]; - if (p) { - p.onLocationChange(webProgress, null, loc); - if (securityUI) - p.onSecurityChange(webProgress, null, securityUI.state); + if (p) + try { + p.onLocationChange(webProgress, null, loc); + if (securityUI) + p.onSecurityChange(webProgress, null, securityUI.state); - // make sure that all status indicators are properly updated - if ("onUpdateCurrentBrowser" in p) { - var listener = this.mTabListeners[this.mTabContainer.selectedIndex] || null; - if (listener && listener.mStateFlags) - p.onUpdateCurrentBrowser(listener.mStateFlags, listener.mStatus, - listener.mMessage, listener.mTotalProgress); + // make sure that all status indicators are properly updated + if ("onUpdateCurrentBrowser" in p) { + var listener = this.mTabListeners[this.mTabContainer.selectedIndex] || null; + if (listener && listener.mStateFlags) + p.onUpdateCurrentBrowser(listener.mStateFlags, listener.mStatus, + listener.mMessage, listener.mTotalProgress); + } + } catch (e) { + // don't inhibit other listeners or following code } - } } this._fastFind.setDocShell(this.mCurrentBrowser.docShell); @@ -766,7 +798,11 @@ for (i = 0; i < this.mProgressListeners.length; i++) { p = this.mProgressListeners[i]; if (p) - p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_START | nsIWebProgressListener.STATE_IS_NETWORK, 0); + try { + p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_START | nsIWebProgressListener.STATE_IS_NETWORK, 0); + } catch (e) { + // don't inhibit other listeners or following code + } } } @@ -778,7 +814,11 @@ for (i = 0; i < this.mProgressListeners.length; i++) { p = this.mProgressListeners[i]; if (p) - p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0); + try { + p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0); + } catch (e) { + // don't inhibit other listeners or following code + } } } From 81d841c1fc0673478b51d3df81a78830d790582a Mon Sep 17 00:00:00 2001 From: "blassey@mozilla.com" Date: Wed, 5 Mar 2008 14:56:43 -0800 Subject: [PATCH 025/248] backing out b=418703, caused test 40118 to fail on WINNT 5.2 qm-win2k3-01 dep unit test tinderbox --- accessible/src/msaa/nsAccessNodeWrap.cpp | 2 +- accessible/src/msaa/nsAccessibleWrap.cpp | 2 +- browser/app/nsBrowserApp.cpp | 8 +- .../migration/src/nsIEProfileMigrator.cpp | 13 +- .../shell/src/nsWindowsShellService.cpp | 8 +- db/mork/src/morkFile.cpp | 10 + .../activex/src/plugin/LegacyPlugin.cpp | 3 +- .../activex/src/plugin/XPCDocument.cpp | 2 +- .../browser/activex/src/plugin/XPConnect.cpp | 2 +- extensions/auth/nsAuthSSPI.cpp | 34 +-- gfx/src/thebes/nsSystemFontsWin.cpp | 10 +- gfx/src/thebes/nsSystemFontsWin.h | 3 +- gfx/src/windows/nsDeviceContextWin.cpp | 2 +- gfx/src/windows/nsDeviceContextWin.h | 3 +- gfx/src/windows/nsFontMetricsWin.cpp | 33 ++- gfx/thebes/src/gfxWindowsFonts.cpp | 4 +- gfx/thebes/src/gfxWindowsSurface.cpp | 34 ++- intl/uconv/src/nsWinCharset.cpp | 6 +- ipc/ipcd/client/src/ipcConnectionWin.cpp | 2 +- .../decoders/icon/win/nsIconChannel.cpp | 34 ++- .../libpr0n/decoders/icon/win/nsIconChannel.h | 2 +- modules/oji/src/scd.cpp | 2 +- .../base/src/nsPluginDirServiceProvider.cpp | 229 +++++++++--------- modules/plugin/base/src/nsPluginHostImpl.cpp | 12 +- .../base/src/nsPluginNativeWindowWin.cpp | 10 +- modules/plugin/base/src/nsPluginsDirWin.cpp | 67 ++--- .../samples/default/windows/dialogs.cpp | 45 ++-- .../samples/default/windows/npshell.cpp | 14 +- .../plugin/samples/default/windows/plugin.cpp | 105 ++++---- .../plugin/samples/default/windows/plugin.h | 6 +- .../plugin/samples/default/windows/utils.cpp | 65 +++-- .../plugin/samples/default/windows/utils.h | 2 +- .../sdk/samples/basic/windows/plugin.cpp | 4 +- .../sdk/samples/scriptable/windows/plugin.cpp | 4 +- rdf/datasource/src/nsFileSystemDataSource.cpp | 7 +- .../components/startup/src/nsUserInfoWin.cpp | 9 +- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 14 +- .../exthandler/win/nsOSHelperAppService.cpp | 4 +- widget/src/windows/nsAppShell.cpp | 14 +- widget/src/windows/nsBidiKeyboard.cpp | 31 ++- widget/src/windows/nsBidiKeyboard.h | 6 +- widget/src/windows/nsClipboard.cpp | 8 +- widget/src/windows/nsDataObj.h | 8 +- widget/src/windows/nsFilePicker.cpp | 8 +- widget/src/windows/nsLookAndFeel.cpp | 8 +- widget/src/windows/nsNativeThemeWin.cpp | 4 +- widget/src/windows/nsSound.cpp | 10 +- widget/src/windows/nsToolkit.cpp | 6 +- widget/src/windows/nsWindow.cpp | 34 ++- widget/src/windows/nsWindow.h | 7 - xpcom/base/nsDebugImpl.cpp | 27 +-- xpcom/base/nsStackWalk.cpp | 4 +- xpcom/io/SpecialSystemDirectory.cpp | 2 +- xpcom/io/nsLocalFileWin.cpp | 9 +- xpcom/threads/nsProcessCommon.cpp | 39 ++- xpcom/windbgdlg/Makefile.in | 2 - xpcom/windbgdlg/windbgdlg.cpp | 20 +- xpfe/bootstrap/showOSAlert.cpp | 14 +- 58 files changed, 551 insertions(+), 526 deletions(-) diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index 96ebfdb0696b..575a26485b85 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -576,7 +576,7 @@ void nsAccessNodeWrap::InitAccessibility() } if (!gmUserLib) { - gmUserLib =::LoadLibraryW(L"USER32.DLL"); + gmUserLib =::LoadLibrary("USER32.DLL"); } if (gmUserLib) { diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index 8e45c5feed43..ee3adfbb40d2 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -156,7 +156,7 @@ STDMETHODIMP nsAccessibleWrap::AccessibleObjectFromWindow(HWND hwnd, { // open the dll dynamically if (!gmAccLib) - gmAccLib =::LoadLibraryW(L"OLEACC.DLL"); + gmAccLib =::LoadLibrary("OLEACC.DLL"); if (gmAccLib) { if (!gmAccessibleObjectFromWindow) diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index 6e7c518b366c..0c867f701ffc 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -64,9 +64,11 @@ static void Output(const char *fmt, ... ) va_start(ap, fmt); #if defined(XP_WIN) && !MOZ_WINCONSOLE - PRUnichar msg[2048]; - _vsnwprintf(msg, sizeof(msg), NS_ConvertUTF8toUTF16(fmt).get(), ap); - MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR); + char msg[2048]; + + _vsnprintf(msg, sizeof(msg), fmt, ap); + + MessageBox(NULL, msg, "XULRunner", MB_OK | MB_ICONERROR); #else vfprintf(stderr, fmt, ap); #endif diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp index 9cb7ef0102ab..500d66caeaf9 100644 --- a/browser/components/migration/src/nsIEProfileMigrator.cpp +++ b/browser/components/migration/src/nsIEProfileMigrator.cpp @@ -867,7 +867,7 @@ nsIEProfileMigrator::CopyPasswords(PRBool aReplace) nsresult rv; nsVoidArray signonsFound; - HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll"); + HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll"); if (!pstoreDLL) { // XXXben TODO // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read @@ -1177,7 +1177,7 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace) { HRESULT hr; - HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll"); + HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll"); if (!pstoreDLL) { // XXXben TODO // Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read @@ -1410,19 +1410,20 @@ nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL) { HRESULT result; - IUniformResourceLocatorW* urlLink = nsnull; + IUniformResourceLocator* urlLink = nsnull; result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, - IID_IUniformResourceLocatorW, (void**)&urlLink); + IID_IUniformResourceLocator, (void**)&urlLink); if (SUCCEEDED(result) && urlLink) { IPersistFile* urlFile = nsnull; result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile); if (SUCCEEDED(result) && urlFile) { result = urlFile->Load(aFileName.get(), STGM_READ); if (SUCCEEDED(result) ) { - LPWSTR lpTemp = nsnull; + LPSTR lpTemp = nsnull; result = urlLink->GetURL(&lpTemp); if (SUCCEEDED(result) && lpTemp) { - *aOutURL = *aOutURL = (char*)ToNewUTF8String(nsDependentString(lpTemp)); + *aOutURL = PL_strdup(lpTemp); + // free the string that GetURL alloc'd ::CoTaskMemFree(lpTemp); } diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 30c716af3b0b..65b58570062b 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -396,8 +396,8 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs rv = appHelper->AppendNative(NS_LITERAL_CSTRING("helper.exe")); NS_ENSURE_SUCCESS(rv, rv); - nsAutoString appHelperPath; - rv = appHelper->GetPath(appHelperPath); + nsCAutoString appHelperPath; + rv = appHelper->GetNativePath(appHelperPath); NS_ENSURE_SUCCESS(rv, rv); if (aForAllUsers) { @@ -406,10 +406,10 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs appHelperPath.AppendLiteral(" /SetAsDefaultAppUser"); } - STARTUPINFOW si = {sizeof(si), 0}; + STARTUPINFO si = {sizeof(si), 0}; PROCESS_INFORMATION pi = {0}; - BOOL ok = CreateProcessW(NULL, (LPWSTR)appHelperPath.get(), NULL, NULL, + BOOL ok = CreateProcess(NULL, (LPSTR)appHelperPath.get(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); if (!ok) diff --git a/db/mork/src/morkFile.cpp b/db/mork/src/morkFile.cpp index a3167afa0952..011056fa81ba 100644 --- a/db/mork/src/morkFile.cpp +++ b/db/mork/src/morkFile.cpp @@ -929,6 +929,16 @@ morkStdioFile::Steal(nsIMdbEnv* ev, nsIMdbFile* ioThief) void mork_fileflush(FILE * file) { fflush(file); +#ifndef WINCE + OSVERSIONINFOA vi = { sizeof(OSVERSIONINFOA) }; + if ((GetVersionExA(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)) + { + // Win9x/ME + int fd = fileno(file); + HANDLE fh = (HANDLE)_get_osfhandle(fd); + FlushFileBuffers(fh); + } +#endif } #endif /*MORK_WIN*/ diff --git a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp index f0044c2217c4..8ab3fe738dc5 100644 --- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp +++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp @@ -303,7 +303,8 @@ ShowError(MozAxPluginErrors errorCode, const CLSID &clsid) LPOLESTR szClsid; StringFromCLSID(clsid, &szClsid); _sntprintf(szBuffer, kBufSize - 1, - _T("Could not create the control %s. Check that it has been installed on your computer and that this page correctly references it."), OLE2T(szClsid)); + _T("Could not create the control %s. Check that it has been installed on your computer " + "and that this page correctly references it."), OLE2T(szClsid)); CoTaskMemFree(szClsid); szMsg = szBuffer; } diff --git a/embedding/browser/activex/src/plugin/XPCDocument.cpp b/embedding/browser/activex/src/plugin/XPCDocument.cpp index 60f9c86a6b61..1c6a9235ae02 100644 --- a/embedding/browser/activex/src/plugin/XPCDocument.cpp +++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp @@ -1915,7 +1915,7 @@ END_COM_MAP() NS_SUCCEEDED(baseURI->GetSpec(spec))) { USES_CONVERSION; - if (FAILED(CreateURLMoniker(NULL, A2CW(spec.get()), &baseURLMoniker))) + if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker))) return E_UNEXPECTED; } } diff --git a/embedding/browser/activex/src/plugin/XPConnect.cpp b/embedding/browser/activex/src/plugin/XPConnect.cpp index 0620194ed363..c5dc232d4672 100644 --- a/embedding/browser/activex/src/plugin/XPConnect.cpp +++ b/embedding/browser/activex/src/plugin/XPConnect.cpp @@ -372,7 +372,7 @@ nsScriptablePeer::ConvertVariants(VARIANT *aIn, nsIVariant **aOut) { // do_CreateInstance macro is broken so load the component manager by // hand and get it to create the component. - HMODULE hlib = ::LoadLibraryW(L"xpcom.dll"); + HMODULE hlib = ::LoadLibrary("xpcom.dll"); if (hlib) { nsIComponentManager *pManager = nsnull; // A frozen interface, even in 1.0.x diff --git a/extensions/auth/nsAuthSSPI.cpp b/extensions/auth/nsAuthSSPI.cpp index 353d3b8219c5..ca70729e7c5d 100644 --- a/extensions/auth/nsAuthSSPI.cpp +++ b/extensions/auth/nsAuthSSPI.cpp @@ -52,8 +52,6 @@ #include "nsNetCID.h" #include "nsCOMPtr.h" -#include - #define SEC_SUCCESS(Status) ((Status) >= 0) #ifndef KERB_WRAP_NO_ENCRYPT @@ -105,25 +103,25 @@ static const char *MapErrorCode(int rc) //----------------------------------------------------------------------------- static HINSTANCE sspi_lib; -static PSecurityFunctionTableW sspi; +static PSecurityFunctionTable sspi; static nsresult InitSSPI() { - PSecurityFunctionTableW (*initFun)(void); + PSecurityFunctionTable (*initFun)(void); LOG((" InitSSPI\n")); - sspi_lib = LoadLibraryW(L"secur32.dll"); + sspi_lib = LoadLibrary("secur32.dll"); if (!sspi_lib) { - sspi_lib = LoadLibraryW(L"security.dll"); + sspi_lib = LoadLibrary("security.dll"); if (!sspi_lib) { LOG(("SSPI library not found")); return NS_ERROR_UNEXPECTED; } } - initFun = (PSecurityFunctionTableW (*)(void)) + initFun = (PSecurityFunctionTable (*)(void)) GetProcAddress(sspi_lib, "InitSecurityInterfaceA"); if (!initFun) { LOG(("InitSecurityInterfaceA not found")); @@ -244,9 +242,11 @@ nsAuthSSPI::Init(const char *serviceName, if (NS_FAILED(rv)) return rv; } - SEC_WCHAR *package; - package = (SEC_WCHAR *) pTypeName[(int)mPackage]; + SEC_CHAR *package; + + package = (SEC_CHAR *) pTypeName[(int)mPackage]; + if (mPackage != PACKAGE_TYPE_NTLM) { rv = MakeSN(serviceName, mServiceName); @@ -257,8 +257,8 @@ nsAuthSSPI::Init(const char *serviceName, SECURITY_STATUS rc; - PSecPkgInfoW pinfo; - rc = (sspi->QuerySecurityPackageInfoW)(package, &pinfo); + PSecPkgInfo pinfo; + rc = (sspi->QuerySecurityPackageInfo)(package, &pinfo); if (rc != SEC_E_OK) { LOG(("%s package not found\n", package)); return NS_ERROR_UNEXPECTED; @@ -268,7 +268,7 @@ nsAuthSSPI::Init(const char *serviceName, TimeStamp useBefore; - rc = (sspi->AcquireCredentialsHandleW)(NULL, + rc = (sspi->AcquireCredentialsHandle)(NULL, package, SECPKG_CRED_OUTBOUND, NULL, @@ -336,13 +336,15 @@ nsAuthSSPI::GetNextToken(const void *inToken, if (!ob.pvBuffer) return NS_ERROR_OUT_OF_MEMORY; memset(ob.pvBuffer, 0, ob.cbBuffer); - SEC_WCHAR *sn; + + SEC_CHAR *sn; + if (mPackage == PACKAGE_TYPE_NTLM) sn = NULL; else - sn = (SEC_WCHAR *) mServiceName.get(); + sn = (SEC_CHAR *) mServiceName.get(); - rc = (sspi->InitializeSecurityContextW)(&mCred, + rc = (sspi->InitializeSecurityContext)(&mCred, ctxIn, sn, ctxReq, @@ -459,7 +461,7 @@ nsAuthSSPI::Wrap(const void *inToken, secBuffers bufs; SecPkgContext_Sizes sizes; - rc = (sspi->QueryContextAttributesW)( + rc = (sspi->QueryContextAttributes)( &mCtxt, SECPKG_ATTR_SIZES, &sizes); diff --git a/gfx/src/thebes/nsSystemFontsWin.cpp b/gfx/src/thebes/nsSystemFontsWin.cpp index f84f184ca427..f53f06ae1028 100644 --- a/gfx/src/thebes/nsSystemFontsWin.cpp +++ b/gfx/src/thebes/nsSystemFontsWin.cpp @@ -44,12 +44,18 @@ nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsString *aFontName, - gfxFontStyle *aFontStyle) const + nsString *aFontName, + gfxFontStyle *aFontStyle, + PRBool aIsWide) const { PRUnichar name[LF_FACESIZE]; name[0] = 0; + if (aIsWide) memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2); + else { + MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName, + strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0])); + } *aFontName = name; // Do Style diff --git a/gfx/src/thebes/nsSystemFontsWin.h b/gfx/src/thebes/nsSystemFontsWin.h index 2d98724b9bd4..a8a047e0ed42 100644 --- a/gfx/src/thebes/nsSystemFontsWin.h +++ b/gfx/src/thebes/nsSystemFontsWin.h @@ -51,7 +51,8 @@ public: gfxFontStyle *aFontStyle) const; private: nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsString *aFontName, gfxFontStyle *aFontStyle) const; + nsString *aFontName, gfxFontStyle *aFontStyle, + PRBool aIsWide = PR_FALSE) const; nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsString *aFontName, gfxFontStyle *aFontStyle) const; diff --git a/gfx/src/windows/nsDeviceContextWin.cpp b/gfx/src/windows/nsDeviceContextWin.cpp index 2afffa42daee..28e157363609 100644 --- a/gfx/src/windows/nsDeviceContextWin.cpp +++ b/gfx/src/windows/nsDeviceContextWin.cpp @@ -310,7 +310,7 @@ NS_IMETHODIMP nsDeviceContextWin :: SetCanonicalPixelScale(float aScale) nsresult nsDeviceContextWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, - nsFont* aFont) const + nsFont* aFont, PRBool aIsWide) const { PRUnichar name[LF_FACESIZE]; name[0] = 0; diff --git a/gfx/src/windows/nsDeviceContextWin.h b/gfx/src/windows/nsDeviceContextWin.h index 291e6a6c25a9..6a02af01b934 100644 --- a/gfx/src/windows/nsDeviceContextWin.h +++ b/gfx/src/windows/nsDeviceContextWin.h @@ -101,7 +101,8 @@ protected: void ComputeFullAreaUsingScreen ( nsRect* outRect ) ; nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const; - nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont) const; + nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont, + PRBool aIsWide = PR_FALSE) const; PRBool mCachedClientRect; PRBool mCachedFullRect; diff --git a/gfx/src/windows/nsFontMetricsWin.cpp b/gfx/src/windows/nsFontMetricsWin.cpp index a066ddc67f74..d6fbf78a31e4 100644 --- a/gfx/src/windows/nsFontMetricsWin.cpp +++ b/gfx/src/windows/nsFontMetricsWin.cpp @@ -2121,9 +2121,40 @@ nsGlyphAgent::GetGlyphMetrics(HDC aDC, GLYPHMETRICS* aGlyphMetrics) { memset(aGlyphMetrics, 0, sizeof(GLYPHMETRICS)); // UMR: bug 46438 + if (eGlyphAgent_UNKNOWN == mState) { // first time we have been in this function + // see if this platform implements GetGlyphOutlineW() + DWORD len = GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat); + if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { + // next time, we won't bother trying GetGlyphOutlineW() + mState = eGlyphAgent_ANSI; + } + else { + // all is well with GetGlyphOutlineW(), we will be using it from now on mState = eGlyphAgent_UNICODE; - return GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat); + return len; + } + } + if (eGlyphAgent_UNICODE == mState) { + return GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat); + } + + // Otherwise, we are on a platform that doesn't implement GetGlyphOutlineW() + // (see Q241358: The GetGlyphOutlineW Function Fails on Windows 95 & 98 + // http://support.microsoft.com/support/kb/articles/Q241/3/58.ASP) + // we will use glyph indices as a work around. + if (0 == aGlyphIndex) { // caller doesn't know the glyph index, so find it + nsAutoChar16Buffer buf; + if (NS_SUCCEEDED(GetGlyphIndices(aDC, nsnull, &aChar, 1, buf))) + aGlyphIndex = *(buf.Elements()); + } + if (0 < aGlyphIndex) { + return GetGlyphOutlineA(aDC, aGlyphIndex, GGO_METRICS | GGO_GLYPH_INDEX, aGlyphMetrics, 0, nsnull, &mMat); + } + + // if we ever reach here, something went wrong in GetGlyphIndices() above + // because the current font in aDC wasn't a Unicode font + return GDI_ERROR; } // the global glyph agent that we will be using diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index 63e3837cfe2b..c20abc171041 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -340,13 +340,13 @@ gfxWindowsFont::ComputeMetrics() // Cache the width of a single space. SIZE size; - GetTextExtentPoint32W(dc, L" ", 1, &size); + GetTextExtentPoint32(dc, " ", 1, &size); mMetrics->spaceWidth = ROUND(size.cx); mSpaceGlyph = 0; if (metrics.tmPitchAndFamily & TMPF_TRUETYPE) { WORD glyph; - DWORD ret = GetGlyphIndicesW(dc, L" ", 1, &glyph, + DWORD ret = GetGlyphIndicesA(dc, " ", 1, &glyph, GGI_MARK_NONEXISTING_GLYPHS); if (ret != GDI_ERROR && glyph != 0xFFFF) { mSpaceGlyph = glyph; diff --git a/gfx/thebes/src/gfxWindowsSurface.cpp b/gfx/thebes/src/gfxWindowsSurface.cpp index 83cf0ff9533f..a2a7c8a636ae 100644 --- a/gfx/thebes/src/gfxWindowsSurface.cpp +++ b/gfx/thebes/src/gfxWindowsSurface.cpp @@ -168,11 +168,27 @@ gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat return raw; } +static char* +GetACPString(const nsAString& aStr) +{ + int acplen = aStr.Length() * 2 + 1; + char * acp = new char[acplen]; + if(acp) { + int outlen = ::WideCharToMultiByte(CP_ACP, 0, + PromiseFlatString(aStr).get(), + aStr.Length(), + acp, acplen, NULL, NULL); + if (outlen > 0) + acp[outlen] = '\0'; // null terminate + } + return acp; +} + nsresult gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName) { #define DOC_TITLE_LENGTH 30 - DOCINFOW docinfo; + DOCINFO docinfo; nsString titleStr; titleStr = aTitle; @@ -180,21 +196,23 @@ nsresult gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, titleStr.SetLength(DOC_TITLE_LENGTH-3); titleStr.AppendLiteral("..."); } - nsPromiseFlatString flatTitleStr(titleStr); - const PRUnichar *title = (const PRUnichar*)(flatTitleStr.get()); - const PRUnichar *docName = nsnull; - nsPromiseFlatString printToFileNameStr(aPrintToFileName); + char *title = GetACPString(titleStr); + + char *docName = nsnull; if (!aPrintToFileName.IsEmpty()) { - docName = (const PRUnichar*)(printToFileNameStr.get()); + docName = ToNewCString(aPrintToFileName); } + docinfo.cbSize = sizeof(docinfo); - docinfo.lpszDocName = title ? title : L"Mozilla Document"; + docinfo.lpszDocName = title ? title : "Mozilla Document"; docinfo.lpszOutput = docName; docinfo.lpszDatatype = NULL; docinfo.fwType = 0; - ::StartDocW(mDC, &docinfo); + ::StartDoc(mDC, &docinfo); + delete [] title; + if (docName != nsnull) nsMemory::Free(docName); return NS_OK; } diff --git a/intl/uconv/src/nsWinCharset.cpp b/intl/uconv/src/nsWinCharset.cpp index 3fdb83dced4a..c3eae316a334 100644 --- a/intl/uconv/src/nsWinCharset.cpp +++ b/intl/uconv/src/nsWinCharset.cpp @@ -133,7 +133,7 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS { nsCOMPtr winLocale; LCID localeAsLCID; - PRUnichar acp_name[6]; + char acp_name[6]; // // convert locale name to a code page (through the LCID) @@ -147,11 +147,11 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID); if (NS_FAILED(rv)) { return rv; } - if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { + if (GetLocaleInfo(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { return NS_ERROR_FAILURE; } nsAutoString acp_key(NS_LITERAL_STRING("acp.")); - acp_key.Append(acp_name); + acp_key.AppendWithConversion(acp_name); return MapToCharset(acp_key, oResult); } diff --git a/ipc/ipcd/client/src/ipcConnectionWin.cpp b/ipc/ipcd/client/src/ipcConnectionWin.cpp index b6ac516ff176..9a99c1956b5c 100644 --- a/ipc/ipcd/client/src/ipcConnectionWin.cpp +++ b/ipc/ipcd/client/src/ipcConnectionWin.cpp @@ -112,7 +112,7 @@ ipcThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) cd.dwData = GetCurrentProcessId(); cd.cbData = (DWORD) msg->MsgLen(); cd.lpData = (PVOID) msg->MsgBuf(); - SendMessage(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd); + SendMessageA(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd); LOG((" done.\n")); delete msg; } diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index 5e1bc11c6eab..e0e896a57d17 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -63,7 +63,6 @@ #include #include #include -#include struct ICONFILEHEADER { PRUint16 ifhReserved; @@ -190,7 +189,7 @@ nsIconChannel::Open(nsIInputStream **_retval) return MakeInputStream(_retval, PR_FALSE); } -nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension) +nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension) { nsresult rv = NS_OK; nsCOMPtr iconURI (do_QueryInterface(mUrl, &rv)); @@ -237,28 +236,29 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports return rv; } -static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI, UINT aInfoFlags) +static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFO* aSFI, UINT aInfoFlags) { DWORD shellResult = 0; if (!aFile) return shellResult; - PRUnichar fileNativePath[MAX_PATH]; - nsAutoString fileNativePathStr; - aFile->GetPath(fileNativePathStr); - ::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath)); + char fileNativePath[MAX_PATH]; + nsCAutoString fileNativePathStr; + aFile->GetNativePath(fileNativePathStr); + ::GetShortPathName(fileNativePathStr.get(), fileNativePath, sizeof(fileNativePath)); LPITEMIDLIST idList; HRESULT hr = ::SHGetSpecialFolderLocation(NULL, aFolder, &idList); if (SUCCEEDED(hr)) { - PRUnichar specialNativePath[MAX_PATH]; - ::SHGetPathFromIDListW(idList, specialNativePath); - ::GetShortPathNameW(specialNativePath, specialNativePath, sizeof(specialNativePath)); - if (!wcsicmp(fileNativePath,specialNativePath)) { + char specialNativePath[MAX_PATH]; + ::SHGetPathFromIDList(idList, specialNativePath); + ::GetShortPathName(specialNativePath, specialNativePath, sizeof(specialNativePath)); + + if (nsDependentCString(fileNativePath).EqualsIgnoreCase(specialNativePath)) { aInfoFlags |= (SHGFI_PIDL | SHGFI_SYSICONINDEX); - shellResult = ::SHGetFileInfoW((LPCWSTR)(LPCITEMIDLIST)idList, 0, aSFI, - sizeof(SHFILEINFOW), aInfoFlags); + shellResult = ::SHGetFileInfo((LPCTSTR)(LPCITEMIDLIST)idList, 0, aSFI, + sizeof(SHFILEINFO), aInfoFlags); IMalloc* pMalloc; hr = ::SHGetMalloc(&pMalloc); if (SUCCEEDED(hr)) { @@ -273,14 +273,14 @@ static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking) { nsXPIDLCString contentType; - nsCString filePath; + nsCAutoString filePath; nsCOMPtr localFile; // file we want an icon for PRUint32 desiredImageSize; nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, contentType, filePath); NS_ENSURE_SUCCESS(rv, rv); // if the file exists, we are going to use it's real attributes...otherwise we only want to use it for it's extension... - SHFILEINFOW sfi; + SHFILEINFO sfi; UINT infoFlags = SHGFI_ICON; PRBool fileExists = PR_FALSE; @@ -342,9 +342,7 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc // Not a special folder, or something else failed above. if (!shellResult) - shellResult = ::SHGetFileInfoW( - NS_ConvertUTF8toUTF16(filePath).get(), - FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags); + shellResult = ::SHGetFileInfo(filePath.get(), FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags); if (shellResult && sfi.hIcon) { diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.h b/modules/libpr0n/decoders/icon/win/nsIconChannel.h index a69ea61c0d87..bf59799ae8b7 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.h +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.h @@ -77,7 +77,7 @@ protected: nsCOMPtr mPump; nsCOMPtr mListener; - nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension); + nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension); nsresult MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking); }; diff --git a/modules/oji/src/scd.cpp b/modules/oji/src/scd.cpp index 6b49e7058fae..34e9925318f7 100644 --- a/modules/oji/src/scd.cpp +++ b/modules/oji/src/scd.cpp @@ -100,7 +100,7 @@ nsSymantecDebugManager::SetDebugAgentPassword(PRInt32 pwd) // ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError())); /* continue so that we try to wake up the DebugManager */ } - sem = OpenSemaphoreW(SEMAPHORE_MODIFY_STATE, FALSE, L"Netscape-Symantec Debugger"); + sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger"); if (sem) { ReleaseSemaphore(sem, 1, NULL); CloseHandle(sem); diff --git a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp index 893100776321..db6e4c56bc0b 100644 --- a/modules/plugin/base/src/nsPluginDirServiceProvider.cpp +++ b/modules/plugin/base/src/nsPluginDirServiceProvider.cpp @@ -66,14 +66,14 @@ ClearVersion(verBlock *ver) } static BOOL -FileExists(wchar_t* szFile) +FileExists(LPCSTR szFile) { - return GetFileAttributesW(szFile) != 0xFFFFFFFF; + return GetFileAttributes(szFile) != 0xFFFFFFFF; } // Get file version information from a file static BOOL -GetFileVersion(wchar_t* szFile, verBlock *vbVersion) +GetFileVersion(LPSTR szFile, verBlock *vbVersion) { UINT uLen; UINT dwLen; @@ -86,12 +86,12 @@ GetFileVersion(wchar_t* szFile, verBlock *vbVersion) ClearVersion(vbVersion); if (FileExists(szFile)) { bRv = TRUE; - dwLen = GetFileVersionInfoSizeW(szFile, &dwHandle); + dwLen = GetFileVersionInfoSize(szFile, &dwHandle); lpData = (LPVOID)malloc(dwLen); uLen = 0; - if (lpData && GetFileVersionInfoW(szFile, dwHandle, dwLen, lpData) != 0) { - if (VerQueryValueW(lpData, L"\\", &lpBuffer, &uLen) != 0) { + if (lpData && GetFileVersionInfo(szFile, dwHandle, dwLen, lpData) != 0) { + if (VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0) { lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer; vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS); @@ -124,15 +124,15 @@ CopyVersion(verBlock *ver1, verBlock *ver2) static void TranslateVersionStr(const char* szVersion, verBlock *vbVersion) { - char* szNum1 = NULL; - char* szNum2 = NULL; - char* szNum3 = NULL; - char* szNum4 = NULL; - char* szJavaBuild = NULL; + LPSTR szNum1 = NULL; + LPSTR szNum2 = NULL; + LPSTR szNum3 = NULL; + LPSTR szNum4 = NULL; + LPSTR szJavaBuild = NULL; - char* strVer = nsnull; + char *strVer = nsnull; if (szVersion) { - strVer = strdup(szVersion); + strVer = PL_strdup(szVersion); } if (!strVer) { @@ -157,7 +157,7 @@ TranslateVersionStr(const char* szVersion, verBlock *vbVersion) vbVersion->wRelease = szNum3 ? atoi(szNum3) : 0; vbVersion->wBuild = szNum4 ? atoi(szNum4) : 0; - free(strVer); + PL_strfree(strVer); } // Compare two version struct, return zero if the same @@ -195,28 +195,26 @@ CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) // Indicate whether we should try to use the new NPRuntime-based Java // Plug-In if it's available static PRBool -TryToUseNPRuntimeJavaPlugIn(const wchar_t* javaVersion) +TryToUseNPRuntimeJavaPlugIn(const char* javaVersion) { HKEY javaKey = NULL; - wchar_t keyName[_MAX_PATH]; - - wcsncpy(keyName, L"Software\\JavaSoft\\Java Plug-in\\", wcslen(L"Software\\JavaSoft\\Java Plug-in\\")); - wcscpy(keyName, javaVersion); - + char keyName[_MAX_PATH]; + keyName[0] = 0; + PL_strcat(keyName, "Software\\JavaSoft\\Java Plug-in\\"); + PL_strcat(keyName, javaVersion); DWORD val; DWORD valSize = sizeof(DWORD); - if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, + if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &javaKey)) { return FALSE; } // Look for "UseNewJavaPlugin" - if (ERROR_SUCCESS != ::RegQueryValueExW(javaKey, - L"UseNewJavaPlugin", - NULL, NULL, - (LPBYTE) &val, - &valSize)) { + if (ERROR_SUCCESS != ::RegQueryValueEx(javaKey, "UseNewJavaPlugin", + NULL, NULL, + (LPBYTE) &val, + &valSize)) { val = 0; } @@ -264,7 +262,7 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, return rv; } - if (strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) { + if (nsCRT::strcmp(prop, NS_WIN_4DOTX_SCAN_KEY) == 0) { // Check our prefs to see if scanning the 4.x folder has been // explictly overriden failure to get the pref is okay, we'll do // what we've been doing -- a filtered scan @@ -279,38 +277,38 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, HKEY keyloc; long result; DWORD type; - wchar_t szKey[_MAX_PATH] = L"Software\\Netscape\\Netscape Navigator"; - wchar_t path[_MAX_PATH]; + char szKey[_MAX_PATH] = "Software\\Netscape\\Netscape Navigator"; + char path[_MAX_PATH]; - result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); + result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { - wchar_t current_version[80]; + char current_version[80]; DWORD length = sizeof(current_version); - result = ::RegQueryValueExW(keyloc, L"CurrentVersion", NULL, &type, + result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length); ::RegCloseKey(keyloc); - wcscat(szKey, L"\\"); - wcscat(szKey, current_version); - wcscat(szKey, L"\\Main"); - result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); + PL_strcat(szKey, "\\"); + PL_strcat(szKey, current_version); + PL_strcat(szKey, "\\Main"); + result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { DWORD pathlen = sizeof(path); - result = ::RegQueryValueExW(keyloc, L"Plugins Directory", NULL, &type, + result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen); if (result == ERROR_SUCCESS) { - rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } } - } else if (strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) { + } else if (nsCRT::strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) { nsXPIDLCString strVer; #ifdef OJI if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) @@ -330,25 +328,24 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); - wchar_t curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment"; - wchar_t path[_MAX_PATH]; - + char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Runtime Environment"; + char path[_MAX_PATH]; // Add + 15 to prevent buffer overrun when adding \bin (+ optionally // \new_plugin) #define JAVA_PATH_SIZE _MAX_PATH + 15 - wchar_t newestPath[JAVA_PATH_SIZE]; - const wchar_t mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla"; - wchar_t browserJavaVersion[_MAX_PATH]; + char newestPath[JAVA_PATH_SIZE]; + const char mozPath[_MAX_PATH] = "Software\\mozilla.org\\Mozilla"; + char browserJavaVersion[_MAX_PATH]; PRBool tryNPRuntimeJavaPlugIn = PR_FALSE; newestPath[0] = 0; - LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, + LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); if (ERROR_SUCCESS != result) return NS_ERROR_FAILURE; // Look for "BrowserJavaVersion" - if (ERROR_SUCCESS != ::RegQueryValueExW(baseloc, L"BrowserJavaVersion", NULL, + if (ERROR_SUCCESS != ::RegQueryValueEx(baseloc, "BrowserJavaVersion", NULL, NULL, (LPBYTE)&browserJavaVersion, &numChars)) browserJavaVersion[0] = 0; @@ -359,13 +356,13 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, path[0] = 0; numChars = _MAX_PATH; pathlen = sizeof(path); - result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, + result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; // Skip major.minor as it always points to latest in its family numChars = 0; - for (wchar_t *p = curKey; *p; p++) { // can I do this with wchar_t xxx? + for (char *p = curKey; *p; p++) { if (*p == '.') { numChars++; } @@ -374,24 +371,24 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, continue; if (ERROR_SUCCESS == result) { - if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"JavaHome", NULL, + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) { verBlock curVer; - TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer); + TranslateVersionStr(curKey, &curVer); if (CompareVersion(curVer, minVer) >= 0) { - if (!wcsncmp(browserJavaVersion, curKey, _MAX_PATH)) { - wcscpy(newestPath, path); + if (!strncmp(browserJavaVersion, curKey, _MAX_PATH)) { + PL_strcpy(newestPath, path); tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey); ::RegCloseKey(keyloc); break; } if (CompareVersion(curVer, maxVer) >= 0) { - wcscpy(newestPath, path); + PL_strcpy(newestPath, path); CopyVersion(&maxVer, &curVer); tryNPRuntimeJavaPlugIn = TryToUseNPRuntimeJavaPlugIn(curKey); } @@ -407,20 +404,20 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // If nothing is found, then don't add \bin dir and don't set // CurrentVersion for Mozilla if (newestPath[0] != 0) { - if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0, + if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, mozPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE|KEY_QUERY_VALUE, NULL, &entryloc, NULL)) { - if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0, + if (ERROR_SUCCESS != ::RegQueryValueEx(entryloc, "CurrentVersion", 0, NULL, NULL, NULL)) { - ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ, + ::RegSetValueEx(entryloc, "CurrentVersion", 0, REG_SZ, (const BYTE*)MOZILLA_VERSION, sizeof(MOZILLA_VERSION)); } ::RegCloseKey(entryloc); } - wcscat(newestPath,L"\\bin"); + PL_strcat(newestPath,"\\bin"); // See whether we should use the new NPRuntime-based Java Plug-In: // - If tryNPRuntimeJavaPlugIn is true, and @@ -430,13 +427,13 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // one any more. if (tryNPRuntimeJavaPlugIn) { // See whether the "new_plugin" directory exists - wchar_t tmpPath[JAVA_PATH_SIZE]; - wcscpy(tmpPath, newestPath); - wcscat(tmpPath, L"\\new_plugin"); + char tmpPath[JAVA_PATH_SIZE]; + PL_strcpy(tmpPath, newestPath); + PL_strcat(tmpPath, "\\new_plugin"); nsCOMPtr tmpFile; - if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(tmpPath), - PR_TRUE, - getter_AddRefs(tmpFile))) && + if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(tmpPath), + PR_TRUE, + getter_AddRefs(tmpFile))) && tmpFile) { PRBool exists = PR_FALSE; PRBool isDir = PR_FALSE; @@ -445,15 +442,15 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, // Assume we're supposed to use this as the search // directory for the Java Plug-In instead of the normal // one - wcscpy(newestPath, tmpPath); + PL_strcpy(newestPath, tmpPath); } } } - rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } - } else if (strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { + } else if (nsCRT::strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) return NS_ERROR_FAILURE; @@ -466,33 +463,33 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD type; verBlock qtVer; ClearVersion(&qtVer); - wchar_t path[_MAX_PATH]; + char path[_MAX_PATH]; DWORD pathlen = sizeof(path); // First we need to check the version of Quicktime via checking // the EXE's version table - if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, - (LPBYTE)&path, &pathlen)) { - GetFileVersion(path, &qtVer); + if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { + GetFileVersion((char*)path, &qtVer); } ::RegCloseKey(keyloc); } if (CompareVersion(qtVer, minVer) < 0) return rv; - if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { DWORD pathlen = sizeof(path); - result = ::RegQueryValueExW(keyloc, L"InstallDir", NULL, &type, + result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type, (LPBYTE)&path, &pathlen); - wcscat(path, L"\\Plugins"); + PL_strcat(path, "\\Plugins"); if (result == ERROR_SUCCESS) - rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); ::RegCloseKey(keyloc); } - } else if (strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) { + } else if (nsCRT::strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) return NS_ERROR_FAILURE; @@ -504,33 +501,33 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD type; verBlock wmpVer; ClearVersion(&wmpVer); - wchar_t path[_MAX_PATH]; + char path[_MAX_PATH]; DWORD pathlen = sizeof(path); // First we need to check the version of WMP - if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, - (LPBYTE)&path, &pathlen)) { - GetFileVersion(path, &wmpVer); + if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { + GetFileVersion((char*)path, &wmpVer); } ::RegCloseKey(keyloc); } if (CompareVersion(wmpVer, minVer) < 0) return rv; - if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"software\\Microsoft\\MediaPlayer", 0, + if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "software\\Microsoft\\MediaPlayer", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Installation Directory", + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory", NULL, &type, (LPBYTE)&path, &pathlen)) { - rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, - getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } - } else if (strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) { + } else if (nsCRT::strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) { return NS_ERROR_FAILURE; @@ -549,16 +546,16 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); - wchar_t curKey[_MAX_PATH] = L"software\\Adobe\\Acrobat Reader"; - wchar_t path[_MAX_PATH]; + char curKey[_MAX_PATH] = "software\\Adobe\\Acrobat Reader"; + char path[_MAX_PATH]; // Add + 8 to prevent buffer overrun when adding \browser - wchar_t newestPath[_MAX_PATH + 8]; + char newestPath[_MAX_PATH + 8]; newestPath[0] = 0; - if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, + if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { - wcscpy(curKey, L"software\\Adobe\\Adobe Acrobat"); - if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, + PL_strcpy(curKey, "software\\Adobe\\Adobe Acrobat"); + if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { return NS_ERROR_FAILURE; } @@ -571,22 +568,22 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, path[0] = 0; numChars = _MAX_PATH; pathlen = sizeof(path); - result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, + result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; if (ERROR_SUCCESS == result) { verBlock curVer; - TranslateVersionStr(NS_ConvertUTF16toUTF8(curKey).get(), &curVer); - wcscat(curKey, L"\\InstallPath"); - if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, + TranslateVersionStr(curKey, &curVer); + PL_strcat(curKey, "\\InstallPath"); + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { if (CompareVersion(curVer, maxVer) >= 0 && CompareVersion(curVer, minVer) >= 0) { - wcscpy(newestPath, path); + PL_strcpy(newestPath, path); CopyVersion(&maxVer, &curVer); } } @@ -599,9 +596,9 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, ::RegCloseKey(baseloc); if (newestPath[0] != 0) { - wcscat(newestPath, L"\\browser"); - rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, - getter_AddRefs(localFile)); + PL_strcat(newestPath,"\\browser"); + rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } } @@ -629,32 +626,32 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator nsresult nsPluginDirServiceProvider::GetPLIDDirectoriesWithHKEY(HKEY aKey, nsCOMArray &aDirs) { - wchar_t subkey[_MAX_PATH] = L"Software\\MozillaPlugins"; + char subkey[_MAX_PATH] = "Software\\MozillaPlugins"; HKEY baseloc; - if (ERROR_SUCCESS != ::RegOpenKeyExW(aKey, subkey, 0, KEY_READ, &baseloc)) + if (ERROR_SUCCESS != ::RegOpenKeyEx(aKey, subkey, 0, KEY_READ, &baseloc)) return NS_ERROR_FAILURE; DWORD index = 0; DWORD subkeylen = _MAX_PATH; FILETIME modTime; - while (ERROR_SUCCESS == ::RegEnumKeyExW(baseloc, index++, subkey, &subkeylen, + while (ERROR_SUCCESS == ::RegEnumKeyEx(baseloc, index++, subkey, &subkeylen, NULL, NULL, NULL, &modTime)) { subkeylen = _MAX_PATH; HKEY keyloc; - if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, subkey, 0, KEY_QUERY_VALUE, + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, subkey, 0, KEY_QUERY_VALUE, &keyloc)) { DWORD type; - wchar_t path[_MAX_PATH]; + char path[_MAX_PATH]; DWORD pathlen = sizeof(path); - if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Path", NULL, &type, + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Path", NULL, &type, (LPBYTE)&path, &pathlen)) { nsCOMPtr localFile; - if (NS_SUCCEEDED(NS_NewLocalFile(nsDependentString(path), - PR_TRUE, - getter_AddRefs(localFile))) && + if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(path), + PR_TRUE, + getter_AddRefs(localFile))) && localFile) { // Some vendors use a path directly to the DLL so chop off // the filename diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 370f40ff0d00..68b03a9ccf81 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -4017,18 +4017,18 @@ nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType, #ifdef XP_WIN static BOOL firstJavaPlugin = FALSE; BOOL restoreOrigDir = FALSE; - PRUnichar origDir[_MAX_PATH]; + char origDir[_MAX_PATH]; if (isJavaPlugin && !firstJavaPlugin) { - DWORD dw = ::GetCurrentDirectoryW(_MAX_PATH, origDir); + DWORD dw = ::GetCurrentDirectory(_MAX_PATH, origDir); NS_ASSERTION(dw <= _MAX_PATH, "Falied to obtain the current directory, which may leads to incorrect class laoding"); nsCOMPtr binDirectory; result = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(binDirectory)); if (NS_SUCCEEDED(result)) { - nsAutoString path; - binDirectory->GetPath(path); - restoreOrigDir = ::SetCurrentDirectoryW(path.get()); + nsCAutoString path; + binDirectory->GetNativePath(path); + restoreOrigDir = ::SetCurrentDirectory(path.get()); } } #endif @@ -4036,7 +4036,7 @@ nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType, #ifdef XP_WIN if (!firstJavaPlugin && restoreOrigDir) { - BOOL bCheck = ::SetCurrentDirectoryW(origDir); + BOOL bCheck = ::SetCurrentDirectory(origDir); NS_ASSERTION(bCheck, " Error restoring driectoy"); firstJavaPlugin = TRUE; } diff --git a/modules/plugin/base/src/nsPluginNativeWindowWin.cpp b/modules/plugin/base/src/nsPluginNativeWindowWin.cpp index fc702c791081..27b74b160d01 100644 --- a/modules/plugin/base/src/nsPluginNativeWindowWin.cpp +++ b/modules/plugin/base/src/nsPluginNativeWindowWin.cpp @@ -62,7 +62,7 @@ static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID); // needed for NS_TRY_SAFE_CALL -#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION L"MozillaPluginWindowPropertyAssociation" +#define NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION "MozillaPluginWindowPropertyAssociation" typedef nsTWeakRef PluginWindowWeakRef; @@ -203,7 +203,7 @@ NS_IMETHODIMP nsDelayedPopupsEnabledEvent::Run() */ static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); if (!win) return TRUE; @@ -526,10 +526,10 @@ nsresult nsPluginNativeWindowWin::SubclassAndAssociateWindow() if (!mPluginWinProc) return NS_ERROR_FAILURE; - nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); NS_ASSERTION(!win || (win == this), "plugin window already has property and this is not us"); - if (!::SetPropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this)) + if (!::SetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION, (HANDLE)this)) return NS_ERROR_FAILURE; return NS_OK; @@ -543,7 +543,7 @@ nsresult nsPluginNativeWindowWin::UndoSubclassAndAssociateWindow() // remove window property HWND hWnd = (HWND)window; if (IsWindow(hWnd)) - ::RemovePropW(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); + ::RemoveProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION); // restore the original win proc // but only do this if this were us last time diff --git a/modules/plugin/base/src/nsPluginsDirWin.cpp b/modules/plugin/base/src/nsPluginsDirWin.cpp index 97b31f2d2de4..35d07f9eaa00 100644 --- a/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -58,18 +58,25 @@ /* Local helper functions */ -static char* GetKeyValue(wchar_t* verbuf, wchar_t* key) +static char* GetKeyValue(char* verbuf, char* key) { - wchar_t *buf = NULL; + char *buf = NULL; UINT blen; - ::VerQueryValueW(verbuf, - key, + ::VerQueryValue(verbuf, + TEXT(key), (void **)&buf, &blen); if(buf != NULL) { - return strdup(NS_ConvertUTF16toUTF8(buf).get()); +#ifdef WINCE + // On windows CE, the verbuf is wide and the shunt + // layer can't do much about it. So, here we + // convert the wide string. + return PL_strdup(NS_ConvertUTF16toUTF8((PRUnichar*)buf).get()); +#else + return PL_strdup(buf); +#endif } return nsnull; @@ -209,35 +216,35 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) if (!mPlugin) return NS_ERROR_NULL_POINTER; - nsAutoString temp; - mPlugin->GetPath(temp); + nsCAutoString temp; + mPlugin->GetNativePath(temp); - PRUnichar* index; - PRUnichar* pluginFolderPath = _wcsdup(temp.get()); + char* index; + char* pluginFolderPath = PL_strdup(temp.get()); - index = wcsrchr(pluginFolderPath, '\\'); + index = PL_strrchr(pluginFolderPath, '\\'); *index = 0; BOOL restoreOrigDir = FALSE; - PRUnichar aOrigDir[MAX_PATH + 1]; - DWORD dwCheck = ::GetCurrentDirectoryW(sizeof(aOrigDir), aOrigDir); + char aOrigDir[MAX_PATH + 1]; + DWORD dwCheck = ::GetCurrentDirectory(sizeof(aOrigDir), aOrigDir); NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin"); if (dwCheck <= MAX_PATH + 1) { - restoreOrigDir = ::SetCurrentDirectoryW(pluginFolderPath); + restoreOrigDir = ::SetCurrentDirectory(pluginFolderPath); NS_ASSERTION(restoreOrigDir, "Error in Loading plugin"); } - outLibrary = PR_LoadLibrary(NS_ConvertUTF16toUTF8(temp).get()); + outLibrary = PR_LoadLibrary(temp.get()); if (restoreOrigDir) { - BOOL bCheck = ::SetCurrentDirectoryW(aOrigDir); + BOOL bCheck = ::SetCurrentDirectory(aOrigDir); NS_ASSERTION(bCheck, "Error in Loading plugin"); } - free(pluginFolderPath); + PL_strfree(pluginFolderPath); return NS_OK; } @@ -249,39 +256,37 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) { nsresult res = NS_OK; DWORD zerome, versionsize; - PRUnichar* verbuf = nsnull; + char* verbuf = nsnull; - const PRUnichar* path; + const char* path; if (!mPlugin) return NS_ERROR_NULL_POINTER; - nsAutoString temp; - mPlugin->GetPath(temp); + nsCAutoString temp; + mPlugin->GetNativePath(temp); path = temp.get(); - versionsize = ::GetFileVersionInfoSizeW(path, &zerome); + versionsize = ::GetFileVersionInfoSize((char*)path, &zerome); if (versionsize > 0) - verbuf = (wchar_t *)PR_Malloc(versionsize); + verbuf = (char *)PR_Malloc(versionsize); if(!verbuf) return NS_ERROR_OUT_OF_MEMORY; - if(::GetFileVersionInfoW(path, NULL, versionsize, verbuf)) + if(::GetFileVersionInfo((char*)path, NULL, versionsize, verbuf)) { - info.fName = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\ProductName"); - info.fDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileDescription"); + info.fName = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\ProductName"); + info.fDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileDescription"); - char *mimeType = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\MIMEType"); - char *mimeDescription = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileOpenName"); - char *extensions = GetKeyValue(verbuf, L"\\StringFileInfo\\040904E4\\FileExtents"); + char *mimeType = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType"); + char *mimeDescription = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileOpenName"); + char *extensions = GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileExtents"); info.fVariantCount = CalculateVariantCount(mimeType); info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType); info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription); info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions); - - // fFileName is narrow. fix? - info.fFileName = PL_strdup(NS_ConvertUTF16toUTF8(path).get()); + info.fFileName = PL_strdup(path); PL_strfree(mimeType); PL_strfree(mimeDescription); diff --git a/modules/plugin/samples/default/windows/dialogs.cpp b/modules/plugin/samples/default/windows/dialogs.cpp index 4c8efb03f73c..eae460d2dcb2 100644 --- a/modules/plugin/samples/default/windows/dialogs.cpp +++ b/modules/plugin/samples/default/windows/dialogs.cpp @@ -79,18 +79,17 @@ static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) pPlugin->m_hWndDialog = hWnd; - wchar_t szString[512]; - LoadStringW(hInst, IDS_TITLE, szString, sizeof(szString)); - SetWindowTextW(hWnd, szString); + char szString[512]; + LoadString(hInst, IDS_TITLE, szString, sizeof(szString)); + SetWindowText(hWnd, szString); - LoadStringW(hInst, IDS_INFO, szString, sizeof(szString)); - SetDlgItemTextW(hWnd, IDC_STATIC_INFO, szString); + LoadString(hInst, IDS_INFO, szString, sizeof(szString)); + SetDlgItemText(hWnd, IDC_STATIC_INFO, szString); - // convert m_pNPMIMEType dougt - SetDlgItemTextA(hWnd, IDC_STATIC_INFOTYPE, pPlugin->m_pNPMIMEType); + SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType); - LoadStringW(hInst, IDS_LOCATION, szString, sizeof(szString)); - SetDlgItemTextW(hWnd, IDC_STATIC_LOCATION, szString); + LoadString(hInst, IDS_LOCATION, szString, sizeof(szString)); + SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString); char contentTypeIsJava = 0; @@ -100,36 +99,30 @@ static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) } if(pPlugin->m_szPageURL == NULL || contentTypeIsJava) - LoadStringW(hInst, IDS_FINDER_PAGE, szString, sizeof(szString)); + LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString)); else - { - MultiByteToWideChar( CP_ACP, 0, - pPlugin->m_szPageURL, - strlen(pPlugin->m_szPageURL)+1, - szString, - 511 ); // defect #362738 - } - + strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738 + SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString); - LoadStringW(hInst, IDS_QUESTION, szString, sizeof(szString)); - SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, szString); + LoadString(hInst, IDS_QUESTION, szString, sizeof(szString)); + SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString); - SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, L""); + SetDlgItemText(hWnd, IDC_STATIC_WARNING, ""); if(!pPlugin->m_bOnline) { EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE); - LoadStringW(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString)); - SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString); - SetDlgItemTextW(hWnd, IDC_STATIC_QUESTION, L""); + LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString)); + SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString); + SetDlgItemText(hWnd, IDC_STATIC_QUESTION, ""); return TRUE; } if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate)) { - LoadStringW(hInst, IDS_WARNING_JS, szString, sizeof(szString)); - SetDlgItemTextW(hWnd, IDC_STATIC_WARNING, szString); + LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString)); + SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString); return TRUE; } diff --git a/modules/plugin/samples/default/windows/npshell.cpp b/modules/plugin/samples/default/windows/npshell.cpp index 1525b84cc96a..b7d2683d4a1b 100644 --- a/modules/plugin/samples/default/windows/npshell.cpp +++ b/modules/plugin/samples/default/windows/npshell.cpp @@ -86,18 +86,18 @@ NPError NP_LOADDS NPP_New(NPMIMEType pluginType, for(int i = 0; i < argc; i++) { - if(strcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL) + if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL) szPageURL = (char *)argv[i]; - else if(strcmpi(argn[i],"codebase") == 0 && argv[i] != NULL) + else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL) szPageURL = (char *)argv[i]; - else if(strcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL) + else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL) szFileURL = (char *)argv[i]; - else if(strcmpi(argn[i],"classid") == 0 && argv[i] != NULL) + else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL) szFileURL = (char *)argv[i]; - else if(strcmpi(argn[i],"SRC") == 0 && argv[i] != NULL) + else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL) buf = (char *)argv[i]; - else if(strcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL) - bHidden = (strcmp((char *)argv[i], "TRUE") == 0); + else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL) + bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0); } /* some post-processing on the filename to attempt to extract the extension: */ diff --git a/modules/plugin/samples/default/windows/plugin.cpp b/modules/plugin/samples/default/windows/plugin.cpp index 2b5fac54d40e..c22de1023b4c 100644 --- a/modules/plugin/samples/default/windows/plugin.cpp +++ b/modules/plugin/samples/default/windows/plugin.cpp @@ -51,7 +51,7 @@ nsIServiceManager * gServiceManager = NULL; -static wchar_t szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN; +static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN; static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM); @@ -66,7 +66,7 @@ BOOL RegisterNullPluginWindowClass() { assert(hInst != NULL); - WNDCLASSW wc; + WNDCLASS wc; memset(&wc, 0, sizeof(wc)); @@ -78,14 +78,14 @@ BOOL RegisterNullPluginWindowClass() wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1); wc.lpszClassName = szNullPluginWindowClassName; - ATOM aRet = RegisterClassW(&wc); + ATOM aRet = RegisterClass(&wc); return (aRet != NULL); } void UnregisterNullPluginWindowClass() { assert(hInst != NULL); - UnregisterClassW(szNullPluginWindowClassName, hInst); + UnregisterClass(szNullPluginWindowClassName, hInst); } /*********************************************/ @@ -129,41 +129,41 @@ CPlugin::CPlugin(HINSTANCE hInst, if(pluginType && *pluginType) { - m_pNPMIMEType = (NPMIMEType) new char[strlen(pluginType) + 1]; + m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1]; if(m_pNPMIMEType != NULL) - strcpy(m_pNPMIMEType, pluginType); + lstrcpy((LPSTR)m_pNPMIMEType, pluginType); } if(szPageURL && *szPageURL) { - m_szPageURL = new char[strlen(szPageURL) + 1]; + m_szPageURL = new char[lstrlen(szPageURL) + 1]; if(m_szPageURL != NULL) - strcpy(m_szPageURL, szPageURL); + lstrcpy(m_szPageURL, szPageURL); } if(szFileURL && *szFileURL) { - m_szFileURL = new char[strlen(szFileURL) + 1]; + m_szFileURL = new char[lstrlen(szFileURL) + 1]; if(m_szFileURL != NULL) - strcpy(m_szFileURL, szFileURL); + lstrcpy(m_szFileURL, szFileURL); } if(szFileExtension && *szFileExtension) { - m_szFileExtension = new char[strlen(szFileExtension) + 1]; + m_szFileExtension = new char[lstrlen(szFileExtension) + 1]; if(m_szFileExtension != NULL) - strcpy(m_szFileExtension, szFileExtension); + lstrcpy(m_szFileExtension, szFileExtension); } m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON)); - wchar_t szString[1024] = {'\0'}; - LoadStringW(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString)); + char szString[1024] = {'\0'}; + LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString)); if(*szString) { - m_szCommandMessage = new wchar_t[wcslen(szString) + 1]; + m_szCommandMessage = new char[lstrlen(szString) + 1]; if(m_szCommandMessage != NULL) - wcscpy(m_szCommandMessage, szString); + lstrcpy(m_szCommandMessage, szString); } } @@ -253,8 +253,8 @@ BOOL CPlugin::init(HWND hWndParent) RECT rcParent; GetClientRect(m_hWndParent, &rcParent); - CreateWindowW(szNullPluginWindowClassName, - L"NULL Plugin", + CreateWindow(szNullPluginWindowClassName, + "NULL Plugin", WS_CHILD, 0,0, rcParent.right, rcParent.bottom, m_hWndParent, @@ -332,10 +332,10 @@ LPSTR CPlugin::createURLString() // check if there is file URL first if(!m_bSmartUpdate && m_szFileURL != NULL) { - m_szURLString = new char[strlen(m_szFileURL) + 1]; + m_szURLString = new char[lstrlen(m_szFileURL) + 1]; if(m_szURLString == NULL) return NULL; - strcpy(m_szURLString, m_szFileURL); + lstrcpy(m_szURLString, m_szFileURL); return m_szURLString; } @@ -351,18 +351,18 @@ LPSTR CPlugin::createURLString() if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava) { - szAddress = new char[strlen(m_szPageURL) + 1]; + szAddress = new char[lstrlen(m_szPageURL) + 1]; if(szAddress == NULL) return NULL; - strcpy(szAddress, m_szPageURL); + lstrcpy(szAddress, m_szPageURL); - m_szURLString = new char[strlen(szAddress) + 1 + strlen(m_pNPMIMEType) + 1]; + m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1]; if(m_szURLString == NULL) return NULL; // Append the MIME type to the URL - sprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType); + wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType); } else // default { @@ -374,20 +374,20 @@ LPSTR CPlugin::createURLString() urlToOpen = szPageUrlForJVM; } - szAddress = new char[strlen(urlToOpen) + 1]; + szAddress = new char[lstrlen(urlToOpen) + 1]; if(szAddress == NULL) return NULL; - strcpy(szAddress, urlToOpen); + lstrcpy(szAddress, urlToOpen); - m_szURLString = new char[strlen(szAddress) + 10 + - strlen(m_pNPMIMEType) + 1]; + m_szURLString = new char[lstrlen(szAddress) + 10 + + lstrlen((LPSTR)m_pNPMIMEType) + 1]; if(m_szURLString == NULL) return NULL; // Append the MIME type to the URL - sprintf(m_szURLString, "%s?mimetype=%s", - szAddress, m_pNPMIMEType); + wsprintf(m_szURLString, "%s?mimetype=%s", + szAddress, (LPSTR)m_pNPMIMEType); } else { @@ -409,15 +409,14 @@ LPSTR CPlugin::createURLString() m_szFileURL[0] = '\0'; } - m_szURLString = new char[strlen(szPluginFinderCommandBeginning) + strlen(urlToOpen) + 10 + - strlen((LPSTR)m_pNPMIMEType) + 13 + - strlen((LPSTR)m_szPageURL) + 11 + - strlen((LPSTR)m_szFileURL) + - strlen(szPluginFinderCommandEnd) + 1]; - sprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s", - szPluginFinderCommandBeginning, urlToOpen, - m_pNPMIMEType, m_szPageURL, m_szFileURL, - szPluginFinderCommandEnd); + m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 + + lstrlen((LPSTR)m_pNPMIMEType) + 13 + + lstrlen((LPSTR)m_szPageURL) + 11 + + lstrlen((LPSTR)m_szFileURL) + + lstrlen(szPluginFinderCommandEnd) + 1]; + wsprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s", + szPluginFinderCommandBeginning, urlToOpen, + (LPSTR)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd); } } @@ -513,13 +512,13 @@ void CPlugin::getPlugin() m_szCommandMessage = NULL; } - wchar_t szString[1024] = {'\0'}; - LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); + char szString[1024] = {'\0'}; + LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); if(*szString) { - m_szCommandMessage = new wchar_t[wcslen(szString) + 1]; + m_szCommandMessage = new char[lstrlen(szString) + 1]; if(m_szCommandMessage != NULL) - wcscpy(m_szCommandMessage, szString); + lstrcpy(m_szCommandMessage, szString); } InvalidateRect(m_hWnd, NULL, TRUE); @@ -549,20 +548,20 @@ void CPlugin::URLNotify(const char * szURL) dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL); NPStream * pStream = NULL; - wchar_t buf[256]; + char buf[256]; assert(m_hInst != NULL); assert(m_pNPInstance != NULL); - int iSize = LoadStringW(m_hInst, IDS_GOING2HTML, buf, sizeof(buf)); + int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf)); NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream); if (rc != NPERR_NO_ERROR) return; - //wchar_t buf[] = L"\n\n\n

NPN_NewStream / NPN_Write - This seems to work.

\n\n\n"; + //char buf[] = "\n\n\n

NPN_NewStream / NPN_Write - This seems to work.

\n\n\n"; - NPN_Write(m_pNPInstance, pStream, iSize, buf); // buf is unicode now. + NPN_Write(m_pNPInstance, pStream, iSize, buf); NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE); } @@ -595,12 +594,12 @@ NPError CPlugin::destroyStream(NPStream *stream, NPError reason) BOOL CPlugin::readyToRefresh() { - wchar_t szString[1024] = {'\0'}; - LoadStringW(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); + char szString[1024] = {'\0'}; + LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString)); if(m_szCommandMessage == NULL) return FALSE; - return (wcscmp(m_szCommandMessage, szString) == 0); + return (lstrcmp(m_szCommandMessage, szString) == 0); } //*************************** @@ -627,7 +626,7 @@ void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags) NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self"); } -static void DrawCommandMessage(HDC hDC, wchar_t* szString, LPRECT lprc) +static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc) { if(szString == NULL) return; @@ -638,7 +637,7 @@ static void DrawCommandMessage(HDC hDC, wchar_t* szString, LPRECT lprc) HFONT hFontOld = SelectFont(hDC, hFont); SIZE sz; - GetTextExtentPoint32W(hDC, szString, wcslen(szString), &sz); + GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz); POINT pt; pt.x = sz.cx; pt.y = sz.cy; @@ -660,7 +659,7 @@ static void DrawCommandMessage(HDC hDC, wchar_t* szString, LPRECT lprc) int iModeOld = SetBkMode(hDC, TRANSPARENT); COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0)); - DrawTextW(hDC, szString, wcslen(szString), &rcText, DT_CENTER|DT_VCENTER); + DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER); SetTextColor(hDC, crColorOld); SetBkMode(hDC, iModeOld); SelectFont(hDC, hFontOld); diff --git a/modules/plugin/samples/default/windows/plugin.h b/modules/plugin/samples/default/windows/plugin.h index 21b6f45c50f0..34961aa4369c 100644 --- a/modules/plugin/samples/default/windows/plugin.h +++ b/modules/plugin/samples/default/windows/plugin.h @@ -51,7 +51,7 @@ private: HICON m_hIcon; char* m_szURLString; - wchar_t* m_szCommandMessage; + char* m_szCommandMessage; BOOL m_bWaitingStreamFromPFS; NPStream* m_PFSStream; @@ -118,7 +118,7 @@ public: #define JVM_SMARTUPDATE_URL "http://java.com/download" #ifdef WIN32 -#define REGISTRY_PLACE L"Software\\Netscape\\Netscape Navigator\\Default Plugin" +#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin" #else #define GWL_USERDATA 0 #define COLOR_3DSHADOW COLOR_BTNFACE @@ -126,7 +126,7 @@ public: #define COLOR_3DDKSHADOW COLOR_BTNSHADOW #endif -#define CLASS_NULL_PLUGIN L"NullPluginClass" +#define CLASS_NULL_PLUGIN "NullPluginClass" BOOL RegisterNullPluginWindowClass(); void UnregisterNullPluginWindowClass(); diff --git a/modules/plugin/samples/default/windows/utils.cpp b/modules/plugin/samples/default/windows/utils.cpp index 01cf1f3928a5..2371e71430c7 100644 --- a/modules/plugin/samples/default/windows/utils.cpp +++ b/modules/plugin/samples/default/windows/utils.cpp @@ -45,8 +45,8 @@ HKEY openRegistry() { HKEY phkResult; - if(RegCreateKeyW(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS) - MessageBoxW(0, L"Error creating Default Plugin registry key", L"Default Plugin", MB_OK); + if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS) + MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK); return phkResult; } @@ -56,37 +56,30 @@ BOOL IsNewMimeType(LPSTR mime) { HKEY hkey = openRegistry(); DWORD dwType, keysize = 512; - wchar_t keybuf[512]; - wchar_t wideMime[64]; + char keybuf[512]; - MultiByteToWideChar(CP_ACP, 0, - mime, - strlen(mime) + 1, - wideMime, - 64); - - if(RegQueryValueExW(hkey, wideMime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS) + if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS) { // key exists, must have already been here... return FALSE; } else { - if(RegSetValueExW(hkey, wideMime, 0, REG_SZ, (LPBYTE) L"(none)", 7) != ERROR_SUCCESS) - MessageBoxW(0, L"Error adding MIME type value", L"Default Plugin", MB_OK); + if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS) + MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK); return TRUE; } } // string length in pixels for the specific window (selected font) -static int getWindowStringLength(HWND hWnd, wchar_t* lpsz) +static int getWindowStringLength(HWND hWnd, LPSTR lpsz) { SIZE sz; HDC hDC = GetDC(hWnd); HFONT hWindowFont = GetWindowFont(hWnd); HFONT hFontOld = SelectFont(hDC, hWindowFont); - GetTextExtentPoint32W(hDC, lpsz, wcslen(lpsz), &sz); + GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz); POINT pt; pt.x = sz.cx; pt.y = sz.cy; @@ -96,20 +89,20 @@ static int getWindowStringLength(HWND hWnd, wchar_t* lpsz) return (int)pt.x; } -/*******************************************************************/ -/* */ -/* void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) */ -/* */ -/* helper to wrap long lines in a static control, which do not */ -/* wrap automatically if they do not have space characters */ -/* */ -/*******************************************************************/ -void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) +/****************************************************************/ +/* */ +/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */ +/* */ +/* helper to wrap long lines in a static control, which do not */ +/* wrap automatically if they do not have space characters */ +/* */ +/****************************************************************/ +void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) { HWND hWndStatic = GetDlgItem(hWnd, iID); - if((szText == NULL) || (wcslen(szText) == 0)) + if((szText == NULL) || (lstrlen(szText) == 0)) { - SetDlgItemTextW(hWnd, iID, L""); + SetDlgItemText(hWnd, iID, ""); return; } @@ -121,7 +114,7 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) if(iStringLength <= iStaticLength) { - SetDlgItemTextW(hWnd, iID, szText); + SetDlgItemText(hWnd, iID, szText); return; } @@ -129,19 +122,19 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) if(iBreaks <= 0) return; - wchar_t * pBuf = new wchar_t[iStringLength + iBreaks + 1]; + char * pBuf = new char[iStringLength + iBreaks + 1]; if(pBuf == NULL) return; - wcscpy(pBuf, L""); + lstrcpy(pBuf, ""); int iStart = 0; int iLines = 0; for(int i = 0; i < iStringLength; i++) { - wchar_t* sz = &szText[iStart]; + char * sz = &szText[iStart]; int iIndex = i - iStart; - wchar_t ch = sz[iIndex + 1]; + char ch = sz[iIndex + 1]; sz[iIndex + 1] = '\0'; @@ -152,7 +145,7 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) sz[iIndex + 1] = ch; if(iLines == iBreaks) { - wcscat(pBuf, sz); + lstrcat(pBuf, sz); break; } continue; @@ -164,15 +157,15 @@ void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText) ch = sz[iIndex]; sz[iIndex] = '\0'; // terminate string one char shorter - wcscat(pBuf, sz); // append the string - wcscat(pBuf, L" "); // append space character for successful wrapping + lstrcat(pBuf, sz); // append the string + lstrcat(pBuf, " "); // append space character for successful wrapping - iStart += wcslen(sz); // shift new start position + iStart += lstrlen(sz);// shift new start position sz[iIndex] = ch; // restore zeroed element iLines++; // count lines } - SetDlgItemTextW(hWnd, iID, pBuf); + SetDlgItemText(hWnd, iID, pBuf); delete [] pBuf; } diff --git a/modules/plugin/samples/default/windows/utils.h b/modules/plugin/samples/default/windows/utils.h index a4b5a44443ea..1e1691d78287 100644 --- a/modules/plugin/samples/default/windows/utils.h +++ b/modules/plugin/samples/default/windows/utils.h @@ -40,6 +40,6 @@ HKEY openRegistry(); BOOL IsNewMimeType(LPSTR szMimeType); -void SetDlgItemTextWrapped(HWND hWnd, int iID, wchar_t* szText); +void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText); #endif // __UTILS_H__ diff --git a/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp b/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp index 923f6ef2ea1b..8443ce501f06 100644 --- a/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp +++ b/modules/plugin/tools/sdk/samples/basic/windows/plugin.cpp @@ -146,11 +146,11 @@ static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA); if (plugin) { const char * string = plugin->getVersion(); - DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } else { char string[] = "Error occured"; - DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } EndPaint(hWnd, &ps); diff --git a/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp b/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp index a2bed6b18021..23d06902ccc0 100644 --- a/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp +++ b/modules/plugin/tools/sdk/samples/scriptable/windows/plugin.cpp @@ -220,10 +220,10 @@ static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM // get our plugin instance object and ask it for the version string nsPluginInstance *plugin = (nsPluginInstance *)GetWindowLong(hWnd, GWL_USERDATA); if (plugin) - DrawTextA(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawText(hdc, plugin->mString, strlen(plugin->mString), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); else { char string[] = "Error occured"; - DrawTextA(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); + DrawText(hdc, string, strlen(string), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } EndPaint(hWnd, &ps); diff --git a/rdf/datasource/src/nsFileSystemDataSource.cpp b/rdf/datasource/src/nsFileSystemDataSource.cpp index d88221b77f26..cd1bf5eb8fc1 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -928,15 +928,14 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult) #if defined (XP_WIN) && !defined (WINCE) PRInt32 driveType; - PRUnichar drive[32]; + char drive[32]; PRInt32 volNum; char *url; for (volNum = 0; volNum < 26; volNum++) { - swprintf( drive, L"%c:\\", volNum + (PRUnichar)'A'); - - driveType = GetDriveTypeW(drive); + sprintf(drive, "%c:\\", volNum + 'A'); + driveType = GetDriveType(drive); if (driveType != DRIVE_UNKNOWN && driveType != DRIVE_NO_ROOT_DIR) { if (nsnull != (url = PR_smprintf("file:///%c|/", volNum + 'A'))) diff --git a/toolkit/components/startup/src/nsUserInfoWin.cpp b/toolkit/components/startup/src/nsUserInfoWin.cpp index 4bdc29fa246d..bbb16c7a099e 100644 --- a/toolkit/components/startup/src/nsUserInfoWin.cpp +++ b/toolkit/components/startup/src/nsUserInfoWin.cpp @@ -58,13 +58,14 @@ nsUserInfo::GetUsername(char **aUsername) { *aUsername = nsnull; - PRUnichar username[256]; + TCHAR username[256]; DWORD size = 256; - if (!GetUserNameW(username, &size)) + if (!GetUserName(username, &size)) return NS_ERROR_FAILURE; - - *aUsername = ToNewUTF8String(nsDependentString(username)); + + *aUsername = nsCRT::strdup(username); + if (*aUsername) return NS_OK; return NS_ERROR_FAILURE; diff --git a/uriloader/exthandler/win/nsMIMEInfoWin.cpp b/uriloader/exthandler/win/nsMIMEInfoWin.cpp index c4e2a59e41ea..2ed61c0e760c 100755 --- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp +++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp @@ -266,7 +266,7 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) SFGAOF sfgao; // Bug 394974 - HMODULE hDll = ::LoadLibraryW(L"shell32.dll"); + HMODULE hDll = ::LoadLibrary("shell32.dll"); MySHParseDisplayName pMySHParseDisplayName = NULL; // Version 6.0 and higher if (pMySHParseDisplayName = @@ -274,19 +274,19 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) "SHParseDisplayName")) { if (SUCCEEDED(pMySHParseDisplayName(NS_ConvertUTF8toUTF16(urlSpec).get(), NULL, &pidl, 0, &sfgao))) { - static const PRUnichar cmdVerb[] = L"open"; - SHELLEXECUTEINFOW sinfo; + static const char cmdVerb[] = "open"; + SHELLEXECUTEINFO sinfo; memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO)); sinfo.cbSize = sizeof(SHELLEXECUTEINFO); sinfo.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI | SEE_MASK_INVOKEIDLIST; sinfo.hwnd = NULL; - sinfo.lpVerb = (LPWSTR)&cmdVerb; + sinfo.lpVerb = (LPCSTR)&cmdVerb; sinfo.nShow = SW_SHOWNORMAL; sinfo.lpIDList = pidl; - BOOL result = ShellExecuteExW(&sinfo); + BOOL result = ShellExecuteEx(&sinfo); CoTaskMemFree(pidl); @@ -295,9 +295,7 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL) } } else { // Version of shell32.dll < 6.0 - LONG r = (LONG) ::ShellExecuteW(NULL, L"open", - NS_ConvertUTF8toUTF16(urlSpec).get(), - NULL, NULL, + LONG r = (LONG) ::ShellExecute(NULL, "open", urlSpec.get(), NULL, NULL, SW_SHOWNORMAL); if (r < 32) rv = NS_ERROR_FAILURE; diff --git a/uriloader/exthandler/win/nsOSHelperAppService.cpp b/uriloader/exthandler/win/nsOSHelperAppService.cpp index 8d63241533be..bfe39446ec5b 100644 --- a/uriloader/exthandler/win/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp @@ -145,11 +145,11 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch if (aProtocolScheme && *aProtocolScheme) { HKEY hKey; - LONG err = ::RegOpenKeyExA(HKEY_CLASSES_ROOT, aProtocolScheme, 0, + LONG err = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, aProtocolScheme, 0, KEY_QUERY_VALUE, &hKey); if (err == ERROR_SUCCESS) { - err = ::RegQueryValueExW(hKey, L"URL Protocol", NULL, NULL, NULL, NULL); + err = ::RegQueryValueEx(hKey, "URL Protocol", NULL, NULL, NULL, NULL); *aHandlerExists = (err == ERROR_SUCCESS); // close the key ::RegCloseKey(hKey); diff --git a/widget/src/windows/nsAppShell.cpp b/widget/src/windows/nsAppShell.cpp index 9dd15f5bfa2e..9b81af7060fe 100644 --- a/widget/src/windows/nsAppShell.cpp +++ b/widget/src/windows/nsAppShell.cpp @@ -93,13 +93,13 @@ nsresult nsAppShell::Init() { if (!sMsgId) - sMsgId = RegisterWindowMessageW(L"nsAppShell:EventID"); + sMsgId = RegisterWindowMessage("nsAppShell:EventID"); - WNDCLASSW wc; + WNDCLASS wc; HINSTANCE module = GetModuleHandle(NULL); - const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass"; - if (!GetClassInfoW(module, kWindowClass, &wc)) { + const char *const kWindowClass = "nsAppShell:EventWindowClass"; + if (!GetClassInfo(module, kWindowClass, &wc)) { wc.style = 0; wc.lpfnWndProc = EventWindowProc; wc.cbClsExtra = 0; @@ -108,12 +108,12 @@ nsAppShell::Init() wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = (HBRUSH) NULL; - wc.lpszMenuName = (LPCWSTR) NULL; + wc.lpszMenuName = (LPCSTR) NULL; wc.lpszClassName = kWindowClass; - RegisterClassW(&wc); + RegisterClass(&wc); } - mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow", + mEventWnd = CreateWindow(kWindowClass, "nsAppShell:EventWindow", 0, 0, 0, 10, 10, NULL, NULL, module, NULL); NS_ENSURE_STATE(mEventWnd); diff --git a/widget/src/windows/nsBidiKeyboard.cpp b/widget/src/windows/nsBidiKeyboard.cpp index 07afbd6f565f..03c7df9c72cc 100644 --- a/widget/src/windows/nsBidiKeyboard.cpp +++ b/widget/src/windows/nsBidiKeyboard.cpp @@ -40,7 +40,6 @@ #include #include "nsBidiKeyboard.h" #include "prmem.h" -#include NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard) @@ -64,8 +63,8 @@ NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel) return result; // call LoadKeyboardLayout() only if the target keyboard layout is different from the current - PRUnichar currentLocaleName[KL_NAMELENGTH]; - wcsncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH); + char currentLocaleName[KL_NAMELENGTH]; + strncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH); currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate NS_ASSERTION(*currentLocaleName, @@ -97,26 +96,26 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL) currentLocale = ::GetKeyboardLayout(0); *aIsRTL = IsRTLLanguage(currentLocale); - if (!::GetKeyboardLayoutNameW(mCurrentLocaleName)) + if (!::GetKeyboardLayoutName(mCurrentLocaleName)) return NS_ERROR_FAILURE; NS_ASSERTION(*mCurrentLocaleName, "GetKeyboardLayoutName return string length == 0"); - NS_ASSERTION((wcslen(mCurrentLocaleName) < KL_NAMELENGTH), + NS_ASSERTION((strlen(mCurrentLocaleName) < KL_NAMELENGTH), "GetKeyboardLayoutName return string length >= KL_NAMELENGTH"); // The language set by the user overrides the default language for that direction if (*aIsRTL) { - wcsncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH); + strncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH); mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } else { - wcsncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH); + strncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH); mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } - NS_ASSERTION((wcslen(mRTLKeyboard) < KL_NAMELENGTH), + NS_ASSERTION((strlen(mRTLKeyboard) < KL_NAMELENGTH), "mLTRKeyboard has string length >= KL_NAMELENGTH"); - NS_ASSERTION((wcslen(mLTRKeyboard) < KL_NAMELENGTH), + NS_ASSERTION((strlen(mLTRKeyboard) < KL_NAMELENGTH), "mRTLKeyboard has string length >= KL_NAMELENGTH"); return NS_OK; } @@ -133,7 +132,7 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() int keyboards; HKL far* buf; HKL locale; - PRUnichar localeName[KL_NAMELENGTH]; + char localeName[KL_NAMELENGTH]; PRBool isLTRKeyboardSet = PR_FALSE; PRBool isRTLKeyboardSet = PR_FALSE; @@ -157,11 +156,11 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() while (keyboards--) { locale = buf[keyboards]; if (IsRTLLanguage(locale)) { - swprintf(mRTLKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); + sprintf(mRTLKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); isRTLKeyboardSet = PR_TRUE; } else { - swprintf( mLTRKeyboard, L"%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); + sprintf(mLTRKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID(locale)); isLTRKeyboardSet = PR_TRUE; } } @@ -179,20 +178,20 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards() // installed this prevents us from arbitrarily resetting the current // layout (bug 80274) locale = ::GetKeyboardLayout(0); - if (!::GetKeyboardLayoutNameW(localeName)) + if (!::GetKeyboardLayoutName(localeName)) return NS_ERROR_FAILURE; NS_ASSERTION(*localeName, "GetKeyboardLayoutName return string length == 0"); - NS_ASSERTION((wcslen(localeName) < KL_NAMELENGTH), + NS_ASSERTION((strlen(localeName) < KL_NAMELENGTH), "GetKeyboardLayout return string length >= KL_NAMELENGTH"); if (IsRTLLanguage(locale)) { - swprintf(mRTLKeyboard, localeName, KL_NAMELENGTH); + strncpy(mRTLKeyboard, localeName, KL_NAMELENGTH); mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } else { - swprintf( mLTRKeyboard, localeName, KL_NAMELENGTH); + strncpy(mLTRKeyboard, localeName, KL_NAMELENGTH); mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate } diff --git a/widget/src/windows/nsBidiKeyboard.h b/widget/src/windows/nsBidiKeyboard.h index de859f5f6807..71a9a40962f5 100644 --- a/widget/src/windows/nsBidiKeyboard.h +++ b/widget/src/windows/nsBidiKeyboard.h @@ -58,9 +58,9 @@ protected: PRPackedBool mInitialized; PRPackedBool mHaveBidiKeyboards; - PRUnichar mLTRKeyboard[KL_NAMELENGTH]; - PRUnichar mRTLKeyboard[KL_NAMELENGTH]; - PRUnichar mCurrentLocaleName[KL_NAMELENGTH]; + char mLTRKeyboard[KL_NAMELENGTH]; + char mRTLKeyboard[KL_NAMELENGTH]; + char mCurrentLocaleName[KL_NAMELENGTH]; }; diff --git a/widget/src/windows/nsClipboard.cpp b/widget/src/windows/nsClipboard.cpp index 8b515f674c9a..8c54fc79a413 100644 --- a/widget/src/windows/nsClipboard.cpp +++ b/widget/src/windows/nsClipboard.cpp @@ -70,7 +70,7 @@ // oddly, this isn't in the MSVC headers anywhere. -UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format"); +UINT nsClipboard::CF_HTML = ::RegisterClipboardFormat("HTML Format"); //------------------------------------------------------------------------- @@ -111,9 +111,7 @@ UINT nsClipboard::GetFormat(const char* aMimeStr) else if (strcmp(aMimeStr, kNativeHTMLMime) == 0) format = CF_HTML; else - format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get()); - - + format = ::RegisterClipboardFormat(aMimeStr); return format; } @@ -318,7 +316,7 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, PRUint32 * aLe ); // Display the string. - MessageBoxW( NULL, (LPCWSTR)lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION ); + MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION ); // Free the buffer. LocalFree( lpMsgBuf ); diff --git a/widget/src/windows/nsDataObj.h b/widget/src/windows/nsDataObj.h index 226e3e38f247..95f33d5f44a9 100644 --- a/widget/src/windows/nsDataObj.h +++ b/widget/src/windows/nsDataObj.h @@ -82,10 +82,10 @@ IAsyncOperation : public IUnknown * See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp */ #ifndef CFSTR_INETURLA -#define CFSTR_INETURLA L"UniformResourceLocator" +#define CFSTR_INETURLA "UniformResourceLocator" #endif #ifndef CFSTR_INETURLW -#define CFSTR_INETURLW L"UniformResourceLocatorW" +#define CFSTR_INETURLW "UniformResourceLocatorW" #endif // For support of MinGW w32api v2.4. @@ -93,10 +93,10 @@ IAsyncOperation : public IUnknown // http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/shlobj.h?cvsroot=src // then that can be made the base required version and this code should be removed. #ifndef CFSTR_FILEDESCRIPTORA -# define CFSTR_FILEDESCRIPTORA L"FileGroupDescriptor" +# define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor" #endif #ifndef CFSTR_FILEDESCRIPTORW -# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW" +# define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW" #endif #ifdef __MINGW32__ diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index 1b1c708c59a3..bd68753e9778 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -280,10 +280,10 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) #ifndef WINCE } catch(...) { - MessageBoxW(ofn.hwndOwner, - 0, - L"The filepicker was unexpectedly closed by Windows.", - MB_ICONERROR); + MessageBox(ofn.hwndOwner, + 0, + "The filepicker was unexpectedly closed by Windows.", + MB_ICONERROR); result = PR_FALSE; } #endif diff --git a/widget/src/windows/nsLookAndFeel.cpp b/widget/src/windows/nsLookAndFeel.cpp index 43599495ee24..c07094aa8dcd 100644 --- a/widget/src/windows/nsLookAndFeel.cpp +++ b/widget/src/windows/nsLookAndFeel.cpp @@ -56,7 +56,7 @@ static CloseThemeDataPtr closeTheme = NULL; static GetThemeColorPtr getThemeColor = NULL; static IsAppThemedPtr isAppThemed = NULL; -static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll"; +static const char kThemeLibraryName[] = "uxtheme.dll"; static HINSTANCE gThemeDLLInst = NULL; static HANDLE gMenuTheme = NULL; @@ -105,13 +105,13 @@ static PRInt32 GetSystemParam(long flag, PRInt32 def) nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel() { #ifndef WINCE - gShell32DLLInst = LoadLibraryW(L"Shell32.dll"); + gShell32DLLInst = LoadLibrary("Shell32.dll"); if (gShell32DLLInst) { gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst, "SHAppBarMessage"); } - gThemeDLLInst = LoadLibraryW(kThemeLibraryName); + gThemeDLLInst = LoadLibrary(kThemeLibraryName); if(gThemeDLLInst) { openTheme = (OpenThemeDataPtr)GetProcAddress(gThemeDLLInst, "OpenThemeData"); @@ -504,7 +504,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) if (gSHAppBarMessage) { // Get task bar window handle - HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL); + HWND shellWindow = FindWindow("Shell_TrayWnd", NULL); if (shellWindow != NULL) { diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index a4ba95007c65..6c53bfd5bd42 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -279,7 +279,7 @@ static GetThemeSysFontPtr getThemeSysFont = NULL; static GetThemeColorPtr getThemeColor = NULL; static GetThemeMarginsPtr getThemeMargins = NULL; -static const PRUnichar kThemeLibraryName[] = L"uxtheme.dll"; +static const char kThemeLibraryName[] = "uxtheme.dll"; static inline bool IsCheckboxWidgetType(PRUint8 aWidgetType) { @@ -318,7 +318,7 @@ nsNativeThemeWin::nsNativeThemeWin() { mHeaderTheme = NULL; mMenuTheme = NULL; - mThemeDLL = ::LoadLibraryW(kThemeLibraryName); + mThemeDLL = ::LoadLibrary(kThemeLibraryName); if (mThemeDLL) { openTheme = (OpenThemeDataPtr)GetProcAddress(mThemeDLL, "OpenThemeData"); closeTheme = (CloseThemeDataPtr)GetProcAddress(mThemeDLL, "CloseThemeData"); diff --git a/widget/src/windows/nsSound.cpp b/widget/src/windows/nsSound.cpp index 403a782d87d5..552171cb9ff0 100644 --- a/widget/src/windows/nsSound.cpp +++ b/widget/src/windows/nsSound.cpp @@ -40,7 +40,7 @@ #include "nscore.h" #include "plstr.h" #include -#include "nsString.h" + #include // mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN @@ -125,7 +125,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, flags |= SND_ASYNC; } - ::PlaySoundA(reinterpret_cast(data), 0, flags); + ::PlaySound(reinterpret_cast(data), 0, flags); } return NS_OK; @@ -166,10 +166,12 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias) PurgeLastSound(); if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) { - ::PlaySoundW(L"MailBeep", nsnull, SND_ALIAS | SND_ASYNC); + ::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC); } else { - ::PlaySoundW(PromiseFlatString(aSoundAlias).get(), nsnull, SND_ALIAS | SND_ASYNC); + nsCAutoString nativeSoundAlias; + NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias); + ::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC); } return NS_OK; diff --git a/widget/src/windows/nsToolkit.cpp b/widget/src/windows/nsToolkit.cpp index 1e62d2941ee4..dcd196150552 100644 --- a/widget/src/windows/nsToolkit.cpp +++ b/widget/src/windows/nsToolkit.cpp @@ -264,7 +264,7 @@ nsToolkit::Startup(HMODULE hModule) typedef BOOL (*SetProcessDPIAwareFunc)(VOID); SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc) - GetProcAddress(LoadLibraryW(L"user32.dll"), + GetProcAddress(LoadLibrary("user32.dll"), "SetProcessDPIAware"); if (setDPIAware) @@ -295,8 +295,8 @@ void nsToolkit::CreateInternalWindow(PRThread *aThread) // create the internal window // - mDispatchWnd = ::CreateWindowW(L"nsToolkitClass", - L"NetscapeDispatchWnd", + mDispatchWnd = ::CreateWindow("nsToolkitClass", + "NetscapeDispatchWnd", WS_DISABLED, -50, -50, 10, 10, diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 200ad9054c4b..7e9e96c8a19e 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -150,7 +150,7 @@ #include "prprf.h" #include "prmem.h" -static const PRUnichar kMozHeapDumpMessageString[] = L"MOZ_HeapDump"; +static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump"; #define kWindowPositionSlop 20 @@ -699,7 +699,7 @@ nsWindow::nsWindow() : nsBaseWidget() // Heap dump #ifndef WINCE - nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessageW(kMozHeapDumpMessageString); + nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString); #endif } @@ -1119,26 +1119,26 @@ nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow) return (PRBool) PtInRect(&r, mp); } -static PRUnichar sPropName[40] = L""; -static PRUnichar* GetNSWindowPropName() { +static char sPropName[40] = ""; +static char* GetNSWindowPropName() { if (!*sPropName) { - _snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p", _getpid()); + _snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid()); sPropName[39] = '\0'; } return sPropName; } nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) { - return (nsWindow *) ::GetPropW(aWnd, GetNSWindowPropName()); + return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName()); } BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) { if (ptr == NULL) { - ::RemovePropW(aWnd, GetNSWindowPropName()); + ::RemovePropA(aWnd, GetNSWindowPropName()); return TRUE; } else { - return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)ptr); + return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr); } } @@ -1788,7 +1788,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) { // Play the minimize sound while we're here, since that is also // forgotten when we use SW_SHOWMINIMIZED. - ::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC); + ::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC); } #endif break; @@ -5192,7 +5192,7 @@ LPCWSTR nsWindow::WindowPopupClassW() return className; } -LPCTSTR nsWindow::WindowClass() +LPCSTR nsWindow::WindowClass() { // Call into the wide version to make sure things get // registered properly. @@ -5200,9 +5200,7 @@ LPCTSTR nsWindow::WindowClass() // XXX: The class name used here must be kept in sync with // the classname used in WindowClassW(); -#ifdef UNICODE - return classNameW; -#else + if (classNameW == kWClassNameHidden) { return kClassNameHidden; } @@ -5219,21 +5217,17 @@ LPCTSTR nsWindow::WindowClass() return kClassNameContentFrame; } return kClassNameGeneral; -#endif } -LPCTSTR nsWindow::WindowPopupClass() +LPCSTR nsWindow::WindowPopupClass() { // Call into the wide version to make sure things get // registered properly. -#ifdef UNICODE - return WindowPopupClassW(); -#else + WindowPopupClassW(); // XXX: The class name used here must be kept in sync with // the classname used in WindowPopupClassW(); return "MozillaDropShadowWindowClass"; -#endif } //------------------------------------------------------------------------- @@ -7724,7 +7718,7 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L { // open the dll dynamically if (!gmAccLib) - gmAccLib =::LoadLibraryW(L"OLEACC.DLL"); + gmAccLib =::LoadLibrary("OLEACC.DLL"); if (gmAccLib) { if (!gmLresultFromObject) diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 77167963ac71..ecdaf4b0cf4f 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -105,13 +105,6 @@ const LPCSTR kClassNameContent = "MozillaContentWindowClass"; const LPCSTR kClassNameContentFrame = "MozillaContentFrameWindowClass"; const LPCSTR kClassNameGeneral = "MozillaWindowClass"; const LPCSTR kClassNameDialog = "MozillaDialogClass"; -const LPCTSTR kTClassNameHidden = TEXT("MozillaHiddenWindowClass"); -const LPCTSTR kTClassNameUI = TEXT("MozillaUIWindowClass"); -const LPCTSTR kTClassNameContent = TEXT("MozillaContentWindowClass"); -const LPCTSTR kTClassNameContentFrame = TEXT("MozillaContentFrameWindowClass"); -const LPCTSTR kTClassNameGeneral = TEXT("MozillaWindowClass"); -const LPCTSTR kTClassNameDialog = TEXT("MozillaDialogClass"); - /** * Native WIN32 window wrapper. diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index fe7aa06a37cf..6c7a7f3576a2 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -66,11 +66,6 @@ #include #endif -#if defined(XP_WIN) -#include -#include "nsString.h" -#endif - static void Abort(const char *aMsg); @@ -102,7 +97,7 @@ PRBool InDebugger() #ifndef WINCE PRBool fReturn = PR_FALSE; LPFNISDEBUGGERPRESENT lpfnIsDebuggerPresent = NULL; - HINSTANCE hKernel = LoadLibraryW(L"Kernel32.dll"); + HINSTANCE hKernel = LoadLibrary("Kernel32.dll"); if(hKernel) { @@ -406,9 +401,9 @@ Break(const char *aMsg) * See http://bugzilla.mozilla.org/show_bug.cgi?id=54792 */ PROCESS_INFORMATION pi; - STARTUPINFOW si; - PRUnichar executable[MAX_PATH]; - PRUnichar* pName; + STARTUPINFO si; + char executable[MAX_PATH]; + char* pName; memset(&pi, 0, sizeof(pi)); @@ -417,15 +412,13 @@ Break(const char *aMsg) si.wShowWindow = SW_SHOW; // 2nd arg of CreateProcess is in/out - PRUnichar *msgCopy = (PRUnichar*) _alloca((strlen(aMsg) + 1)*sizeof(PRUnichar)); - wcscpy(msgCopy , (PRUnichar*)NS_ConvertUTF8toUTF16(aMsg).get()); + char *msgCopy = (char*) _alloca(strlen(aMsg) + 1); + strcpy(msgCopy, aMsg); - if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), (LPWCH)executable, MAX_PATH) && - NULL != (pName = wcsrchr(executable, '\\')) && - NULL != - wcscpy((WCHAR*) - pName+1, L"windbgdlg.exe") && - CreateProcessW((LPCWSTR)executable, (LPWSTR)msgCopy, NULL, NULL, PR_FALSE, + if(GetModuleFileName(GetModuleHandle("xpcom.dll"), executable, MAX_PATH) && + NULL != (pName = strrchr(executable, '\\')) && + NULL != strcpy(pName+1, "windbgdlg.exe") && + CreateProcess(executable, msgCopy, NULL, NULL, PR_FALSE, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { WaitForSingleObject(pi.hProcess, INFINITE); diff --git a/xpcom/base/nsStackWalk.cpp b/xpcom/base/nsStackWalk.cpp index 3e26d76681e2..5a2059e35ebf 100644 --- a/xpcom/base/nsStackWalk.cpp +++ b/xpcom/base/nsStackWalk.cpp @@ -328,9 +328,9 @@ EnsureImageHlpInitialized() ::InitializeCriticalSection(&gDbgHelpCS); - HMODULE module = ::LoadLibraryW(L"DBGHELP.DLL"); + HMODULE module = ::LoadLibrary("DBGHELP.DLL"); if (!module) { - module = ::LoadLibraryW(L"IMAGEHLP.DLL"); + module = ::LoadLibrary("IMAGEHLP.DLL"); if (!module) return PR_FALSE; } diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 41f7325cccbc..5ceea5ed1050 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -127,7 +127,7 @@ NS_COM void StartupSpecialSystemDirectory() #if defined (XP_WIN) && !defined (WINCE) // SHGetKnownFolderPath is only available on Windows Vista // so that we need to use GetProcAddress to get the pointer. - gShell32DLLInst = LoadLibraryW(L"Shell32.dll"); + gShell32DLLInst = LoadLibrary("Shell32.dll"); if(gShell32DLLInst) { gGetKnownFolderPath = (nsGetKnownFolderPath) diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index c4554a824e44..ce5d35364411 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -108,8 +108,8 @@ private: * HasMoreElements reads mLetter. * GetNext advances mLetter. */ - nsString mDrives; - const PRUnichar *mLetter; + nsCString mDrives; + const char *mLetter; }; //---------------------------------------------------------------------------- @@ -2952,7 +2952,7 @@ nsresult nsDriveEnumerator::Init() /* The string is null terminated */ if (!EnsureStringLength(mDrives, length+1)) return NS_ERROR_OUT_OF_MEMORY; - if (!GetLogicalDriveStringsW(length, mDrives.BeginWriting())) + if (!GetLogicalDriveStrings(length, mDrives.BeginWriting())) return NS_ERROR_FAILURE; mLetter = mDrives.get(); return NS_OK; @@ -2982,9 +2982,8 @@ NS_IMETHODIMP nsDriveEnumerator::GetNext(nsISupports **aNext) *aNext = nsnull; return NS_OK; } - nsString drive(mDrives); + NS_ConvertASCIItoUTF16 drive(mLetter); mLetter += drive.Length() + 1; - nsILocalFile *file; nsresult rv = NS_NewLocalFile(drive, PR_FALSE, &file); diff --git a/xpcom/threads/nsProcessCommon.cpp b/xpcom/threads/nsProcessCommon.cpp index ebf8e02cad0d..21d45e1698e6 100644 --- a/xpcom/threads/nsProcessCommon.cpp +++ b/xpcom/threads/nsProcessCommon.cpp @@ -106,11 +106,10 @@ nsProcess::Init(nsIFile* executable) #if defined(XP_WIN) -static int assembleCmdLine(char *const *argv, PRUnichar **cmdLine) +static int assembleCmdLine(char *const *argv, char **cmdLine) { char *const *arg; - PRUnichar *p; - char *q; + char *p, *q; int cmdLineSize; int numBackslashes; int i; @@ -132,7 +131,7 @@ static int assembleCmdLine(char *const *argv, PRUnichar **cmdLine) + 2 /* we quote every argument */ + 1; /* space in between, or final null */ } - p = *cmdLine = (PRUnichar *) PR_MALLOC(cmdLineSize*sizeof(PRUnichar)); + p = *cmdLine = (char *) PR_MALLOC(cmdLineSize); if (p == NULL) { return -1; } @@ -238,10 +237,10 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count, my_argv[count+1] = NULL; #if defined(XP_WIN) && !defined (WINCE) /* wince uses nspr */ - STARTUPINFOW startupInfo; + STARTUPINFO startupInfo; PROCESS_INFORMATION procInfo; BOOL retVal; - PRUnichar *cmdLine; + char *cmdLine; if (assembleCmdLine(my_argv, &cmdLine) == -1) { nsMemory::Free(my_argv); @@ -251,20 +250,20 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count, ZeroMemory(&startupInfo, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); - retVal = CreateProcessW(NULL, - // const_cast(mTargetPath.get()), - cmdLine, - NULL, /* security attributes for the new - * process */ - NULL, /* security attributes for the primary - * thread in the new process */ - FALSE, /* inherit handles */ - 0, /* creation flags */ - NULL, /* env */ - NULL, /* current drive and directory */ - &startupInfo, - &procInfo - ); + retVal = CreateProcess(NULL, + // const_cast(mTargetPath.get()), + cmdLine, + NULL, /* security attributes for the new + * process */ + NULL, /* security attributes for the primary + * thread in the new process */ + FALSE, /* inherit handles */ + 0, /* creation flags */ + NULL, /* env */ + NULL, /* current drive and directory */ + &startupInfo, + &procInfo + ); PR_Free( cmdLine ); if (blocking) { diff --git a/xpcom/windbgdlg/Makefile.in b/xpcom/windbgdlg/Makefile.in index b2dcc1ef9d9d..da1bcfae4993 100644 --- a/xpcom/windbgdlg/Makefile.in +++ b/xpcom/windbgdlg/Makefile.in @@ -42,8 +42,6 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -OS_LIBS += shell32.lib - SIMPLE_PROGRAMS = windbgdlg$(BIN_SUFFIX) CPPSRCS = windbgdlg.cpp diff --git a/xpcom/windbgdlg/windbgdlg.cpp b/xpcom/windbgdlg/windbgdlg.cpp index cef47730de49..1a19f0165694 100644 --- a/xpcom/windbgdlg/windbgdlg.cpp +++ b/xpcom/windbgdlg/windbgdlg.cpp @@ -42,7 +42,6 @@ #include #include -#include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -60,11 +59,10 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, DWORD regValue = -1; DWORD regLength = sizeof regValue; HKEY hkeyCU, hkeyLM; - RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU); - RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM); - int argc =0; - LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); - for (int i = argc - 1; regValue == (DWORD)-1 && i; --i) { + RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU); + RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM); + const char * const * argv = __argv; + for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) { bool ok = false; if (hkeyCU) ok = RegQueryValueEx(hkeyCU, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS; @@ -79,15 +77,15 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, RegCloseKey(hkeyLM); if (regValue != (DWORD)-1 && regValue != (DWORD)-2) return regValue; - static PRUnichar msg[4048]; + static char msg[4048]; wsprintf(msg, - L"%s\n\nClick Abort to exit the Application.\n" - L"Click Retry to Debug the Application..\n" - L"Click Ignore to continue running the Application.", + "%s\n\nClick Abort to exit the Application.\n" + "Click Retry to Debug the Application..\n" + "Click Ignore to continue running the Application.", lpszCmdLine); - return MessageBoxW(NULL, msg, L"NSGlue_Assertion", + return MessageBox(NULL, msg, "NSGlue_Assertion", MB_ICONSTOP | MB_SYSTEMMODAL| MB_ABORTRETRYIGNORE | MB_DEFBUTTON3); } diff --git a/xpfe/bootstrap/showOSAlert.cpp b/xpfe/bootstrap/showOSAlert.cpp index 346214fe61f5..7d0d70b02a48 100644 --- a/xpfe/bootstrap/showOSAlert.cpp +++ b/xpfe/bootstrap/showOSAlert.cpp @@ -39,7 +39,6 @@ #include #include #include "nscore.h" -#include "nsString.h" //defines and includes for previous installation cleanup process #if defined (XP_WIN) @@ -64,18 +63,15 @@ printf("\n****Inside ShowOSAlert ***\n"); #endif const PRInt32 max_len = 255; + char message_copy[max_len+1] = { 0 }; PRInt32 input_len = strlen(aMessage); PRInt32 copy_len = (input_len > max_len) ? max_len : input_len; -#if defined (XP_WIN) - NS_ConvertUTF8toUTF16 msg_str(aMessage, copy_len); - PRUnichar* message_copy = (PRUnichar*)msg_str.get(); - MessageBoxW(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND ); -#else - char message_copy[max_len+1] = { 0 }; strncpy(message_copy, aMessage, copy_len); message_copy[copy_len] = 0; -#endif -#if (XP_MAC) + +#if defined (XP_WIN) + MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND ); +#elif (XP_MAC) short buttonClicked; StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked); #elif defined (XP_OS2) From e84ffaeda146da7f635b19556a54305acd231d9e Mon Sep 17 00:00:00 2001 From: "brendan@mozilla.org" Date: Wed, 5 Mar 2008 15:43:33 -0800 Subject: [PATCH 026/248] Fix signed vs. unsigned comparison in assertion warning. --- js/src/jsopcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jsopcode.c b/js/src/jsopcode.c index f2c8399dc9a2..32be82432afb 100644 --- a/js/src/jsopcode.c +++ b/js/src/jsopcode.c @@ -5100,7 +5100,7 @@ ReconstructPCStack(JSContext *cx, JSScript *script, jsbytecode *pc, ndefs = OBJ_BLOCK_COUNT(cx, obj); } - LOCAL_ASSERT(pcdepth + ndefs <= script->depth); + LOCAL_ASSERT((uintN)(pcdepth + ndefs) <= script->depth); if (pcstack) { intN i; jsbytecode *pc2; From 6f9a1f75f772ff0d31d2a7cfacc0f5f765ad8663 Mon Sep 17 00:00:00 2001 From: "dbaron@dbaron.org" Date: Wed, 5 Mar 2008 16:03:50 -0800 Subject: [PATCH 027/248] Update properties that are ignored when 'Allow pages to choose their own colors' is unchecked for the splitting of left/right border properties and the introduction of start/end border properties. b=419167 Patch by Bernd Mielke . r+sr=dbaron a=beltzner --- layout/style/nsCSSDataBlock.cpp | 8 ++- .../test/test_dont_use_document_colors.html | 65 ++++++++++++++++++- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp index 60c35edfa127..ddf8b3bd8e91 100644 --- a/layout/style/nsCSSDataBlock.cpp +++ b/layout/style/nsCSSDataBlock.cpp @@ -220,9 +220,13 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const iProp == eCSSProperty_background_color || iProp == eCSSProperty_background_image || iProp == eCSSProperty_border_top_color || - iProp == eCSSProperty_border_right_color || + iProp == eCSSProperty_border_right_color_value || + iProp == eCSSProperty_border_right_color_ltr_source || + iProp == eCSSProperty_border_right_color_rtl_source || iProp == eCSSProperty_border_bottom_color || - iProp == eCSSProperty_border_left_color || + iProp == eCSSProperty_border_left_color_value || + iProp == eCSSProperty_border_left_color_ltr_source || + iProp == eCSSProperty_border_left_color_rtl_source || iProp == eCSSProperty_outline_color) { if (ShouldIgnoreColors(aRuleData)) { if (iProp == eCSSProperty_background_color) { diff --git a/layout/style/test/test_dont_use_document_colors.html b/layout/style/test/test_dont_use_document_colors.html index a96f1984350e..f03cecd24b56 100644 --- a/layout/style/test/test_dont_use_document_colors.html +++ b/layout/style/test/test_dont_use_document_colors.html @@ -11,6 +11,7 @@ #one, #three { background: blue; color: yellow; border: thin solid red; } #two { background: transparent; border: thin solid; } + #five, #six {border: thick solid red; -moz-border-start-color:green; -moz-border-end-color:blue} /* XXX also test rgba() */ @@ -25,6 +26,8 @@
Hello
+
Hello
+
Hello
@@ -53,13 +56,17 @@ var cs1 = getComputedStyle(document.getElementById("one"), "");
 var cs2 = getComputedStyle(document.getElementById("two"), "");
 var cs3 = getComputedStyle(document.getElementById("three"), "");
 var cs4 = getComputedStyle(document.getElementById("four"), "");
+var cs5 = getComputedStyle(document.getElementById("five"), "");
+var cs6 = getComputedStyle(document.getElementById("six"), "");
+
 
 var oldVal = get_pref();
 set_pref(true);
 setTimeout(part1, 0);
 
 var transparentBackgroundColor;
-var inputBackgroundColor, inputColor, inputBorderColor;
+var inputBackgroundColor, inputColor, inputBorderTopColor;
+var inputBorderRightColor, inputBorderLeftColor, inputBorderBottomColor;
 
 function part1()
 {
@@ -67,17 +74,45 @@ function part1()
     isnot(cs1.backgroundColor, cs2.backgroundColor, "background-color applies");
     isnot(cs1.color, cs2.color, "color applies");
     isnot(cs1.borderTopColor, cs2.borderTopColor, "border-top-color applies");
+    isnot(cs1.borderRightColor, cs2.borderRightColor,
+          "border-right-color applies");
+    isnot(cs1.borderLeftColor, cs2.borderLeftColor,
+          "border-left-color applies");
+    isnot(cs1.borderBottomColor, cs2.borderBottomColor,
+          "border-top-color applies");
     is(cs1.borderTopColor, cs3.borderTopColor, "border-top-color applies");
+    is(cs1.borderRightColor, cs3.borderRightColor,
+       "border-right-color applies");
+    is(cs1.borderLeftColor, cs3.borderLeftColor,
+       "border-left-color applies");
+    is(cs1.borderBottomColor, cs3.borderBottomColor, 
+       "border-top-color applies");
+    isnot(cs5.borderRightColor, cs2.borderRightColor,
+          "-moz-border-end-color applies");
+    isnot(cs5.borderLeftColor, cs2.borderLeftColor,
+          "-moz-border-start-color applies");    
+    isnot(cs6.borderRightColor, cs2.borderRightColor,
+          "-moz-border-start-color applies");
+    isnot(cs6.borderLeftColor, cs2.borderLeftColor,
+          "-moz-border-end-color applies");
     is(cs1.color, cs3.color, "color applies");
     is(cs1.backgroundColor, cs3.backgroundColor, "background-color applies");
     isnot(cs3.backgroundColor, cs4.backgroundColor, "background-color applies");
     isnot(cs3.color, cs4.color, "color applies");
     isnot(cs3.borderTopColor, cs4.borderTopColor, "border-top-color applies");
+    isnot(cs3.borderRightColor, cs4.borderRightColor,
+          "border-right-color applies");
+    isnot(cs3.borderLeftColor, cs4.borderLeftColor,
+          "border-left-color applies");
+    isnot(cs3.borderBottomColor, cs4.borderBottomColor,
+          "border-bottom-color applies");
     transparentBackgroundColor = cs2.backgroundColor;
     inputBackgroundColor = cs4.backgroundColor;
     inputColor = cs4.color;
     inputBorderTopColor = cs4.borderTopColor;
-
+    inputBorderRightColor = cs4.borderRightColor;
+    inputBorderLeftColor = cs4.borderLeftColor;
+    inputBorderBottomColor = cs4.borderBottomColor;
     set_pref(false);
     setTimeout(part2, 0);
 }
@@ -88,12 +123,38 @@ function part2()
     is(cs2.backgroundColor, transparentBackgroundColor, "background-color transparency is preserved (transparent)");
     is(cs1.color, cs2.color, "color is blocked");
     is(cs1.borderTopColor, cs2.borderTopColor, "border-top-color is blocked");
+    is(cs1.borderRightColor, cs2.borderRightColor,
+       "border-right-color is blocked");
+    is(cs1.borderLeftColor, cs2.borderLeftColor,
+       "border-left-color is blocked");
+    is(cs5.borderRightColor, cs2.borderRightColor,
+       "-moz-border-end-color is blocked");
+    is(cs5.borderLeftColor, cs2.borderLeftColor,
+       "-moz-border-start-color is blocked");
+    is(cs6.borderRightColor, cs2.borderRightColor,
+       "-moz-border-start-color is blocked");
+    is(cs6.borderLeftColor, cs2.borderLeftColor,
+       "-moz-border-end-color is blocked");
+    is(cs1.borderBottomColor, cs2.borderBottomColor,
+       "border-bottom-color is blocked");
     is(cs3.backgroundColor, cs1.backgroundColor, "background-color transparency preserved (opaque)");
     is(cs3.color, cs4.color, "color is blocked");
     is(cs3.borderTopColor, cs4.borderTopColor, "border-top-color is blocked");
+    is(cs3.borderRightColor, cs4.borderRightColor,
+       "border-right-color is blocked");
+    is(cs3.borderLeftColor, cs4.borderLeftColor,
+       "border-left-color is blocked");
+    is(cs3.borderBottomColor, cs4.borderBottomColor,
+       "border-bottom-color is blocked");
     is(cs4.backgroundColor, inputBackgroundColor, "background-color not broken on inputs");
     is(cs4.color, inputColor, "color not broken on inputs");
     is(cs4.borderTopColor, inputBorderTopColor, "border-top-color not broken on inputs");
+    is(cs4.borderRightColor, inputBorderRightColor,
+       "border-right-color not broken on inputs");
+    is(cs4.borderLeftColor, inputBorderLeftColor,
+       "border-left-color not broken on inputs");
+    is(cs4.borderBottomColor, inputBorderBottomColor,
+       "border-bottom-color not broken on inputs");
 
     set_pref(oldVal);
     SimpleTest.finish();

From 0d8b56073306b49b228a5bb01dc6bb400b541973 Mon Sep 17 00:00:00 2001
From: "dbaron@dbaron.org" 
Date: Wed, 5 Mar 2008 16:05:26 -0800
Subject: [PATCH 028/248] Fix the weird Get* API on nsStyleSides in favor of
 returning structs by value, to avoid further occurrences of bug 420069. 
 b=420069  r+sr=roc  a=beltzner

---
 layout/base/nsCSSRendering.cpp        | 32 +++++++-------
 layout/base/nsLayoutUtils.cpp         | 14 ++----
 layout/forms/nsFieldSetFrame.cpp      | 10 ++---
 layout/generic/nsBlockFrame.cpp       | 17 ++-----
 layout/generic/nsContainerFrame.cpp   |  9 ++--
 layout/generic/nsFrame.cpp            |  9 ++--
 layout/generic/nsHTMLReflowState.cpp  | 64 +++++++++------------------
 layout/generic/nsInlineFrame.cpp      | 17 ++++---
 layout/style/nsComputedDOMStyle.cpp   | 20 +++------
 layout/style/nsRuleNode.cpp           | 20 ++++-----
 layout/style/nsStyleCoord.cpp         | 35 ++-------------
 layout/style/nsStyleCoord.h           | 56 +++++++++++++++--------
 layout/style/nsStyleStruct.cpp        |  8 +---
 layout/xul/base/src/nsStackLayout.cpp |  8 +---
 14 files changed, 127 insertions(+), 192 deletions(-)

diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp
index 7bb50d7d9d75..1d96118a80ca 100644
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -2724,10 +2724,10 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
   }
 
   // get the radius for our border
-  aBorderStyle.mBorderRadius.GetTop(bordStyleRadius[0]);      //topleft
-  aBorderStyle.mBorderRadius.GetRight(bordStyleRadius[1]);    //topright
-  aBorderStyle.mBorderRadius.GetBottom(bordStyleRadius[2]);   //bottomright
-  aBorderStyle.mBorderRadius.GetLeft(bordStyleRadius[3]);     //bottomleft
+  bordStyleRadius[0] = aBorderStyle.mBorderRadius.GetTop();    //topleft
+  bordStyleRadius[1] = aBorderStyle.mBorderRadius.GetRight();  //topright
+  bordStyleRadius[2] = aBorderStyle.mBorderRadius.GetBottom(); //bottomright
+  bordStyleRadius[3] = aBorderStyle.mBorderRadius.GetLeft();   //bottomleft
 
   // convert percentage values
   for(int i = 0; i < 4; i++) {
@@ -2890,10 +2890,10 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
     (aStyleContext, PR_FALSE);
 
   // get the radius for our outline
-  aOutlineStyle.mOutlineRadius.GetTop(bordStyleRadius[0]);      //topleft
-  aOutlineStyle.mOutlineRadius.GetRight(bordStyleRadius[1]);    //topright
-  aOutlineStyle.mOutlineRadius.GetBottom(bordStyleRadius[2]);   //bottomright
-  aOutlineStyle.mOutlineRadius.GetLeft(bordStyleRadius[3]);     //bottomleft
+  bordStyleRadius[0] = aOutlineStyle.mOutlineRadius.GetTop();    //topleft
+  bordStyleRadius[1] = aOutlineStyle.mOutlineRadius.GetRight();  //topright
+  bordStyleRadius[2] = aOutlineStyle.mOutlineRadius.GetBottom(); //bottomright
+  bordStyleRadius[3] = aOutlineStyle.mOutlineRadius.GetLeft();   //bottomleft
 
   // convert percentage values
   for (int i = 0; i < 4; i++) {
@@ -3737,10 +3737,10 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
   nscoord borderRadii[4];
 
   // get the radius for our border
-  aBorder.mBorderRadius.GetTop(bordStyleRadius[NS_SIDE_TOP]);       // topleft
-  aBorder.mBorderRadius.GetRight(bordStyleRadius[NS_SIDE_RIGHT]);   // topright
-  aBorder.mBorderRadius.GetBottom(bordStyleRadius[NS_SIDE_BOTTOM]); // bottomright
-  aBorder.mBorderRadius.GetLeft(bordStyleRadius[NS_SIDE_LEFT]);     // bottomleft
+  bordStyleRadius[NS_SIDE_TOP] = aBorder.mBorderRadius.GetTop();       // topleft
+  bordStyleRadius[NS_SIDE_RIGHT] = aBorder.mBorderRadius.GetRight();   // topright
+  bordStyleRadius[NS_SIDE_BOTTOM] = aBorder.mBorderRadius.GetBottom(); // bottomright
+  bordStyleRadius[NS_SIDE_LEFT] = aBorder.mBorderRadius.GetLeft();     // bottomleft
 
   PRBool haveRadius = PR_FALSE;
   PRUint8 side = 0;
@@ -3951,10 +3951,10 @@ nsCSSRendering::PaintBackgroundColor(nsPresContext* aPresContext,
   nsRect bgClipArea(aBgClipArea);
 
   // get the radius for our border
-  aBorder.mBorderRadius.GetTop(bordStyleRadius[NS_SIDE_TOP]);       // topleft
-  aBorder.mBorderRadius.GetRight(bordStyleRadius[NS_SIDE_RIGHT]);   // topright
-  aBorder.mBorderRadius.GetBottom(bordStyleRadius[NS_SIDE_BOTTOM]); // bottomright
-  aBorder.mBorderRadius.GetLeft(bordStyleRadius[NS_SIDE_LEFT]);     // bottomleft
+  bordStyleRadius[NS_SIDE_TOP] = aBorder.mBorderRadius.GetTop();       // topleft
+  bordStyleRadius[NS_SIDE_RIGHT] = aBorder.mBorderRadius.GetRight();   // topright
+  bordStyleRadius[NS_SIDE_BOTTOM] = aBorder.mBorderRadius.GetBottom(); // bottomright
+  bordStyleRadius[NS_SIDE_LEFT] = aBorder.mBorderRadius.GetLeft();     // bottomleft
 
   PRUint8 side = 0;
   for (; side < 4; ++side) {
diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp
index b7813b77d8a0..d271fede78f9 100644
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2458,16 +2458,10 @@ static PRBool NonZeroStyleCoord(const nsStyleCoord& aCoord)
 /* static */ PRBool
 nsLayoutUtils::HasNonZeroSide(const nsStyleSides& aSides)
 {
-  nsStyleCoord coord;
-  aSides.GetTop(coord);
-  if (NonZeroStyleCoord(coord)) return PR_TRUE;    
-  aSides.GetRight(coord);
-  if (NonZeroStyleCoord(coord)) return PR_TRUE;    
-  aSides.GetBottom(coord);
-  if (NonZeroStyleCoord(coord)) return PR_TRUE;    
-  aSides.GetLeft(coord);
-  if (NonZeroStyleCoord(coord)) return PR_TRUE;    
-  return PR_FALSE;
+  return NonZeroStyleCoord(aSides.GetTop()) ||
+         NonZeroStyleCoord(aSides.GetRight()) ||
+         NonZeroStyleCoord(aSides.GetBottom()) ||
+         NonZeroStyleCoord(aSides.GetLeft());
 }
 
 /* static */ PRBool
diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp
index b27531bb4d7a..23854e9776fe 100644
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -352,19 +352,17 @@ nsFieldSetFrame::GetLegendPrefWidth(nsIRenderingContext* aRenderingContext)
   // because legends ignore their CSS-specified width.
   nscoord result = mLegendFrame->GetPrefWidth(aRenderingContext);
 
-  nsStyleCoord tmp;
-
   const nsStylePadding *stylePadding = mLegendFrame->GetStylePadding();
-  result += GetCoord(stylePadding->mPadding.GetLeft(tmp), 0);
-  result += GetCoord(stylePadding->mPadding.GetRight(tmp), 0);
+  result += GetCoord(stylePadding->mPadding.GetLeft(), 0);
+  result += GetCoord(stylePadding->mPadding.GetRight(), 0);
 
   const nsStyleBorder *styleBorder = mLegendFrame->GetStyleBorder();
   result += styleBorder->GetBorderWidth(NS_SIDE_LEFT);
   result += styleBorder->GetBorderWidth(NS_SIDE_RIGHT);
 
   const nsStyleMargin *styleMargin = mLegendFrame->GetStyleMargin();
-  result += GetCoord(styleMargin->mMargin.GetLeft(tmp), 0);
-  result += GetCoord(styleMargin->mMargin.GetRight(tmp), 0);
+  result += GetCoord(styleMargin->mMargin.GetLeft(), 0);
+  result += GetCoord(styleMargin->mMargin.GetRight(), 0);
 
   return result;
 }
diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp
index c6166d8d9d5b..b7b7acaa5fae 100644
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -2575,21 +2575,13 @@ nsBlockFrame::AttributeChanged(PRInt32         aNameSpaceID,
   return rv;
 }
 
-inline PRBool
-IsPaddingZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
+static inline PRBool
+IsPaddingZero(nsStyleUnit aUnit, const nsStyleCoord &aCoord)
 {
     return ((aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
             (aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
 }
 
-inline PRBool
-IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
-{
-    return (aUnit == eStyleUnit_Auto ||
-            (aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
-            (aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
-}
-
 /* virtual */ PRBool
 nsBlockFrame::IsSelfEmpty()
 {
@@ -2631,13 +2623,12 @@ nsBlockFrame::IsSelfEmpty()
 
   const nsStyleBorder* border = GetStyleBorder();
   const nsStylePadding* padding = GetStylePadding();
-  nsStyleCoord coord;
   if (border->GetBorderWidth(NS_SIDE_TOP) != 0 ||
       border->GetBorderWidth(NS_SIDE_BOTTOM) != 0 ||
       !IsPaddingZero(padding->mPadding.GetTopUnit(),
-                    padding->mPadding.GetTop(coord)) ||
+                     padding->mPadding.GetTop()) ||
       !IsPaddingZero(padding->mPadding.GetBottomUnit(),
-                    padding->mPadding.GetBottom(coord))) {
+                     padding->mPadding.GetBottom())) {
     return PR_FALSE;
   }
 
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp
index 070da842e4ab..9415cb755447 100644
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -655,16 +655,15 @@ nsContainerFrame::DoInlineIntrinsicWidth(nsIRenderingContext *aRenderingContext,
   const nsStylePadding *stylePadding = GetStylePadding();
   const nsStyleBorder *styleBorder = GetStyleBorder();
   const nsStyleMargin *styleMargin = GetStyleMargin();
-  nsStyleCoord marginCoord, paddingCoord;
 
   // This goes at the beginning no matter how things are broken and how
   // messy the bidi situations are, since per CSS2.1 section 8.6
   // (implemented in bug 328168), the startSide border is always on the
   // first line.
   aData->currentLine +=
-    GetCoord(stylePadding->mPadding.Get(startSide, paddingCoord), 0) +
+    GetCoord(stylePadding->mPadding.Get(startSide), 0) +
     styleBorder->GetBorderWidth(startSide) +
-    GetCoord(styleMargin->mMargin.Get(startSide, marginCoord), 0);
+    GetCoord(styleMargin->mMargin.Get(startSide), 0);
 
   const nsLineList_iterator* savedLine = aData->line;
 
@@ -692,9 +691,9 @@ nsContainerFrame::DoInlineIntrinsicWidth(nsIRenderingContext *aRenderingContext,
   // (implemented in bug 328168), the endSide border is always on the
   // last line.
   aData->currentLine +=
-    GetCoord(stylePadding->mPadding.Get(endSide, paddingCoord), 0) +
+    GetCoord(stylePadding->mPadding.Get(endSide), 0) +
     styleBorder->GetBorderWidth(endSide) +
-    GetCoord(styleMargin->mMargin.Get(endSide, marginCoord), 0);
+    GetCoord(styleMargin->mMargin.Get(endSide), 0);
 }
 
 /* virtual */ nsSize
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
index e4b9d9c649eb..33c432087404 100644
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2917,18 +2917,17 @@ AddCoord(const nsStyleCoord& aStyle,
 nsFrame::IntrinsicWidthOffsets(nsIRenderingContext* aRenderingContext)
 {
   IntrinsicWidthOffsetData result;
-  nsStyleCoord tmp;
 
   const nsStyleMargin *styleMargin = GetStyleMargin();
-  AddCoord(styleMargin->mMargin.GetLeft(tmp), aRenderingContext, this,
+  AddCoord(styleMargin->mMargin.GetLeft(), aRenderingContext, this,
            &result.hMargin, &result.hPctMargin);
-  AddCoord(styleMargin->mMargin.GetRight(tmp), aRenderingContext, this,
+  AddCoord(styleMargin->mMargin.GetRight(), aRenderingContext, this,
            &result.hMargin, &result.hPctMargin);
 
   const nsStylePadding *stylePadding = GetStylePadding();
-  AddCoord(stylePadding->mPadding.GetLeft(tmp), aRenderingContext, this,
+  AddCoord(stylePadding->mPadding.GetLeft(), aRenderingContext, this,
            &result.hPadding, &result.hPctPadding);
-  AddCoord(stylePadding->mPadding.GetRight(tmp), aRenderingContext, this,
+  AddCoord(stylePadding->mPadding.GetRight(), aRenderingContext, this,
            &result.hPadding, &result.hPctPadding);
 
   const nsStyleBorder *styleBorder = GetStyleBorder();
diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp
index 1732e2781765..d2c311dc28e4 100644
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -579,8 +579,6 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
                                           nscoord aContainingBlockWidth,
                                           nscoord aContainingBlockHeight)
 {
-  nsStyleCoord  coord;
-
   // Compute the 'left' and 'right' values. 'Left' moves the boxes to the right,
   // and 'right' moves the boxes to the left. The computed values are always:
   // left=-right
@@ -616,7 +614,7 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
     } else {
       // 'Right' isn't 'auto' so compute its value
       ComputeWidthDependentValue(aContainingBlockWidth,
-                                 mStylePosition->mOffset.GetRight(coord),
+                                 mStylePosition->mOffset.GetRight(),
                                  mComputedOffsets.right);
       
       // Computed value for 'left' is minus the value of 'right'
@@ -628,7 +626,7 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
     
     // 'Left' isn't 'auto' so compute its value
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               mStylePosition->mOffset.GetLeft(coord),
+                               mStylePosition->mOffset.GetLeft(),
                                mComputedOffsets.left);
 
     // Computed value for 'right' is minus the value of 'left'
@@ -664,7 +662,7 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
     } else {
       // 'Bottom' isn't 'auto' so compute its value
       ComputeHeightDependentValue(aContainingBlockHeight,
-                                  mStylePosition->mOffset.GetBottom(coord),
+                                  mStylePosition->mOffset.GetBottom(),
                                   mComputedOffsets.bottom);
       
       // Computed value for 'top' is minus the value of 'bottom'
@@ -676,7 +674,7 @@ nsHTMLReflowState::ComputeRelativeOffsets(const nsHTMLReflowState* cbrs,
     
     // 'Top' isn't 'auto' so compute its value
     ComputeHeightDependentValue(aContainingBlockHeight,
-                                mStylePosition->mOffset.GetTop(coord),
+                                mStylePosition->mOffset.GetTop(),
                                 mComputedOffsets.top);
 
     // Computed value for 'bottom' is minus the value of 'top'
@@ -779,28 +777,24 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(
 
   // See if the style system can provide us the padding directly
   if (!mStylePadding->GetPadding(padding)) {
-    nsStyleCoord left, right;
-
     // We have to compute the left and right values
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               mStylePadding->mPadding.GetLeft(left),
+                               mStylePadding->mPadding.GetLeft(),
                                padding.left);
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               mStylePadding->mPadding.GetRight(right),
+                               mStylePadding->mPadding.GetRight(),
                                padding.right);
   }
 
   // See if the style system can provide us the margin directly
   if (!mStyleMargin->GetMargin(margin)) {
-    nsStyleCoord left, right;
-
     // We have to compute the left and right values
     if (eStyleUnit_Auto == mStyleMargin->mMargin.GetLeftUnit()) {
       // XXX FIXME (or does CalculateBlockSideMargins do this?)
       margin.left = 0;  // just ignore
     } else {
       ComputeWidthDependentValue(aContainingBlockWidth,
-                                 mStyleMargin->mMargin.GetLeft(left),
+                                 mStyleMargin->mMargin.GetLeft(),
                                  margin.left);
     }
     if (eStyleUnit_Auto == mStyleMargin->mMargin.GetRightUnit()) {
@@ -808,7 +802,7 @@ nsHTMLReflowState::CalculateHorizBorderPaddingMargin(
       margin.right = 0;  // just ignore
     } else {
       ComputeWidthDependentValue(aContainingBlockWidth,
-                                 mStyleMargin->mMargin.GetRight(right),
+                                 mStyleMargin->mMargin.GetRight(),
                                  margin.right);
     }
   }
@@ -1108,13 +1102,12 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
   // Initialize the 'left' and 'right' computed offsets
   // XXX Handle new 'static-position' value...
   PRBool        leftIsAuto = PR_FALSE, rightIsAuto = PR_FALSE;
-  nsStyleCoord  coord;
   if (eStyleUnit_Auto == mStylePosition->mOffset.GetLeftUnit()) {
     mComputedOffsets.left = 0;
     leftIsAuto = PR_TRUE;
   } else {
     ComputeWidthDependentValue(containingBlockWidth,
-                               mStylePosition->mOffset.GetLeft(coord),
+                               mStylePosition->mOffset.GetLeft(),
                                mComputedOffsets.left);
   }
   if (eStyleUnit_Auto == mStylePosition->mOffset.GetRightUnit()) {
@@ -1122,7 +1115,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
     rightIsAuto = PR_TRUE;
   } else {
     ComputeWidthDependentValue(containingBlockWidth,
-                               mStylePosition->mOffset.GetRight(coord),
+                               mStylePosition->mOffset.GetRight(),
                                mComputedOffsets.right);
   }
 
@@ -1160,18 +1153,16 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
     mComputedOffsets.top = 0;
     topIsAuto = PR_TRUE;
   } else {
-    nsStyleCoord c;
     ComputeHeightDependentValue(containingBlockHeight,
-                                mStylePosition->mOffset.GetTop(c),
+                                mStylePosition->mOffset.GetTop(),
                                 mComputedOffsets.top);
   }
   if (eStyleUnit_Auto == mStylePosition->mOffset.GetBottomUnit()) {
     mComputedOffsets.bottom = 0;        
     bottomIsAuto = PR_TRUE;
   } else {
-    nsStyleCoord c;
     ComputeHeightDependentValue(containingBlockHeight,
-                                mStylePosition->mOffset.GetBottom(c),
+                                mStylePosition->mOffset.GetBottom(),
                                 mComputedOffsets.bottom);
   }
 
@@ -2084,39 +2075,30 @@ nsCSSOffsetState::ComputeMargin(nscoord aContainingBlockWidth)
       mComputedMargin.right = 0;
 
       if (eStyleUnit_Coord == styleMargin->mMargin.GetLeftUnit()) {
-        nsStyleCoord left;
-        
-        styleMargin->mMargin.GetLeft(left),
-        mComputedMargin.left = left.GetCoordValue();
+        mComputedMargin.left = styleMargin->mMargin.GetLeft().GetCoordValue();
       }
       if (eStyleUnit_Coord == styleMargin->mMargin.GetRightUnit()) {
-        nsStyleCoord right;
-        
-        styleMargin->mMargin.GetRight(right),
-        mComputedMargin.right = right.GetCoordValue();
+        mComputedMargin.right = styleMargin->mMargin.GetRight().GetCoordValue();
       }
 
     } else {
-      nsStyleCoord left, right;
-
       ComputeWidthDependentValue(aContainingBlockWidth,
-                                 styleMargin->mMargin.GetLeft(left),
+                                 styleMargin->mMargin.GetLeft(),
                                  mComputedMargin.left);
       ComputeWidthDependentValue(aContainingBlockWidth,
-                                 styleMargin->mMargin.GetRight(right),
+                                 styleMargin->mMargin.GetRight(),
                                  mComputedMargin.right);
     }
 
-    nsStyleCoord top, bottom;
     // According to the CSS2 spec, margin percentages are
     // calculated with respect to the *width* of the containing
     // block, even for margin-top and margin-bottom.
     // XXX This isn't true for page boxes, if we implement them.
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               styleMargin->mMargin.GetTop(top),
+                               styleMargin->mMargin.GetTop(),
                                mComputedMargin.top);
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               styleMargin->mMargin.GetBottom(bottom),
+                               styleMargin->mMargin.GetBottom(),
                                mComputedMargin.bottom);
 
     // XXX We need to include 'auto' horizontal margins in this too!
@@ -2136,22 +2118,20 @@ nsCSSOffsetState::ComputePadding(nscoord aContainingBlockWidth)
   const nsStylePadding *stylePadding = frame->GetStylePadding();
   if (!stylePadding->GetPadding(mComputedPadding)) {
     // We have to compute the value
-    nsStyleCoord left, right, top, bottom;
-
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               stylePadding->mPadding.GetLeft(left),
+                               stylePadding->mPadding.GetLeft(),
                                mComputedPadding.left);
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               stylePadding->mPadding.GetRight(right),
+                               stylePadding->mPadding.GetRight(),
                                mComputedPadding.right);
 
     // According to the CSS2 spec, percentages are calculated with respect to
     // containing block width for padding-top and padding-bottom
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               stylePadding->mPadding.GetTop(top),
+                               stylePadding->mPadding.GetTop(),
                                mComputedPadding.top);
     ComputeWidthDependentValue(aContainingBlockWidth,
-                               stylePadding->mPadding.GetBottom(bottom),
+                               stylePadding->mPadding.GetBottom(),
                                mComputedPadding.bottom);
 
     frame->SetProperty(nsGkAtoms::usedPaddingProperty,
diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp
index 4bd703e1cb20..921e531a0767 100644
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -102,15 +102,15 @@ nsInlineFrame::GetType() const
   return nsGkAtoms::inlineFrame;
 }
 
-inline PRBool
-IsPaddingZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
+static inline PRBool
+IsPaddingZero(nsStyleUnit aUnit, const nsStyleCoord &aCoord)
 {
     return ((aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
             (aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
 }
 
-inline PRBool
-IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
+static inline PRBool
+IsMarginZero(nsStyleUnit aUnit, const nsStyleCoord &aCoord)
 {
     return (aUnit == eStyleUnit_Auto ||
             (aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
@@ -130,20 +130,19 @@ nsInlineFrame::IsSelfEmpty()
   const nsStyleMargin* margin = GetStyleMargin();
   const nsStyleBorder* border = GetStyleBorder();
   const nsStylePadding* padding = GetStylePadding();
-  nsStyleCoord coord;
   // XXX Top and bottom removed, since they shouldn't affect things, but this
   // doesn't really match with nsLineLayout.cpp's setting of
   // ZeroEffectiveSpanBox, anymore, so what should this really be?
   if (border->GetBorderWidth(NS_SIDE_RIGHT) != 0 ||
       border->GetBorderWidth(NS_SIDE_LEFT) != 0 ||
       !IsPaddingZero(padding->mPadding.GetRightUnit(),
-                     padding->mPadding.GetRight(coord)) ||
+                     padding->mPadding.GetRight()) ||
       !IsPaddingZero(padding->mPadding.GetLeftUnit(),
-                     padding->mPadding.GetLeft(coord)) ||
+                     padding->mPadding.GetLeft()) ||
       !IsMarginZero(margin->mMargin.GetRightUnit(),
-                    margin->mMargin.GetRight(coord)) ||
+                    margin->mMargin.GetRight()) ||
       !IsMarginZero(margin->mMargin.GetLeftUnit(),
-                    margin->mMargin.GetLeft(coord))) {
+                    margin->mMargin.GetLeft())) {
     return PR_FALSE;
   }
   return PR_TRUE;
diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp
index 3bc781b62a2d..aec5be0f8bbc 100644
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1551,8 +1551,7 @@ nsComputedDOMStyle::GetOutlineRadiusFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
-  nsStyleCoord coord;
-  SetValueToCoord(val, GetStyleOutline()->mOutlineRadius.Get(aSide, coord),
+  SetValueToCoord(val, GetStyleOutline()->mOutlineRadius.Get(aSide),
                   &nsComputedDOMStyle::GetFrameBorderRectWidth);
 
   return CallQueryInterface(val, aValue);
@@ -2696,9 +2695,8 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
   const nsStylePosition* positionData = GetStylePosition();
-  nsStyleCoord coord;
   PRInt32 sign = 1;
-  positionData->mOffset.Get(aSide, coord);
+  nsStyleCoord coord = positionData->mOffset.Get(aSide);
 
   NS_ASSERTION(coord.GetUnit() == eStyleUnit_Coord ||
                coord.GetUnit() == eStyleUnit_Percent ||
@@ -2707,7 +2705,7 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
                "Unexpected unit");
   
   if (coord.GetUnit() == eStyleUnit_Auto) {
-    positionData->mOffset.Get(NS_OPPOSITE_SIDE(aSide), coord);
+    coord = positionData->mOffset.Get(NS_OPPOSITE_SIDE(aSide));
     sign = -1;
   }
   PercentageBaseGetter baseGetter;
@@ -2729,8 +2727,7 @@ nsComputedDOMStyle::GetStaticOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
-  nsStyleCoord coord;
-  SetValueToCoord(val, GetStylePosition()->mOffset.Get(aSide, coord));
+  SetValueToCoord(val, GetStylePosition()->mOffset.Get(aSide));
   
   return CallQueryInterface(val, aValue);
 }
@@ -2752,8 +2749,7 @@ nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
   if (!mInnerFrame) {
-    nsStyleCoord c;
-    SetValueToCoord(val, GetStylePadding()->mPadding.Get(aSide, c));
+    SetValueToCoord(val, GetStylePadding()->mPadding.Get(aSide));
   } else {
     FlushPendingReflows();
   
@@ -2848,8 +2844,7 @@ nsComputedDOMStyle::GetBorderRadiusFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
-  nsStyleCoord coord;
-  SetValueToCoord(val, GetStyleBorder()->mBorderRadius.Get(aSide, coord),
+  SetValueToCoord(val, GetStyleBorder()->mBorderRadius.Get(aSide),
                   &nsComputedDOMStyle::GetFrameBorderRectWidth);
 
   return CallQueryInterface(val, aValue);
@@ -2909,8 +2904,7 @@ nsComputedDOMStyle::GetMarginWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
   if (!mInnerFrame) {
-    nsStyleCoord c;
-    SetValueToCoord(val, GetStyleMargin()->mMargin.Get(aSide, c));
+    SetValueToCoord(val, GetStyleMargin()->mMargin.Get(aSide));
   } else {
     FlushPendingReflows();
 
diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp
index 77116d46f5bb..c7e1a750d1ce 100644
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3599,7 +3599,6 @@ nsRuleNode::ComputeMarginData(void* aStartStruct,
 
   // margin: length, percent, auto, inherit
   nsStyleCoord  coord;
-  nsStyleCoord  parentCoord;
   nsCSSRect ourMargin(marginData.mMargin);
   AdjustLogicalBoxProp(aContext,
                        marginData.mMarginLeftLTRSource,
@@ -3612,7 +3611,7 @@ nsRuleNode::ComputeMarginData(void* aStartStruct,
                        marginData.mMarginEnd, marginData.mMarginStart,
                        NS_SIDE_RIGHT, ourMargin, inherited);
   NS_FOR_CSS_SIDES(side) {
-    parentMargin->mMargin.Get(side, parentCoord);
+    nsStyleCoord parentCoord = parentMargin->mMargin.Get(side);
     if (SetCoord(ourMargin.*(nsCSSRect::sides[side]),
                  coord, parentCoord, SETCOORD_LPAH | SETCOORD_INITIAL_ZERO,
                  aContext, mPresContext, inherited)) {
@@ -3636,7 +3635,6 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
 
   // border-width, border-*-width: length, enum, inherit
   nsStyleCoord  coord;
-  nsStyleCoord  parentCoord;
   nsCSSRect ourBorderWidth(marginData.mBorderWidth);
   AdjustLogicalBoxProp(aContext,
                        marginData.mBorderLeftWidthLTRSource,
@@ -3669,8 +3667,9 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
         border->SetBorderWidth(side,
                                (mPresContext->GetBorderWidthTable())[value.GetIntValue()]);
       }
-      else if (SetCoord(value, coord, parentCoord, SETCOORD_LENGTH, aContext,
-                        mPresContext, inherited)) {
+      // OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT
+      else if (SetCoord(value, coord, nsStyleCoord(), SETCOORD_LENGTH,
+                        aContext, mPresContext, inherited)) {
         if (coord.GetUnit() == eStyleUnit_Coord) {
           border->SetBorderWidth(side, coord.GetCoordValue());
         }
@@ -3807,7 +3806,7 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
   // -moz-border-radius: length, percent, inherit
   { // scope for compilers with broken |for| loop scoping
     NS_FOR_CSS_SIDES(side) {
-      parentBorder->mBorderRadius.Get(side, parentCoord);
+      nsStyleCoord parentCoord = parentBorder->mBorderRadius.Get(side);
       if (SetCoord(marginData.mBorderRadius.*(nsCSSRect::sides[side]), coord,
                    parentCoord, SETCOORD_LPH | SETCOORD_INITIAL_ZERO,
                    aContext, mPresContext, inherited))
@@ -3840,7 +3839,6 @@ nsRuleNode::ComputePaddingData(void* aStartStruct,
 
   // padding: length, percent, inherit
   nsStyleCoord  coord;
-  nsStyleCoord  parentCoord;
   nsCSSRect ourPadding(marginData.mPadding);
   AdjustLogicalBoxProp(aContext,
                        marginData.mPaddingLeftLTRSource,
@@ -3853,7 +3851,7 @@ nsRuleNode::ComputePaddingData(void* aStartStruct,
                        marginData.mPaddingEnd, marginData.mPaddingStart,
                        NS_SIDE_RIGHT, ourPadding, inherited);
   NS_FOR_CSS_SIDES(side) {
-    parentPadding->mPadding.Get(side, parentCoord);
+    nsStyleCoord parentCoord = parentPadding->mPadding.Get(side);
     if (SetCoord(ourPadding.*(nsCSSRect::sides[side]),
                  coord, parentCoord, SETCOORD_LPH | SETCOORD_INITIAL_ZERO,
                  aContext, mPresContext, inherited)) {
@@ -3925,10 +3923,9 @@ nsRuleNode::ComputeOutlineData(void* aStartStruct,
 
   // -moz-outline-radius: length, percent, inherit
   nsStyleCoord  coord;
-  nsStyleCoord  parentCoord;
   { // scope for compilers with broken |for| loop scoping
     NS_FOR_CSS_SIDES(side) {
-      parentOutline->mOutlineRadius.Get(side, parentCoord);
+      nsStyleCoord parentCoord = parentOutline->mOutlineRadius.Get(side);
       if (SetCoord(marginData.mOutlineRadius.*(nsCSSRect::sides[side]), coord,
                    parentCoord, SETCOORD_LPH | SETCOORD_INITIAL_ZERO,
                    aContext, mPresContext, inherited))
@@ -4049,9 +4046,8 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
 
   // box offsets: length, percent, auto, inherit
   nsStyleCoord  coord;
-  nsStyleCoord  parentCoord;
   NS_FOR_CSS_SIDES(side) {
-    parentPos->mOffset.Get(side, parentCoord);
+    nsStyleCoord parentCoord = parentPos->mOffset.Get(side);
     if (SetCoord(posData.mOffset.*(nsCSSRect::sides[side]),
                  coord, parentCoord, SETCOORD_LPAH | SETCOORD_INITIAL_AUTO,
                  aContext, mPresContext, inherited)) {
diff --git a/layout/style/nsStyleCoord.cpp b/layout/style/nsStyleCoord.cpp
index 9bffb232ef4d..34c66e91b0ae 100644
--- a/layout/style/nsStyleCoord.cpp
+++ b/layout/style/nsStyleCoord.cpp
@@ -89,17 +89,6 @@ nsStyleCoord::nsStyleCoord(float aValue, nsStyleUnit aUnit)
   }
 }
 
-nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy)
-  : mUnit(aCopy.mUnit)
-{
-  if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) {
-    mValue.mFloat = aCopy.mValue.mFloat;
-  }
-  else {
-    mValue.mInt = aCopy.mValue.mInt;
-  }
-}
-
 nsStyleCoord& nsStyleCoord::operator=(const nsStyleCoord& aCopy)
 {
   mUnit = aCopy.mUnit;
@@ -183,16 +172,6 @@ void nsStyleCoord::SetNoneValue(void)
   mValue.mInt = 0;
 }
 
-void nsStyleCoord::SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit)
-{
-  mUnit = aUnit;
-#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT
-  mValue.mInt = aValue.mInt;
-#else
-  memcpy(&mValue, &aValue, sizeof(nsStyleUnion));
-#endif
-}
-
 void nsStyleCoord::AppendToString(nsString& aBuffer) const
 {
   if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) {
@@ -269,23 +248,17 @@ void nsStyleSides::Reset(void)
 
 void nsStyleSides::AppendToString(nsString& aBuffer) const
 {
-  nsStyleCoord  temp;
-
-  GetLeft(temp);
   aBuffer.AppendLiteral("left: ");
-  temp.AppendToString(aBuffer);
+  GetLeft().AppendToString(aBuffer);
 
-  GetTop(temp);
   aBuffer.AppendLiteral("top: ");
-  temp.AppendToString(aBuffer);
+  GetTop().AppendToString(aBuffer);
 
-  GetRight(temp);
   aBuffer.AppendLiteral("right: ");
-  temp.AppendToString(aBuffer);
+  GetRight().AppendToString(aBuffer);
 
-  GetBottom(temp);
   aBuffer.AppendLiteral("bottom: ");
-  temp.AppendToString(aBuffer);
+  GetBottom().AppendToString(aBuffer);
 }
 
 void nsStyleSides::ToString(nsString& aBuffer) const
diff --git a/layout/style/nsStyleCoord.h b/layout/style/nsStyleCoord.h
index fa7b9330c9c8..56e3fbce1868 100644
--- a/layout/style/nsStyleCoord.h
+++ b/layout/style/nsStyleCoord.h
@@ -78,7 +78,8 @@ public:
   nsStyleCoord(nscoord aValue);
   nsStyleCoord(PRInt32 aValue, nsStyleUnit aUnit);
   nsStyleCoord(float aValue, nsStyleUnit aUnit);
-  nsStyleCoord(const nsStyleCoord& aCopy);
+  inline nsStyleCoord(const nsStyleCoord& aCopy);
+  inline nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit);
 
   nsStyleCoord&  operator=(const nsStyleCoord& aCopy);
   PRBool         operator==(const nsStyleCoord& aOther) const;
@@ -102,7 +103,6 @@ public:
   void  SetNormalValue(void);
   void  SetAutoValue(void);
   void  SetNoneValue(void);
-  void  SetUnionValue(const nsStyleUnion& aValue, nsStyleUnit aUnit);
 
   void  AppendToString(nsString& aBuffer) const;
   void  ToString(nsString& aBuffer) const;
@@ -134,11 +134,11 @@ public:
   inline nsStyleUnit GetRightUnit(void) const;
   inline nsStyleUnit GetBottomUnit(void) const;
 
-  inline nsStyleCoord& Get(PRUint8 aSide, nsStyleCoord& aCoord) const;
-  inline nsStyleCoord& GetLeft(nsStyleCoord& aCoord) const;
-  inline nsStyleCoord& GetTop(nsStyleCoord& aCoord) const;
-  inline nsStyleCoord& GetRight(nsStyleCoord& aCoord) const;
-  inline nsStyleCoord& GetBottom(nsStyleCoord& aCoord) const;
+  inline nsStyleCoord Get(PRUint8 aSide) const;
+  inline nsStyleCoord GetLeft() const;
+  inline nsStyleCoord GetTop() const;
+  inline nsStyleCoord GetRight() const;
+  inline nsStyleCoord GetBottom() const;
 
   void  Reset(void);
 
@@ -159,6 +159,27 @@ protected:
 // -------------------------
 // nsStyleCoord inlines
 //
+inline nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy)
+  : mUnit(aCopy.mUnit)
+{
+  if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) {
+    mValue.mFloat = aCopy.mValue.mFloat;
+  }
+  else {
+    mValue.mInt = aCopy.mValue.mInt;
+  }
+}
+
+inline nsStyleCoord::nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit)
+  : mUnit(aUnit)
+{
+#if PR_BYTES_PER_INT == PR_BYTES_PER_FLOAT
+  mValue.mInt = aValue.mInt;
+#else
+  memcpy(&mValue, &aValue, sizeof(nsStyleUnion));
+#endif
+}
+
 inline PRBool nsStyleCoord::operator!=(const nsStyleCoord& aOther) const
 {
   return PRBool(! ((*this) == aOther));
@@ -242,30 +263,29 @@ inline nsStyleUnit nsStyleSides::GetBottomUnit(void) const
   return GetUnit(NS_SIDE_BOTTOM);
 }
 
-inline nsStyleCoord& nsStyleSides::Get(PRUint8 aSide, nsStyleCoord& aCoord) const
+inline nsStyleCoord nsStyleSides::Get(PRUint8 aSide) const
 {
-  aCoord.SetUnionValue(mValues[aSide], (nsStyleUnit)mUnits[aSide]);
-  return aCoord;
+  return nsStyleCoord(mValues[aSide], nsStyleUnit(mUnits[aSide]));
 }
 
-inline nsStyleCoord& nsStyleSides::GetLeft(nsStyleCoord& aCoord) const
+inline nsStyleCoord nsStyleSides::GetLeft() const
 {
-  return Get(NS_SIDE_LEFT, aCoord);
+  return Get(NS_SIDE_LEFT);
 }
 
-inline nsStyleCoord& nsStyleSides::GetTop(nsStyleCoord& aCoord) const
+inline nsStyleCoord nsStyleSides::GetTop() const
 {
-  return Get(NS_SIDE_TOP, aCoord);
+  return Get(NS_SIDE_TOP);
 }
 
-inline nsStyleCoord& nsStyleSides::GetRight(nsStyleCoord& aCoord) const
+inline nsStyleCoord nsStyleSides::GetRight() const
 {
-  return Get(NS_SIDE_RIGHT, aCoord);
+  return Get(NS_SIDE_RIGHT);
 }
 
-inline nsStyleCoord& nsStyleSides::GetBottom(nsStyleCoord& aCoord) const
+inline nsStyleCoord nsStyleSides::GetBottom() const
 {
-  return Get(NS_SIDE_BOTTOM, aCoord);
+  return Get(NS_SIDE_BOTTOM);
 }
 
 inline void nsStyleSides::Set(PRUint8 aSide, const nsStyleCoord& aCoord)
diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp
index 9a04ca1fb996..eb93e918f795 100644
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -272,10 +272,8 @@ nsStyleMargin::Destroy(nsPresContext* aContext) {
 void nsStyleMargin::RecalcData()
 {
   if (IsFixedData(mMargin, PR_FALSE)) {
-    nsStyleCoord coord;
     NS_FOR_CSS_SIDES(side) {
-      mCachedMargin.side(side) =
-        CalcCoord(mMargin.Get(side, coord), nsnull, 0);
+      mCachedMargin.side(side) = CalcCoord(mMargin.Get(side), nsnull, 0);
     }
     mHasCachedMargin = PR_TRUE;
   }
@@ -329,10 +327,8 @@ nsStylePadding::Destroy(nsPresContext* aContext) {
 void nsStylePadding::RecalcData()
 {
   if (IsFixedData(mPadding, PR_FALSE)) {
-    nsStyleCoord coord;
     NS_FOR_CSS_SIDES(side) {
-      mCachedPadding.side(side) =
-        CalcCoord(mPadding.Get(side, coord), nsnull, 0);
+      mCachedPadding.side(side) = CalcCoord(mPadding.Get(side), nsnull, 0);
     }
     mHasCachedPadding = PR_TRUE;
   }
diff --git a/layout/xul/base/src/nsStackLayout.cpp b/layout/xul/base/src/nsStackLayout.cpp
index e90a229f1440..8cbc2c9483dc 100644
--- a/layout/xul/base/src/nsStackLayout.cpp
+++ b/layout/xul/base/src/nsStackLayout.cpp
@@ -186,16 +186,12 @@ nsStackLayout::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize
   PRBool offsetSpecified = PR_FALSE;
   const nsStylePosition* pos = aChild->GetStylePosition();
   if (eStyleUnit_Coord == pos->mOffset.GetLeftUnit()) {
-     nsStyleCoord left = 0;
-     pos->mOffset.GetLeft(left);
-     offset.width = left.GetCoordValue();
+     offset.width = pos->mOffset.GetLeft().GetCoordValue();
      offsetSpecified = PR_TRUE;
   }
 
   if (eStyleUnit_Coord == pos->mOffset.GetTopUnit()) {
-     nsStyleCoord top = 0;
-     pos->mOffset.GetTop(top);
-     offset.height = top.GetCoordValue();
+     offset.height = pos->mOffset.GetTop().GetCoordValue();
      offsetSpecified = PR_TRUE;
   }
 

From 2fd83187539a1091a2118707f6a7e714200a6d23 Mon Sep 17 00:00:00 2001
From: "dbaron@dbaron.org" 
Date: Wed, 5 Mar 2008 16:06:15 -0800
Subject: [PATCH 029/248] Fix greediness of A ~ B C selector matching. 
 b=420814  r+sr=bzbarsky  a=beltzner

---
 layout/style/nsCSSRuleProcessor.cpp   |  9 ++-
 layout/style/test/Makefile.in         |  1 +
 layout/style/test/test_selectors.html | 83 +++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 2 deletions(-)
 create mode 100644 layout/style/test/test_selectors.html

diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
index 48a567ba149a..c8ad1e24732e 100644
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1620,10 +1620,15 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData,
     }
     if (SelectorMatches(*data, selector, 0, nsnull)) {
       // to avoid greedy matching, we need to recur if this is a
-      // descendant combinator and the next combinator is not
+      // descendant or general sibling combinator and the next
+      // combinator is different, but we can make an exception for
+      // sibling, then parent, since a sibling's parent is always the
+      // same.
       if ((NS_IS_GREEDY_OPERATOR(selector->mOperator)) &&
           (selector->mNext) &&
-          (!NS_IS_GREEDY_OPERATOR(selector->mNext->mOperator))) {
+          (selector->mNext->mOperator != selector->mOperator) &&
+          !(selector->mOperator == '~' &&
+            selector->mNext->mOperator == PRUnichar(0))) {
 
         // pretend the selector didn't match, and step through content
         // while testing the same selector
diff --git a/layout/style/test/Makefile.in b/layout/style/test/Makefile.in
index 37f02402804f..298a2a17dea7 100644
--- a/layout/style/test/Makefile.in
+++ b/layout/style/test/Makefile.in
@@ -102,6 +102,7 @@ _TEST_FILES =	test_bug73586.html \
 		test_parse_rule.html \
 		test_property_database.html \
 		test_property_syntax_errors.html \
+		test_selectors.html \
 		test_style_struct_copy_constructors.html \
 		test_value_storage.html \
 		test_value_computation.html \
diff --git a/layout/style/test/test_selectors.html b/layout/style/test/test_selectors.html
new file mode 100644
index 000000000000..5ecc85245a07
--- /dev/null
+++ b/layout/style/test/test_selectors.html
@@ -0,0 +1,83 @@
+
+
+
+  Test for CSS Selectors
+  
+  
+  
+
+
+

+
+
+
+ + + From 5ec954dd52b6de24e2347b5e047b8690afb65ad9 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 16:23:38 -0800 Subject: [PATCH 030/248] b=418537, vista textfield/dropdown appearance incorrect when active, r=stuart --- widget/src/windows/nsNativeThemeWin.cpp | 143 ++++++++++++++++-------- 1 file changed, 95 insertions(+), 48 deletions(-) diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 6c53bfd5bd42..97b4a60c9476 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -59,6 +59,7 @@ #include "nsWidgetAtoms.h" #include #include "nsWindow.h" +#include "nsIComboboxControlFrame.h" #include "gfxPlatform.h" #include "gfxContext.h" @@ -98,10 +99,17 @@ #define BP_CHECKBOX 3 // Textfield constants +/* This is the EP_EDITTEXT part */ #define TFP_TEXTFIELD 1 #define TFP_EDITBORDER_NOSCROLL 6 #define TFS_READONLY 6 +/* These are the state constants for the EDITBORDER parts */ +#define TFS_EDITBORDER_NORMAL 1 +#define TFS_EDITBORDER_HOVER 2 +#define TFS_EDITBORDER_FOCUSED 3 +#define TFS_EDITBORDER_DISABLED 4 + // Treeview/listbox constants #define TREEVIEW_BODY 1 @@ -696,7 +704,6 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, } case NS_THEME_TEXTFIELD: case NS_THEME_TEXTFIELD_MULTILINE: { - aPart = TFP_TEXTFIELD; if (mIsVistaOrLater) { /* Note: the NOSCROLL type has a rounded corner in each * corner. The more specific HSCROLL, VSCROLL, HVSCROLL types @@ -707,25 +714,43 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, * here. */ aPart = TFP_EDITBORDER_NOSCROLL; + + if (!aFrame) { + aState = TFS_EDITBORDER_NORMAL; + } else if (IsDisabled(aFrame)) { + aState = TFS_EDITBORDER_DISABLED; + } else if (IsReadOnly(aFrame)) { + /* no special read-only state */ + aState = TFS_EDITBORDER_NORMAL; + } else { + PRInt32 eventState = GetContentState(aFrame, aWidgetType); + nsIContent* content = aFrame->GetContent(); + + /* XUL textboxes don't get focused themselves, because they have child + * html:input.. but we can check the XUL focused attributes on them + */ + if (content && content->IsNodeOfType(nsINode::eXUL) && IsFocused(aFrame)) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState & NS_EVENT_STATE_ACTIVE || eventState & NS_EVENT_STATE_FOCUS) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState & NS_EVENT_STATE_HOVER) + aState = TFS_EDITBORDER_HOVER; + else + aState = TFS_EDITBORDER_NORMAL; + } + } else { + aPart = TFP_TEXTFIELD; + + if (!aFrame) + aState = TS_NORMAL; + else if (IsDisabled(aFrame)) + aState = TS_DISABLED; + else if (IsReadOnly(aFrame)) + aState = TFS_READONLY; + else + aState = StandardGetState(aFrame, aWidgetType, PR_TRUE); } - if (!aFrame) { - aState = TS_NORMAL; - return NS_OK; - } - - if (IsDisabled(aFrame)) { - aState = TS_DISABLED; - return NS_OK; - } - - if (IsReadOnly(aFrame)) { - aState = TFS_READONLY; - return NS_OK; - } - - aState = StandardGetState(aFrame, aWidgetType, PR_TRUE); - return NS_OK; } case NS_THEME_TOOLTIP: { @@ -1006,7 +1031,12 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, } case NS_THEME_DROPDOWN: { nsIContent* content = aFrame->GetContent(); - if (content && content->IsNodeOfType(nsINode::eHTML)) + PRBool isHTML = content && content->IsNodeOfType(nsINode::eHTML); + + /* On vista, in HTML, we use CBP_DROPBORDER instead of DROPFRAME for HTML content; + * this gives us the thin outline in HTML content, instead of the gradient-filled + * background */ + if (isHTML) aPart = CBP_DROPBORDER; else aPart = CBP_DROPFRAME; @@ -1014,47 +1044,53 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, PRBool isOpen = CheckBooleanAttr(aFrame, nsWidgetAtoms::open); if (isOpen) { aState = TS_ACTIVE; - return NS_OK; + } else { + PRInt32 eventState = GetContentState(aFrame, aWidgetType); + if (isHTML && eventState & NS_EVENT_STATE_FOCUS) + aState = TS_ACTIVE; + else if (eventState & NS_EVENT_STATE_HOVER && eventState & NS_EVENT_STATE_ACTIVE) + aState = TS_ACTIVE; + else if (eventState & NS_EVENT_STATE_HOVER) + aState = TS_HOVER; + else + aState = TS_NORMAL; } - PRInt32 eventState = GetContentState(aFrame, aWidgetType); - if (eventState & NS_EVENT_STATE_HOVER && eventState & NS_EVENT_STATE_ACTIVE) - aState = TS_ACTIVE; - else if (eventState & NS_EVENT_STATE_HOVER) - aState = TS_HOVER; - else - aState = TS_NORMAL; - return NS_OK; } case NS_THEME_DROPDOWN_BUTTON: { PRBool isHTML = IsHTMLContent(aFrame); + nsIFrame* origFrame = aFrame; nsIFrame* parentFrame = aFrame->GetParent(); if ((parentFrame && parentFrame->GetType() == nsWidgetAtoms::menuFrame) || isHTML) // XUL menu lists and HTML selects get state from parent aFrame = parentFrame; - if (mIsVistaOrLater) { - /* On vista, in HTML, we use CBP_DROPBORDER instead of DROPFRAME for HTML content. - * For that, we want to draw the normal DROPMARKER. But if we're not in HTML, - * we want to use DROPMARKER_VISTA, which will just draw the arrow (since we've already - * drawn the background). - */ - aPart = CBP_DROPMARKER_VISTA; - if (IsDisabled(aFrame)) - aState = TS_DISABLED; - else if (isHTML) - aState = StandardGetState(aFrame, aWidgetType, PR_FALSE); - else - aState = TS_NORMAL; - } else { - aPart = CBP_DROPMARKER; - if (IsDisabled(aFrame)) - aState = TS_DISABLED; - else - aState = StandardGetState(aFrame, aWidgetType, PR_FALSE); + aPart = mIsVistaOrLater ? CBP_DROPMARKER_VISTA : CBP_DROPMARKER; + + if (IsDisabled(aFrame)) { + aState = TS_DISABLED; + return NS_OK; } + if (mIsVistaOrLater && isHTML) { + nsIComboboxControlFrame* ccf = nsnull; + CallQueryInterface(aFrame, &ccf); + if (ccf && ccf->IsDroppedDown()) { + /* Hover is propagated, but we need to know whether we're + * hovering just the combobox frame, not the dropdown frame. + * But, we can't get that information, since hover is on the + * content node, and they share the same content node. So, + * instead, we cheat -- if the dropdown is open, we always + * show the hover state. This looks fine in practice. + */ + aState = TS_HOVER; + return NS_OK; + } + } + + aState = StandardGetState(aFrame, aWidgetType, PR_FALSE); + return NS_OK; } case NS_THEME_MENUPOPUP: { @@ -1764,6 +1800,16 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, return NS_OK; } + // We need to repaint the dropdown arrow in vista HTML combobox controls when + // the control is closed to get rid of the hover effect. + if (mIsVistaOrLater && + (aWidgetType == NS_THEME_DROPDOWN || aWidgetType == NS_THEME_DROPDOWN_BUTTON) && + IsHTMLContent(aFrame)) + { + *aShouldRepaint = PR_TRUE; + return NS_OK; + } + // XXXdwh Not sure what can really be done here. Can at least guess for // specific widgets that they're highly unlikely to have certain states. // For example, a toolbar doesn't care about any states. @@ -1780,7 +1826,8 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, aAttribute == nsWidgetAtoms::selected || aAttribute == nsWidgetAtoms::readonly || aAttribute == nsWidgetAtoms::open || - aAttribute == nsWidgetAtoms::mozmenuactive) + aAttribute == nsWidgetAtoms::mozmenuactive || + aAttribute == nsWidgetAtoms::focused) *aShouldRepaint = PR_TRUE; } From f6c48c056acdb4e65089a57906072f5a7b867a56 Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Wed, 5 Mar 2008 16:27:27 -0800 Subject: [PATCH 031/248] Fix nsIAutoCompleteController's handleEvent signature change bustage rs=ajschult --- .../autocomplete/resources/content/autocomplete.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xpfe/components/autocomplete/resources/content/autocomplete.xml b/xpfe/components/autocomplete/resources/content/autocomplete.xml index fd5b1a2aa0a4..ab144d5c890c 100644 --- a/xpfe/components/autocomplete/resources/content/autocomplete.xml +++ b/xpfe/components/autocomplete/resources/content/autocomplete.xml @@ -1295,7 +1295,11 @@ return null; // XXX equivalent to falling off the end? }, - handleEnter: function() { + ////////////////////////////////////////////////////////// + // nsIAutoCompleteController interface + + // this is the only method required by the treebody mouseup handler + handleEnter: function(aIsPopupSelection) { this.mTextbox.onResultClick(); }, @@ -1629,7 +1633,7 @@ var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY); if (rc != -1) { this.resultsPopup.selectedIndex = rc; - this.resultsPopup.view.handleEnter(); + this.resultsPopup.view.handleEnter(true); } ]]> From 0a78e520beb471d3a5dc6bf3ca11f70f926f5973 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 16:40:58 -0800 Subject: [PATCH 032/248] b=392351, implement about:memory framework core r=shaver, sr=bsmedberg --- xpcom/base/Makefile.in | 4 +- xpcom/base/nsIMemoryReporter.idl | 103 +++++++++++++++++++++++++ xpcom/base/nsMemoryReporterManager.cpp | 52 +++++++++++++ xpcom/base/nsMemoryReporterManager.h | 17 ++++ xpcom/build/nsXPCOMCIDInternal.h | 5 ++ xpcom/build/nsXPComInit.cpp | 5 ++ 6 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 xpcom/base/nsIMemoryReporter.idl create mode 100644 xpcom/base/nsMemoryReporterManager.cpp create mode 100644 xpcom/base/nsMemoryReporterManager.h diff --git a/xpcom/base/Makefile.in b/xpcom/base/Makefile.in index ea8ef1fc311e..4b95919ae92c 100644 --- a/xpcom/base/Makefile.in +++ b/xpcom/base/Makefile.in @@ -66,6 +66,7 @@ CPPSRCS = \ nsSystemInfo.cpp \ nsCycleCollector.cpp \ nsStackWalk.cpp \ + nsMemoryReporterManager.cpp \ $(NULL) ifdef GC_LEAK_DETECTOR @@ -107,7 +108,7 @@ SDK_XPIDLSRCS = \ nsISupports.idl \ nsITraceRefcnt.idl \ nsIWeakReference.idl \ - nsrootidl.idl \ + nsrootidl.idl SDK_HEADERS = \ nsError.h \ @@ -126,6 +127,7 @@ XPIDLSRCS = \ nsIVersionComparator.idl \ nsIUUIDGenerator.idl \ nsIMutable.idl \ + nsIMemoryReporter.idl \ $(NULL) ifdef GC_LEAK_DETECTOR diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl new file mode 100644 index 000000000000..9828efad08fa --- /dev/null +++ b/xpcom/base/nsIMemoryReporter.idl @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * mozilla.org + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Vladimir Vukicevic (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 "nsISupports.idl" +#include "nsISimpleEnumerator.idl" + +[scriptable, uuid(d298b942-3e66-4cd3-9ff5-46abc69147a7)] +interface nsIMemoryReporter : nsISupports +{ + /* + * The path that this memory usage should be reported under. + * + * Normally "/"-delimited for organization. + */ + readonly attribute string path; + + /* + * A human-readable description of this memory usage report + */ + readonly attribute string description; + + /* + * The current amount of memory in use, as reported by this memory + * reporter. + */ + readonly attribute long long memoryUsed; +}; + +[scriptable, uuid(63fc8fbd-509b-4fdb-93b4-2e6caeeddab1)] +interface nsIMemoryReporterManager : nsISupports +{ + /* + * Return an enumerator of nsIMemoryReporters that are currently registered. + */ + nsISimpleEnumerator enumerateReporters (); + + /* + * Register the given nsIMemoryReporter. It is an error to register + * more than one reporter with the same path. After a reporter is + * registered, it will be available via enumerateReporters(). The + * Manager service will hold a strong reference to the given reporter. + */ + void registerReporter (in nsIMemoryReporter reporter); + + /* + * Unregister the given memory reporter. + */ + void unregisterReporter (in nsIMemoryReporter reporter); +}; + +%{C++ + +#define NS_MEMORY_REPORTER_IMPLEMENT(_classname,_path,_desc,_usageFunction,_dataptr) \ + class MemoryReporter_##_classname : public nsIMemoryReporter { \ + public: \ + NS_DECL_ISUPPORTS \ + NS_IMETHOD GetPath(char **memoryPath) { *memoryPath = strdup(_path); return NS_OK; } \ + NS_IMETHOD GetDescription(char **desc) { *desc = strdup(_desc); return NS_OK; } \ + NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) { *memoryUsed = _usageFunction(_dataptr); return NS_OK; } \ + }; \ + NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter) + +#define NS_MEMORY_REPORTER_NAME(_classname) MemoryReporter_##_classname + +NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter); +NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter); + +%} diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp new file mode 100644 index 000000000000..9c619fdf04c3 --- /dev/null +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -0,0 +1,52 @@ + +#include "nsCOMPtr.h" +#include "nsServiceManagerUtils.h" +#include "nsMemoryReporterManager.h" + +#include "nsArrayEnumerator.h" + +NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager) + +NS_IMETHODIMP +nsMemoryReporterManager::EnumerateReporters(nsISimpleEnumerator **result) +{ + return NS_NewArrayEnumerator(result, mReporters); +} + +NS_IMETHODIMP +nsMemoryReporterManager::RegisterReporter(nsIMemoryReporter *reporter) +{ + if (mReporters.IndexOf(reporter) != -1) + return NS_ERROR_FAILURE; + + mReporters.AppendObject(reporter); + return NS_OK; +} + +NS_IMETHODIMP +nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter) +{ + if (!mReporters.RemoveObject(reporter)) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +nsresult +NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) +{ + nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); + if (mgr == nsnull) + return NS_ERROR_FAILURE; + return mgr->RegisterReporter(reporter); +} + +nsresult +NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) +{ + nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); + if (mgr == nsnull) + return NS_ERROR_FAILURE; + return mgr->UnregisterReporter(reporter); +} + diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h new file mode 100644 index 000000000000..98f00a70151d --- /dev/null +++ b/xpcom/base/nsMemoryReporterManager.h @@ -0,0 +1,17 @@ + +#include "nsIMemoryReporter.h" +#include "nsCOMArray.h" + +class nsMemoryReporterManager : public nsIMemoryReporterManager +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMEMORYREPORTERMANAGER + +private: + nsCOMArray mReporters; +}; + +#define NS_MEMORY_REPORTER_MANAGER_CID \ +{ 0xfb97e4f5, 0x32dd, 0x497a, \ +{ 0xba, 0xa2, 0x7d, 0x1e, 0x55, 0x7, 0x99, 0x10 } } diff --git a/xpcom/build/nsXPCOMCIDInternal.h b/xpcom/build/nsXPCOMCIDInternal.h index 5ad9845d21d6..464443014c19 100644 --- a/xpcom/build/nsXPCOMCIDInternal.h +++ b/xpcom/build/nsXPCOMCIDInternal.h @@ -77,4 +77,9 @@ */ #define NS_XPCOMPROXY_CONTRACTID "@mozilla.org/xpcomproxy;1" +/** + * Memory reporter service CID + */ +#define NS_MEMORY_REPORTER_MANAGER_CONTRACTID "@mozilla.org/memory-reporter-manager;1" + #endif // nsXPCOMCIDInternal_h__ diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index de773b861bdd..f1891769c9e8 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -136,6 +136,7 @@ NS_DECL_CLASSINFO(nsStringInputStream) #endif #include "nsSystemInfo.h" +#include "nsMemoryReporterManager.h" #include @@ -229,6 +230,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryReporterManager) + static NS_METHOD nsThreadManagerGetSingleton(nsISupports* outer, const nsIID& aIID, @@ -444,6 +447,8 @@ static const nsModuleComponentInfo components[] = { #endif COMPONENT(SYSTEMINFO, nsSystemInfoConstructor), +#define NS_MEMORY_REPORTER_MANAGER_CLASSNAME "Memory Reporter Manager" + COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor), }; #undef COMPONENT From ef5f5b5bcb61415b2be66465dcc8fab4680bc820 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 16:54:15 -0800 Subject: [PATCH 033/248] backed out --- xpcom/base/Makefile.in | 4 +- xpcom/base/nsIMemoryReporter.idl | 103 ------------------------- xpcom/base/nsMemoryReporterManager.cpp | 52 ------------- xpcom/base/nsMemoryReporterManager.h | 17 ---- xpcom/build/nsXPCOMCIDInternal.h | 5 -- xpcom/build/nsXPComInit.cpp | 5 -- 6 files changed, 1 insertion(+), 185 deletions(-) delete mode 100644 xpcom/base/nsIMemoryReporter.idl delete mode 100644 xpcom/base/nsMemoryReporterManager.cpp delete mode 100644 xpcom/base/nsMemoryReporterManager.h diff --git a/xpcom/base/Makefile.in b/xpcom/base/Makefile.in index 4b95919ae92c..ea8ef1fc311e 100644 --- a/xpcom/base/Makefile.in +++ b/xpcom/base/Makefile.in @@ -66,7 +66,6 @@ CPPSRCS = \ nsSystemInfo.cpp \ nsCycleCollector.cpp \ nsStackWalk.cpp \ - nsMemoryReporterManager.cpp \ $(NULL) ifdef GC_LEAK_DETECTOR @@ -108,7 +107,7 @@ SDK_XPIDLSRCS = \ nsISupports.idl \ nsITraceRefcnt.idl \ nsIWeakReference.idl \ - nsrootidl.idl + nsrootidl.idl \ SDK_HEADERS = \ nsError.h \ @@ -127,7 +126,6 @@ XPIDLSRCS = \ nsIVersionComparator.idl \ nsIUUIDGenerator.idl \ nsIMutable.idl \ - nsIMemoryReporter.idl \ $(NULL) ifdef GC_LEAK_DETECTOR diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl deleted file mode 100644 index 9828efad08fa..000000000000 --- a/xpcom/base/nsIMemoryReporter.idl +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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 mozilla.org code. - * - * The Initial Developer of the Original Code is - * mozilla.org - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either of 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 "nsISupports.idl" -#include "nsISimpleEnumerator.idl" - -[scriptable, uuid(d298b942-3e66-4cd3-9ff5-46abc69147a7)] -interface nsIMemoryReporter : nsISupports -{ - /* - * The path that this memory usage should be reported under. - * - * Normally "/"-delimited for organization. - */ - readonly attribute string path; - - /* - * A human-readable description of this memory usage report - */ - readonly attribute string description; - - /* - * The current amount of memory in use, as reported by this memory - * reporter. - */ - readonly attribute long long memoryUsed; -}; - -[scriptable, uuid(63fc8fbd-509b-4fdb-93b4-2e6caeeddab1)] -interface nsIMemoryReporterManager : nsISupports -{ - /* - * Return an enumerator of nsIMemoryReporters that are currently registered. - */ - nsISimpleEnumerator enumerateReporters (); - - /* - * Register the given nsIMemoryReporter. It is an error to register - * more than one reporter with the same path. After a reporter is - * registered, it will be available via enumerateReporters(). The - * Manager service will hold a strong reference to the given reporter. - */ - void registerReporter (in nsIMemoryReporter reporter); - - /* - * Unregister the given memory reporter. - */ - void unregisterReporter (in nsIMemoryReporter reporter); -}; - -%{C++ - -#define NS_MEMORY_REPORTER_IMPLEMENT(_classname,_path,_desc,_usageFunction,_dataptr) \ - class MemoryReporter_##_classname : public nsIMemoryReporter { \ - public: \ - NS_DECL_ISUPPORTS \ - NS_IMETHOD GetPath(char **memoryPath) { *memoryPath = strdup(_path); return NS_OK; } \ - NS_IMETHOD GetDescription(char **desc) { *desc = strdup(_desc); return NS_OK; } \ - NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) { *memoryUsed = _usageFunction(_dataptr); return NS_OK; } \ - }; \ - NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter) - -#define NS_MEMORY_REPORTER_NAME(_classname) MemoryReporter_##_classname - -NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter); -NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter); - -%} diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp deleted file mode 100644 index 9c619fdf04c3..000000000000 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -#include "nsCOMPtr.h" -#include "nsServiceManagerUtils.h" -#include "nsMemoryReporterManager.h" - -#include "nsArrayEnumerator.h" - -NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager) - -NS_IMETHODIMP -nsMemoryReporterManager::EnumerateReporters(nsISimpleEnumerator **result) -{ - return NS_NewArrayEnumerator(result, mReporters); -} - -NS_IMETHODIMP -nsMemoryReporterManager::RegisterReporter(nsIMemoryReporter *reporter) -{ - if (mReporters.IndexOf(reporter) != -1) - return NS_ERROR_FAILURE; - - mReporters.AppendObject(reporter); - return NS_OK; -} - -NS_IMETHODIMP -nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter) -{ - if (!mReporters.RemoveObject(reporter)) - return NS_ERROR_FAILURE; - - return NS_OK; -} - -nsresult -NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) -{ - nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); - if (mgr == nsnull) - return NS_ERROR_FAILURE; - return mgr->RegisterReporter(reporter); -} - -nsresult -NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) -{ - nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); - if (mgr == nsnull) - return NS_ERROR_FAILURE; - return mgr->UnregisterReporter(reporter); -} - diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h deleted file mode 100644 index 98f00a70151d..000000000000 --- a/xpcom/base/nsMemoryReporterManager.h +++ /dev/null @@ -1,17 +0,0 @@ - -#include "nsIMemoryReporter.h" -#include "nsCOMArray.h" - -class nsMemoryReporterManager : public nsIMemoryReporterManager -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIMEMORYREPORTERMANAGER - -private: - nsCOMArray mReporters; -}; - -#define NS_MEMORY_REPORTER_MANAGER_CID \ -{ 0xfb97e4f5, 0x32dd, 0x497a, \ -{ 0xba, 0xa2, 0x7d, 0x1e, 0x55, 0x7, 0x99, 0x10 } } diff --git a/xpcom/build/nsXPCOMCIDInternal.h b/xpcom/build/nsXPCOMCIDInternal.h index 464443014c19..5ad9845d21d6 100644 --- a/xpcom/build/nsXPCOMCIDInternal.h +++ b/xpcom/build/nsXPCOMCIDInternal.h @@ -77,9 +77,4 @@ */ #define NS_XPCOMPROXY_CONTRACTID "@mozilla.org/xpcomproxy;1" -/** - * Memory reporter service CID - */ -#define NS_MEMORY_REPORTER_MANAGER_CONTRACTID "@mozilla.org/memory-reporter-manager;1" - #endif // nsXPCOMCIDInternal_h__ diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index f1891769c9e8..de773b861bdd 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -136,7 +136,6 @@ NS_DECL_CLASSINFO(nsStringInputStream) #endif #include "nsSystemInfo.h" -#include "nsMemoryReporterManager.h" #include @@ -230,8 +229,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryReporterManager) - static NS_METHOD nsThreadManagerGetSingleton(nsISupports* outer, const nsIID& aIID, @@ -447,8 +444,6 @@ static const nsModuleComponentInfo components[] = { #endif COMPONENT(SYSTEMINFO, nsSystemInfoConstructor), -#define NS_MEMORY_REPORTER_MANAGER_CLASSNAME "Memory Reporter Manager" - COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor), }; #undef COMPONENT From 262a9caf1946505ca7e31c883121f236153ad184 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 17:28:25 -0800 Subject: [PATCH 034/248] b=392351, implement about:memory framework core, relading with forward-declaration victory; r=shaver,sr=bsdmedberg --- xpcom/base/Makefile.in | 4 +- xpcom/base/nsIMemoryReporter.idl | 104 +++++++++++++++++++++++++ xpcom/base/nsMemoryReporterManager.cpp | 52 +++++++++++++ xpcom/base/nsMemoryReporterManager.h | 17 ++++ xpcom/build/nsXPCOMCIDInternal.h | 5 ++ xpcom/build/nsXPComInit.cpp | 5 ++ 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 xpcom/base/nsIMemoryReporter.idl create mode 100644 xpcom/base/nsMemoryReporterManager.cpp create mode 100644 xpcom/base/nsMemoryReporterManager.h diff --git a/xpcom/base/Makefile.in b/xpcom/base/Makefile.in index ea8ef1fc311e..4b95919ae92c 100644 --- a/xpcom/base/Makefile.in +++ b/xpcom/base/Makefile.in @@ -66,6 +66,7 @@ CPPSRCS = \ nsSystemInfo.cpp \ nsCycleCollector.cpp \ nsStackWalk.cpp \ + nsMemoryReporterManager.cpp \ $(NULL) ifdef GC_LEAK_DETECTOR @@ -107,7 +108,7 @@ SDK_XPIDLSRCS = \ nsISupports.idl \ nsITraceRefcnt.idl \ nsIWeakReference.idl \ - nsrootidl.idl \ + nsrootidl.idl SDK_HEADERS = \ nsError.h \ @@ -126,6 +127,7 @@ XPIDLSRCS = \ nsIVersionComparator.idl \ nsIUUIDGenerator.idl \ nsIMutable.idl \ + nsIMemoryReporter.idl \ $(NULL) ifdef GC_LEAK_DETECTOR diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl new file mode 100644 index 000000000000..3c797bbc9f8c --- /dev/null +++ b/xpcom/base/nsIMemoryReporter.idl @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * mozilla.org + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Vladimir Vukicevic (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 "nsISupports.idl" + +interface nsISimpleEnumerator; + +[scriptable, uuid(d298b942-3e66-4cd3-9ff5-46abc69147a7)] +interface nsIMemoryReporter : nsISupports +{ + /* + * The path that this memory usage should be reported under. + * + * Normally "/"-delimited for organization. + */ + readonly attribute string path; + + /* + * A human-readable description of this memory usage report + */ + readonly attribute string description; + + /* + * The current amount of memory in use, as reported by this memory + * reporter. + */ + readonly attribute long long memoryUsed; +}; + +[scriptable, uuid(63fc8fbd-509b-4fdb-93b4-2e6caeeddab1)] +interface nsIMemoryReporterManager : nsISupports +{ + /* + * Return an enumerator of nsIMemoryReporters that are currently registered. + */ + nsISimpleEnumerator enumerateReporters (); + + /* + * Register the given nsIMemoryReporter. It is an error to register + * more than one reporter with the same path. After a reporter is + * registered, it will be available via enumerateReporters(). The + * Manager service will hold a strong reference to the given reporter. + */ + void registerReporter (in nsIMemoryReporter reporter); + + /* + * Unregister the given memory reporter. + */ + void unregisterReporter (in nsIMemoryReporter reporter); +}; + +%{C++ + +#define NS_MEMORY_REPORTER_IMPLEMENT(_classname,_path,_desc,_usageFunction,_dataptr) \ + class MemoryReporter_##_classname : public nsIMemoryReporter { \ + public: \ + NS_DECL_ISUPPORTS \ + NS_IMETHOD GetPath(char **memoryPath) { *memoryPath = strdup(_path); return NS_OK; } \ + NS_IMETHOD GetDescription(char **desc) { *desc = strdup(_desc); return NS_OK; } \ + NS_IMETHOD GetMemoryUsed(PRInt64 *memoryUsed) { *memoryUsed = _usageFunction(_dataptr); return NS_OK; } \ + }; \ + NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter) + +#define NS_MEMORY_REPORTER_NAME(_classname) MemoryReporter_##_classname + +NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter); +NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter); + +%} diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp new file mode 100644 index 000000000000..9c619fdf04c3 --- /dev/null +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -0,0 +1,52 @@ + +#include "nsCOMPtr.h" +#include "nsServiceManagerUtils.h" +#include "nsMemoryReporterManager.h" + +#include "nsArrayEnumerator.h" + +NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager) + +NS_IMETHODIMP +nsMemoryReporterManager::EnumerateReporters(nsISimpleEnumerator **result) +{ + return NS_NewArrayEnumerator(result, mReporters); +} + +NS_IMETHODIMP +nsMemoryReporterManager::RegisterReporter(nsIMemoryReporter *reporter) +{ + if (mReporters.IndexOf(reporter) != -1) + return NS_ERROR_FAILURE; + + mReporters.AppendObject(reporter); + return NS_OK; +} + +NS_IMETHODIMP +nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter) +{ + if (!mReporters.RemoveObject(reporter)) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +nsresult +NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) +{ + nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); + if (mgr == nsnull) + return NS_ERROR_FAILURE; + return mgr->RegisterReporter(reporter); +} + +nsresult +NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) +{ + nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); + if (mgr == nsnull) + return NS_ERROR_FAILURE; + return mgr->UnregisterReporter(reporter); +} + diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h new file mode 100644 index 000000000000..98f00a70151d --- /dev/null +++ b/xpcom/base/nsMemoryReporterManager.h @@ -0,0 +1,17 @@ + +#include "nsIMemoryReporter.h" +#include "nsCOMArray.h" + +class nsMemoryReporterManager : public nsIMemoryReporterManager +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMEMORYREPORTERMANAGER + +private: + nsCOMArray mReporters; +}; + +#define NS_MEMORY_REPORTER_MANAGER_CID \ +{ 0xfb97e4f5, 0x32dd, 0x497a, \ +{ 0xba, 0xa2, 0x7d, 0x1e, 0x55, 0x7, 0x99, 0x10 } } diff --git a/xpcom/build/nsXPCOMCIDInternal.h b/xpcom/build/nsXPCOMCIDInternal.h index 5ad9845d21d6..464443014c19 100644 --- a/xpcom/build/nsXPCOMCIDInternal.h +++ b/xpcom/build/nsXPCOMCIDInternal.h @@ -77,4 +77,9 @@ */ #define NS_XPCOMPROXY_CONTRACTID "@mozilla.org/xpcomproxy;1" +/** + * Memory reporter service CID + */ +#define NS_MEMORY_REPORTER_MANAGER_CONTRACTID "@mozilla.org/memory-reporter-manager;1" + #endif // nsXPCOMCIDInternal_h__ diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index de773b861bdd..f1891769c9e8 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -136,6 +136,7 @@ NS_DECL_CLASSINFO(nsStringInputStream) #endif #include "nsSystemInfo.h" +#include "nsMemoryReporterManager.h" #include @@ -229,6 +230,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryReporterManager) + static NS_METHOD nsThreadManagerGetSingleton(nsISupports* outer, const nsIID& aIID, @@ -444,6 +447,8 @@ static const nsModuleComponentInfo components[] = { #endif COMPONENT(SYSTEMINFO, nsSystemInfoConstructor), +#define NS_MEMORY_REPORTER_MANAGER_CLASSNAME "Memory Reporter Manager" + COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor), }; #undef COMPONENT From 48755a2e3d2c99883251987a7b9ebed0a94cc6d9 Mon Sep 17 00:00:00 2001 From: "jdaggett@mozilla.com" Date: Wed, 5 Mar 2008 17:47:33 -0800 Subject: [PATCH 035/248] Bug 421135. Fix typo in setting of mLastPrefFirstFont. r+sr=vlad --- gfx/thebes/src/gfxAtsuiFonts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/thebes/src/gfxAtsuiFonts.cpp b/gfx/thebes/src/gfxAtsuiFonts.cpp index 6000129ef5d3..5b078382dba1 100644 --- a/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -747,7 +747,7 @@ gfxAtsuiFontGroup::WhichPrefFontSupportsChar(PRUint32 aCh) mLastPrefFamily = family; mLastPrefFont = prefFont; mLastPrefLang = charLang; - mLastPrefFirstFont == (i == 0); + mLastPrefFirstFont = (i == 0); return prefFont.forget(); } From 17c992a3f596d7deac6c082eb01ae3534ba64bf3 Mon Sep 17 00:00:00 2001 From: "jwalden@mit.edu" Date: Wed, 5 Mar 2008 18:10:43 -0800 Subject: [PATCH 036/248] Bug 420243 - Fix an arithmetic mistake in SVGTextContentElement.getSubStringLength. r+sr=roc, a=beltzner --- content/svg/content/Makefile.in | 4 + content/svg/content/test/Makefile.in | 53 +++++++++ .../test/getSubStringLength-helper.svg | 7 ++ .../test/test_getSubStringLength.xhtml | 105 ++++++++++++++++++ .../svg/base/src/nsSVGTextContainerFrame.cpp | 11 +- 5 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 content/svg/content/test/Makefile.in create mode 100644 content/svg/content/test/getSubStringLength-helper.svg create mode 100644 content/svg/content/test/test_getSubStringLength.xhtml diff --git a/content/svg/content/Makefile.in b/content/svg/content/Makefile.in index 92b87bc00a03..d90c200d5938 100644 --- a/content/svg/content/Makefile.in +++ b/content/svg/content/Makefile.in @@ -45,5 +45,9 @@ include $(DEPTH)/config/autoconf.mk DIRS = src +ifdef MOZ_MOCHITEST +DIRS += test +endif + include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/test/Makefile.in b/content/svg/content/test/Makefile.in new file mode 100644 index 000000000000..181b3a1b639f --- /dev/null +++ b/content/svg/content/test/Makefile.in @@ -0,0 +1,53 @@ +# +# ***** 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 mozilla.org code. +# +# 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 of 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 ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = content/svg/content/test + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_TEST_FILES = \ + test_getSubStringLength.xhtml \ + getSubStringLength-helper.svg \ + $(NULL) + +libs:: $(_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/content/svg/content/test/getSubStringLength-helper.svg b/content/svg/content/test/getSubStringLength-helper.svg new file mode 100644 index 000000000000..6c80d9d46bd4 --- /dev/null +++ b/content/svg/content/test/getSubStringLength-helper.svg @@ -0,0 +1,7 @@ + + + + abc + diff --git a/content/svg/content/test/test_getSubStringLength.xhtml b/content/svg/content/test/test_getSubStringLength.xhtml new file mode 100644 index 000000000000..aedf018624f6 --- /dev/null +++ b/content/svg/content/test/test_getSubStringLength.xhtml @@ -0,0 +1,105 @@ + + + + + Test for Bug 420243 + + + + + +Mozilla Bug 420243 +

+ + + + +
+
+
+ + diff --git a/layout/svg/base/src/nsSVGTextContainerFrame.cpp b/layout/svg/base/src/nsSVGTextContainerFrame.cpp index 8e1a00afae72..e4c147bc564a 100755 --- a/layout/svg/base/src/nsSVGTextContainerFrame.cpp +++ b/layout/svg/base/src/nsSVGTextContainerFrame.cpp @@ -182,16 +182,17 @@ nsSVGTextContainerFrame::GetSubStringLength(PRUint32 charnum, PRUint32 nchars, float *_retval) { + PRUint32 charcount = GetNumberOfChars(); + if (charcount <= charnum || nchars > charcount - charnum) { + *_retval = 0.0f; + return NS_ERROR_DOM_INDEX_SIZE_ERR; + } + if (nchars == 0) { *_retval = 0.0f; return NS_OK; } - if (charnum + nchars > GetNumberOfChars()) { - *_retval = 0.0f; - return NS_ERROR_DOM_INDEX_SIZE_ERR; - } - *_retval = GetSubStringLengthNoValidation(charnum, nchars); return NS_OK; From 7bda30d29536fe0c1fc3d74999551b472b677eab Mon Sep 17 00:00:00 2001 From: "mark.finkle@gmail.com" Date: Wed, 5 Mar 2008 18:27:59 -0800 Subject: [PATCH 037/248] b=421005, r=gavin, a=damons. FUEL Preference.type uses undefined variables --- browser/fuel/src/fuelApplication.js | 2 +- browser/fuel/test/browser_ApplicationPrefs.js | 72 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/browser/fuel/src/fuelApplication.js b/browser/fuel/src/fuelApplication.js index cbeec57b149c..f3d1407bcb4e 100644 --- a/browser/fuel/src/fuelApplication.js +++ b/browser/fuel/src/fuelApplication.js @@ -302,7 +302,7 @@ Preference.prototype = { get type() { var value = ""; - var type = this._prefs.getPrefType(name); + var type = this.branch._prefs.getPrefType(this._name); switch (type) { case Ci.nsIPrefBranch2.PREF_STRING: diff --git a/browser/fuel/test/browser_ApplicationPrefs.js b/browser/fuel/test/browser_ApplicationPrefs.js index ab962b2e80c4..42d5e7a72f40 100644 --- a/browser/fuel/test/browser_ApplicationPrefs.js +++ b/browser/fuel/test/browser_ApplicationPrefs.js @@ -11,9 +11,9 @@ function test() { // test getting non-existing values var itemValue = Application.prefs.getValue(testdata.missing, "default"); is(itemValue, "default", "Check 'Application.prefs.getValue' for non-existing item"); - + is(Application.prefs.get(testdata.missing), null, "Check 'Application.prefs.get' for non-existing item"); - + // test setting and getting a value Application.prefs.setValue(testdata.dummy, "dummy"); itemValue = Application.prefs.getValue(testdata.dummy, "default"); @@ -23,7 +23,7 @@ function test() { Application.prefs.setValue(testdata.dummy, "smarty"); itemValue = Application.prefs.getValue(testdata.dummy, "default"); is(itemValue, "smarty", "Check 'Application.prefs.getValue' for overwritten item"); - + // test setting and getting a value Application.prefs.get(testdata.dummy).value = "dummy2"; itemValue = Application.prefs.get(testdata.dummy).value; @@ -31,44 +31,48 @@ function test() { // test resetting a pref [since there is no default value, the pref should disappear] Application.prefs.get(testdata.dummy).reset(); - var itemValue = Application.prefs.getValue(testdata.dummy, "default"); + itemValue = Application.prefs.getValue(testdata.dummy, "default"); is(itemValue, "default", "Check 'Application.prefs.getValue' for reset pref"); - + // test to see if a non-existant property exists ok(!Application.prefs.has(testdata.dummy), "Check non-existant property for existance"); - + // PREF: string browser.active_color == #EE0000 - + // test to see if an existing string property exists ok(Application.prefs.has(testdata.string), "Check existing string property for existance"); - + // test accessing a non-existant string property var val = Application.prefs.getValue(testdata.dummy, "default"); is(val, "default", "Check non-existant string property for expected value"); - + // test accessing an existing string property var val = Application.prefs.getValue(testdata.string, "default"); is(val, "#EE0000", "Check existing string property for expected value"); - + // test manipulating an existing string property Application.prefs.setValue(testdata.string, "#EF0000"); var val = Application.prefs.getValue(testdata.string, "default"); is(val, "#EF0000", "Set existing string property"); - + + // test getting the type of an existing string property + var type = Application.prefs.get(testdata.string).type; + is(type, "String", "Check 'Application.prefs.get().type' for string pref"); + // test resetting an existing string property Application.prefs.get(testdata.string).reset(); var val = Application.prefs.getValue(testdata.string, "default"); is(val, "#EE0000", "Reset existing string property"); - + // PREF: integer permissions.default.image == 1 - + // test to see if an existing integer property exists ok(Application.prefs.has(testdata.integer), "Check existing integer property for existance"); - + // test accessing a non-existant integer property var val = Application.prefs.getValue(testdata.dummy, 0); is(val, 0, "Check non-existant integer property for expected value"); - + // test accessing an existing integer property var val = Application.prefs.getValue(testdata.integer, 0); is(val, 1, "Check existing integer property for expected value"); @@ -77,35 +81,43 @@ function test() { Application.prefs.setValue(testdata.integer, 0); var val = Application.prefs.getValue(testdata.integer, 1); is(val, 0, "Set existing integer property"); - + + // test getting the type of an existing integer property + var type = Application.prefs.get(testdata.integer).type; + is(type, "Number", "Check 'Application.prefs.get().type' for integer pref"); + // test resetting an existing integer property Application.prefs.get(testdata.integer).reset(); var val = Application.prefs.getValue(testdata.integer, 0); is(val, 1, "Reset existing integer property"); // PREF: boolean browser.blink_allowed == true - + // test to see if an existing boolean property exists ok(Application.prefs.has(testdata.boolean), "Check existing boolean property for existance"); - + // test accessing a non-existant boolean property var val = Application.prefs.getValue(testdata.dummy, true); ok(val, "Check non-existant boolean property for expected value"); - + // test accessing an existing boolean property var val = Application.prefs.getValue(testdata.boolean, false); ok(val, "Check existing boolean property for expected value"); - + // test manipulating an existing boolean property Application.prefs.setValue(testdata.boolean, false); var val = Application.prefs.getValue(testdata.boolean, true); ok(!val, "Set existing boolean property"); - + + // test getting the type of an existing boolean property + var type = Application.prefs.get(testdata.boolean).type; + is(type, "Boolean", "Check 'Application.prefs.get().type' for boolean pref"); + // test resetting an existing boolean property Application.prefs.get(testdata.boolean).reset(); var val = Application.prefs.getValue(testdata.boolean, false); ok(val, "Reset existing string property for expected value"); - + // test getting all preferences var allPrefs = Application.prefs.all; ok(allPrefs.length >= 800, "Check 'Application.prefs.all' for the right number of preferences"); @@ -113,29 +125,29 @@ function test() { // test the value of the preference root is(Application.prefs.root, "", "Check the Application preference root"); - + // test for user changed preferences ok(Application.prefs.get("browser.shell.checkDefaultBrowser").modified, "A single preference is marked as modified."); ok(!Application.prefs.get(testdata.string).modified, "A single preference is marked as not modified."); - + // test for a locked preference var pref = Application.prefs.get(testdata.string); ok(!pref.locked, "A single preference should not be locked."); - + pref.locked = true; ok(pref.locked, "A single preference should be locked."); - + try { prev.value = "test value"; - + ok(false, "A locked preference should not be able to be modified."); } catch(e){ ok(true, "A locked preference should not be able to be modified."); } - + pref.locked = false; ok(!pref.locked, "A single preference should not be locked."); - + // check for change event when setting a value waitForExplicitFinish(); Application.prefs.events.addListener("change", onPrefChange); @@ -153,6 +165,6 @@ function onPrefChange(evt) { function onPrefChange2(evt) { is(evt.data, testdata.dummy, "Check 'Application.prefs.set' fired a change event for a single preference"); Application.prefs.events.removeListener("change", onPrefChange2); - + finish(); } From 0a50515f0e3e53054dfed3cf9bb336399f8ecdfb Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Wed, 5 Mar 2008 19:33:33 -0800 Subject: [PATCH 038/248] Bug 419786 - Link children associated with imagemaps do not implement the nsIAccessibleHyperLink interface, r=ginn.chen, aaronlev, a=beltzner --- accessible/src/html/nsHTMLAreaAccessible.cpp | 4 + accessible/src/html/nsHTMLAreaAccessible.h | 7 +- accessible/src/html/nsHTMLImageAccessible.cpp | 181 +++++++++++++----- accessible/src/html/nsHTMLImageAccessible.h | 13 +- 4 files changed, 151 insertions(+), 54 deletions(-) diff --git a/accessible/src/html/nsHTMLAreaAccessible.cpp b/accessible/src/html/nsHTMLAreaAccessible.cpp index 4ea1b5fab3ce..bcc72fc1321f 100644 --- a/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -53,6 +53,10 @@ nsLinkableAccessible(aDomNode, aShell) { } +// Expose nsIAccessibleHyperLink unconditionally +NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLAreaAccessible, nsLinkableAccessible, + nsIAccessibleHyperLink) + /* wstring getName (); */ NS_IMETHODIMP nsHTMLAreaAccessible::GetName(nsAString & aName) { diff --git a/accessible/src/html/nsHTMLAreaAccessible.h b/accessible/src/html/nsHTMLAreaAccessible.h index 9b5aa97f27e6..a2f9b87bb8c2 100644 --- a/accessible/src/html/nsHTMLAreaAccessible.h +++ b/accessible/src/html/nsHTMLAreaAccessible.h @@ -48,7 +48,12 @@ class nsHTMLAreaAccessible : public nsLinkableAccessible { public: - nsHTMLAreaAccessible(nsIDOMNode *domNode, nsIAccessible *accParent, nsIWeakReference* aShell); + nsHTMLAreaAccessible(nsIDOMNode *domNode, nsIAccessible *accParent, + nsIWeakReference* aShell); + + NS_DECL_ISUPPORTS_INHERITED + + // nsIAccessible NS_IMETHOD GetName(nsAString & _retval); NS_IMETHOD GetRole(PRUint32 *_retval); NS_IMETHOD GetFirstChild(nsIAccessible **_retval); diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp index 745de54b7cd0..d144b1791e04 100644 --- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -47,6 +47,7 @@ #include "nsIDocument.h" #include "nsIHTMLDocument.h" #include "nsIImageLoadingContent.h" +#include "nsILink.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" #include "nsIDOMHTMLImageElement.h" @@ -57,6 +58,9 @@ const PRUint32 kDefaultImageCacheSize = 256; +//////////////////////////////////////////////////////////////////////////////// +// nsHTMLImageAccessible + nsHTMLImageAccessible::nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell): nsLinkableAccessible(aDOMNode, aShell), mAccessNodeCache(nsnull) { @@ -84,7 +88,11 @@ nsLinkableAccessible(aDOMNode, aShell), mAccessNodeCache(nsnull) } } -NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageAccessible, nsAccessible, nsIAccessibleImage) +NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageAccessible, nsAccessible, + nsIAccessibleImage) + +//////////////////////////////////////////////////////////////////////////////// +// nsIAccessible NS_IMETHODIMP nsHTMLImageAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) @@ -151,50 +159,6 @@ NS_IMETHODIMP nsHTMLImageAccessible::GetRole(PRUint32 *_retval) return NS_OK; } - -already_AddRefed -nsHTMLImageAccessible::GetAreaAccessible(PRInt32 aAreaNum) -{ - if (!mMapElement) - return nsnull; - - nsCOMPtr mapAreas; - mMapElement->GetAreas(getter_AddRefs(mapAreas)); - if (!mapAreas) - return nsnull; - - nsCOMPtr domNode; - mapAreas->Item(aAreaNum,getter_AddRefs(domNode)); - if (!domNode) - return nsnull; - - nsCOMPtr accessNode; - GetCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), - getter_AddRefs(accessNode)); - - if (!accessNode) { - accessNode = new nsHTMLAreaAccessible(domNode, this, mWeakShell); - if (!accessNode) - return nsnull; - - nsCOMPtr privateAccessNode(do_QueryInterface(accessNode)); - NS_ASSERTION(privateAccessNode, - "Accessible doesn't implement nsPIAccessNode"); - - nsresult rv = privateAccessNode->Init(); - if (NS_FAILED(rv)) - return nsnull; - - PutCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), accessNode); - } - - nsCOMPtr accessible(do_QueryInterface(accessNode)); - nsIAccessible *accPtr; - NS_IF_ADDREF(accPtr = accessible); - return accPtr; -} - - void nsHTMLImageAccessible::CacheChildren() { if (!mWeakShell) { @@ -208,13 +172,9 @@ void nsHTMLImageAccessible::CacheChildren() } mAccChildCount = 0; - nsCOMPtr mapAreas; - if (mMapElement) { - mMapElement->GetAreas(getter_AddRefs(mapAreas)); - } - if (!mapAreas) { + nsCOMPtr mapAreas = GetAreaCollection(); + if (!mapAreas) return; - } PRUint32 numMapAreas; mapAreas->GetLength(&numMapAreas); @@ -223,7 +183,7 @@ void nsHTMLImageAccessible::CacheChildren() nsCOMPtr areaAccessible; nsCOMPtr privatePrevAccessible; while (childCount < (PRInt32)numMapAreas && - (areaAccessible = GetAreaAccessible(childCount)) != nsnull) { + (areaAccessible = GetAreaAccessible(mapAreas, childCount)) != nsnull) { if (privatePrevAccessible) { privatePrevAccessible->SetNextSibling(areaAccessible); } @@ -263,6 +223,66 @@ NS_IMETHODIMP nsHTMLImageAccessible::DoAction(PRUint8 index) return nsLinkableAccessible::DoAction(index); } +//////////////////////////////////////////////////////////////////////////////// +// nsIAccessibleHyperLink +NS_IMETHODIMP +nsHTMLImageAccessible::GetAnchors(PRInt32 *aAnchors) +{ + NS_ENSURE_ARG_POINTER(aAnchors); + + if (!mMapElement) + return nsLinkableAccessible::GetAnchors(aAnchors); + + return GetChildCount(aAnchors); +} + +NS_IMETHODIMP +nsHTMLImageAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI) +{ + NS_ENSURE_ARG_POINTER(aURI); + *aURI = nsnull; + + if (!mMapElement) + return nsLinkableAccessible::GetURI(aIndex, aURI); + + nsCOMPtr mapAreas = GetAreaCollection(); + if (!mapAreas) + return NS_OK; + + nsCOMPtr domNode; + mapAreas->Item(aIndex, getter_AddRefs(domNode)); + if (!domNode) + return NS_ERROR_INVALID_ARG; + + nsCOMPtr link(do_QueryInterface(domNode)); + if (link) + link->GetHrefURI(aURI); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImageAccessible::GetObject(PRInt32 aIndex, nsIAccessible **aAccessible) +{ + NS_ENSURE_ARG_POINTER(aAccessible); + *aAccessible = nsnull; + + if (!mMapElement) + return nsLinkableAccessible::GetObject(aIndex, aAccessible); + + nsCOMPtr mapAreas = GetAreaCollection(); + if (mapAreas) { + nsCOMPtr accessible; + accessible = GetAreaAccessible(mapAreas, aIndex); + NS_IF_ADDREF(*aAccessible = accessible); + } + + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIAccessibleImage + NS_IMETHODIMP nsHTMLImageAccessible::GetImagePosition(PRUint32 aCoordType, PRInt32 *aX, PRInt32 *aY) @@ -282,6 +302,9 @@ nsHTMLImageAccessible::GetImageSize(PRInt32 *aWidth, PRInt32 *aHeight) return GetBounds(&x, &y, aWidth, aHeight); } +//////////////////////////////////////////////////////////////////////////////// +// nsPIAccessNode + NS_IMETHODIMP nsHTMLImageAccessible::Shutdown() { @@ -296,3 +319,57 @@ nsHTMLImageAccessible::Shutdown() return NS_OK; } +//////////////////////////////////////////////////////////////////////////////// +// nsHTMLImageAccessible + +already_AddRefed +nsHTMLImageAccessible::GetAreaCollection() +{ + if (!mMapElement) + return nsnull; + + nsIDOMHTMLCollection *mapAreas = nsnull; + nsresult rv = mMapElement->GetAreas(&mapAreas); + if (NS_FAILED(rv)) + return nsnull; + + return mapAreas; +} + +already_AddRefed +nsHTMLImageAccessible::GetAreaAccessible(nsIDOMHTMLCollection *aAreaCollection, + PRInt32 aAreaNum) +{ + if (!aAreaCollection) + return nsnull; + + nsCOMPtr domNode; + aAreaCollection->Item(aAreaNum,getter_AddRefs(domNode)); + if (!domNode) + return nsnull; + + nsCOMPtr accessNode; + GetCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), + getter_AddRefs(accessNode)); + + if (!accessNode) { + accessNode = new nsHTMLAreaAccessible(domNode, this, mWeakShell); + if (!accessNode) + return nsnull; + + nsCOMPtr privateAccessNode(do_QueryInterface(accessNode)); + NS_ASSERTION(privateAccessNode, + "Accessible doesn't implement nsPIAccessNode"); + + nsresult rv = privateAccessNode->Init(); + if (NS_FAILED(rv)) + return nsnull; + + PutCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), accessNode); + } + + nsIAccessible *accessible = nsnull; + CallQueryInterface(accessNode, &accessible); + + return accessible; +} diff --git a/accessible/src/html/nsHTMLImageAccessible.h b/accessible/src/html/nsHTMLImageAccessible.h index 625b3edc747b..7d15eeba9850 100644 --- a/accessible/src/html/nsHTMLImageAccessible.h +++ b/accessible/src/html/nsHTMLImageAccessible.h @@ -66,6 +66,11 @@ public: NS_IMETHOD GetRole(PRUint32 *_retval); NS_IMETHOD DoAction(PRUint8 index); + // nsIAccessibleHyperLink + NS_IMETHOD GetAnchors(PRInt32 *aAnchors); + NS_IMETHOD GetURI(PRInt32 aIndex, nsIURI **aURI); + NS_IMETHOD GetObject(PRInt32 aIndex, nsIAccessible **aAccessible); + // nsPIAccessNode NS_IMETHOD Shutdown(); @@ -73,8 +78,14 @@ public: NS_DECL_NSIACCESSIBLEIMAGE protected: + // nsAccessible virtual void CacheChildren(); - already_AddRefed GetAreaAccessible(PRInt32 aAreaNum); + + already_AddRefed GetAreaCollection(); + already_AddRefed + GetAreaAccessible(nsIDOMHTMLCollection* aAreaNodes, PRInt32 aAreaNum); + + // Reference on linked map element if any. nsCOMPtr mMapElement; // Cache of area accessibles. We do not use common cache because images can From 9a0ae4b30d9bc8db5e20ef065adf5c33de5846d5 Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Wed, 5 Mar 2008 19:43:50 -0800 Subject: [PATCH 039/248] Bug 420960. Crash when aria-activedescendant attribute removed. r=marcoz, a=beltzner --- accessible/src/base/nsAccessible.h | 4 +-- accessible/src/base/nsRootAccessible.cpp | 38 +++++++++++++----------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/accessible/src/base/nsAccessible.h b/accessible/src/base/nsAccessible.h index 6d5ecbbe19d5..51a2a99d7164 100644 --- a/accessible/src/base/nsAccessible.h +++ b/accessible/src/base/nsAccessible.h @@ -142,8 +142,8 @@ public: #endif static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom); - static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state; aAcc->GetFinalState(&state, nsnull); return state; } - static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role; aAcc->GetFinalRole(&role); return role; } + static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state = 0; if (aAcc) aAcc->GetFinalState(&state, nsnull); return state; } + static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role = nsIAccessibleRole::ROLE_NOTHING; if (aAcc) aAcc->GetFinalRole(&role); return role; } static PRBool IsText(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role == nsIAccessibleRole::ROLE_TEXT_LEAF || role == nsIAccessibleRole::ROLE_STATICTEXT; } static PRBool IsEmbeddedObject(nsIAccessible *aAcc) { PRUint32 role = Role(aAcc); return role != nsIAccessibleRole::ROLE_TEXT_LEAF && role != nsIAccessibleRole::ROLE_WHITESPACE && role != nsIAccessibleRole::ROLE_STATICTEXT; } static PRInt32 TextLength(nsIAccessible *aAccessible); // Returns -1 on failure diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 026d62931409..42c48ab7a3b6 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -463,13 +463,7 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, if (!finalFocusNode) { return PR_FALSE; } - GetAccService()->GetAccessibleFor(finalFocusNode, getter_AddRefs(finalFocusAccessible)); - // For activedescendant, the ARIA spec does not require that the user agent - // checks whether finalFocusNode is actually a descendant of the element with - // the activedescendant attribute. - if (!finalFocusAccessible) { - return PR_FALSE; - } + finalFocusAccessible = nsnull; } } @@ -478,6 +472,16 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, return PR_FALSE; } + if (!finalFocusAccessible) { + GetAccService()->GetAccessibleFor(finalFocusNode, getter_AddRefs(finalFocusAccessible)); + // For activedescendant, the ARIA spec does not require that the user agent + // checks whether finalFocusNode is actually a descendant of the element with + // the activedescendant attribute. + if (!finalFocusAccessible) { + return PR_FALSE; + } + } + gLastFocusedAccessiblesState = State(finalFocusAccessible); PRUint32 role = Role(finalFocusAccessible); if (role == nsIAccessibleRole::ROLE_MENUITEM) { @@ -845,7 +849,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, } } else if (eventType.EqualsLiteral("DOMMenuItemActive")) { - PRBool fireFocus = PR_FALSE; + PRBool fireFocus = PR_FALSE; if (!treeItemAccessible) { #ifdef MOZ_XUL if (isTree) { @@ -858,8 +862,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, NS_ENSURE_TRUE(menuFrame, NS_ERROR_FAILURE); nsIMenuFrame* imenuFrame; CallQueryInterface(menuFrame, &imenuFrame); - if (imenuFrame) - fireFocus = PR_TRUE; + if (imenuFrame) + fireFocus = PR_TRUE; // QI failed for nsIMenuFrame means it's not on menu bar if (imenuFrame && imenuFrame->IsOnMenuBar() && !imenuFrame->IsOnActiveMenuBar()) { @@ -873,7 +877,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, // It is not top level menuitem // Only fire focus event if it is not inside collapsed popup // and not a listitem of a combo box - if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) { + if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED) { nsCOMPtr containerParent; containerAccessible->GetParent(getter_AddRefs(containerParent)); NS_ENSURE_TRUE(containerParent, NS_ERROR_FAILURE); @@ -893,16 +897,16 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, if (popup || containerContent == realFocusedContent) { // If we're inside the focus or a popup we can fire focus events // for the changed active item - fireFocus = PR_TRUE; - break; + fireFocus = PR_TRUE; + break; } containerContent = containerContent->GetParent(); } } - if (fireFocus) { - nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE); // Always asynch, always from user input - FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE, PR_TRUE); - } + if (fireFocus) { + nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE); // Always asynch, always from user input + FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE, PR_TRUE); + } } else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always asynch, always from user input nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE); From 9a92be7d14d3be3edf772b95d4f7378564504dea Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Wed, 5 Mar 2008 19:45:43 -0800 Subject: [PATCH 040/248] Bug 419770. Can't get to the frame/iframe of a document with IAccessible::accParent --- accessible/src/base/nsAccessible.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 9d88b7acf8dd..213ee8152ed5 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -72,6 +72,7 @@ #include "nsIFrame.h" #include "nsIViewManager.h" #include "nsIDocShellTreeItem.h" +#include "nsIScrollableFrame.h" #include "nsXPIDLString.h" #include "nsUnicharUtils.h" @@ -2671,6 +2672,21 @@ NS_IMETHODIMP nsAccessible::GetAccessibleRelated(PRUint32 aRelationType, nsIAcce nsAccUtils::GetARIATreeItemParent(this, content, aRelated); return NS_OK; } + // If accessible is in its own Window then we should provide NODE_CHILD_OF relation + // so that MSAA clients can easily get to true parent instead of getting to oleacc's + // ROLE_WINDOW accessible which will prevent us from going up further (because it is + // system generated and has no idea about the hierarchy above it). + nsIFrame *frame = GetFrame(); + if (frame) { + nsIView *view = frame->GetViewExternal(); + if (view) { + nsIScrollableFrame *scrollFrame = nsnull; + CallQueryInterface(frame, &scrollFrame); + if (scrollFrame || view->GetWidget()) { + return GetParent(aRelated); + } + } + } break; } case nsIAccessibleRelation::RELATION_CONTROLLED_BY: From e5cba8bfef95c15b8bb1ff1f356217df8215be5b Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Wed, 5 Mar 2008 19:49:44 -0800 Subject: [PATCH 041/248] Bug 418043 - add mochitest for bug 308564, r=evan.yan --- accessible/tests/mochitest/test_bug368835.xul | 204 ++++++++++++------ 1 file changed, 136 insertions(+), 68 deletions(-) diff --git a/accessible/tests/mochitest/test_bug368835.xul b/accessible/tests/mochitest/test_bug368835.xul index 605407ce06cf..fe72762c46dd 100644 --- a/accessible/tests/mochitest/test_bug368835.xul +++ b/accessible/tests/mochitest/test_bug368835.xul @@ -5,6 +5,7 @@ - - - Mozilla Bug 368835 - -

- -
-    
- + + + + Mozilla Bug 368835 +
+ + Mozilla Bug 308564 + +

+ +
+      
+ + + + + + + + + +
- - - - - - -
From 818390570b8c548541fb89c5190143ba0a825c56 Mon Sep 17 00:00:00 2001 From: "jwalden@mit.edu" Date: Wed, 5 Mar 2008 19:58:48 -0800 Subject: [PATCH 042/248] Bug 401514 - Don't use a getter when a property will do. r=gavin, a=beltzner --- .../components/feeds/src/WebContentConverter.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/browser/components/feeds/src/WebContentConverter.js b/browser/components/feeds/src/WebContentConverter.js index 4c03d1e5632a..33ee18084e30 100644 --- a/browser/components/feeds/src/WebContentConverter.js +++ b/browser/components/feeds/src/WebContentConverter.js @@ -169,16 +169,12 @@ ServiceInfo.prototype = { function WebContentConverterRegistrar() {} WebContentConverterRegistrar.prototype = { - _stringBundle: null, - get stringBundle() { - if (!this._stringBundle) { - this._stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]. - getService(Ci.nsIStringBundleService). - createBundle(STRING_BUNDLE_URI); - } - - return this._stringBundle; + var sb = Cc["@mozilla.org/intl/stringbundle;1"]. + getService(Ci.nsIStringBundleService). + createBundle(STRING_BUNDLE_URI); + delete WebContentConverterRegistrar.prototype.stringBundle; + return WebContentConverterRegistrar.prototype.stringBundle = sb; }, _getFormattedString: function WCCR__getFormattedString(key, params) { From e8a0a8a6e2a40353d69e8b7555af44b8241391d1 Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Wed, 5 Mar 2008 20:11:45 -0800 Subject: [PATCH 043/248] Bug 417912 - GetCellDataAt callers that expect an error if no cell is found are wrong, r=evan.yan, bernd, a=beltzner --- accessible/src/html/nsHTMLTableAccessible.cpp | 43 ++++++++++++------- .../mochitest/test_nsIAccessibleTable_2.html | 42 +++++++++++++++++- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index 8d677f51233b..fb5b90113499 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -58,6 +58,7 @@ #include "nsIServiceManager.h" #include "nsITableLayout.h" #include "nsITableCellLayout.h" +#include "nsLayoutErrors.h" NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableCellAccessible, nsHyperTextAccessible) @@ -662,11 +663,15 @@ nsHTMLTableAccessible::IsRowSelected(PRInt32 aRow, PRBool *_retval) NS_IMETHODIMP nsHTMLTableAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, - PRBool *_retval) + PRBool *aIsSelected) { - NS_ENSURE_TRUE(IsValidRow(aRow) && IsValidColumn(aColumn), NS_ERROR_INVALID_ARG); + NS_ENSURE_ARG_POINTER(aIsSelected); + *aIsSelected = PR_FALSE; - nsITableLayout *tableLayout; + NS_ENSURE_TRUE(IsValidRow(aRow) && IsValidColumn(aColumn), + NS_ERROR_INVALID_ARG); + + nsITableLayout *tableLayout = nsnull; nsresult rv = GetTableLayout(&tableLayout); NS_ENSURE_SUCCESS(rv, rv); @@ -674,11 +679,14 @@ nsHTMLTableAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, PRInt32 startRowIndex = 0, startColIndex = 0, rowSpan, colSpan, actualRowSpan, actualColSpan; - return tableLayout->GetCellDataAt(aRow, aColumn, - *getter_AddRefs(domElement), - startRowIndex, startColIndex, rowSpan, - colSpan, actualRowSpan, actualColSpan, - *_retval); + rv = tableLayout->GetCellDataAt(aRow, aColumn, *getter_AddRefs(domElement), + startRowIndex, startColIndex, + rowSpan, colSpan, + actualRowSpan, actualColSpan, *aIsSelected); + + if (rv == NS_TABLELAYOUT_CELL_NOT_FOUND) + return NS_ERROR_INVALID_ARG; + return rv; } PRBool @@ -867,15 +875,18 @@ nsHTMLTableAccessible::GetCellAt(PRInt32 aRowIndex, rowSpan, colSpan, actualRowSpan, actualColSpan; PRBool isSelected; - nsITableLayout *tableLayout; + nsITableLayout *tableLayout = nsnull; nsresult rv = GetTableLayout(&tableLayout); NS_ENSURE_SUCCESS(rv, rv); - return tableLayout->GetCellDataAt(aRowIndex, aColIndex, aCell, - startRowIndex, startColIndex, - rowSpan, colSpan, - actualRowSpan, actualColSpan, - isSelected); + rv = tableLayout->GetCellDataAt(aRowIndex, aColIndex, aCell, + startRowIndex, startColIndex, + rowSpan, colSpan, + actualRowSpan, actualColSpan, isSelected); + + if (rv == NS_TABLELAYOUT_CELL_NOT_FOUND) + return NS_ERROR_INVALID_ARG; + return rv; } NS_IMETHODIMP nsHTMLTableAccessible::GetDescription(nsAString& aDescription) @@ -1030,7 +1041,9 @@ NS_IMETHODIMP nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForL // Check to see if there are visible borders on the cells // XXX currently, we just check the first cell -- do we really need to do more? nsCOMPtr cellElement; - GetCellAt(0, 0, *getter_AddRefs(cellElement)); + nsresult rv = GetCellAt(0, 0, *getter_AddRefs(cellElement)); + NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); + nsCOMPtr cellContent(do_QueryInterface(cellElement)); NS_ENSURE_TRUE(cellContent, NS_ERROR_FAILURE); nsCOMPtr shell(GetPresShell()); diff --git a/accessible/tests/mochitest/test_nsIAccessibleTable_2.html b/accessible/tests/mochitest/test_nsIAccessibleTable_2.html index f7b3b1956344..b6642f72f9b8 100644 --- a/accessible/tests/mochitest/test_nsIAccessibleTable_2.html +++ b/accessible/tests/mochitest/test_nsIAccessibleTable_2.html @@ -12,10 +12,11 @@ function doTest() { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var table = document.getElementById("table"); var accService = Components.classes["@mozilla.org/accessibleRetrieval;1"]. getService(Components.interfaces.nsIAccessibleRetrieval); + // bug 410052 + var table = document.getElementById("table"); var accTable = accService.getAccessibleFor(table). QueryInterface(Components.interfaces.nsIAccessibleTable); @@ -29,15 +30,45 @@ function doTest() is(accTable.getRowExtentAt(2,7), 4,"rowspan wrong"); is(accTable.getColumnExtentAt(2,3), 1, "colspan wrong"); is(accTable.cellRefAt(2,1).firstChild.name, "c1", "wrong cell"); + + // bug 417912 + var table2 = document.getElementById("table2"); + var accTable2 = accService.getAccessibleFor(table2). + QueryInterface(Components.interfaces.nsIAccessibleTable); + testCellAt(accTable2, 0, 0, true); + testCellAt(accTable2, 0, 1, true); + testCellAt(accTable2, 0, 2, true); + testCellAt(accTable2, 1, 0, true); + testCellAt(accTable2, 1, 1, false); + testCellAt(accTable2, 1, 2, true); + testCellAt(accTable2, 2, 0, true); + testCellAt(accTable2, 2, 1, true); + testCellAt(accTable2, 2, 2, true); + SimpleTest.finish(); } +function testCellAt(aTable, aRow, aColumn, aSucceeded) +{ + try { + aTable.cellRefAt(aRow, aColumn); + ok(aSucceeded, "cell is available at (" + aRow + ", " + aColumn + ")."); + } catch (e) { + ok(!aSucceeded, "cell is not available at (" + aRow + ", " + aColumn + ")."); + } +} + SimpleTest.waitForExplicitFinish(); addLoadEvent(doTest); Mozilla Bug 410052 +
+ + Mozilla Bug 417912 +

@@ -83,5 +114,14 @@ addLoadEvent(doTest);
     
    
   
+
+  

Testing Table 2:

+
+ + + + +
123
4
56
+
From 86a5941cc53cfd6dda168eb1868f0497a825f8f3 Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Wed, 5 Mar 2008 20:14:10 -0800 Subject: [PATCH 044/248] Bug 418371 - implement the rest of methods of nsIAccessibleTable on xul:listbox, r=evan.yan, a=beltzner --- accessible/src/base/nsAccessibilityAtomList.h | 2 + accessible/src/xul/nsXULSelectAccessible.cpp | 280 ++++++++++++-- accessible/tests/mochitest/Makefile.in | 1 + .../test_nsIAccessibleTable_listboxes.xul | 343 ++++++++++++++++++ 4 files changed, 604 insertions(+), 22 deletions(-) create mode 100644 accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul diff --git a/accessible/src/base/nsAccessibilityAtomList.h b/accessible/src/base/nsAccessibilityAtomList.h index 85d436067c17..1a143aee7ce9 100755 --- a/accessible/src/base/nsAccessibilityAtomList.h +++ b/accessible/src/base/nsAccessibilityAtomList.h @@ -116,6 +116,8 @@ ACCESSIBILITY_ATOM(label, "label") ACCESSIBILITY_ATOM(legend, "legend") ACCESSIBILITY_ATOM(li, "li") ACCESSIBILITY_ATOM(link, "link") +ACCESSIBILITY_ATOM(listcols, "listcols") // XUL +ACCESSIBILITY_ATOM(listcol, "listcol") // XUL ACCESSIBILITY_ATOM(listhead, "listhead") // XUL ACCESSIBILITY_ATOM(listheader, "listheader") // XUL ACCESSIBILITY_ATOM(map, "map") diff --git a/accessible/src/xul/nsXULSelectAccessible.cpp b/accessible/src/xul/nsXULSelectAccessible.cpp index 8d407f0a2b06..33249d8c3257 100644 --- a/accessible/src/xul/nsXULSelectAccessible.cpp +++ b/accessible/src/xul/nsXULSelectAccessible.cpp @@ -42,8 +42,8 @@ #include "nsIContent.h" #include "nsIDOMXULMenuListElement.h" #include "nsIDOMXULPopupElement.h" +#include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIDOMXULSelectCntrlItemEl.h" -#include "nsIDOMXULSelectCntrlEl.h" #include "nsIDOMXULTextboxElement.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" @@ -258,7 +258,7 @@ nsXULListboxAccessible::GetCaption(nsIAccessible **aCaption) NS_ENSURE_ARG_POINTER(aCaption); *aCaption = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; + return NS_OK; } NS_IMETHODIMP @@ -266,7 +266,7 @@ nsXULListboxAccessible::GetSummary(nsAString &aSummary) { aSummary.Truncate(); - return NS_ERROR_NOT_IMPLEMENTED; + return NS_OK; } NS_IMETHODIMP @@ -287,7 +287,7 @@ nsXULListboxAccessible::GetColumns(PRInt32 *aNumColumns) nsCOMPtr childContent(content->GetChildAt(index)); NS_ENSURE_STATE(childContent); - if (childContent->NodeInfo()->Equals(nsAccessibilityAtoms::listhead, + if (childContent->NodeInfo()->Equals(nsAccessibilityAtoms::listcols, kNameSpaceID_XUL)) { headContent = childContent; } @@ -303,7 +303,7 @@ nsXULListboxAccessible::GetColumns(PRInt32 *aNumColumns) nsCOMPtr childContent(headContent->GetChildAt(index)); NS_ENSURE_STATE(childContent); - if (childContent->NodeInfo()->Equals(nsAccessibilityAtoms::listheader, + if (childContent->NodeInfo()->Equals(nsAccessibilityAtoms::listcol, kNameSpaceID_XUL)) { columnCount++; } @@ -452,71 +452,214 @@ NS_IMETHODIMP nsXULListboxAccessible::GetColumnDescription(PRInt32 aColumn, nsAString& aDescription) { - return NS_ERROR_NOT_IMPLEMENTED; + aDescription.Truncate(); + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::GetRowDescription(PRInt32 aRow, nsAString& aDescription) { - return NS_ERROR_NOT_IMPLEMENTED; + aDescription.Truncate(); + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::IsColumnSelected(PRInt32 aColumn, PRBool *aIsSelected) { NS_ENSURE_ARG_POINTER(aIsSelected); + *aIsSelected = PR_FALSE; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + PRInt32 selectedRowsCount = 0; + nsresult rv = control->GetSelectedCount(&selectedRowsCount); + NS_ENSURE_SUCCESS(rv, rv); + + PRInt32 rowsCount = 0; + rv = GetRows(&rowsCount); + NS_ENSURE_SUCCESS(rv, rv); + + *aIsSelected = (selectedRowsCount == rowsCount); + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::IsRowSelected(PRInt32 aRow, PRBool *aIsSelected) { NS_ENSURE_ARG_POINTER(aIsSelected); + *aIsSelected = PR_FALSE; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULSelectControlElement."); + + nsCOMPtr item; + control->GetItemAtIndex(aRow, getter_AddRefs(item)); + NS_ENSURE_TRUE(item, NS_ERROR_INVALID_ARG); + + return item->GetSelected(aIsSelected); } NS_IMETHODIMP nsXULListboxAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, PRBool *aIsSelected) { - NS_ENSURE_ARG_POINTER(aIsSelected); - - return NS_ERROR_NOT_IMPLEMENTED; + return IsRowSelected(aRow, aIsSelected); } NS_IMETHODIMP nsXULListboxAccessible::GetSelectedCellsCount(PRUint32* aCount) { NS_ENSURE_ARG_POINTER(aCount); + *aCount = 0; - return NS_ERROR_NOT_IMPLEMENTED; + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + nsCOMPtr selectedItems; + control->GetSelectedItems(getter_AddRefs(selectedItems)); + if (!selectedItems) + return NS_OK; + + PRUint32 selectedItemsCount = 0; + nsresult rv = selectedItems->GetLength(&selectedItemsCount); + NS_ENSURE_SUCCESS(rv, rv); + + if (!selectedItemsCount) + return NS_OK; + + PRInt32 columnsCount = 0; + rv = GetColumns(&columnsCount); + NS_ENSURE_SUCCESS(rv, rv); + + *aCount = selectedItemsCount * columnsCount; + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::GetSelectedColumnsCount(PRUint32* aCount) { NS_ENSURE_ARG_POINTER(aCount); + *aCount = 0; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + PRInt32 selectedRowsCount = 0; + nsresult rv = control->GetSelectedCount(&selectedRowsCount); + NS_ENSURE_SUCCESS(rv, rv); + + PRInt32 rowsCount = 0; + rv = GetRows(&rowsCount); + NS_ENSURE_SUCCESS(rv, rv); + + if (selectedRowsCount != rowsCount) + return NS_OK; + + PRInt32 columnsCount = 0; + rv = GetColumns(&columnsCount); + NS_ENSURE_SUCCESS(rv, rv); + + *aCount = columnsCount; + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::GetSelectedRowsCount(PRUint32* aCount) { NS_ENSURE_ARG_POINTER(aCount); + *aCount = 0; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + PRInt32 selectedRowsCount = 0; + nsresult rv = control->GetSelectedCount(&selectedRowsCount); + NS_ENSURE_SUCCESS(rv, rv); + + *aCount = selectedRowsCount; + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells) { NS_ENSURE_ARG_POINTER(aNumCells); + *aNumCells = 0; NS_ENSURE_ARG_POINTER(aCells); + *aCells = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + nsCOMPtr selectedItems; + control->GetSelectedItems(getter_AddRefs(selectedItems)); + if (!selectedItems) + return NS_OK; + + PRUint32 selectedItemsCount = 0; + nsresult rv = selectedItems->GetLength(&selectedItemsCount); + NS_ENSURE_SUCCESS(rv, rv); + + PRInt32 columnsCount = 0; + rv = GetColumns(&columnsCount); + NS_ENSURE_SUCCESS(rv, rv); + + PRUint32 cellsCount = selectedItemsCount * columnsCount; + + PRInt32 *cellsIdxArray = + static_cast(nsMemory::Alloc((cellsCount) * sizeof(PRInt32))); + NS_ENSURE_TRUE(cellsIdxArray, NS_ERROR_OUT_OF_MEMORY); + + PRUint32 index = 0, cellsIdx = 0; + for (; index < selectedItemsCount; index++) { + nsCOMPtr itemNode; + selectedItems->Item(index, getter_AddRefs(itemNode)); + nsCOMPtr item = + do_QueryInterface(itemNode); + + if (item) { + PRInt32 itemIdx = -1; + control->GetIndexOfItem(item, &itemIdx); + if (itemIdx != -1) { + PRInt32 colIdx = 0; + for (; colIdx < columnsCount; colIdx++) + cellsIdxArray[cellsIdx++] = itemIdx * columnsCount + colIdx; + } + } + } + + *aNumCells = cellsCount; + *aCells = cellsIdxArray; + + return NS_OK; } NS_IMETHODIMP @@ -524,42 +667,135 @@ nsXULListboxAccessible::GetSelectedColumns(PRUint32 *aNumColumns, PRInt32 **aColumns) { NS_ENSURE_ARG_POINTER(aNumColumns); + *aNumColumns = 0; NS_ENSURE_ARG_POINTER(aColumns); + *aColumns = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + PRUint32 columnsCount = 0; + nsresult rv = GetSelectedColumnsCount(&columnsCount); + NS_ENSURE_SUCCESS(rv, rv); + + if (!columnsCount) + return NS_OK; + + PRInt32 *colsIdxArray = + static_cast(nsMemory::Alloc((columnsCount) * sizeof(PRInt32))); + NS_ENSURE_TRUE(colsIdxArray, NS_ERROR_OUT_OF_MEMORY); + + PRUint32 colIdx = 0; + for (; colIdx < columnsCount; colIdx++) + colsIdxArray[colIdx] = colIdx; + + *aNumColumns = columnsCount; + *aColumns = colsIdxArray; + + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::GetSelectedRows(PRUint32 *aNumRows, PRInt32 **aRows) { NS_ENSURE_ARG_POINTER(aNumRows); + *aNumRows = 0; NS_ENSURE_ARG_POINTER(aRows); + *aRows = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + nsCOMPtr selectedItems; + control->GetSelectedItems(getter_AddRefs(selectedItems)); + if (!selectedItems) + return NS_OK; + + PRUint32 selectedItemsCount = 0; + nsresult rv = selectedItems->GetLength(&selectedItemsCount); + NS_ENSURE_SUCCESS(rv, rv); + + if (!selectedItemsCount) + return NS_OK; + + PRInt32 *rowsIdxArray = + static_cast(nsMemory::Alloc((selectedItemsCount) * sizeof(PRInt32))); + NS_ENSURE_TRUE(rowsIdxArray, NS_ERROR_OUT_OF_MEMORY); + + PRUint32 index = 0; + for (; index < selectedItemsCount; index++) { + nsCOMPtr itemNode; + selectedItems->Item(index, getter_AddRefs(itemNode)); + nsCOMPtr item = + do_QueryInterface(itemNode); + + if (item) { + PRInt32 itemIdx = -1; + control->GetIndexOfItem(item, &itemIdx); + if (itemIdx != -1) + rowsIdxArray[index] = itemIdx; + } + } + + *aNumRows = selectedItemsCount; + *aRows = rowsIdxArray; + + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::SelectRow(PRInt32 aRow) { - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + nsCOMPtr item; + control->GetItemAtIndex(aRow, getter_AddRefs(item)); + NS_ENSURE_TRUE(item, NS_ERROR_INVALID_ARG); + + return control->SelectItem(item); } NS_IMETHODIMP nsXULListboxAccessible::SelectColumn(PRInt32 aColumn) { - return NS_ERROR_NOT_IMPLEMENTED; + // xul:listbox and xul:richlistbox support row selection only. + return NS_OK; } NS_IMETHODIMP nsXULListboxAccessible::UnselectRow(PRInt32 aRow) { - return NS_ERROR_NOT_IMPLEMENTED; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsCOMPtr control = + do_QueryInterface(mDOMNode); + NS_ASSERTION(control, + "Doesn't implement nsIDOMXULMultiSelectControlElement."); + + nsCOMPtr item; + control->GetItemAtIndex(aRow, getter_AddRefs(item)); + NS_ENSURE_TRUE(item, NS_ERROR_INVALID_ARG); + + return control->RemoveItemFromSelection(item); } NS_IMETHODIMP nsXULListboxAccessible::UnselectColumn(PRInt32 aColumn) { - return NS_ERROR_NOT_IMPLEMENTED; + // xul:listbox and xul:richlistbox support row selection only. + return NS_OK; } NS_IMETHODIMP diff --git a/accessible/tests/mochitest/Makefile.in b/accessible/tests/mochitest/Makefile.in index 77a6da177916..77cd6bfb63dd 100644 --- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -51,6 +51,7 @@ _TEST_FILES =\ test_nsIAccessibleTable_1.html \ test_nsIAccessibleTable_2.html \ test_nsIAccessibleTable_3.html \ + test_nsIAccessibleTable_listboxes.xul \ $(NULL) libs:: $(_TEST_FILES) diff --git a/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul b/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul new file mode 100644 index 000000000000..a85d543a288b --- /dev/null +++ b/accessible/tests/mochitest/test_nsIAccessibleTable_listboxes.xul @@ -0,0 +1,343 @@ + + + + + + + + + + + + + Mozilla Bug 418371 + +

+ +
+    
+ + + + +
+ +
+ From 94d72b9614e8177a1d98dbcfe0f57facf58ec751 Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Wed, 5 Mar 2008 20:17:19 -0800 Subject: [PATCH 045/248] Bug 419867 - statusbarpanel accessibility interface, r=evan.yan, enndeakin, a=beltzner --- toolkit/content/widgets/general.xml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/toolkit/content/widgets/general.xml b/toolkit/content/widgets/general.xml index 0eb65ad2e105..168cc67d5a5e 100644 --- a/toolkit/content/widgets/general.xml +++ b/toolkit/content/widgets/general.xml @@ -237,7 +237,15 @@ - + + + + + + + @@ -282,16 +290,6 @@ - - - - - - - - Date: Wed, 5 Mar 2008 20:37:37 -0800 Subject: [PATCH 046/248] bootstrap config for xulrunner releases b=415180 r=nthomas --- tools/release/configs/xr-moz19-bootstrap.cfg | 85 ++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tools/release/configs/xr-moz19-bootstrap.cfg diff --git a/tools/release/configs/xr-moz19-bootstrap.cfg b/tools/release/configs/xr-moz19-bootstrap.cfg new file mode 100644 index 000000000000..087ae3ab8c13 --- /dev/null +++ b/tools/release/configs/xr-moz19-bootstrap.cfg @@ -0,0 +1,85 @@ +version = 3.0b4 +prettyAusVersion = 3 Beta 4 +milestone = 1.9b4 +# _RCn and _RELEASE will be appended as-needed +productTag = FIREFOX_3_0b4 +# Branch name and pull dates to use for base tag +branchTag = HEAD +#RelbranchOverride = GECKO190_20071207_RELBRANCH +pullDate = 2008-03-03 11:15 PST +l10n_pullDate = 2008-03-03 05:00 PST +rc = 1 +# oldVersion and oldRc refer to the previous release +oldVersion = 3.0b3 +oldRc = 3 +appName = xulrunner +product = xulrunner +# Absolute path to tinderbox build directory +# The win32 ones are kept short because of a long path issue detailed in +# bug# 400846 +linux_buildDir = /builds/tinderbox/Xr-Mozilla1.9-Release +macosx_buildDir = /builds/tinderbox/Xr-Mozilla1.9-Release +win32_buildDir = /e/xr19rel +linux_l10n_buildDir = /builds/tinderbox/Xr-Mozilla1.9-l10n-Release +macosx_l10n_buildDir = /builds/tinderbox/Xr-Mozilla1.9-l10n-Release +win32_l10n_buildDir = /e/xr19l10nrel +# Absolute path to store bootstrap's logs +linux_logDir = /builds/logs +macosx_logDir = /builds/logs +win32_logDir = /builds/logs +mozillaCvsroot = cltbld@cvs.mozilla.org:/cvsroot +l10nCvsroot = cltbld@cvs.mozilla.org:/l10n +mofoCvsroot = cltbld@cvs.mozilla.org:/mofo +anonCvsroot = :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot +# private staging area +stageHome = /data/cltbld +updateDir = /builds/updates +verifyDir = /builds/verify +tagDir = /builds/tags +configBumpDir = /builds/config +# Build platform, as specified by tinderbox +linux_buildPlatform = Linux_2.6.18-53.1.13.el5_Depend +macosx_buildPlatform = Darwin_8.8.4_Depend +win32_buildPlatform = WINNT_5.2_Depend +linux_l10n_buildPlatform = Linux_2.6.18-53.1.13.el5_Depend +macosx_l10n_buildPlatform = Darwin_8.8.4_Depend +win32_l10n_buildPlatform = WINNT_5.2_Depend +from = bootstrap@mozilla.org +to = build@mozilla.org +cc = bhearsum@mozilla.com +patcherConfig = moz19-branch-patcher2.cfg +# Tag to use for building MAR/MBSDIFF and other update tools +patcherToolsRev = UPDATE_PACKAGING_R1 +linux_verifyConfig = moz19-xulrunner-linux.cfg +win32_verifyConfig = moz19-xulrunner-win32.cfg +macosx_verifyConfig = moz19-xulrunner-mac.cfg +blat = /d/mozilla-build/blat261/full/blat.exe +sendmail = /usr/sbin/sendmail +# dump Log output to stdout +dumpLogs = 1 +# symbol server variables +symbolServer = stage.mozilla.org +symbolServerUser = xrbld +symbolServerPath = /mnt/netapp/breakpad/symbols_xr +win32_symbolServerKey = /c/Documents and Settings/cltbld/.ssh/xrbld_dsa +linux_symbolServerKey = /home/cltbld/.ssh/xrbld_dsa +macosx_symbolServerKey = /Users/cltbld/.ssh/xrbld_dsa +# username and server to push update snippets to +ausUser = cltbld +ausServer = aus2-staging.mozilla.org +ausServerUrl = https://aus2.mozilla.org +buildTree = MozillaRelease +# where QA updates/builds go +stagingUser = cltbld +stagingServer = production-1.9-master.build.mozilla.org +externalStagingUser = cltbld +externalStagingServer = stage.mozilla.org +# where beta updates/builds go +ftpServer = ftp.mozilla.org +# where release updates/builds go +bouncerServer = download.mozilla.org +# username and server to push builds +sshUser = cltbld +sshServer = production-1.9-master.build.mozilla.org +useTalkback = 0 +useCvsCompression = 1 From 7151835b7d90e8b1358df41b8002994d9762e1e2 Mon Sep 17 00:00:00 2001 From: "jruderman@hmc.edu" Date: Wed, 5 Mar 2008 20:42:55 -0800 Subject: [PATCH 047/248] Add crashtest --- content/xbl/crashtests/418133-1.xhtml | 22 ++++++++++++++++++++++ content/xbl/crashtests/crashtests.list | 1 + 2 files changed, 23 insertions(+) create mode 100644 content/xbl/crashtests/418133-1.xhtml diff --git a/content/xbl/crashtests/418133-1.xhtml b/content/xbl/crashtests/418133-1.xhtml new file mode 100644 index 000000000000..ea821b76eda4 --- /dev/null +++ b/content/xbl/crashtests/418133-1.xhtml @@ -0,0 +1,22 @@ + + + + + + + + + + diff --git a/content/xbl/crashtests/crashtests.list b/content/xbl/crashtests/crashtests.list index 49ec92527861..e6c37b140eeb 100644 --- a/content/xbl/crashtests/crashtests.list +++ b/content/xbl/crashtests/crashtests.list @@ -7,3 +7,4 @@ load 342954-2.xhtml load 406900-1.xul load 406904-1.xhtml load 406904-2.xhtml +load 418133-1.xhtml From 43a4c32bc4907b8680f452c0dc6a252a41811be4 Mon Sep 17 00:00:00 2001 From: "rhelmer@mozilla.com" Date: Wed, 5 Mar 2008 20:48:37 -0800 Subject: [PATCH 048/248] typo in symbolServer for staging config r=rhelmer --- tools/release/configs/fx-moz18-staging-bootstrap.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/release/configs/fx-moz18-staging-bootstrap.cfg b/tools/release/configs/fx-moz18-staging-bootstrap.cfg index 9051e51e579a..eeda126b5686 100644 --- a/tools/release/configs/fx-moz18-staging-bootstrap.cfg +++ b/tools/release/configs/fx-moz18-staging-bootstrap.cfg @@ -1,7 +1,7 @@ -version = 2.0.0.12 -milestone = 1.8.1.12 +version = 2.0.0.13 +milestone = 1.8.1.13 # _RCn and _RELEASE will be appended as-needed -productTag = FIREFOX_2_0_0_12 +productTag = FIREFOX_2_0_0_13 # Branch name and pull dates to use for base tag branchTag = MOZILLA_1_8_BRANCH #RelbranchOverride = GECKO181_20071115_RELBRANCH @@ -9,7 +9,7 @@ pullDate = 2008-01-15 14:20 PST l10n_pullDate = 2008-01-15 14:20 PST rc = 1 # oldVersion and oldRc refer to the previous release -oldVersion = 2.0.0.11 +oldVersion = 2.0.0.12 oldRc = 1 appName = browser product = firefox @@ -75,7 +75,7 @@ sshUser = cltbld sshServer = staging-1.8-master.build.mozilla.org # force 1.8 specific behavior useTalkback = 0 -symbolServer = staging-1.8-master.mozilla.org +symbolServer = staging-1.8-master.build.mozilla.org symbolServerUser = cltbld symbolServerPath = /data/symbols symbolServerKey = /home/cltbld/.ssh/id_rsa From a2838e38fa8ad6f6a972d73dbc90db367d3ee095 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 22:39:36 -0800 Subject: [PATCH 049/248] leftover bit from earlier 392351; get rid of compiler warnings --- xpcom/base/nsMemoryReporterManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 9c619fdf04c3..71be9834905f 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -32,7 +32,7 @@ nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter) return NS_OK; } -nsresult +NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); @@ -41,7 +41,7 @@ NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) return mgr->RegisterReporter(reporter); } -nsresult +NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); From c325e922a72f810f397c875469fbfccf7b4ae5db Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 22:51:13 -0800 Subject: [PATCH 050/248] b=415854, make single-pixel optimized images release memory; patch from joe@drew.ca; r+sr=vlad --- .../canvas/src/nsCanvasRenderingContext2D.cpp | 15 ++- content/svg/content/src/Makefile.in | 1 - content/svg/content/src/nsSVGFilters.cpp | 15 +-- gfx/public/nsIImage.h | 20 +++- gfx/src/thebes/nsThebesImage.cpp | 16 +-- gfx/src/thebes/nsThebesImage.h | 17 +++ gfx/thebes/public/gfxPattern.h | 11 ++ gfx/thebes/src/gfxPattern.cpp | 13 ++- layout/svg/base/src/Makefile.in | 1 - layout/svg/base/src/nsSVGImageFrame.cpp | 15 +-- layout/svg/base/src/nsSVGUtils.cpp | 21 ++++ layout/svg/base/src/nsSVGUtils.h | 5 + modules/libpr0n/src/imgContainer.cpp | 14 ++- modules/libpr0n/src/imgTools.cpp | 7 +- widget/src/gtk2/nsImageToPixbuf.cpp | 106 ++++++++++++------ widget/src/gtk2/nsImageToPixbuf.h | 6 + 16 files changed, 208 insertions(+), 75 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 135103440e59..f4e26d328ca7 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -2220,9 +2220,18 @@ nsCanvasRenderingContext2D::CairoSurfaceFromElement(nsIDOMElement *imgElt, if (heightOut) *heightOut = imgHeight; - nsRefPtr gfxsurf; - rv = img->GetSurface(getter_AddRefs(gfxsurf)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr gfxpattern; + img->GetPattern(getter_AddRefs(gfxpattern)); + nsRefPtr gfxsurf = gfxpattern->GetSurface(); + + if (!gfxsurf) { + gfxsurf = new gfxImageSurface (gfxIntSize(imgWidth, imgHeight), gfxASurface::ImageFormatARGB32); + nsRefPtr ctx = new gfxContext(gfxsurf); + + ctx->SetOperator(gfxContext::OPERATOR_SOURCE); + ctx->SetPattern(gfxpattern); + ctx->Paint(); + } *aCairoSurface = gfxsurf->CairoSurface(); cairo_surface_reference (*aCairoSurface); diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 8c1a0805fcc6..95906fd8138c 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -174,7 +174,6 @@ INCLUDES += \ -I$(srcdir)/../../../events/src \ -I$(srcdir)/../../../html/content/src \ -I$(topsrcdir)/content/xbl/src \ - -I$(topsrcdir)/gfx/src/thebes \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index f5735bb2804f..9ff8d7b48e1b 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -63,7 +63,7 @@ #include "nsImageLoadingContent.h" #include "imgIContainer.h" #include "gfxIImageFrame.h" -#include "nsThebesImage.h" +#include "nsIImage.h" #include "nsSVGAnimatedPreserveAspectRatio.h" #include "nsSVGPreserveAspectRatio.h" #include "nsIInterfaceRequestorUtils.h" @@ -5582,19 +5582,14 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance) if (imageContainer) imageContainer->GetCurrentFrame(getter_AddRefs(currentFrame)); - gfxASurface *thebesSurface = nsnull; + nsRefPtr thebesPattern = nsnull; if (currentFrame) { nsCOMPtr img(do_GetInterface(currentFrame)); - nsThebesImage *thebesImage = nsnull; - if (img) - thebesImage = static_cast(img.get()); - - if (thebesImage) - thebesSurface = thebesImage->ThebesSurface(); + img->GetPattern(getter_AddRefs(thebesPattern)); } - if (thebesSurface) { + if (thebesPattern) { PRInt32 x, y, nativeWidth, nativeHeight; currentFrame->GetX(&x); currentFrame->GetY(&y); @@ -5611,7 +5606,7 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance) xy->Multiply(trans, getter_AddRefs(fini)); gfxContext ctx(targetSurface); - nsSVGUtils::CompositeSurfaceMatrix(&ctx, thebesSurface, fini, 1.0); + nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, fini, nativeWidth, nativeHeight, 1.0); } return NS_OK; diff --git a/gfx/public/nsIImage.h b/gfx/public/nsIImage.h index 37fe47605d6c..d02e31ad5aee 100644 --- a/gfx/public/nsIImage.h +++ b/gfx/public/nsIImage.h @@ -44,6 +44,7 @@ #include "gfxRect.h" class gfxASurface; +class gfxPattern; class nsIDeviceContext; @@ -213,7 +214,11 @@ public: /** * LockImagePixels * Lock the image pixels so that we can access them directly, - * with safely. May be a noop on some platforms. + * with safety. May be a noop on some platforms. + * + * If you want to be able to call GetSurface(), wrap the call in + * LockImagePixels()/UnlockImagePixels(). This also allows you to write to + * the surface returned by GetSurface(). * * aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image * @@ -239,13 +244,24 @@ public: /** * GetSurface - * Return the Thebes gfxASurface in aSurface. + * Return the Thebes gfxASurface in aSurface, if there is one. Should be + * wrapped by LockImagePixels()/UnlockImagePixels(). * * aSurface will be AddRef'd (as with most getters), so * getter_AddRefs should be used. */ NS_IMETHOD GetSurface(gfxASurface **aSurface) = 0; + /** + * GetSurface + * Return the Thebes gfxPattern in aPattern. It is always possible to get a + * gfxPattern (unlike the gfxASurface from GetSurface()). + * + * aPattern will be AddRef'd (as with most getters), so + * getter_AddRefs should be used. + */ + NS_IMETHOD GetPattern(gfxPattern **aPattern) = 0; + /** * SetHasNoAlpha * diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index f94309324deb..c5fea7c6efb4 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -259,13 +259,6 @@ nsThebesImage::Optimize(nsIDeviceContext* aContext) mSinglePixel = PR_TRUE; - // XXX we can't do this until we either teach anyone - // who calls GetSurface() about single-color stuff, - // or until we make GetSurface() create a new temporary - // surface to return (and that callers understand that - // modifying that surface won't modify the image). - // Current users are drag & drop and clipboard. -#if 0 // blow away the older surfaces, to release data mImageSurface = nsnull; @@ -275,7 +268,6 @@ nsThebesImage::Optimize(nsIDeviceContext* aContext) #endif #ifdef XP_MACOSX mQuartzSurface = nsnull; -#endif #endif return NS_OK; } @@ -391,7 +383,15 @@ nsThebesImage::LockImagePixels(PRBool aMaskPixels) else context.SetSource(mOptSurface); context.Paint(); + +#ifdef XP_WIN + mWinSurface = nsnull; +#endif +#ifdef XP_MACOSX + mQuartzSurface = nsnull; +#endif } + return NS_OK; } diff --git a/gfx/src/thebes/nsThebesImage.h b/gfx/src/thebes/nsThebesImage.h index c87995c61165..975884bc46fe 100644 --- a/gfx/src/thebes/nsThebesImage.h +++ b/gfx/src/thebes/nsThebesImage.h @@ -44,6 +44,7 @@ #include "gfxColor.h" #include "gfxASurface.h" #include "gfxImageSurface.h" +#include "gfxPattern.h" #if defined(XP_WIN) #include "gfxWindowsSurface.h" #elif defined(XP_MACOSX) @@ -96,6 +97,22 @@ public: return NS_OK; } + NS_IMETHOD GetPattern(gfxPattern **aPattern) { + *aPattern = ThebesPattern(); + NS_ADDREF(*aPattern); + return NS_OK; + } + + gfxPattern* ThebesPattern() { + gfxPattern *pattern; + if (mSinglePixel) + pattern = new gfxPattern(mSinglePixelColor); + else + pattern = new gfxPattern(ThebesSurface()); + + return pattern; + } + gfxASurface* ThebesSurface() { if (mOptSurface) return mOptSurface; diff --git a/gfx/thebes/public/gfxPattern.h b/gfx/thebes/public/gfxPattern.h index 807f94a1b643..696934fcd981 100644 --- a/gfx/thebes/public/gfxPattern.h +++ b/gfx/thebes/public/gfxPattern.h @@ -78,6 +78,17 @@ public: void SetExtend(GraphicsExtend extend); GraphicsExtend Extend() const; + enum GraphicsPatternType { + PATTERN_SOLID, + PATTERN_SURFACE, + PATTERN_LINEAR, + PATTERN_RADIAL + }; + + GraphicsPatternType GetType() const; + + int CairoStatus(); + void SetFilter(int filter); int Filter() const; diff --git a/gfx/thebes/src/gfxPattern.cpp b/gfx/thebes/src/gfxPattern.cpp index 5f1a821e7660..7253cc1d3cc3 100644 --- a/gfx/thebes/src/gfxPattern.cpp +++ b/gfx/thebes/src/gfxPattern.cpp @@ -168,6 +168,17 @@ gfxPattern::GetSurface() if (cairo_pattern_get_surface (mPattern, &surf) != CAIRO_STATUS_SUCCESS) return nsnull; - return gfxASurface::Wrap(surf); } + +gfxPattern::GraphicsPatternType +gfxPattern::GetType() const +{ + return (GraphicsPatternType) cairo_pattern_get_type(mPattern); +} + +int +gfxPattern::CairoStatus() +{ + return cairo_pattern_status(mPattern); +} diff --git a/layout/svg/base/src/Makefile.in b/layout/svg/base/src/Makefile.in index 2a4067595813..7d20f0449028 100644 --- a/layout/svg/base/src/Makefile.in +++ b/layout/svg/base/src/Makefile.in @@ -117,7 +117,6 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../../xul/base/src \ -I$(srcdir)/../../../../content/svg/content/src \ -I$(srcdir)/../../../../content/base/src \ - -I$(topsrcdir)/gfx/src/thebes \ $(NULL) libs:: diff --git a/layout/svg/base/src/nsSVGImageFrame.cpp b/layout/svg/base/src/nsSVGImageFrame.cpp index f3fd8efc6e7e..89ae4a70ec8a 100644 --- a/layout/svg/base/src/nsSVGImageFrame.cpp +++ b/layout/svg/base/src/nsSVGImageFrame.cpp @@ -47,7 +47,7 @@ #include "nsSVGMatrix.h" #include "gfxContext.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsThebesImage.h" +#include "nsIImage.h" class nsSVGImageFrame; @@ -257,19 +257,14 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect) if (mImageContainer) mImageContainer->GetCurrentFrame(getter_AddRefs(currentFrame)); - gfxASurface *thebesSurface = nsnull; + nsRefPtr thebesPattern = nsnull; if (currentFrame) { nsCOMPtr img(do_GetInterface(currentFrame)); - nsThebesImage *thebesImage = nsnull; - if (img) - thebesImage = static_cast(img.get()); - - if (thebesImage) - thebesSurface = thebesImage->ThebesSurface(); + img->GetPattern(getter_AddRefs(thebesPattern)); } - if (thebesSurface) { + if (thebesPattern) { gfxContext *gfx = aContext->GetGfxContext(); if (GetStyleDisplay()->IsScrollableOverflow()) { @@ -293,7 +288,7 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect) opacity = GetStyleDisplay()->mOpacity; } - nsSVGUtils::CompositeSurfaceMatrix(gfx, thebesSurface, fini, opacity); + nsSVGUtils::CompositePatternMatrix(gfx, thebesPattern, fini, width, height, opacity); if (GetStyleDisplay()->IsScrollableOverflow()) gfx->Restore(); diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 62c224e8dce9..6582acf51049 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -1599,6 +1599,27 @@ nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext, aContext->Restore(); } +void +nsSVGUtils::CompositePatternMatrix(gfxContext *aContext, + gfxPattern *aPattern, + nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity) +{ + gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM); + if (matrix.IsSingular()) + return; + + aContext->Save(); + + SetClipRect(aContext, aCTM, 0, 0, aWidth, aHeight); + + aContext->Multiply(matrix); + + aContext->SetPattern(aPattern); + aContext->Paint(aOpacity); + + aContext->Restore(); +} + void nsSVGUtils::SetClipRect(gfxContext *aContext, nsIDOMSVGMatrix *aCTM, float aX, float aY, diff --git a/layout/svg/base/src/nsSVGUtils.h b/layout/svg/base/src/nsSVGUtils.h index 57e5173c1845..2a9f0cd3352e 100644 --- a/layout/svg/base/src/nsSVGUtils.h +++ b/layout/svg/base/src/nsSVGUtils.h @@ -69,6 +69,7 @@ class nsSVGSVGElement; class nsAttrValue; class gfxContext; class gfxASurface; +class gfxPattern; class nsIRenderingContext; class gfxImageSurface; struct gfxRect; @@ -410,6 +411,10 @@ public: gfxASurface *aSurface, nsIDOMSVGMatrix *aCTM, float aOpacity); + static void CompositePatternMatrix(gfxContext *aContext, + gfxPattern *aPattern, + nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity); + static void SetClipRect(gfxContext *aContext, nsIDOMSVGMatrix *aCTM, float aX, float aY, float aWidth, float aHeight); diff --git a/modules/libpr0n/src/imgContainer.cpp b/modules/libpr0n/src/imgContainer.cpp index 863c67a50258..73b93fc24143 100644 --- a/modules/libpr0n/src/imgContainer.cpp +++ b/modules/libpr0n/src/imgContainer.cpp @@ -1039,12 +1039,15 @@ void imgContainer::ClearFrame(gfxIImageFrame *aFrame) nsCOMPtr img(do_GetInterface(aFrame)); nsRefPtr surf; + + img->LockImagePixels(0); img->GetSurface(getter_AddRefs(surf)); // Erase the surface to transparent gfxContext ctx(surf); ctx.SetOperator(gfxContext::OPERATOR_CLEAR); ctx.Paint(); + img->UnlockImagePixels(0); } //****************************************************************************** @@ -1056,6 +1059,8 @@ void imgContainer::ClearFrame(gfxIImageFrame *aFrame, nsIntRect &aRect) nsCOMPtr img(do_GetInterface(aFrame)); nsRefPtr surf; + + img->LockImagePixels(0); img->GetSurface(getter_AddRefs(surf)); // Erase the destination rectangle to transparent @@ -1063,6 +1068,7 @@ void imgContainer::ClearFrame(gfxIImageFrame *aFrame, nsIntRect &aRect) ctx.SetOperator(gfxContext::OPERATOR_CLEAR); ctx.Rectangle(gfxRect(aRect.x, aRect.y, aRect.width, aRect.height)); ctx.Fill(); + img->UnlockImagePixels(0); } @@ -1184,11 +1190,13 @@ nsresult imgContainer::DrawFrameTo(gfxIImageFrame *aSrc, } nsCOMPtr srcImg(do_GetInterface(aSrc)); - nsRefPtr srcSurf; - srcImg->GetSurface(getter_AddRefs(srcSurf)); + nsRefPtr srcPatt; + srcImg->GetPattern(getter_AddRefs(srcPatt)); nsCOMPtr dstImg(do_GetInterface(aDst)); nsRefPtr dstSurf; + // Note: dstImage has LockImageData() called on it above, so it's safe to get + // the surface. dstImg->GetSurface(getter_AddRefs(dstSurf)); gfxContext dst(dstSurf); @@ -1204,7 +1212,7 @@ nsresult imgContainer::DrawFrameTo(gfxIImageFrame *aSrc, dst.Fill(); dst.SetOperator(defaultOperator); } - dst.SetSource(srcSurf); + dst.SetPattern(srcPatt); dst.Paint(); return NS_OK; diff --git a/modules/libpr0n/src/imgTools.cpp b/modules/libpr0n/src/imgTools.cpp index d22b549c9371..4a562fdad935 100644 --- a/modules/libpr0n/src/imgTools.cpp +++ b/modules/libpr0n/src/imgTools.cpp @@ -319,9 +319,8 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer, // Prepare to draw a scaled version of the image to a temporary surface... // Get the source image surface - nsRefPtr gfxsurf; - rv = img->GetSurface(getter_AddRefs(gfxsurf)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr gfxpat; + img->GetPattern(getter_AddRefs(gfxpat)); // Create a temporary image surface dest = new gfxImageSurface(gfxIntSize(aScaledWidth, aScaledHeight), @@ -338,7 +337,7 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer, // Paint a scaled image ctx.SetOperator(gfxContext::OPERATOR_SOURCE); - ctx.SetSource(gfxsurf); + ctx.SetPattern(gfxpat); ctx.Paint(); bitmapData = dest->Data(); diff --git a/widget/src/gtk2/nsImageToPixbuf.cpp b/widget/src/gtk2/nsImageToPixbuf.cpp index 8e591b2e709b..496815c7e211 100644 --- a/widget/src/gtk2/nsImageToPixbuf.cpp +++ b/widget/src/gtk2/nsImageToPixbuf.cpp @@ -71,40 +71,15 @@ nsImageToPixbuf::ImageToPixbuf(nsIImage* aImage) PRInt32 width = aImage->GetWidth(), height = aImage->GetHeight(); - nsRefPtr surface; - aImage->GetSurface(getter_AddRefs(surface)); + nsRefPtr pattern; + aImage->GetPattern(getter_AddRefs(pattern)); - return SurfaceToPixbuf(surface, width, height); + return PatternToPixbuf(pattern, width, height); } GdkPixbuf* -nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 aHeight) +nsImageToPixbuf::ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface, PRInt32 aWidth, PRInt32 aHeight) { - if (aSurface->CairoStatus()) { - NS_ERROR("invalid surface"); - return nsnull; - } - - nsRefPtr imgSurface; - if (aSurface->GetType() == gfxASurface::SurfaceTypeImage) { - imgSurface = static_cast - (static_cast(aSurface)); - } else { - imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), - gfxImageSurface::ImageFormatARGB32); - - if (!imgSurface) - return nsnull; - - nsRefPtr context = new gfxContext(imgSurface); - if (!context) - return nsnull; - - context->SetOperator(gfxContext::OPERATOR_SOURCE); - context->SetSource(aSurface); - context->Paint(); - } - GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, PR_TRUE, 8, aWidth, aHeight); if (!pixbuf) @@ -113,10 +88,10 @@ nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 PRUint32 rowstride = gdk_pixbuf_get_rowstride (pixbuf); guchar* pixels = gdk_pixbuf_get_pixels (pixbuf); - long cairoStride = imgSurface->Stride(); - unsigned char* cairoData = imgSurface->Data(); + long cairoStride = aImgSurface->Stride(); + unsigned char* cairoData = aImgSurface->Data(); - gfxASurface::gfxImageFormat format = imgSurface->Format(); + gfxASurface::gfxImageFormat format = aImgSurface->Format(); for (PRInt32 row = 0; row < aHeight; ++row) { for (PRInt32 col = 0; col < aWidth; ++col) { @@ -152,3 +127,70 @@ nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 return pixbuf; } + +GdkPixbuf* +nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 aHeight) +{ + if (aSurface->CairoStatus()) { + NS_ERROR("invalid surface"); + return nsnull; + } + + nsRefPtr imgSurface; + if (aSurface->GetType() == gfxASurface::SurfaceTypeImage) { + imgSurface = static_cast + (static_cast(aSurface)); + } else { + imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), + gfxImageSurface::ImageFormatARGB32); + + if (!imgSurface) + return nsnull; + + nsRefPtr context = new gfxContext(imgSurface); + if (!context) + return nsnull; + + context->SetOperator(gfxContext::OPERATOR_SOURCE); + context->SetSource(aSurface); + context->Paint(); + } + + return ImgSurfaceToPixbuf(imgSurface, aWidth, aHeight); +} + +GdkPixbuf* +nsImageToPixbuf::PatternToPixbuf(gfxPattern* aPattern, PRInt32 aWidth, PRInt32 aHeight) +{ + if (aPattern->CairoStatus()) { + NS_ERROR("invalid pattern"); + return nsnull; + } + + nsRefPtr imgSurface; + if (aPattern->GetType() == gfxPattern::PATTERN_SURFACE) { + nsRefPtr surface = aPattern->GetSurface(); + if (surface->GetType() == gfxASurface::SurfaceTypeImage) { + imgSurface = static_cast + (static_cast(surface.get())); + } + } + + if (!imgSurface) { + imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), + gfxImageSurface::ImageFormatARGB32); + + if (!imgSurface) + return nsnull; + + nsRefPtr context = new gfxContext(imgSurface); + if (!context) + return nsnull; + + context->SetOperator(gfxContext::OPERATOR_SOURCE); + context->SetPattern(aPattern); + context->Paint(); + } + + return ImgSurfaceToPixbuf(imgSurface, aWidth, aHeight); +} diff --git a/widget/src/gtk2/nsImageToPixbuf.h b/widget/src/gtk2/nsImageToPixbuf.h index e861f83f4c9d..0e3f5167c8a9 100644 --- a/widget/src/gtk2/nsImageToPixbuf.h +++ b/widget/src/gtk2/nsImageToPixbuf.h @@ -41,6 +41,8 @@ #include "nsIImageToPixbuf.h" class gfxASurface; +class gfxPattern; +class gfxImageSurface; class nsImageToPixbuf : public nsIImageToPixbuf { public: @@ -52,7 +54,11 @@ class nsImageToPixbuf : public nsIImageToPixbuf { static GdkPixbuf* ImageToPixbuf(nsIImage* aImage); static GdkPixbuf* SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 aHeight); + static GdkPixbuf* PatternToPixbuf(gfxPattern* aPattern, + PRInt32 aWidth, PRInt32 aHeight); private: + static GdkPixbuf* ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface, + PRInt32 aWidth, PRInt32 aHeight); ~nsImageToPixbuf() {} }; From 287fde9d4d60c44f4fc05f03d9e0573b7af10fb7 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 23:06:46 -0800 Subject: [PATCH 051/248] b=418915, plugin print rendering coordinates incorrect on win32; r+sr=roc --- layout/generic/nsObjectFrame.cpp | 48 +++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index fa6c6e2e6857..4f0c75cd0cbd 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1132,23 +1132,16 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, pi->GetValue(nsPluginInstanceVariable_WindowlessBool, (void *)&windowless); window.type = windowless ? nsPluginWindowType_Drawable : nsPluginWindowType_Window; - // Get the offset of the DC - nsTransform2D* rcTransform; - aRenderingContext.GetCurrentTransform(rcTransform); - nsPoint origin; - rcTransform->GetTranslationCoord(&origin.x, &origin.y); - - // set it all up - // XXX is windowless different? - window.x = presContext->AppUnitsToDevPixels(origin.x); - window.y = presContext->AppUnitsToDevPixels(origin.y); - window.width = presContext->AppUnitsToDevPixels(mRect.width); - window.height= presContext->AppUnitsToDevPixels(mRect.height); window.clipRect.bottom = 0; window.clipRect.top = 0; window.clipRect.left = 0; window.clipRect.right = 0; // XXX platform specific printing code #if defined(XP_UNIX) && !defined(XP_MACOSX) + + /* XXX this just flat-out doesn't work in a thebes world -- + * RenderEPS is a no-op. So don't bother to do any work here. + */ +#if 0 /* UNIX does things completely differently: * We call the plugin and it sends generated PostScript data into a * file handle we provide. If the plugin returns with success we embed @@ -1188,6 +1181,7 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, fclose(plugintmpfile); PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG, ("plugin printing done, return code is %lx\n", (long)rv)); +#endif #elif defined(XP_WIN) @@ -1206,15 +1200,30 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, * meta surface. */ + /* we'll already be translated into the right spot by gfxWindowsNativeDrawing */ + window.x = 0; + window.y = 0; + window.width = presContext->AppUnitsToDevPixels(mRect.width); + window.height = presContext->AppUnitsToDevPixels(mRect.height); + gfxContext *ctx = aRenderingContext.ThebesContext(); ctx->Save(); + /* Make sure plugins don't do any damage outside of where they're supposed to */ ctx->NewPath(); ctx->Rectangle(gfxRect(window.x, window.y, window.width, window.height)); ctx->Clip(); - ctx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA); + + /* If we're windowless, we need to do COLOR_ALPHA, and do alpha recovery. + * XXX - we could have some sort of flag here that would indicate whether + * the plugin knows how to render to an ARGB DIB + */ + if (windowless) + ctx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA); + else + ctx->PushGroup(gfxASurface::CONTENT_COLOR); gfxWindowsNativeDrawing nativeDraw(ctx, gfxRect(window.x, window.y, @@ -1240,6 +1249,19 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, #else + // Get the offset of the DC + nsTransform2D* rcTransform; + aRenderingContext.GetCurrentTransform(rcTransform); + nsPoint origin; + rcTransform->GetTranslationCoord(&origin.x, &origin.y); + + // set it all up + // XXX is windowless different? + window.x = presContext->AppUnitsToDevPixels(origin.x); + window.y = presContext->AppUnitsToDevPixels(origin.y); + window.width = presContext->AppUnitsToDevPixels(mRect.width); + window.height= presContext->AppUnitsToDevPixels(mRect.height); + // we need the native printer device context to pass to plugin // NATIVE_WINDOWS_DC is a misnomer, it's whatever the native platform // thing is. From fec3787d21c0e61c1d82980414e0a8f01189d7ac Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Wed, 5 Mar 2008 23:36:20 -0800 Subject: [PATCH 052/248] reftest analyzer improvements; npotb, a=dbaron --- layout/tools/reftest/reftest-analyzer.xhtml | 153 ++++++++++---------- 1 file changed, 78 insertions(+), 75 deletions(-) diff --git a/layout/tools/reftest/reftest-analyzer.xhtml b/layout/tools/reftest/reftest-analyzer.xhtml index 26b644d7e077..a9674d8accba 100644 --- a/layout/tools/reftest/reftest-analyzer.xhtml +++ b/layout/tools/reftest/reftest-analyzer.xhtml @@ -56,9 +56,8 @@ Features to add: Reftest analyzer + + +
+ diff --git a/layout/reftests/bugs/417246-1.html b/layout/reftests/bugs/417246-1.html new file mode 100644 index 000000000000..cd4681c3a28c --- /dev/null +++ b/layout/reftests/bugs/417246-1.html @@ -0,0 +1,14 @@ + + + + + +
+ diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 8bd9cae87ed7..362e870f2913 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -737,6 +737,7 @@ random == 403134-1.html 403134-1-ref.html # bug 405377 == 414851-1.html 414851-1-ref.html == 416106-1.xhtml 416106-1-ref.xhtml == 416752-1.html 416752-1-ref.html +== 417246-1.html 417246-1-ref.html == 417676.html 417676-ref.html == 418766-1a.html 418766-1-ref.html == 418766-1b.html 418766-1-ref.html From 900558825d26f276fcce2a16e204346bd1c85ebb Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Thu, 6 Mar 2008 00:02:50 -0800 Subject: [PATCH 054/248] Bug 420252 - "Duplicated code in browser.css" [p=reed r=Mano a1.9=beltzner] --- browser/themes/pinstripe/browser/browser.css | 7 ------- 1 file changed, 7 deletions(-) diff --git a/browser/themes/pinstripe/browser/browser.css b/browser/themes/pinstripe/browser/browser.css index 52a9a6d686b4..508543d3dfd3 100755 --- a/browser/themes/pinstripe/browser/browser.css +++ b/browser/themes/pinstripe/browser/browser.css @@ -298,13 +298,6 @@ toolbar[mode="icons"] #forward-button .toolbarbutton-text-box, display: none; } -toolbar[mode="icons"] #back-button .toolbarbutton-text-box, -toolbar[mode="icons"] #forward-button .toolbarbutton-text-box, -#back-button .toolbarbutton-menubutton-dropmarker, -#forward-button .toolbarbutton-menubutton-dropmarker { - display: none; -} - /* ----- DEFAULT PRIMARY TOOLBAR BUTTONS ----- */ .toolbarbutton-text-shadow, From 107afeac0330ab09f1ffe6dfa628d5427e8d9519 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Thu, 6 Mar 2008 01:45:16 -0800 Subject: [PATCH 055/248] JavaScript Tests - update known failures, bug 355258 --- js/tests/public-failures.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/tests/public-failures.txt b/js/tests/public-failures.txt index 82dd23806f7e..6db081be864b 100644 --- a/js/tests/public-failures.txt +++ b/js/tests/public-failures.txt @@ -60,8 +60,6 @@ TEST_ID=e4x/decompilation/regress-352013.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAIL TEST_ID=e4x/decompilation/regress-352013.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 8 of test - Decompilation with new operator redeaux expected: function ( ) { new ( x ( y ) . @ [ n : : a ] ) ; } actual: function ( ) { new x ( y ) . @ [ n : : a ] ; } reason: Expected value ' function ( ) { new ( x ( y ) . @ [ n : : a ] ) ; } ', Actual value ' function ( ) { new x ( y ) . @ [ n : : a ] ; } ' TEST_ID=e4x/decompilation/regress-352013.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 9 of test - Decompilation with new operator redeaux expected: function ( ) { new ( x ( y ) . @ [ n : : a ] ) ; } actual: function ( ) { new x ( y ) . @ [ n : : a ] ; } reason: Expected value ' function ( ) { new ( x ( y ) . @ [ n : : a ] ) ; } ', Actual value ' function ( ) { new x ( y ) . @ [ n : : a ] ; } ' TEST_ID=e4x/decompilation/regress-352789.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 1 of test - Decompilation of new and .@ expected: function ( ) { return new ( a ( ) . @ z ) ; } actual: function ( ) { return new a . @ z ; } reason: Expected value ' function ( ) { return new ( a ( ) . @ z ) ; } ', Actual value ' function ( ) { return new a . @ z ; } ' -TEST_ID=e4x/extensions/regress-312196.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 1 of test - Extending E4X XML objects with __noSuchMethod__ expected: NL NL thisNL isNL aNL testNL actual: TypeError: ws.function::sample is not a function reason: Expected value 'NL NL thisNL isNL aNL testNL', Actual value 'TypeError: ws.function::sample is not a function' -TEST_ID=e4x/extensions/regress-312196.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 2 of test - Extending E4X XML objects with __noSuchMethod__ expected: NL NL thisNL isNL aNL testNL thisNL isNL aNL testNL actual: NL NL thisNL isNL aNL testNL reason: Expected value 'NL NL thisNL isNL aNL testNL thisNL isNL aNL testNL', Actual value 'NL NL thisNL isNL aNL testNL' TEST_ID=e4x/extensions/regress-337226.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=`.``*`reason: `.``*`/e4x/extensions/regress-337226.js:`.``*`: `(`ReferenceError: `)``?`reference to undefined XML name @mozilla.org/js/function::parseInt TEST_ID=e4x/extensions/regress-410192.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Section 1 of test - Proper quoting of attribute by uneval/toSource expected: "v" actual: v reason: Expected value '"v"', Actual value 'v' TEST_ID=ecma/Math/15.8.2.5.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=debug, TEST_TYPE=browser, TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Infinity/Math.atan2(-0, 1) expected: -Infinity actual: Infinity reason: wrong value From 90c0cce3774767d12aa6e0f53088cdab43697092 Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Thu, 6 Mar 2008 03:01:08 -0800 Subject: [PATCH 056/248] Bug 419769: nsIZipWriter crashes with a 0 length file and COMPRESSION_BEST. r=biesi --- .../zipwriter/src/nsDeflateConverter.cpp | 4 + .../zipwriter/test/unit/data/emptyfile.txt | 0 .../zipwriter/test/unit/test_bug419769_1.js | 104 ++++++++++++++++++ .../zipwriter/test/unit/test_bug419769_2.js | 97 ++++++++++++++++ 4 files changed, 205 insertions(+) create mode 100644 modules/libjar/zipwriter/test/unit/data/emptyfile.txt create mode 100644 modules/libjar/zipwriter/test/unit/test_bug419769_1.js create mode 100644 modules/libjar/zipwriter/test/unit/test_bug419769_2.js diff --git a/modules/libjar/zipwriter/src/nsDeflateConverter.cpp b/modules/libjar/zipwriter/src/nsDeflateConverter.cpp index da2fa7fe9239..42e1649045c1 100644 --- a/modules/libjar/zipwriter/src/nsDeflateConverter.cpp +++ b/modules/libjar/zipwriter/src/nsDeflateConverter.cpp @@ -85,6 +85,10 @@ nsresult nsDeflateConverter::Init() mZstream.next_out = mWriteBuffer; mZstream.avail_out = sizeof(mWriteBuffer); + // mark the input buffer as empty. + mZstream.avail_in = 0; + mZstream.next_in = Z_NULL; + return NS_OK; } diff --git a/modules/libjar/zipwriter/test/unit/data/emptyfile.txt b/modules/libjar/zipwriter/test/unit/data/emptyfile.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/libjar/zipwriter/test/unit/test_bug419769_1.js b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js new file mode 100644 index 000000000000..c97f8206dd82 --- /dev/null +++ b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js @@ -0,0 +1,104 @@ +/* ***** 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 Zip Writer Component. + * + * The Initial Developer of the Original Code is + * Dave Townsend . + * + * 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 ***** + */ + +const DATA = ""; +const FILENAME = "test.txt"; +const CRC = 0x00000000; +const time = Date.now(); + +function testpass(source) +{ + // Should exist. + do_check_true(source.hasEntry(FILENAME)); + + var entry = source.getEntry(FILENAME); + do_check_neq(entry, null); + + do_check_false(entry.isDirectory); + + // Should be stored + do_check_eq(entry.compression, ZIP_METHOD_DEFLATE); + + var diff = Math.abs((entry.lastModifiedTime / PR_USEC_PER_MSEC) - time); + if (diff > TIME_RESOLUTION) + do_throw(diff); + + // File size should match our data size. + do_check_eq(entry.realSize, DATA.length); + + // Check that the CRC is accurate + do_check_eq(entry.CRC32, CRC); +} + +function run_test() +{ + zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); + + // Shouldn't be there to start with. + do_check_false(zipW.hasEntry(FILENAME)); + + do_check_false(zipW.inQueue); + + var stream = Cc["@mozilla.org/io/string-input-stream;1"] + .createInstance(Ci.nsIStringInputStream); + stream.setData(DATA, DATA.length); + zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC, + Ci.nsIZipWriter.COMPRESSION_BEST, stream, false); + + // Check that zip state is right at this stage. + testpass(zipW); + zipW.close(); + + // Check to see if we get the same results loading afresh. + zipW.open(tmpFile, PR_RDWR); + testpass(zipW); + zipW.close(); + + // Test the stored data with the zipreader + var zipR = new ZipReader(tmpFile); + testpass(zipR); + zipR.test(FILENAME); + var stream = Cc["@mozilla.org/scriptableinputstream;1"] + .createInstance(Ci.nsIScriptableInputStream); + stream.init(zipR.getInputStream(FILENAME)); + var result = stream.read(DATA.length); + stream.close(); + zipR.close(); + + do_check_eq(result, DATA); +} diff --git a/modules/libjar/zipwriter/test/unit/test_bug419769_2.js b/modules/libjar/zipwriter/test/unit/test_bug419769_2.js new file mode 100644 index 000000000000..46ef0a74903d --- /dev/null +++ b/modules/libjar/zipwriter/test/unit/test_bug419769_2.js @@ -0,0 +1,97 @@ +/* ***** 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 Zip Writer Component. + * + * The Initial Developer of the Original Code is + * Dave Townsend . + * + * 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 ***** + */ + +const DATA = ""; +const FILENAME = "test.txt"; +const CRC = 0x00000000; +const time = Date.now(); + +function testpass(source) +{ + // Should exist. + do_check_true(source.hasEntry(FILENAME)); + + var entry = source.getEntry(FILENAME); + do_check_neq(entry, null); + + do_check_false(entry.isDirectory); + + // Should be stored + do_check_eq(entry.compression, ZIP_METHOD_DEFLATE); + + // File size should match our data size. + do_check_eq(entry.realSize, DATA.length); + + // Check that the CRC is accurate + do_check_eq(entry.CRC32, CRC); +} + +function run_test() +{ + zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); + + // Shouldn't be there to start with. + do_check_false(zipW.hasEntry(FILENAME)); + + do_check_false(zipW.inQueue); + + var file = do_get_file(DATA_DIR + "emptyfile.txt"); + zipW.addEntryFile(FILENAME, Ci.nsIZipWriter.COMPRESSION_BEST, file, false); + + // Check that zip state is right at this stage. + testpass(zipW); + zipW.close(); + + // Check to see if we get the same results loading afresh. + zipW.open(tmpFile, PR_RDWR); + testpass(zipW); + zipW.close(); + + // Test the stored data with the zipreader + var zipR = new ZipReader(tmpFile); + testpass(zipR); + zipR.test(FILENAME); + var stream = Cc["@mozilla.org/scriptableinputstream;1"] + .createInstance(Ci.nsIScriptableInputStream); + stream.init(zipR.getInputStream(FILENAME)); + var result = stream.read(DATA.length); + stream.close(); + zipR.close(); + + do_check_eq(result, DATA); +} From 4dd135904de91f1f149269cb1d880d9cc00812e7 Mon Sep 17 00:00:00 2001 From: "kaie@kuix.de" Date: Thu, 6 Mar 2008 03:21:37 -0800 Subject: [PATCH 057/248] Bug 412456, ###!!! ASSERTION: nsSecureBrowserUIImpl not thread-safe r=rrelyea, blocking1.9=beltzner --- .../boot/src/nsSecureBrowserUIImpl.cpp | 310 ++++++++++++++---- .../manager/boot/src/nsSecureBrowserUIImpl.h | 15 +- 2 files changed, 257 insertions(+), 68 deletions(-) diff --git a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp index 48edb4284842..98049c5c4681 100644 --- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp +++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp @@ -82,6 +82,7 @@ #include "nsThreadUtils.h" #include "nsNetUtil.h" #include "nsCRT.h" +#include "nsAutoLock.h" #define SECURITY_STRING_BUNDLE_URL "chrome://pipnss/locale/security.properties" @@ -134,12 +135,32 @@ static PLDHashTableOps gMapOps = { RequestMapInitEntry }; +class nsAutoAtomic { + public: + nsAutoAtomic(PRInt32 &i) + :mI(i) { + PR_AtomicIncrement(&mI); + } + + ~nsAutoAtomic() { + PR_AtomicDecrement(&mI); + } + + protected: + PRInt32 &mI; + + private: + nsAutoAtomic(); // not accessible +}; + nsSecureBrowserUIImpl::nsSecureBrowserUIImpl() : mNotifiedSecurityState(lis_no_security), mNotifiedToplevelIsEV(PR_FALSE), mIsViewSource(PR_FALSE) { + mMonitor = PR_NewMonitor(); + mOnStateLocationChangeReentranceDetection = 0; mTransferringRequests.ops = nsnull; mNewToplevelSecurityState = STATE_IS_INSECURE; mNewToplevelIsEV = PR_FALSE; @@ -158,16 +179,17 @@ nsSecureBrowserUIImpl::~nsSecureBrowserUIImpl() PL_DHashTableFinish(&mTransferringRequests); mTransferringRequests.ops = nsnull; } + if (mMonitor) + PR_DestroyMonitor(mMonitor); } -NS_IMPL_ISUPPORTS6(nsSecureBrowserUIImpl, - nsISecureBrowserUI, - nsIWebProgressListener, - nsIFormSubmitObserver, - nsIObserver, - nsISupportsWeakReference, - nsISSLStatusProvider) - +NS_IMPL_THREADSAFE_ISUPPORTS6(nsSecureBrowserUIImpl, + nsISecureBrowserUI, + nsIWebProgressListener, + nsIFormSubmitObserver, + nsIObserver, + nsISupportsWeakReference, + nsISSLStatusProvider) NS_IMETHODIMP nsSecureBrowserUIImpl::Init(nsIDOMWindow *aWindow) @@ -241,6 +263,7 @@ nsSecureBrowserUIImpl::Init(nsIDOMWindow *aWindow) NS_IMETHODIMP nsSecureBrowserUIImpl::GetState(PRUint32* aState) { + nsAutoMonitor lock(mMonitor); return MapInternalToExternalState(aState, mNotifiedSecurityState, mNotifiedToplevelIsEV); } @@ -282,14 +305,23 @@ nsSecureBrowserUIImpl::MapInternalToExternalState(PRUint32* aState, lockIconStat NS_IMETHODIMP nsSecureBrowserUIImpl::GetTooltipText(nsAString& aText) { - if (mNotifiedSecurityState == lis_mixed_security) + lockIconState state; + nsXPIDLString tooltip; + + { + nsAutoMonitor lock(mMonitor); + state = mNotifiedSecurityState; + tooltip = mInfoTooltip; + } + + if (state == lis_mixed_security) { GetBundleString(NS_LITERAL_STRING("SecurityButtonMixedContentTooltipText").get(), aText); } - else if (!mInfoTooltip.IsEmpty()) + else if (!tooltip.IsEmpty()) { - aText = mInfoTooltip; + aText = tooltip; } else { @@ -397,8 +429,12 @@ nsSecureBrowserUIImpl::Notify(nsIDOMHTMLFormElement* aDOMForm, return NS_OK; } - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } PRBool isChild; IsChildOfDomWindow(window, postingWindow, &isChild); @@ -431,6 +467,8 @@ nsSecureBrowserUIImpl::OnProgressChange(nsIWebProgress* aWebProgress, void nsSecureBrowserUIImpl::ResetStateTracking() { + nsAutoMonitor lock(mMonitor); + mInfoTooltip.Truncate(); mDocumentRequestsInProgress = 0; mSubRequestsHighSecurity = 0; @@ -450,15 +488,25 @@ nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest *aRequest) { nsCOMPtr channel(do_QueryInterface(aRequest)); - mNewToplevelSecurityState = nsIWebProgressListener::STATE_IS_INSECURE; - mNewToplevelIsEV = PR_FALSE; + /* I explicitly ignore the camelCase variable naming style here, + I want to make it clear these are temp variables that relate to the + member variables with the same suffix.*/ + + PRUint32 temp_NewToplevelSecurityState = nsIWebProgressListener::STATE_IS_INSECURE; + PRBool temp_NewToplevelIsEV = PR_FALSE; + + PRBool updateStatus = PR_FALSE; + nsCOMPtr temp_SSLStatus; + + PRBool updateTooltip = PR_FALSE; + nsXPIDLString temp_InfoTooltip; if (channel) { - mNewToplevelSecurityState = GetSecurityStateFromChannel(channel); + temp_NewToplevelSecurityState = GetSecurityStateFromChannel(channel); PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnStateChange: remember mNewToplevelSecurityState => %x\n", this, - mNewToplevelSecurityState)); + temp_NewToplevelSecurityState)); // Get SSL Status information if possible nsCOMPtr info; @@ -466,28 +514,43 @@ nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest *aRequest) nsCOMPtr sp = do_QueryInterface(info); if (sp) { // Ignore result - sp->GetSSLStatus(getter_AddRefs(mSSLStatus)); + updateStatus = PR_TRUE; + sp->GetSSLStatus(getter_AddRefs(temp_SSLStatus)); } if (info) { nsCOMPtr secInfo(do_QueryInterface(info)); if (secInfo) { - secInfo->GetShortSecurityDescription(getter_Copies(mInfoTooltip)); + updateTooltip = PR_TRUE; + secInfo->GetShortSecurityDescription(getter_Copies(temp_InfoTooltip)); } nsCOMPtr idinfo = do_QueryInterface(info); if (idinfo) { PRBool aTemp; - if (NS_SUCCEEDED(idinfo->GetIsExtendedValidation(&aTemp))) - mNewToplevelIsEV = aTemp; + if (NS_SUCCEEDED(idinfo->GetIsExtendedValidation(&aTemp))) { + temp_NewToplevelIsEV = aTemp; + } } } } - // assume mNewToplevelSecurityState was set in this scope! + // assume temp_NewToplevelSecurityState was set in this scope! // see code that is directly above - mNewToplevelSecurityStateKnown = PR_TRUE; + { + nsAutoMonitor lock(mMonitor); + mNewToplevelSecurityStateKnown = PR_TRUE; + mNewToplevelSecurityState = temp_NewToplevelSecurityState; + mNewToplevelIsEV = temp_NewToplevelIsEV; + if (updateStatus) { + mSSLStatus = temp_SSLStatus; + } + if (updateTooltip) { + mInfoTooltip = temp_InfoTooltip; + } + } + return UpdateSecurityState(aRequest); } @@ -503,6 +566,9 @@ nsSecureBrowserUIImpl::UpdateSubrequestMembers(nsIRequest *aRequest) reqState = GetSecurityStateFromChannel(channel); } + // the code above this line should run without a lock + nsAutoMonitor lock(mMonitor); + if (reqState & STATE_IS_SECURE) { if (reqState & STATE_SECURE_LOW || reqState & STATE_SECURE_MED) { PR_LOG(gSecureDocLog, PR_LOG_DEBUG, @@ -524,14 +590,16 @@ nsSecureBrowserUIImpl::UpdateSubrequestMembers(nsIRequest *aRequest) } } - - NS_IMETHODIMP nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, PRUint32 aProgressStateFlags, nsresult aStatus) { + nsAutoAtomic atomic(mOnStateLocationChangeReentranceDetection); + NS_ASSERTION(mOnStateLocationChangeReentranceDetection == 1, + "unexpected parallel nsIWebProgress OnStateChange and/or OnLocationChange notification"); + /* All discussion, unless otherwise mentioned, only refers to http, https, file or wyciwig requests. @@ -625,10 +693,17 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, nsCOMPtr windowForProgress; aWebProgress->GetDOMWindow(getter_AddRefs(windowForProgress)); - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + PRBool isViewSource; - const PRBool isToplevelProgress = (windowForProgress == window); + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + isViewSource = mIsViewSource; + } + + const PRBool isToplevelProgress = (windowForProgress.get() == window.get()); #ifdef PR_LOGGING if (windowForProgress) @@ -654,7 +729,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnStateChange\n", this)); - if (mIsViewSource) + if (isViewSource) return NS_OK; if (!aRequest) @@ -867,6 +942,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, // The listing of a request in mTransferringRequests // means, there has already been data transfered. + nsAutoMonitor lock(mMonitor); PL_DHashTableOperate(&mTransferringRequests, aRequest, PL_DHASH_ADD); return NS_OK; @@ -878,6 +954,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, && aProgressStateFlags & STATE_IS_REQUEST) { + nsAutoMonitor lock(mMonitor); PLDHashEntryHdr *entry = PL_DHashTableOperate(&mTransferringRequests, aRequest, PL_DHASH_LOOKUP); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { @@ -903,6 +980,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, && loadFlags & nsIChannel::LOAD_DOCUMENT_URI) { + nsAutoMonitor lock(mMonitor); if (!mDocumentRequestsInProgress) { PR_LOG(gSecureDocLog, PR_LOG_DEBUG, @@ -934,7 +1012,16 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, && loadFlags & nsIChannel::LOAD_DOCUMENT_URI) { - if (mDocumentRequestsInProgress <= 0) + PRInt32 temp_DocumentRequestsInProgress; + nsCOMPtr temp_ToplevelEventSink; + + { + nsAutoMonitor lock(mMonitor); + temp_DocumentRequestsInProgress = mDocumentRequestsInProgress; + temp_ToplevelEventSink = mToplevelEventSink; + } + + if (temp_DocumentRequestsInProgress <= 0) { // Ignore stop requests unless a document load is in progress // Unfortunately on application start, see some stops without having seen any starts... @@ -945,12 +1032,16 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, ("SecureUI:%p: OnStateChange: --mDocumentRequestsInProgress\n", this )); - if (!mToplevelEventSink && channel) + if (!temp_ToplevelEventSink && channel) { - ObtainEventSink(channel); + ObtainEventSink(channel, temp_ToplevelEventSink); } - --mDocumentRequestsInProgress; + { + nsAutoMonitor lock(mMonitor); + mToplevelEventSink = temp_ToplevelEventSink; + --mDocumentRequestsInProgress; + } if (requestHasTransferedData) { // Data has been transferred for the single toplevel @@ -987,7 +1078,13 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, // // We skip updating the security state in this case. - if (mNewToplevelSecurityStateKnown) + PRBool temp_NewToplevelSecurityStateKnown; + { + nsAutoMonitor lock(mMonitor); + temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown; + } + + if (temp_NewToplevelSecurityStateKnown) return UpdateSecurityState(aRequest); } @@ -997,18 +1094,31 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, return NS_OK; } -void nsSecureBrowserUIImpl::ObtainEventSink(nsIChannel *channel) +// I'm keeping this as a separate function, in order to simplify the review +// for bug 412456. We should inline this in a follow up patch. +void nsSecureBrowserUIImpl::ObtainEventSink(nsIChannel *channel, + nsCOMPtr &sink) { - if (!mToplevelEventSink) - NS_QueryNotificationCallbacks(channel, mToplevelEventSink); + if (!sink) + NS_QueryNotificationCallbacks(channel, sink); } nsresult nsSecureBrowserUIImpl::UpdateSecurityState(nsIRequest* aRequest) { - lockIconState newSecurityState; - - PRBool showWarning = PR_FALSE; lockIconState warnSecurityState = lis_no_security; + PRBool showWarning = PR_FALSE; + + UpdateMyFlags(showWarning, warnSecurityState); + return TellTheWorld(showWarning, warnSecurityState, aRequest); +} + +// must not fail, by definition, only trivial assignments +// or string operations are allowed +void nsSecureBrowserUIImpl::UpdateMyFlags(PRBool &showWarning, lockIconState &warnSecurityState) +{ + nsAutoMonitor lock(mMonitor); + + lockIconState newSecurityState; if (mNewToplevelSecurityState & STATE_IS_SECURE) { @@ -1139,17 +1249,35 @@ nsresult nsSecureBrowserUIImpl::UpdateSecurityState(nsIRequest* aRequest) } mNotifiedToplevelIsEV = mNewToplevelIsEV; +} - if (mToplevelEventSink) +nsresult nsSecureBrowserUIImpl::TellTheWorld(PRBool &showWarning, + lockIconState &warnSecurityState, + nsIRequest* aRequest) +{ + nsCOMPtr temp_ToplevelEventSink; + lockIconState temp_NotifiedSecurityState; + PRBool temp_NotifiedToplevelIsEV; + + { + nsAutoMonitor lock(mMonitor); + temp_ToplevelEventSink = mToplevelEventSink; + temp_NotifiedSecurityState = mNotifiedSecurityState; + temp_NotifiedToplevelIsEV = mNotifiedToplevelIsEV; + } + + if (temp_ToplevelEventSink) { PRUint32 newState = STATE_IS_INSECURE; - MapInternalToExternalState(&newState, mNotifiedSecurityState, mNotifiedToplevelIsEV); + MapInternalToExternalState(&newState, + temp_NotifiedSecurityState, + temp_NotifiedToplevelIsEV); PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: UpdateSecurityState: calling OnSecurityChange\n", this )); - mToplevelEventSink->OnSecurityChange(aRequest, newState); + temp_ToplevelEventSink->OnSecurityChange(aRequest, newState); } else { @@ -1190,6 +1318,14 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI* aLocation) { + nsAutoAtomic atomic(mOnStateLocationChangeReentranceDetection); + NS_ASSERTION(mOnStateLocationChangeReentranceDetection == 1, + "unexpected parallel nsIWebProgress OnStateChange and/or OnLocationChange notification"); + + PRBool updateIsViewSource = PR_FALSE; + PRBool temp_IsViewSource = PR_FALSE; + nsCOMPtr window; + if (aLocation) { PRBool vs; @@ -1202,10 +1338,19 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, ("SecureUI:%p: OnLocationChange: view-source\n", this)); } - mIsViewSource = vs; + updateIsViewSource = PR_TRUE; + temp_IsViewSource = vs; } - mCurrentURI = aLocation; + { + nsAutoMonitor lock(mMonitor); + if (updateIsViewSource) { + mIsViewSource = temp_IsViewSource; + } + mCurrentURI = aLocation; + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } // If the location change does not have a corresponding request, then we // assume that it does not impact the security state. @@ -1223,10 +1368,7 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, nsCOMPtr windowForProgress; aWebProgress->GetDOMWindow(getter_AddRefs(windowForProgress)); - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); - - if (windowForProgress == window) { + if (windowForProgress.get() == window.get()) { // For toplevel channels, update the security state right away. return EvaluateAndUpdateSecurityState(aRequest); } @@ -1245,7 +1387,13 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, // // We skip updating the security state in this case. - if (mNewToplevelSecurityStateKnown) + PRBool temp_NewToplevelSecurityStateKnown; + { + nsAutoMonitor lock(mMonitor); + temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown; + } + + if (temp_NewToplevelSecurityStateKnown) return UpdateSecurityState(aRequest); return NS_OK; @@ -1292,6 +1440,7 @@ nsSecureBrowserUIImpl::GetSSLStatus(nsISupports** _result) { NS_ENSURE_ARG_POINTER(_result); + nsAutoMonitor lock(mMonitor); *_result = mSSLStatus; NS_IF_ADDREF(*_result); @@ -1324,10 +1473,17 @@ void nsSecureBrowserUIImpl::GetBundleString(const PRUnichar* name, nsAString &outString) { - if (mStringBundle && name) { + nsCOMPtr temp_StringBundle; + + { + nsAutoMonitor lock(mMonitor); + temp_StringBundle = mStringBundle; + } + + if (temp_StringBundle && name) { PRUnichar *ptrv = nsnull; - if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name, - &ptrv))) + if (NS_SUCCEEDED(temp_StringBundle->GetStringFromName(name, + &ptrv))) outString = ptrv; else outString.SetLength(0); @@ -1462,8 +1618,12 @@ ConfirmEnteringSecure() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); @@ -1481,8 +1641,12 @@ ConfirmEnteringWeak() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); @@ -1500,8 +1664,12 @@ ConfirmLeavingSecure() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); @@ -1519,8 +1687,12 @@ ConfirmMixedMode() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); @@ -1545,8 +1717,12 @@ ConfirmPostToInsecure() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); @@ -1573,8 +1749,12 @@ ConfirmPostToInsecureFromSecure() GetNSSDialogs(getter_AddRefs(dialogs)); if (!dialogs) return PR_FALSE; // Should this allow PR_TRUE for unimplemented? - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ASSERTION(window, "Window has gone away?!"); + nsCOMPtr window; + { + nsAutoMonitor lock(mMonitor); + window = do_QueryReferent(mWindow); + NS_ASSERTION(window, "Window has gone away?!"); + } nsCOMPtr ctx = new nsUIContext(window); diff --git a/security/manager/boot/src/nsSecureBrowserUIImpl.h b/security/manager/boot/src/nsSecureBrowserUIImpl.h index 8c358e064bfc..7e7baf510b25 100644 --- a/security/manager/boot/src/nsSecureBrowserUIImpl.h +++ b/security/manager/boot/src/nsSecureBrowserUIImpl.h @@ -59,6 +59,7 @@ #include "nsWeakReference.h" #include "nsISSLStatusProvider.h" #include "pldhash.h" +#include "prmon.h" class nsITransportSecurityInfo; class nsISecurityWarningDialogs; @@ -92,6 +93,8 @@ public: nsIURI *actionURL, PRBool* cancelSubmit); protected: + PRMonitor *mMonitor; + PRInt32 mOnStateLocationChangeReentranceDetection; nsWeakPtr mWindow; nsCOMPtr mStringBundle; @@ -123,12 +126,18 @@ protected: PRInt32 mSubRequestsBrokenSecurity; PRInt32 mSubRequestsNoSecurity; - nsresult MapInternalToExternalState(PRUint32* aState, lockIconState lock, PRBool ev); + static nsresult MapInternalToExternalState(PRUint32* aState, lockIconState lock, PRBool ev); nsresult UpdateSecurityState(nsIRequest* aRequest); + void UpdateMyFlags(PRBool &showWarning, lockIconState &warnSecurityState); + nsresult TellTheWorld(PRBool &showWarning, + lockIconState &warnSecurityState, + nsIRequest* aRequest); + nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest); void UpdateSubrequestMembers(nsIRequest *aRequest); - void ObtainEventSink(nsIChannel *channel); + void ObtainEventSink(nsIChannel *channel, + nsCOMPtr &sink); nsCOMPtr mSSLStatus; @@ -146,7 +155,7 @@ protected: PRBool ConfirmPostToInsecureFromSecure(); // Support functions - nsresult GetNSSDialogs(nsISecurityWarningDialogs **); + static nsresult GetNSSDialogs(nsISecurityWarningDialogs **); PLDHashTable mTransferringRequests; }; From eb836b91ccb855727bc5dfb438fe7cba1028e7e3 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Thu, 6 Mar 2008 03:57:21 -0800 Subject: [PATCH 058/248] bug 419348 - build config fixes for profile-guided optimization on mac. fixes for PGO on universal builds, configure arg to disable PGO in spite of profiled build. r=bsmedberg --- Makefile.in | 5 +++++ client.mk | 52 ++++++++++++++++++++++++++----------------- config/autoconf.mk.in | 1 + config/config.mk | 5 +++++ configure.in | 9 ++++++++ 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/Makefile.in b/Makefile.in index d7ff65ee7903..f168a0423373 100644 --- a/Makefile.in +++ b/Makefile.in @@ -218,9 +218,14 @@ endif #XXX: this is a hack, since we don't want to clobber for MSVC # PGO support, but we can't do this test in client.mk ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) +# No point in clobbering if PGO has been explicitly disabled. +ifndef NO_PROFILE_GUIDED_OPTIMIZE maybe_clobber_profiledbuild: clobber_all else maybe_clobber_profiledbuild: endif +else +maybe_clobber_profiledbuild: +endif .PHONY: maybe_clobber_profiledbuild diff --git a/client.mk b/client.mk index aaa10a276174..41a7d42b174e 100644 --- a/client.mk +++ b/client.mk @@ -931,6 +931,30 @@ real_l10n-checkout: else true; \ fi +#################################### +# Profile-Guided Optimization +# To use this, you should set the following variables in your mozconfig +# mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script +# +# The profile script should exercise the functionality to be included +# in the profile feedback. +# +# This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this +# is usable in multi-pass builds, where you might not have a runnable +# application until all the build passes and postflight scripts have run. +ifdef MOZ_OBJDIR + PGO_OBJDIR = $(MOZ_OBJDIR) +else + PGO_OBJDIR := $(TOPSRCDIR) +endif + +profiledbuild:: + $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1 + OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT) + $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild + $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1 + + ##################################################### # First Checkout @@ -958,7 +982,7 @@ endif ##################################################### # Preflight, before building any project -build profiledbuild alldep preflight_all:: +build alldep preflight_all:: ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1)) # Don't run preflight_all for individual projects in multi-project builds # (when MOZ_CURRENT_PROJECT is set.) @@ -982,7 +1006,7 @@ endif # loop through them. ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1)) -configure depend build profiledbuild install export libs clean realclean distclean alldep preflight postflight:: +configure depend build install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild:: set -e; \ for app in $(MOZ_BUILD_PROJECTS); do \ $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \ @@ -1072,7 +1096,7 @@ depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status #################################### # Preflight -build profiledbuild alldep preflight:: +build alldep preflight:: ifdef MOZ_PREFLIGHT set -e; \ for mkfile in $(MOZ_PREFLIGHT); do \ @@ -1086,31 +1110,17 @@ endif build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status $(MOZ_MAKE) -#################################### -# Profile-feedback build (gcc only) -# To use this, you should set the following variables in your mozconfig -# mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script -# -# The profile script should exercise the functionality to be included -# in the profile feedback. - -profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status - $(MOZ_MAKE) MOZ_PROFILE_GENERATE=1 - OBJDIR=${OBJDIR} $(PROFILE_GEN_SCRIPT) - $(MOZ_MAKE) maybe_clobber_profiledbuild - $(MOZ_MAKE) MOZ_PROFILE_USE=1 - #################################### # Other targets # Pass these target onto the real build system -install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status +install export libs clean realclean distclean alldep maybe_clobber_profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status $(MOZ_MAKE) $@ #################################### # Postflight -build profiledbuild alldep postflight:: +build alldep postflight:: ifdef MOZ_POSTFLIGHT set -e; \ for mkfile in $(MOZ_POSTFLIGHT); do \ @@ -1123,7 +1133,7 @@ endif # MOZ_CURRENT_PROJECT #################################### # Postflight, after building all projects -build profiledbuild alldep postflight_all:: +build alldep postflight_all:: ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1)) # Don't run postflight_all for individual projects in multi-project builds # (when MOZ_CURRENT_PROJECT is set.) @@ -1161,4 +1171,4 @@ endif echo-variable-%: @echo $($*) -.PHONY: checkout real_checkout depend build profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all +.PHONY: checkout real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index fe1a26d6e89e..13b63cff53cb 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -283,6 +283,7 @@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@ +MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@ PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@ PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@ PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@ diff --git a/config/config.mk b/config/config.mk index 16e9b8c645ae..c330633458e7 100644 --- a/config/config.mk +++ b/config/config.mk @@ -351,6 +351,11 @@ DSO_PIC_CFLAGS= endif endif +# This comes from configure +ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE +NO_PROFILE_GUIDED_OPTIMIZE = 1 +endif + # Enable profile-based feedback ifndef NO_PROFILE_GUIDED_OPTIMIZE ifdef MOZ_PROFILE_GENERATE diff --git a/configure.in b/configure.in index f0ecb9f36512..a1b928547e72 100644 --- a/configure.in +++ b/configure.in @@ -6550,6 +6550,15 @@ dnl Test for profiling options dnl Under gcc 3.3, use -fprofile-arcs/-fbranch-probabilities dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use +dnl Provide a switch to disable PGO even when called via profiledbuild. +MOZ_ARG_DISABLE_BOOL(profile-guided-optimization, +[ --disable-profile-guided-optimization + Don't build with PGO even if called via make profiledbuild], +MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=1, +MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=) + +AC_SUBST(MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE) + _SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fprofile-generate" From 44eeab6d8d82ab5ab38e3206caf89c4cc998221d Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Thu, 6 Mar 2008 04:15:58 -0800 Subject: [PATCH 059/248] bug 420474 - upload debug info for Linux builds to symbol server (use .gnu_debuglink) (just the necessary changes, not actually turned on). r=bsmedberg --- toolkit/crashreporter/tools/symbolstore.py | 40 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/toolkit/crashreporter/tools/symbolstore.py b/toolkit/crashreporter/tools/symbolstore.py index f6a79acee401..6559978b2610 100755 --- a/toolkit/crashreporter/tools/symbolstore.py +++ b/toolkit/crashreporter/tools/symbolstore.py @@ -346,6 +346,10 @@ class Dumper: def SourceServerIndexing(self, debug_file, guid, sourceFileStream): return "" + # subclasses override this if they want to support this + def CopyDebug(self, file, debug_file, guid): + pass + def Process(self, file_or_dir): "Process a file or all the (valid) files in a directory." if os.path.isdir(file_or_dir): @@ -416,13 +420,7 @@ class Dumper: # was generated print rel_path if self.copy_debug: - rel_path = os.path.join(debug_file, - guid, - debug_file).replace("\\", "/") - print rel_path - full_path = os.path.normpath(os.path.join(self.symbol_path, - rel_path)) - shutil.copyfile(file, full_path) + self.CopyDebug(file, debug_file, guid) if self.srcsrv: # Call on SourceServerIndexing result = self.SourceServerIndexing(debug_file, guid, sourceFileStream) @@ -471,6 +469,16 @@ class Dumper_Win32(Dumper): # Cache the corrected version to avoid future filesystem hits. self.fixedFilenameCaseCache[file] = result return result + + def CopyDebug(self, file, debug_file, guid): + rel_path = os.path.join(debug_file, + guid, + debug_file).replace("\\", "/") + print rel_path + full_path = os.path.normpath(os.path.join(self.symbol_path, + rel_path)) + shutil.copyfile(file, full_path) + pass def SourceServerIndexing(self, debug_file, guid, sourceFileStream): # Creates a .pdb.stream file in the mozilla\objdir to be used for source indexing @@ -502,6 +510,24 @@ class Dumper_Linux(Dumper): return self.RunFileCommand(file).startswith("ELF") return False + def CopyDebug(self, file, debug_file, guid): + # We want to strip out the debug info, and add a + # .gnu_debuglink section to the object, so the debugger can + # actually load our debug info later. + file_dbg = file + ".dbg" + os.system("objcopy --only-keep-debug %s %s" % (file, file_dbg)) + os.system("objcopy --add-gnu-debuglink=%s %s" % (file_dbg, file)) + + rel_path = os.path.join(debug_file, + guid, + debug_file + ".dbg") + full_path = os.path.normpath(os.path.join(self.symbol_path, + rel_path)) + shutil.copyfile(file_dbg, full_path) + # gzip the shipped debug files + os.system("gzip %s" % full_path) + print rel_path + ".gz" + class Dumper_Mac(Dumper): def ShouldProcess(self, file): """This function will allow processing of files that are From a5205cae6eb80001657c946aa2cb2cfd7a017ef8 Mon Sep 17 00:00:00 2001 From: "johnath@mozilla.com" Date: Thu, 6 Mar 2008 06:05:34 -0800 Subject: [PATCH 060/248] Help > Report Web Forgery..." does nothing; "this.appContext is null. b=420667 r=gavin a=blocking-firefox3 (beltzner) --- .../components/safebrowsing/content/sb-loader.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/browser/components/safebrowsing/content/sb-loader.js b/browser/components/safebrowsing/content/sb-loader.js index 36d3e450c7cd..ee3cd789a66b 100644 --- a/browser/components/safebrowsing/content/sb-loader.js +++ b/browser/components/safebrowsing/content/sb-loader.js @@ -38,13 +38,13 @@ var safebrowsing = { appContext: null, startup: function() { - setTimeout(safebrowsing.deferredStartup, 2000); + setTimeout(function() { + safebrowsing.deferredStartup(); + }, 2000); window.removeEventListener("load", safebrowsing.startup, false); }, deferredStartup: function() { - this.appContext = Cc["@mozilla.org/safebrowsing/application;1"]. - getService().wrappedJSObject; this.appContext.initialize(); }, @@ -56,6 +56,15 @@ var safebrowsing = { else broadcaster.disabled = true; }, + + /** + * Lazy init getter for appContext + */ + get appContext() { + delete this.appContext; + return this.appContext = Cc["@mozilla.org/safebrowsing/application;1"] + .getService().wrappedJSObject; + }, /** * Used to report a phishing page or a false positive From ffe3dd8a4436c6c0aaaa32c83f074cae2695da4f Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Thu, 6 Mar 2008 08:01:57 -0800 Subject: [PATCH 061/248] JavaScript Tests - update known failures, bug 418069 --- js/tests/public-failures.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/js/tests/public-failures.txt b/js/tests/public-failures.txt index 6db081be864b..68e7c567a9e9 100644 --- a/js/tests/public-failures.txt +++ b/js/tests/public-failures.txt @@ -230,7 +230,6 @@ TEST_ID=js1_5/Regress/regress-3649-n.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_ID=js1_5/Regress/regress-3649-n.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=opt, TEST_TYPE=browser, TEST_OS=linux, TEST_MACHINE=.*, TEST_PROCESSORTYPE=(athlon|i686), TEST_KERNEL=2.6.9.*ELsmp, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=EXIT STATUS: TIMED OUT TEST_ID=js1_5/Regress/regress-3649-n.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=opt, TEST_TYPE=browser, TEST_OS=linux, TEST_MACHINE=.*, TEST_PROCESSORTYPE=athlon, TEST_KERNEL=2.6.9.*ELsmp, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=EXIT STATUS: CRASHED `.``*`, BUGNUMBER: 3649; STATUS: gc-checking branch callback.; --- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE 0 ---; --- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE 5 --- TEST_ID=js1_5/Regress/regress-3649-n.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=opt, TEST_TYPE=browser, TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=BUGNUMBER: 3649; STATUS: gc-checking branch callback.; --- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE 0 ---; --- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE 5 --- -TEST_ID=js1_5/Regress/regress-379245.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=browser, TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Unknown expected: Unknown actual: error reason: :0: uncaught exception: bad this TEST_ID=js1_5/Regress/regress-383674.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Statement that implicitly calls toString should not be optimized away as a "useless expression": 1 expected: toString called actual: toString not called reason: Expected value 'toString called', Actual value 'toString not called' TEST_ID=js1_5/Regress/regress-383674.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Statement that implicitly calls toString should not be optimized away as a "useless expression": 2 expected: toString called actual: toString not called reason: Expected value 'toString called', Actual value 'toString not called' TEST_ID=js1_5/Regress/regress-385393.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=browser, TEST_OS=linux, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=EXIT STATUS: TIMED OUT From 81de41cfbdec99881ffbd78773faa1ac804b9b67 Mon Sep 17 00:00:00 2001 From: "rhelmer@mozilla.com" Date: Thu, 6 Mar 2008 08:29:18 -0800 Subject: [PATCH 062/248] bump 1.8 branch configs b=417147 r=nthomas --- tools/release/configs/fx-moz18-nightly-bootstrap.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/release/configs/fx-moz18-nightly-bootstrap.cfg b/tools/release/configs/fx-moz18-nightly-bootstrap.cfg index 026e75435018..fbcdc43ec78b 100644 --- a/tools/release/configs/fx-moz18-nightly-bootstrap.cfg +++ b/tools/release/configs/fx-moz18-nightly-bootstrap.cfg @@ -4,7 +4,7 @@ milestone = nightly # not used by nightly productTag = FIREFOX_2_0_0_12pre # Branch name and pull dates to use for base tag -branchTag = MOZILLA_1_8_BRANCH_test +branchTag = MOZILLA_1_8_BRANCH # manually tagged from GECKO181_20070712_RELBRANCH # RelbranchOverride = GECKO181_20070712_RELBRANCH # not used by nightly From 5e1cb9631e49419a3169155d657b5423e59c44b8 Mon Sep 17 00:00:00 2001 From: "rhelmer@mozilla.com" Date: Thu, 6 Mar 2008 08:58:03 -0800 Subject: [PATCH 063/248] use ffxbld for nightly builds b=417147 r=nthomas --- tools/release/configs/fx-moz18-nightly-bootstrap.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/release/configs/fx-moz18-nightly-bootstrap.cfg b/tools/release/configs/fx-moz18-nightly-bootstrap.cfg index fbcdc43ec78b..b5a6603ecc28 100644 --- a/tools/release/configs/fx-moz18-nightly-bootstrap.cfg +++ b/tools/release/configs/fx-moz18-nightly-bootstrap.cfg @@ -77,7 +77,7 @@ ftpServer = ftp.mozilla.org # where release updates/builds go bouncerServer = download.mozilla.org # username and server to push builds -sshUser = cltbld +sshUser = ffxbld sshServer = stage.mozilla.org useTalkback = 0 symbolServer = production-1.8-master.mozilla.org From 8152de54717c3c6100b36f3ea8e921a3e3d6997a Mon Sep 17 00:00:00 2001 From: "bent.mozilla@gmail.com" Date: Thu, 6 Mar 2008 11:12:40 -0800 Subject: [PATCH 064/248] Bug 412862 - "Change the 'allow scripts to move or resize existing windows' pref to a whitelist". Adding back some strings that were removed with that soon-to-be-backed-out fix. r+sr+a=jst. --- .../en-US/chrome/browser/preferences/advanced-scripts.dtd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/browser/locales/en-US/chrome/browser/preferences/advanced-scripts.dtd b/browser/locales/en-US/chrome/browser/preferences/advanced-scripts.dtd index 02ea7de658f5..a176b3cebf68 100644 --- a/browser/locales/en-US/chrome/browser/preferences/advanced-scripts.dtd +++ b/browser/locales/en-US/chrome/browser/preferences/advanced-scripts.dtd @@ -40,6 +40,8 @@ + + From 1c63b1637a6735e50654aa0ee46a9fcd920eed90 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Thu, 6 Mar 2008 11:56:47 -0800 Subject: [PATCH 065/248] b=419718, extend canvas checks, r=stuart --- .../canvas/src/nsCanvasRenderingContext2D.cpp | 107 ++++++++++++------ 1 file changed, 70 insertions(+), 37 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index f4e26d328ca7..f77f7d8369c1 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -420,6 +420,31 @@ protected: PRInt32 *widthOut, PRInt32 *heightOut, nsIPrincipal **prinOut, PRBool *forceWriteOnlyOut); + + // other helpers + void GetAppUnitsValues(PRUint32 *perDevPixel, PRUint32 *perCSSPixel) { + // If we don't have a canvas element, we just return something generic. + PRUint32 devPixel = 60; + PRUint32 cssPixel = 60; + + nsCOMPtr elem = do_QueryInterface(mCanvasElement); + if (elem) { + nsIDocument *doc = elem->GetOwnerDoc(); + if (!doc) goto FINISH; + nsIPresShell *ps = doc->GetPrimaryShell(); + if (!ps) goto FINISH; + nsPresContext *pc = ps->GetPresContext(); + if (!pc) goto FINISH; + devPixel = pc->AppUnitsPerDevPixel(); + cssPixel = pc->AppUnitsPerCSSPixel(); + } + + FINISH: + if (perDevPixel) + *perDevPixel = devPixel; + if (cssPixel) + *perCSSPixel = cssPixel; + } }; NS_IMPL_ADDREF(nsCanvasRenderingContext2D) @@ -570,7 +595,13 @@ nsCanvasRenderingContext2D::DoDrawImageSecurityCheck(nsIPrincipal* aPrincipal, PRBool forceWriteOnly) { NS_PRECONDITION(aPrincipal, "Must have a principal here"); - + + // Callers should ensure that mCanvasElement is non-null before calling this + if (!mCanvasElement) { + NS_WARNING("DoDrawImageSecurityCheck called without canvas element!"); + return; + } + if (mCanvasElement->IsWriteOnly()) return; @@ -610,6 +641,9 @@ nsCanvasRenderingContext2D::ApplyStyle(PRInt32 aWhichStyle) nsCanvasPattern* pattern = CurrentState().patternStyles[aWhichStyle]; if (pattern) { + if (!mCanvasElement) + return; + DoDrawImageSecurityCheck(pattern->Principal(), pattern->GetForceWriteOnly()); pattern->Apply(mCairo); @@ -1432,21 +1466,28 @@ nsCanvasRenderingContext2D::SetMozTextStyle(const nsAString& textStyle) if(mTextStyle.Equals(textStyle)) return NS_OK; nsCOMPtr elem = do_QueryInterface(mCanvasElement); - NS_ASSERTION(elem, "Canvas element must be a dom node"); + if (!elem) { + NS_WARNING("Canvas element must be an nsINode and non-null"); + return NS_ERROR_FAILURE; + } - nsCOMPtr elemPrincipal; - nsCOMPtr elemDocument; + nsIPrincipal* elemPrincipal = elem->NodePrincipal(); + nsIDocument* elemDocument = elem->GetOwnerDoc(); - elemPrincipal = elem->NodePrincipal(); - elemDocument = elem->GetOwnerDoc(); + if (!elemDocument || !elemPrincipal) { + NS_WARNING("Element is missing document or principal"); + return NS_ERROR_FAILURE; + } - NS_ASSERTION(elemDocument && elemPrincipal, "Element is missing document or principal"); + nsIPresShell* presShell = elemDocument->GetPrimaryShell(); + if (!presShell) + return NS_ERROR_FAILURE; nsIURI *docURL = elemDocument->GetDocumentURI(); nsIURI *baseURL = elemDocument->GetBaseURI(); nsCString langGroup; - elemDocument->GetPrimaryShell()->GetPresContext()->GetLangGroup()->ToUTF8String(langGroup); + presShell->GetPresContext()->GetLangGroup()->ToUTF8String(langGroup); nsCOMArray rules; PRBool changed; @@ -1469,14 +1510,14 @@ nsCanvasRenderingContext2D::SetMozTextStyle(const nsAString& textStyle) rules.AppendObject(rule); - nsStyleSet *styleSet = elemDocument->GetPrimaryShell()->StyleSet(); + nsStyleSet *styleSet = presShell->StyleSet(); nsRefPtr sc = styleSet->ResolveStyleForRules(nsnull,rules); const nsStyleFont *fontStyle = sc->GetStyleFont(); NS_ASSERTION(fontStyle, "Could not obtain font style"); - PRUint32 aupdp = elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerDevPixel(); + PRUint32 aupdp = presShell->GetPresContext()->AppUnitsPerDevPixel(); gfxFontStyle style(fontStyle->mFont.style, fontStyle->mFont.weight, @@ -1514,16 +1555,13 @@ gfxFontGroup *nsCanvasRenderingContext2D::GetCurrentFontStyle() NS_IMETHODIMP nsCanvasRenderingContext2D::MozDrawText(const nsAString& textToDraw) { - nsCOMPtr elem = do_QueryInterface(mCanvasElement); - NS_ASSERTION(elem, "Canvas element must be an nsINode"); - - nsCOMPtr elemDocument(elem->GetOwnerDoc()); - const PRUnichar* textdata; textToDraw.GetData(&textdata); PRUint32 textrunflags = 0; - PRUint32 aupdp = elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerDevPixel(); + + PRUint32 aupdp; + GetAppUnitsValues(&aupdp, NULL); gfxTextRunCache::AutoTextRun textRun; textRun = gfxTextRunCache::MakeTextRun(textdata, @@ -1554,16 +1592,12 @@ nsCanvasRenderingContext2D::MozDrawText(const nsAString& textToDraw) NS_IMETHODIMP nsCanvasRenderingContext2D::MozMeasureText(const nsAString& textToMeasure, float *retVal) { - nsCOMPtr elem = do_QueryInterface(mCanvasElement); - NS_ASSERTION(elem, "Canvas element must be an nsINode"); - - nsCOMPtr elemDocument(elem->GetOwnerDoc()); - const PRUnichar* textdata; textToMeasure.GetData(&textdata); PRUint32 textrunflags = 0; - PRUint32 aupdp = elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerDevPixel(); + PRUint32 aupdp, aupcp; + GetAppUnitsValues(&aupdp, &aupcp); gfxTextRunCache::AutoTextRun textRun; textRun = gfxTextRunCache::MakeTextRun(textdata, @@ -1580,23 +1614,20 @@ nsCanvasRenderingContext2D::MozMeasureText(const nsAString& textToMeasure, float gfxTextRun::Metrics metrics = textRun->MeasureText(/* offset = */ 0, textToMeasure.Length(), tightBoundingBox, mThebesContext, nsnull); - *retVal = float(metrics.mAdvanceWidth/gfxFloat(elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerCSSPixel())); + *retVal = float(metrics.mAdvanceWidth/gfxFloat(aupcp)); return NS_OK; } NS_IMETHODIMP nsCanvasRenderingContext2D::MozPathText(const nsAString& textToPath) { - nsCOMPtr elem = do_QueryInterface(mCanvasElement); - NS_ASSERTION(elem, "Canvas element must be an nsINode"); - - nsCOMPtr elemDocument(elem->GetOwnerDoc()); - const PRUnichar* textdata; textToPath.GetData(&textdata); PRUint32 textrunflags = 0; - PRUint32 aupdp = elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerDevPixel(); + + PRUint32 aupdp; + GetAppUnitsValues(&aupdp, NULL); gfxTextRunCache::AutoTextRun textRun; textRun = gfxTextRunCache::MakeTextRun(textdata, @@ -1626,16 +1657,13 @@ nsCanvasRenderingContext2D::MozTextAlongPath(const nsAString& textToDraw, PRBool // Most of this code is copied from its svg equivalent nsRefPtr path(mThebesContext->GetFlattenedPath()); - nsCOMPtr elem = do_QueryInterface(mCanvasElement); - NS_ASSERTION(elem, "Canvas element must be an nsINode"); - - nsCOMPtr elemDocument(elem->GetOwnerDoc()); - const PRUnichar* textdata; textToDraw.GetData(&textdata); PRUint32 textrunflags = 0; - PRUint32 aupdp = elemDocument->GetPrimaryShell()->GetPresContext()->AppUnitsPerDevPixel(); + + PRUint32 aupdp; + GetAppUnitsValues(&aupdp, NULL); gfxTextRunCache::AutoTextRun textRun; textRun = gfxTextRunCache::MakeTextRun(textdata, @@ -1709,7 +1737,7 @@ nsCanvasRenderingContext2D::MozTextAlongPath(const nsAString& textToDraw, PRBool mThebesContext->SetMatrix(matrix); } - delete[] cp; + delete [] cp; return NS_OK; } @@ -1851,6 +1879,11 @@ nsCanvasRenderingContext2D::DrawImage() { nsresult rv; + // we can't do a security check without a canvas element, so + // just skip this entirely + if (!mCanvasElement) + return NS_ERROR_FAILURE; + nsAXPCNativeCallContext *ncc = nsnull; rv = nsContentUtils::XPConnect()-> GetCurrentNativeCallContext(&ncc); @@ -2360,7 +2393,7 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, PRInt32 aX, PRInt3 NS_IMETHODIMP nsCanvasRenderingContext2D::GetImageData() { - if (!mValid) + if (!mValid || !mCanvasElement) return NS_ERROR_FAILURE; if (mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) { From d0322004913d46211d2ecd202332131aa8a9bd02 Mon Sep 17 00:00:00 2001 From: "wr@rosenauer.org" Date: Thu, 6 Mar 2008 11:56:49 -0800 Subject: [PATCH 066/248] Bug 420040 - minimal required gtk2 version in configure.in is outdated, r=bsmedberg, a19=beltzner --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index a1b928547e72..7483a2319d88 100644 --- a/configure.in +++ b/configure.in @@ -117,7 +117,7 @@ LIBART_VERSION=2.3.4 CAIRO_VERSION=1.5.2 GLITZ_VERSION=0.4.0 PANGO_VERSION=1.10.0 -GTK2_VERSION=1.8.0 +GTK2_VERSION=2.10.0 MAKE_VERSION=3.78 WINDRES_VERSION=2.14.90 W32API_VERSION=3.8 From dc73a06aea64a0af717c0f6c7d825acd9409c370 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 11:57:16 -0800 Subject: [PATCH 067/248] Make Object.prototype.toString show the underlying object. bug 420480, r+a=brendan --- js/src/jsobj.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/src/jsobj.c b/js/src/jsobj.c index c034a92315b9..f1f5e8f21628 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -1010,13 +1010,25 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp) JSObject *obj; jschar *chars; size_t nchars; + JSClass *clasp; const char *clazz, *prefix; JSString *str; obj = JS_THIS_OBJECT(cx, vp); if (!obj) return JS_FALSE; - clazz = OBJ_GET_CLASS(cx, obj)->name; + clasp = OBJ_GET_CLASS(cx, obj); + if (clasp->flags & JSCLASS_IS_EXTENDED) { + JSExtendedClass *xclasp; + JSObject *obj2; + + if ((xclasp = (JSExtendedClass *)clasp)->wrappedObject && + (obj2 = xclasp->wrappedObject(cx, obj))) { + obj = obj2; + clasp = OBJ_GET_CLASS(cx, obj); + } + } + clazz = clasp->name; nchars = 9 + strlen(clazz); /* 9 for "[object ]" */ chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar)); if (!chars) From b9ab7bc2c1066e9ff7ba235a80b823a6b7cbb18b Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 11:58:28 -0800 Subject: [PATCH 068/248] Propagate getters and setters onto the inner object. bug 420585, r+sr=jst --- .../xpconnect/src/XPCCrossOriginWrapper.cpp | 2 +- .../xpconnect/src/XPCSafeJSObjectWrapper.cpp | 2 +- js/src/xpconnect/src/XPCWrapper.cpp | 60 ++++++++++++++----- js/src/xpconnect/src/XPCWrapper.h | 3 +- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp index 56fe5a2e5b06..08810107a451 100644 --- a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp +++ b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp @@ -561,7 +561,7 @@ XPC_XOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } // Same origin, pass this request along. - return XPCWrapper::AddProperty(cx, wrappedObj, id, vp); + return XPCWrapper::AddProperty(cx, obj, wrappedObj, id, vp); } JS_STATIC_DLL_CALLBACK(JSBool) diff --git a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp index 92ceb3e7f400..a93f7899106f 100644 --- a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp +++ b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp @@ -496,7 +496,7 @@ XPC_SJOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } - return XPCWrapper::AddProperty(cx, unsafeObj, id, vp); + return XPCWrapper::AddProperty(cx, obj, unsafeObj, id, vp); } JS_STATIC_DLL_CALLBACK(JSBool) diff --git a/js/src/xpconnect/src/XPCWrapper.cpp b/js/src/xpconnect/src/XPCWrapper.cpp index d41ea6bf8251..63369a2bf77f 100644 --- a/js/src/xpconnect/src/XPCWrapper.cpp +++ b/js/src/xpconnect/src/XPCWrapper.cpp @@ -188,23 +188,56 @@ XPCWrapper::CreateIteratorObj(JSContext *cx, JSObject *tempWrapper, // static JSBool -XPCWrapper::AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +XPCWrapper::AddProperty(JSContext *cx, JSObject *wrapperObj, + JSObject *innerObj, jsval id, jsval *vp) { - if (JSVAL_IS_STRING(id)) { - JSString *str = JSVAL_TO_STRING(id); - jschar *chars = ::JS_GetStringChars(str); - size_t length = ::JS_GetStringLength(str); - - return ::JS_DefineUCProperty(cx, obj, chars, length, *vp, nsnull, - nsnull, JSPROP_ENUMERATE); + jsid interned_id; + if (!::JS_ValueToId(cx, id, &interned_id)) { + return JS_FALSE; } - if (!JSVAL_IS_INT(id)) { - return ThrowException(NS_ERROR_NOT_IMPLEMENTED, cx); + JSProperty *prop; + JSObject *wrapperObjp; + if (!OBJ_LOOKUP_PROPERTY(cx, wrapperObj, interned_id, &wrapperObjp, &prop)) { + return JS_FALSE; } - return ::JS_DefineElement(cx, obj, JSVAL_TO_INT(id), *vp, nsnull, - nsnull, JSPROP_ENUMERATE); + NS_ASSERTION(prop && OBJ_IS_NATIVE(wrapperObjp), + "What weird wrapper are we using?"); + + JSBool isXOW = (STOBJ_GET_CLASS(wrapperObj) == &sXPC_XOW_JSClass.base); + uintN attrs = JSPROP_ENUMERATE; + JSPropertyOp getter = nsnull; + JSPropertyOp setter = nsnull; + jsval v; + if (isXOW) { + JSScopeProperty *sprop = reinterpret_cast(prop); + + attrs = sprop->attrs; + if (attrs & JSPROP_GETTER) { + getter = sprop->getter; + } + if (attrs & JSPROP_SETTER) { + setter = sprop->setter; + } + + if (SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(wrapperObjp))) { + v = OBJ_GET_SLOT(cx, wrapperObjp, sprop->slot); + } + } + + OBJ_DROP_PROPERTY(cx, wrapperObjp, prop); + + const uintN interesting_attrs = isXOW + ? (JSPROP_ENUMERATE | + JSPROP_READONLY | + JSPROP_PERMANENT | + JSPROP_SHARED | + JSPROP_GETTER | + JSPROP_SETTER) + : JSPROP_ENUMERATE; + return OBJ_DEFINE_PROPERTY(cx, innerObj, interned_id, v, getter, + setter, (attrs & interesting_attrs), nsnull); } // static @@ -313,8 +346,7 @@ XPCWrapper::NewResolve(JSContext *cx, JSObject *wrapperObj, setter = sprop->setter; } - if ((preserveVal || isXOW) && - SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(innerObjp))) { + if (preserveVal && SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(innerObjp))) { v = OBJ_GET_SLOT(cx, innerObjp, sprop->slot); } } diff --git a/js/src/xpconnect/src/XPCWrapper.h b/js/src/xpconnect/src/XPCWrapper.h index 17be98bb665d..19363df3964a 100644 --- a/js/src/xpconnect/src/XPCWrapper.h +++ b/js/src/xpconnect/src/XPCWrapper.h @@ -258,7 +258,8 @@ public: /** * Called for the common part of adding a property to obj. */ - static JSBool AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp); + static JSBool AddProperty(JSContext *cx, JSObject *wrapperObj, + JSObject *innerObj, jsval id, jsval *vp); /** * Called for the common part of deleting a property from obj. From fd7755367979c40b3fe5132c7ee52c7d3141c60e Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 12:00:23 -0800 Subject: [PATCH 069/248] Fix mochitest depending on the old toString behavior. --- js/src/xpconnect/tests/mochitest/test_wrappers.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/src/xpconnect/tests/mochitest/test_wrappers.html b/js/src/xpconnect/tests/mochitest/test_wrappers.html index fbc8e2facf63..10a3ce5feab8 100644 --- a/js/src/xpconnect/tests/mochitest/test_wrappers.html +++ b/js/src/xpconnect/tests/mochitest/test_wrappers.html @@ -75,9 +75,6 @@ ok(false, 'window.eval does not throw an exception'); } - is(Object.prototype.toString.call(Object.__parent__), - '[object XPCCrossOriginWrapper]', '__parent__ returns an XOW'); - try { window.__proto__ = null; is(window.__proto__, null, From ca37844efee06b6fffc2e0c151eb758b815f5b37 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 12:01:26 -0800 Subject: [PATCH 070/248] Remove a now-unnecessary eval hack. bug 420642, r+sr=jst a=beltzner --- js/src/xpconnect/src/XPCCrossOriginWrapper.cpp | 7 ------- js/src/xpconnect/src/XPCWrapper.cpp | 14 -------------- 2 files changed, 21 deletions(-) diff --git a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp index 08810107a451..bee52c8f01f6 100644 --- a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp +++ b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp @@ -381,13 +381,6 @@ WrapSameOriginProp(JSContext *cx, JSObject *outerObj, jsval *vp) return XPC_XOW_WrapObject(cx, STOBJ_GET_PARENT(outerObj), vp); } - if (JS_ObjectIsFunction(cx, wrappedObj) && - JS_GetFunctionNative(cx, reinterpret_cast - (xpc_GetJSPrivate(wrappedObj))) == - XPCWrapper::sEvalNative) { - return XPC_XOW_WrapFunction(cx, outerObj, wrappedObj, vp); - } - return JS_TRUE; } diff --git a/js/src/xpconnect/src/XPCWrapper.cpp b/js/src/xpconnect/src/XPCWrapper.cpp index 63369a2bf77f..cc66b9b6a61a 100644 --- a/js/src/xpconnect/src/XPCWrapper.cpp +++ b/js/src/xpconnect/src/XPCWrapper.cpp @@ -353,20 +353,6 @@ XPCWrapper::NewResolve(JSContext *cx, JSObject *wrapperObj, OBJ_DROP_PROPERTY(cx, innerObjp, prop); - // Hack alert: we only do this for same-origin calls on XOWs: we want - // to preserve 'eval' function wrapper on the wrapper object itself - // to preserve eval's identity. - if (!preserveVal && isXOW && !JSVAL_IS_PRIMITIVE(v)) { - JSObject *obj = JSVAL_TO_OBJECT(v); - if (JS_ObjectIsFunction(cx, obj)) { - JSFunction *fun = reinterpret_cast(xpc_GetJSPrivate(obj)); - if (JS_GetFunctionNative(cx, fun) == sEvalNative && - !WrapFunction(cx, wrapperObj, obj, &v, JS_FALSE)) { - return JS_FALSE; - } - } - } - jsval oldSlotVal; if (!::JS_GetReservedSlot(cx, wrapperObj, sResolvingSlot, &oldSlotVal) || !::JS_SetReservedSlot(cx, wrapperObj, sResolvingSlot, JSVAL_TRUE)) { From 556a3969cb2a70945b5e28238576ecbb038bf8e3 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 12:04:05 -0800 Subject: [PATCH 071/248] Allow things to happen to SJOWs if there's no code running. bug 420647, r+sr=jst --- js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp index a93f7899106f..a458a65c65bb 100644 --- a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp +++ b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp @@ -115,13 +115,7 @@ FindPrincipals(JSContext *cx, JSObject *obj, nsIPrincipal **objectPrincipal, nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); if (subjectPrincipal) { - nsCOMPtr tmp = ssm->GetCxSubjectPrincipal(cx); - - if (!tmp) { - return NS_ERROR_XPC_SECURITY_MANAGER_VETO; - } - - tmp.swap(*subjectPrincipal); + NS_IF_ADDREF(*subjectPrincipal = ssm->GetCxSubjectPrincipal(cx)); } ssm->GetObjectPrincipal(cx, obj, objectPrincipal); @@ -145,6 +139,11 @@ CanCallerAccess(JSContext *cx, JSObject *unsafeObj) return ThrowException(rv, cx); } + // Assume that we're trusted if there's no running code. + if (!subjPrincipal) { + return PR_TRUE; + } + PRBool subsumes; rv = subjPrincipal->Subsumes(objPrincipal, &subsumes); @@ -305,7 +304,7 @@ WrapJSValue(JSContext *cx, JSObject *obj, jsval val, jsval *rval) // If the subject can access both the source and object principals, then // don't bother forcing the principal below. - if (!subsumes) { + if (!subsumes && subjPrincipal) { PRBool subjSubsumes = PR_FALSE; rv = subjPrincipal->Subsumes(srcObjPrincipal, &subjSubsumes); if (NS_SUCCEEDED(rv) && subjSubsumes) { From 9a51eefa28395feaaccb281ceff4228295d5a594 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 12:05:18 -0800 Subject: [PATCH 072/248] Fix array_concat to be more generic. bug 420966, r=brendan a=beltzner --- js/src/jsarray.c | 5 ++++- js/src/jsgc.c | 12 +----------- js/src/jsinterp.c | 23 ++++------------------- js/src/jsobj.c | 44 ++++++++++++++++++++++---------------------- js/src/jsobj.h | 4 ++++ 5 files changed, 35 insertions(+), 53 deletions(-) diff --git a/js/src/jsarray.c b/js/src/jsarray.c index 934647cb96cd..28dd426ea59b 100644 --- a/js/src/jsarray.c +++ b/js/src/jsarray.c @@ -2390,8 +2390,11 @@ array_concat(JSContext *cx, uintN argc, jsval *vp) goto out; v = argv[i]; if (JSVAL_IS_OBJECT(v)) { + JSObject *wobj; + aobj = JSVAL_TO_OBJECT(v); - if (aobj && OBJ_IS_ARRAY(cx, aobj)) { + wobj = js_GetWrappedObject(cx, aobj); + if (aobj && OBJ_IS_ARRAY(cx, wobj)) { ok = OBJ_GET_PROPERTY(cx, aobj, ATOM_TO_JSID(cx->runtime->atomState .lengthAtom), diff --git a/js/src/jsgc.c b/js/src/jsgc.c index 46411b92a964..077a9183e5d3 100644 --- a/js/src/jsgc.c +++ b/js/src/jsgc.c @@ -2874,17 +2874,7 @@ ProcessSetSlotRequest(JSContext *cx, JSSetSlotRequest *ssr) slot = ssr->slot; while (pobj) { - JSClass *clasp = STOBJ_GET_CLASS(pobj); - if (clasp->flags & JSCLASS_IS_EXTENDED) { - JSExtendedClass *xclasp = (JSExtendedClass *) clasp; - if (xclasp->wrappedObject) { - /* If there is no wrapped object, use the wrapper. */ - JSObject *wrapped = xclasp->wrappedObject(cx, pobj); - if (wrapped) - pobj = wrapped; - } - } - + pobj = js_GetWrappedObject(cx, pobj); if (pobj == obj) { ssr->errnum = JSMSG_CYCLIC_VALUE; return; diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 873e91fdde04..4861296f6e96 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -1769,26 +1769,11 @@ js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval) !JSVAL_IS_NULL(lval) && !JSVAL_IS_NULL(rval)) { JSObject *lobj, *robj; - JSClass *lclasp, *rclasp; - lobj = JSVAL_TO_OBJECT(lval); - robj = JSVAL_TO_OBJECT(rval); - lclasp = OBJ_GET_CLASS(cx, lobj); - rclasp = OBJ_GET_CLASS(cx, robj); - if (lclasp->flags & JSCLASS_IS_EXTENDED) { - JSExtendedClass *xclasp = (JSExtendedClass *) lclasp; - if (xclasp->wrappedObject && - (lobj = xclasp->wrappedObject(cx, lobj))) { - lval = OBJECT_TO_JSVAL(lobj); - } - } - if (rclasp->flags & JSCLASS_IS_EXTENDED) { - JSExtendedClass *xclasp = (JSExtendedClass *) rclasp; - if (xclasp->wrappedObject && - (robj = xclasp->wrappedObject(cx, robj))) { - rval = OBJECT_TO_JSVAL(robj); - } - } + lobj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(lval)); + robj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(rval)); + lval = OBJECT_TO_JSVAL(lobj); + rval = OBJECT_TO_JSVAL(robj); } return lval == rval; } diff --git a/js/src/jsobj.c b/js/src/jsobj.c index f1f5e8f21628..c2541ea525ec 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -1010,25 +1010,14 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp) JSObject *obj; jschar *chars; size_t nchars; - JSClass *clasp; const char *clazz, *prefix; JSString *str; obj = JS_THIS_OBJECT(cx, vp); if (!obj) return JS_FALSE; - clasp = OBJ_GET_CLASS(cx, obj); - if (clasp->flags & JSCLASS_IS_EXTENDED) { - JSExtendedClass *xclasp; - JSObject *obj2; - - if ((xclasp = (JSExtendedClass *)clasp)->wrappedObject && - (obj2 = xclasp->wrappedObject(cx, obj))) { - obj = obj2; - clasp = OBJ_GET_CLASS(cx, obj); - } - } - clazz = clasp->name; + obj = js_GetWrappedObject(cx, obj); + clazz = OBJ_GET_CLASS(cx, obj)->name; nchars = 9 + strlen(clazz); /* 9 for "[object ]" */ chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar)); if (!chars) @@ -1174,16 +1163,10 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) * the former indirect case. */ scopeobj = OBJ_GET_PARENT(cx, obj); - if (scopeobj && - ((clasp = OBJ_GET_CLASS(cx, obj))->flags & JSCLASS_IS_EXTENDED)) { - JSExtendedClass *xclasp = (JSExtendedClass *) clasp; - if (xclasp->wrappedObject) { - JSObject *wrapped = xclasp->wrappedObject(cx, obj); - if (wrapped) - scopeobj = OBJ_GET_PARENT(cx, wrapped); - } + if (scopeobj) { + scopeobj = js_GetWrappedObject(cx, obj); + scopeobj = OBJ_GET_PARENT(cx, scopeobj); } - if (indirectCall || scopeobj) { uintN flags = scopeobj ? JSREPORT_ERROR @@ -5120,6 +5103,23 @@ js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v) return JS_TRUE; } +JSObject * +js_GetWrappedObject(JSContext *cx, JSObject *obj) +{ + JSClass *clasp; + + clasp = OBJ_GET_CLASS(cx, obj); + if (clasp->flags & JSCLASS_IS_EXTENDED) { + JSExtendedClass *xclasp; + JSObject *obj2; + + xclasp = (JSExtendedClass *)clasp; + if (xclasp->wrappedObject && (obj2 = xclasp->wrappedObject(cx, obj))) + return obj2; + } + return obj; +} + #ifdef DEBUG /* Routines to print out values during debugging. */ diff --git a/js/src/jsobj.h b/js/src/jsobj.h index b262602339b9..ba7506eb23a3 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -695,6 +695,10 @@ extern JSBool js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj, JSPrincipals *principals, JSAtom *caller); +/* Infallible -- returns its argument if there is no wrapped object. */ +extern JSObject * +js_GetWrappedObject(JSContext *cx, JSObject *obj); + JS_END_EXTERN_C #endif /* jsobj_h___ */ From be0a36e83377ee8422794f0bae24f67f211ece8b Mon Sep 17 00:00:00 2001 From: "mconnor@steelgryphon.com" Date: Thu, 6 Mar 2008 12:12:09 -0800 Subject: [PATCH 073/248] Bug 419967 - Cannot search in application/javascript page, r=gavin --- browser/base/content/browser.js | 4 ++++ toolkit/content/widgets/findbar.xml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index fb9f19ebcc5a..fd38e2642dfc 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3360,11 +3360,15 @@ var FullScreen = * * @param aMimeType * The MIME type to check. + * + * If adding types to this function, please also check the similar + * function in findbar.xml */ function mimeTypeIsTextBased(aMimeType) { return /^text\/|\+xml$/.test(aMimeType) || aMimeType == "application/x-javascript" || + aMimeType == "application/javascript" || aMimeType == "application/xml" || aMimeType == "mozilla.application/cached-xul"; } diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index cf4d2400cc80..b320bdd8b25c 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -910,12 +910,16 @@ - - @param aMimeType - The MIME type to check. + - + - if adding types to this function, please see the similar function + - in browser/base/content/browser.js --> From 827ac24e1e0fa362b362f26f1c3f52e8b01331a1 Mon Sep 17 00:00:00 2001 From: "bent.mozilla@gmail.com" Date: Thu, 6 Mar 2008 12:14:33 -0800 Subject: [PATCH 074/248] Bug 420700 - Calling createContextualFragment affects subsequent setting of innerHTML. r+sr=jst, a=blocking1.9+. --- content/base/public/nsContentUtils.h | 3 ++ content/base/src/nsContentUtils.cpp | 3 +- content/base/src/nsRange.cpp | 9 ++--- content/base/test/Makefile.in | 1 + content/base/test/test_bug420700.html | 36 +++++++++++++++++++ .../html/content/src/nsGenericHTMLElement.cpp | 1 + .../src/nsHTMLFragmentContentSink.cpp | 12 +++++-- .../document/src/nsXMLFragmentContentSink.cpp | 12 +++++-- .../public/nsIFragmentContentSink.h | 9 +++-- 9 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 content/base/test/test_bug420700.html diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 2548b3931dab..4abe2184c0af 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -901,10 +901,13 @@ public: * * @param aContextNode the node which is used to resolve namespaces * @param aFragment the string which is parsed to a DocumentFragment + * @param aWillOwnFragment is PR_TRUE if ownership of the fragment should be + * transferred to the caller. * @param aReturn [out] the created DocumentFragment */ static nsresult CreateContextualFragment(nsIDOMNode* aContextNode, const nsAString& aFragment, + PRBool aWillOwnFragment, nsIDOMDocumentFragment** aReturn); /** diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 8dcdb1562bed..0f3bcb40aaf3 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -3354,6 +3354,7 @@ nsContentUtils::IsValidNodeName(nsIAtom *aLocalName, nsIAtom *aPrefix, nsresult nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode, const nsAString& aFragment, + PRBool aWillOwnFragment, nsIDOMDocumentFragment** aReturn) { NS_ENSURE_ARG(aContextNode); @@ -3499,7 +3500,7 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode, rv = parser->ParseFragment(aFragment, nsnull, tagStack, !bHTML, contentType, mode); if (NS_SUCCEEDED(rv)) { - rv = sink->GetFragment(aReturn); + rv = sink->GetFragment(aWillOwnFragment, aReturn); } document->SetFragmentParser(parser); diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp index a45aa8d1882a..4973f2c4afff 100644 --- a/content/base/src/nsRange.cpp +++ b/content/base/src/nsRange.cpp @@ -1794,8 +1794,9 @@ nsRange::CreateContextualFragment(const nsAString& aFragment, nsIDOMDocumentFragment** aReturn) { nsCOMPtr start = do_QueryInterface(mStartParent); - return - mIsPositioned - ? nsContentUtils::CreateContextualFragment(start, aFragment, aReturn) - : NS_ERROR_FAILURE; + if (mIsPositioned) { + return nsContentUtils::CreateContextualFragment(start, aFragment, PR_TRUE, + aReturn); + } + return NS_ERROR_FAILURE; } diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 5db9184ae7ec..9a4757f03bdb 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -175,6 +175,7 @@ _TEST_FILES = test_bug5141.html \ test_bug417384.html \ test_bug418214.html \ test_bug420609.xhtml \ + test_bug420700.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/content/base/test/test_bug420700.html b/content/base/test/test_bug420700.html new file mode 100644 index 000000000000..da36a69e944d --- /dev/null +++ b/content/base/test/test_bug420700.html @@ -0,0 +1,36 @@ + + + + + Test for Bug 420700 + + + + + +Mozilla Bug 420700 +

+ +
+
+
+ + + diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 35eba5473435..990880c21f55 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -746,6 +746,7 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML) nsCOMPtr thisNode(do_QueryInterface(static_cast (this))); nsresult rv = nsContentUtils::CreateContextualFragment(thisNode, aInnerHTML, + PR_FALSE, getter_AddRefs(df)); if (NS_SUCCEEDED(rv)) { nsCOMPtr tmpNode; diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp index c11d436f5b84..8248631c70f5 100644 --- a/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -119,7 +119,8 @@ public: NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode); // nsIFragmentContentSink - NS_IMETHOD GetFragment(nsIDOMDocumentFragment** aFragment); + NS_IMETHOD GetFragment(PRBool aWillOwnFragment, + nsIDOMDocumentFragment** aFragment); NS_IMETHOD SetTargetDocument(nsIDocument* aDocument); NS_IMETHOD WillBuildContent(); NS_IMETHOD DidBuildContent(); @@ -608,10 +609,15 @@ nsHTMLFragmentContentSink::AddDocTypeDecl(const nsIParserNode& aNode) } NS_IMETHODIMP -nsHTMLFragmentContentSink::GetFragment(nsIDOMDocumentFragment** aFragment) +nsHTMLFragmentContentSink::GetFragment(PRBool aWillOwnFragment, + nsIDOMDocumentFragment** aFragment) { if (mRoot) { - return CallQueryInterface(mRoot, aFragment); + nsresult rv = CallQueryInterface(mRoot, aFragment); + if (NS_SUCCEEDED(rv) && aWillOwnFragment) { + mRoot = nsnull; + } + return rv; } *aFragment = nsnull; diff --git a/content/xml/document/src/nsXMLFragmentContentSink.cpp b/content/xml/document/src/nsXMLFragmentContentSink.cpp index 3e66cbe8e27d..463b5c4cf3f9 100644 --- a/content/xml/document/src/nsXMLFragmentContentSink.cpp +++ b/content/xml/document/src/nsXMLFragmentContentSink.cpp @@ -102,7 +102,8 @@ public: // nsIXMLContentSink // nsIFragmentContentSink - NS_IMETHOD GetFragment(nsIDOMDocumentFragment** aFragment); + NS_IMETHOD GetFragment(PRBool aWillOwnFragment, + nsIDOMDocumentFragment** aFragment); NS_IMETHOD SetTargetDocument(nsIDocument* aDocument); NS_IMETHOD WillBuildContent(); NS_IMETHOD DidBuildContent(); @@ -400,14 +401,19 @@ nsXMLFragmentContentSink::StartLayout() //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsXMLFragmentContentSink::GetFragment(nsIDOMDocumentFragment** aFragment) +nsXMLFragmentContentSink::GetFragment(PRBool aWillOwnFragment, + nsIDOMDocumentFragment** aFragment) { *aFragment = nsnull; if (mParseError) { //XXX PARSE_ERR from DOM3 Load and Save would be more appropriate return NS_ERROR_DOM_SYNTAX_ERR; } else if (mRoot) { - return CallQueryInterface(mRoot, aFragment); + nsresult rv = CallQueryInterface(mRoot, aFragment); + if (NS_SUCCEEDED(rv) && aWillOwnFragment) { + mRoot = nsnull; + } + return rv; } else { return NS_OK; } diff --git a/parser/htmlparser/public/nsIFragmentContentSink.h b/parser/htmlparser/public/nsIFragmentContentSink.h index 17d723fa1c75..0255f12e8947 100644 --- a/parser/htmlparser/public/nsIFragmentContentSink.h +++ b/parser/htmlparser/public/nsIFragmentContentSink.h @@ -43,8 +43,8 @@ class nsIDOMDocumentFragment; class nsIDocument; #define NS_I_FRAGMENT_CONTENT_SINK_IID \ - { 0x2cec7263, 0x9dd0, 0x4413, \ - { 0xb6, 0x68, 0x6f, 0xf0, 0xa1, 0x40, 0xc1, 0xbe } } + { 0x1ecdb30d, 0x1f10, 0x45d2, \ + { 0xa4, 0xf4, 0xec, 0xbc, 0x03, 0x52, 0x9a, 0x7e } } /** * The fragment sink allows a client to parse a fragment of sink, possibly @@ -60,8 +60,11 @@ public: * a fragment content sink. The value returned will be null * if the content sink hasn't yet received parser notifications. * + * If aWillOwnFragment is PR_TRUE then the sink should drop its + * ownership of the fragment. */ - NS_IMETHOD GetFragment(nsIDOMDocumentFragment** aFragment) = 0; + NS_IMETHOD GetFragment(PRBool aWillOwnFragment, + nsIDOMDocumentFragment** aFragment) = 0; /** * This method is used to set the target document for this fragment From 6af4d0b02190acccd03cfa736aa3033ed90310e4 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 12:16:42 -0800 Subject: [PATCH 075/248] Protect |accum| from being collected in js_ConcatStrings. bug 393874, r=igor a=beltzner --- js/src/jsparse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/src/jsparse.c b/js/src/jsparse.c index 367c283a958c..60b87c5298eb 100644 --- a/js/src/jsparse.c +++ b/js/src/jsparse.c @@ -6021,6 +6021,7 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) JSParseNode **pnp, *pn1, *pn2; JSString *accum, *str; uint32 i, j; + JSTempValueRooter tvr; JS_ASSERT(pn->pn_arity == PN_LIST); tt = PN_TYPE(pn); @@ -6034,6 +6035,13 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) accum = ATOM_TO_STRING(cx->runtime->atomState.stagoAtom); } + /* + * GC Rooting here is tricky: for most of the loop, |accum| is safe via + * the newborn string root. However, when |pn2->pn_type| is TOK_XMLCDATA, + * TOK_XMLCOMMENT, or TOK_XMLPI it is knocked out of the newborn root. + * Therefore, we have to add additonal protection from GC nesting under + * js_ConcatStrings. + */ for (pn2 = pn1, i = j = 0; pn2; pn2 = pn2->pn_next, i++) { /* The parser already rejected end-tags with attributes. */ JS_ASSERT(tt != TOK_XMLETAGO || i == 0); @@ -6104,9 +6112,11 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc) } if (accum) { + JS_PUSH_TEMP_ROOT_STRING(cx, accum, &tvr); str = ((tt == TOK_XMLSTAGO || tt == TOK_XMLPTAGC) && i != 0) ? js_AddAttributePart(cx, i & 1, accum, str) : js_ConcatStrings(cx, accum, str); + JS_POP_TEMP_ROOT(cx, &tvr); if (!str) return JS_FALSE; #ifdef DEBUG_brendanXXX From c6c04d842e403e93456f4810f0ae9eeb903554a7 Mon Sep 17 00:00:00 2001 From: "jst@mozilla.org" Date: Thu, 6 Mar 2008 12:20:42 -0800 Subject: [PATCH 076/248] Fixing bug 396443. Make SVG documents act like all our other documents wrt enumeration hooks. r+sr=mrbkap@gmail.com --- dom/src/base/nsDOMClassInfo.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index 3816a0f53d25..8751722146b1 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -496,6 +496,7 @@ static const char kDOMStringBundleURL[] = nsIXPCScriptable::WANT_ADDPROPERTY | \ nsIXPCScriptable::WANT_DELPROPERTY | \ nsIXPCScriptable::WANT_GETPROPERTY | \ + nsIXPCScriptable::WANT_ENUMERATE | \ nsIXPCScriptable::WANT_POSTCREATE | \ nsIXPCScriptable::WANT_FINALIZE) @@ -593,8 +594,7 @@ static nsDOMClassInfoData sClassInfoData[] = { // Core classes NS_DEFINE_CLASSINFO_DATA(XMLDocument, nsDocumentSH, - DOCUMENT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_ENUMERATE) + DOCUMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(DocumentType, nsNodeSH, NODE_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(DOMImplementation, nsDOMGenericSH, @@ -642,8 +642,7 @@ static nsDOMClassInfoData sClassInfoData[] = { // Misc HTML classes NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH, - DOCUMENT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_ENUMERATE) + DOCUMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection, nsHTMLOptionsCollectionSH, ARRAY_SCRIPTABLE_FLAGS | @@ -813,8 +812,7 @@ static nsDOMClassInfoData sClassInfoData[] = { // XUL classes #ifdef MOZ_XUL NS_DEFINE_CLASSINFO_DATA(XULDocument, nsDocumentSH, - DOCUMENT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_ENUMERATE) + DOCUMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH, @@ -872,8 +870,7 @@ static nsDOMClassInfoData sClassInfoData[] = { NODE_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(ImageDocument, nsHTMLDocumentSH, - DOCUMENT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_ENUMERATE) + DOCUMENT_SCRIPTABLE_FLAGS) #ifdef MOZ_XUL NS_DEFINE_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH, @@ -3740,18 +3737,20 @@ NS_IMETHODIMP nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, PRBool *_retval) { - if (!sSecMan) +#ifdef DEBUG + if (!sSecMan) { + NS_ERROR("No security manager!!!"); return NS_OK; + } // Ask the security manager if it's OK to enumerate nsresult rv = sSecMan->CheckPropertyAccess(cx, obj, mData->mName, sEnumerate_id, nsIXPCSecurityManager::ACCESS_GET_PROPERTY); - if (NS_FAILED(rv)) { - // Let XPConnect know that the access was not granted. - *_retval = PR_FALSE; - } + NS_ASSERTION(NS_SUCCEEDED(rv), + "XOWs should have stopped us from getting here!!!"); +#endif return NS_OK; } From c9d085b470eb5e8894e256753381982c304a3e56 Mon Sep 17 00:00:00 2001 From: "bent.mozilla@gmail.com" Date: Thu, 6 Mar 2008 12:35:42 -0800 Subject: [PATCH 077/248] Bug 420700 - Bustage fix. --- editor/libeditor/html/nsHTMLDataTransfer.cpp | 2 +- toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index 5cb082d753d2..fd24b6fd1c49 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -2643,7 +2643,7 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr, parser->ParseFragment(aFragStr, 0, aTagStack, PR_FALSE, NS_LITERAL_CSTRING("text/html"), eDTDMode_quirks); // get the fragment node nsCOMPtr contextfrag; - res = fragSink->GetFragment(getter_AddRefs(contextfrag)); + res = fragSink->GetFragment(PR_TRUE, getter_AddRefs(contextfrag)); NS_ENSURE_SUCCESS(res, res); *outNode = do_QueryInterface(contextfrag); diff --git a/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp b/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp index 9faf63555cfe..e1b19da5e906 100644 --- a/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp +++ b/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp @@ -198,7 +198,7 @@ nsScriptableUnescapeHTML::ParseFragment(const nsAString &aFragment, rv = parser->ParseFragment(aFragment, nsnull, tagStack, aIsXML, contentType, mode); if (NS_SUCCEEDED(rv)) - rv = sink->GetFragment(aReturn); + rv = sink->GetFragment(PR_TRUE, aReturn); } else { rv = NS_ERROR_FAILURE; From 402deb1b768eabe0204c93546dbc701cf6f9e542 Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Thu, 6 Mar 2008 12:56:47 -0800 Subject: [PATCH 078/248] b=420325, menu item hover/cursor confusion, undoing my previous brokenness; r=enn --- widget/src/windows/nsNativeThemeWin.cpp | 11 +++++------ widget/src/windows/nsNativeThemeWin.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 97b4a60c9476..4eb7187add8b 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -623,10 +623,9 @@ nsNativeThemeWin::StandardGetState(nsIFrame* aFrame, PRUint8 aWidgetType, } PRBool -nsNativeThemeWin::IsMenuActiveOrHover(nsIFrame *aFrame, PRUint8 aWidgetType) +nsNativeThemeWin::IsMenuActive(nsIFrame *aFrame, PRUint8 aWidgetType) { - return CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive) || - (GetContentState(aFrame, aWidgetType) & NS_EVENT_STATE_HOVER) != 0; + return CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive); } nsresult @@ -1112,7 +1111,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, if (menuFrame) isOpen = menuFrame->IsOpen(); - isHover = IsMenuActiveOrHover(aFrame, aWidgetType); + isHover = IsMenuActive(aFrame, aWidgetType); if (isTopLevel) { aPart = MENU_BARITEM; @@ -2294,7 +2293,7 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 aState |= DFCS_PUSHED; } - if (IsMenuActiveOrHover(aFrame, aWidgetType)) + if (IsMenuActive(aFrame, aWidgetType)) aState |= DFCS_HOT; return NS_OK; @@ -2305,7 +2304,7 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 aState = 0; if (IsDisabled(aFrame)) aState |= DFCS_INACTIVE; - if (IsMenuActiveOrHover(aFrame, aWidgetType)) + if (IsMenuActive(aFrame, aWidgetType)) aState |= DFCS_HOT; if (aWidgetType == NS_THEME_MENUCHECKBOX || aWidgetType == NS_THEME_MENURADIO) { diff --git a/widget/src/windows/nsNativeThemeWin.h b/widget/src/windows/nsNativeThemeWin.h index a2f035ea2c4d..aa4b60351247 100644 --- a/widget/src/windows/nsNativeThemeWin.h +++ b/widget/src/windows/nsNativeThemeWin.h @@ -127,7 +127,7 @@ protected: PRInt32 StandardGetState(nsIFrame* aFrame, PRUint8 aWidgetType, PRBool wantFocused); - PRBool IsMenuActiveOrHover(nsIFrame* aFrame, PRUint8 aWidgetType); + PRBool IsMenuActive(nsIFrame* aFrame, PRUint8 aWidgetType); private: HMODULE mThemeDLL; From 5c67b33f61ea1b4ce48cd3fe1e82bc1e73a4349c Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Thu, 6 Mar 2008 13:40:43 -0800 Subject: [PATCH 079/248] bug=415455 r=brendan a1.9=blocking1.9 --- js/src/jsapi.c | 18 +++++++--- js/src/jsarray.c | 7 ++-- js/src/jsexn.c | 13 +++++--- js/src/jsfun.c | 7 ++-- js/src/jsinterp.c | 84 +++++++++++++++++++++++++++++++---------------- js/src/jsnum.c | 77 ++++++++++++++++++++++++++++++++----------- js/src/jsnum.h | 23 ++++++++----- js/src/jsscript.c | 14 +++++--- js/src/jsxml.c | 2 +- 9 files changed, 168 insertions(+), 77 deletions(-) diff --git a/js/src/jsapi.c b/js/src/jsapi.c index b0baa0bfd821..6abdee6c1200 100644 --- a/js/src/jsapi.c +++ b/js/src/jsapi.c @@ -207,11 +207,11 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, return JS_FALSE; break; case 'i': - if (!js_ValueToECMAInt32(cx, *sp, va_arg(ap, int32 *))) + if (!JS_ValueToECMAInt32(cx, *sp, va_arg(ap, int32 *))) return JS_FALSE; break; case 'u': - if (!js_ValueToECMAUint32(cx, *sp, va_arg(ap, uint32 *))) + if (!JS_ValueToECMAUint32(cx, *sp, va_arg(ap, uint32 *))) return JS_FALSE; break; case 'j': @@ -548,15 +548,25 @@ JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp) JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip) { + JSTempValueRooter tvr; + CHECK_REQUEST(cx); - return js_ValueToECMAInt32(cx, v, ip); + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + *ip = js_ValueToECMAInt32(cx, &tvr.u.value); + JS_POP_TEMP_ROOT(cx, &tvr); + return tvr.u.value != JSVAL_NULL; } JS_PUBLIC_API(JSBool) JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip) { + JSTempValueRooter tvr; + CHECK_REQUEST(cx); - return js_ValueToECMAUint32(cx, v, ip); + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + *ip = js_ValueToECMAUint32(cx, &tvr.u.value); + JS_POP_TEMP_ROOT(cx, &tvr); + return tvr.u.value != JSVAL_NULL; } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsarray.c b/js/src/jsarray.c index 28dd426ea59b..862357fcd807 100644 --- a/js/src/jsarray.c +++ b/js/src/jsarray.c @@ -234,15 +234,12 @@ js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp) id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom); ok = OBJ_GET_PROPERTY(cx, obj, id, &tvr.u.value); if (ok) { - /* - * Short-circuit, because js_ValueToECMAUint32 fails when called - * during init time. - */ if (JSVAL_IS_INT(tvr.u.value)) { i = JSVAL_TO_INT(tvr.u.value); *lengthp = (jsuint)i; /* jsuint cast does ToUint32 */ } else { - ok = js_ValueToECMAUint32(cx, tvr.u.value, (uint32 *)lengthp); + *lengthp = js_ValueToECMAUint32(cx, &tvr.u.value); + ok = (tvr.u.value != JSVAL_NULL); } } JS_POP_TEMP_ROOT(cx, &tvr); diff --git a/js/src/jsexn.c b/js/src/jsexn.c index 087070c299d1..c812f1588ca9 100644 --- a/js/src/jsexn.c +++ b/js/src/jsexn.c @@ -793,7 +793,8 @@ Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) /* Set the 'lineNumber' property. */ if (argc > 2) { - if (!js_ValueToECMAUint32(cx, argv[2], &lineno)) + lineno = js_ValueToECMAUint32(cx, &argv[2]); + if (argv[2] == JSVAL_NULL) return JS_FALSE; } else { if (!fp) @@ -909,8 +910,11 @@ exn_toSource(JSContext *cx, uintN argc, jsval *vp) goto out; localroots[1] = STRING_TO_JSVAL(filename); - ok = JS_GetProperty(cx, obj, js_lineNumber_str, &localroots[2]) && - js_ValueToECMAUint32 (cx, localroots[2], &lineno); + ok = JS_GetProperty(cx, obj, js_lineNumber_str, &localroots[2]); + if (!ok) + goto out; + lineno = js_ValueToECMAUint32 (cx, &localroots[2]); + ok = (localroots[2] != JSVAL_NULL); if (!ok) goto out; @@ -1339,7 +1343,8 @@ js_ReportUncaughtException(JSContext *cx) ok = JS_GetProperty(cx, exnObject, js_lineNumber_str, &roots[4]); if (!ok) goto out; - ok = js_ValueToECMAUint32 (cx, roots[4], &lineno); + lineno = js_ValueToECMAUint32 (cx, &roots[4]); + ok = (roots[4] != JSVAL_NULL); if (!ok) goto out; diff --git a/js/src/jsfun.c b/js/src/jsfun.c index 19ec4f3dc19a..a584e62374e9 100644 --- a/js/src/jsfun.c +++ b/js/src/jsfun.c @@ -1454,8 +1454,11 @@ fun_toStringHelper(JSContext *cx, uint32 indent, uintN argc, jsval *vp) } obj = JSVAL_TO_OBJECT(fval); - if (argc != 0 && !js_ValueToECMAUint32(cx, vp[2], &indent)) - return JS_FALSE; + if (argc != 0) { + indent = js_ValueToECMAUint32(cx, &vp[2]); + if (vp[2] == JSVAL_NULL) + return JS_FALSE; + } JS_ASSERT(JS_ObjectIsFunction(cx, obj)); fun = GET_FUNCTION_PRIVATE(cx, obj); diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 4861296f6e96..21374b86fd02 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -2222,44 +2222,36 @@ js_DumpOpMeters() #define STORE_NUMBER(cx, n, d) \ JS_BEGIN_MACRO \ jsint i_; \ - jsval v_; \ \ if (JSDOUBLE_IS_INT(d, i_) && INT_FITS_IN_JSVAL(i_)) { \ - v_ = INT_TO_JSVAL(i_); \ + sp[n] = INT_TO_JSVAL(i_); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_NewDoubleValue(cx, d, &v_)) \ + if (!js_NewDoubleValue(cx, d, &sp[n])) \ goto error; \ } \ - STORE_OPND(n, v_); \ JS_END_MACRO #define STORE_INT(cx, n, i) \ JS_BEGIN_MACRO \ - jsval v_; \ - \ if (INT_FITS_IN_JSVAL(i)) { \ - v_ = INT_TO_JSVAL(i); \ + sp[n] = INT_TO_JSVAL(i); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_NewDoubleValue(cx, (jsdouble)(i), &v_)) \ + if (!js_NewDoubleValue(cx, (jsdouble)(i), &sp[n])) \ goto error; \ } \ - STORE_OPND(n, v_); \ JS_END_MACRO #define STORE_UINT(cx, n, u) \ JS_BEGIN_MACRO \ - jsval v_; \ - \ if ((u) <= JSVAL_INT_MAX) { \ - v_ = INT_TO_JSVAL(u); \ + sp[n] = INT_TO_JSVAL(u); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_NewDoubleValue(cx, (jsdouble)(u), &v_)) \ + if (!js_NewDoubleValue(cx, (jsdouble)(u), &sp[n])) \ goto error; \ } \ - STORE_OPND(n, v_); \ JS_END_MACRO #define FETCH_NUMBER(cx, n, d) \ @@ -2272,25 +2264,30 @@ js_DumpOpMeters() #define FETCH_INT(cx, n, i) \ JS_BEGIN_MACRO \ - jsval v_ = FETCH_OPND(n); \ + jsval v_; \ + \ + v_= FETCH_OPND(n); \ if (JSVAL_IS_INT(v_)) { \ i = JSVAL_TO_INT(v_); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_ValueToECMAInt32(cx, v_, &i)) \ + i = js_ValueToECMAInt32(cx, &sp[n]); \ + if (sp[n] == JSVAL_NULL) \ goto error; \ } \ JS_END_MACRO #define FETCH_UINT(cx, n, ui) \ JS_BEGIN_MACRO \ - jsval v_ = FETCH_OPND(n); \ - jsint i_; \ - if (JSVAL_IS_INT(v_) && (i_ = JSVAL_TO_INT(v_)) >= 0) { \ - ui = (uint32) i_; \ + jsval v_; \ + \ + v_= FETCH_OPND(n); \ + if (JSVAL_IS_INT(v_)) { \ + ui = (uint32) JSVAL_TO_INT(v_); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_ValueToECMAUint32(cx, v_, &ui)) \ + ui = js_ValueToECMAUint32(cx, &sp[n]); \ + if (sp[n] == JSVAL_NULL) \ goto error; \ } \ JS_END_MACRO @@ -2449,6 +2446,10 @@ JS_STATIC_ASSERT(JSOP_SETNAME_LENGTH == JSOP_SETPROP_LENGTH); /* Ensure we can share deffun and closure code. */ JS_STATIC_ASSERT(JSOP_DEFFUN_LENGTH == JSOP_CLOSURE_LENGTH); + +/* See comments in FETCH_SHIFT macro. */ +JS_STATIC_ASSERT((JSVAL_TO_INT(JSVAL_VOID) & 31) == 0); + JSBool js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) { @@ -3403,19 +3404,15 @@ interrupt: PUSH_OPND(OBJECT_TO_JSVAL(obj)); END_CASE(JSOP_BINDNAME) -#define INTEGER_OP(OP, EXTRA_CODE) \ +#define BITWISE_OP(OP) \ JS_BEGIN_MACRO \ FETCH_INT(cx, -2, i); \ FETCH_INT(cx, -1, j); \ - EXTRA_CODE \ i = i OP j; \ sp--; \ STORE_INT(cx, -1, i); \ JS_END_MACRO -#define BITWISE_OP(OP) INTEGER_OP(OP, (void) 0;) -#define SIGNED_SHIFT_OP(OP) INTEGER_OP(OP, j &= 31;) - BEGIN_CASE(JSOP_BITOR) BITWISE_OP(|); END_CASE(JSOP_BITOR) @@ -3618,6 +3615,36 @@ interrupt: #undef EQUALITY_OP #undef RELATIONAL_OP +/* + * We do not check for JSVAL_VOID here since ToInt32(undefined) == 0 + * and (JSVAL_TO_INT(JSVAL_VOID) & 31) == 0. The static assert before + * js_Interpret ensures this. + */ +#define FETCH_SHIFT(shift) \ + JS_BEGIN_MACRO \ + jsval v_; \ + \ + v_ = FETCH_OPND(-1); \ + if (v_ & JSVAL_INT) { \ + shift = JSVAL_TO_INT(v_); \ + } else { \ + SAVE_SP_AND_PC(fp); \ + shift = js_ValueToECMAInt32(cx, &sp[-1]); \ + if (sp[-1] == JSVAL_NULL) \ + goto error; \ + } \ + shift &= 31; \ + JS_END_MACRO + +#define SIGNED_SHIFT_OP(OP) \ + JS_BEGIN_MACRO \ + FETCH_INT(cx, -2, i); \ + FETCH_SHIFT(j); \ + i = i OP j; \ + sp--; \ + STORE_INT(cx, -1, i); \ + JS_END_MACRO + BEGIN_CASE(JSOP_LSH) SIGNED_SHIFT_OP(<<); END_CASE(JSOP_LSH) @@ -3631,14 +3658,13 @@ interrupt: uint32 u; FETCH_UINT(cx, -2, u); - FETCH_INT(cx, -1, j); - u >>= j & 31; + FETCH_SHIFT(j); + u >>= j; sp--; STORE_UINT(cx, -1, u); } END_CASE(JSOP_URSH) -#undef INTEGER_OP #undef BITWISE_OP #undef SIGNED_SHIFT_OP diff --git a/js/src/jsnum.c b/js/src/jsnum.c index 94018b1daf7b..83f10b0ff906 100644 --- a/js/src/jsnum.c +++ b/js/src/jsnum.c @@ -118,7 +118,8 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp) const jschar *bp, *end, *ep; if (argc > 1) { - if (!js_ValueToECMAInt32(cx, vp[3], &radix)) + radix = js_ValueToECMAInt32(cx, &vp[3]); + if (vp[3] == JSVAL_NULL) return JS_FALSE; } else { radix = 0; @@ -262,7 +263,8 @@ num_toString(JSContext *cx, uintN argc, jsval *vp) d = JSVAL_IS_INT(v) ? (jsdouble)JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v); base = 10; if (argc != 0 && !JSVAL_IS_VOID(vp[2])) { - if (!js_ValueToECMAInt32(cx, vp[2], &base)) + base = js_ValueToECMAInt32(cx, &vp[2]); + if (vp[2] == JSVAL_NULL) return JS_FALSE; if (base < 2 || base > 36) { char numBuf[12]; @@ -771,55 +773,92 @@ badstr: return JS_TRUE; } -JSBool -js_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip) +int32 +js_ValueToECMAInt32(JSContext *cx, jsval *vp) { + jsval v; jsdouble d; - if (!js_ValueToNumber(cx, v, &d)) - return JS_FALSE; - *ip = js_DoubleToECMAInt32(d); - return JS_TRUE; + v = *vp; + if (JSVAL_IS_INT(v)) + return JSVAL_TO_INT(v); + if (JSVAL_IS_DOUBLE(v)) { + d = *JSVAL_TO_DOUBLE(v); + } else { + if (!js_ValueToNumber(cx, v, &d)) { + *vp = JSVAL_NULL; + return 0; + } + *vp = JSVAL_ZERO; + } + return js_DoubleToECMAInt32(d); } int32 js_DoubleToECMAInt32(jsdouble d) { - jsdouble two32 = 4294967296.0; - jsdouble two31 = 2147483648.0; + int32 i; + jsdouble two32, two31; - if (!JSDOUBLE_IS_FINITE(d) || d == 0) + if (!JSDOUBLE_IS_FINITE(d)) return 0; + i = (int32) d; + if ((jsdouble) i == d) + return i; + + two32 = 4294967296.0; + two31 = 2147483648.0; d = fmod(d, two32); d = (d >= 0) ? floor(d) : ceil(d) + two32; return (int32) (d >= two31 ? d - two32 : d); } -JSBool -js_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip) +uint32 +js_ValueToECMAUint32(JSContext *cx, jsval *vp) { + jsval v; jsdouble d; - if (!js_ValueToNumber(cx, v, &d)) - return JS_FALSE; - *ip = js_DoubleToECMAUint32(d); - return JS_TRUE; + v = *vp; + if (JSVAL_IS_INT(v)) + return (uint32) JSVAL_TO_INT(v); + if (JSVAL_IS_DOUBLE(v)) { + d = *JSVAL_TO_DOUBLE(v); + } else { + if (!js_ValueToNumber(cx, v, &d)) { + *vp = JSVAL_NULL; + return 0; + } + *vp = JSVAL_ZERO; + } + return js_DoubleToECMAUint32(d); } uint32 js_DoubleToECMAUint32(jsdouble d) { + int32 i; JSBool neg; - jsdouble two32 = 4294967296.0; + jsdouble two32; - if (!JSDOUBLE_IS_FINITE(d) || d == 0) + if (!JSDOUBLE_IS_FINITE(d)) return 0; + /* + * We check whether d fits int32, not uint32, as all but the ">>>" bit + * manipulation bytecode stores the result as int, not uint. When the + * result does not fit int jsval, it will be stored as a negative double. + */ + i = (int32) d; + if ((jsdouble) i == d) + return (int32)i; + neg = (d < 0); d = floor(neg ? -d : d); d = neg ? -d : d; + two32 = 4294967296.0; d = fmod(d, two32); return (uint32) (d >= 0 ? d : d + two32); diff --git a/js/src/jsnum.h b/js/src/jsnum.h index d26af33b7f52..e4e0924ed4b7 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -204,24 +204,29 @@ extern JSBool js_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp); /* - * Convert a value or a double to an int32, according to the ECMA rules - * for ToInt32. + * Convert a value to an int32 or uint32, according to the ECMA rules for + * ToInt32 and ToUint32. On failure the functions sets *vp to JSVAL_NULL. Any + * other value in *vp on exit indicates a success. */ -extern JSBool -js_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip); +extern int32 +js_ValueToECMAInt32(JSContext *cx, jsval *vp); +extern uint32 +js_ValueToECMAUint32(JSContext *cx, jsval *vp); + +/* + * Specialized ToInt32 and ToUint32 converters for doubles. + */ extern int32 js_DoubleToECMAInt32(jsdouble d); +extern uint32 +js_DoubleToECMAUint32(jsdouble d); + /* * Convert a value or a double to a uint32, according to the ECMA rules * for ToUint32. */ -extern JSBool -js_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip); - -extern uint32 -js_DoubleToECMAUint32(jsdouble d); /* * Convert a value to a number, then to an int32 if it fits by rounding to diff --git a/js/src/jsscript.c b/js/src/jsscript.c index 7e9549f60dab..7dc9dbc50bee 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -110,8 +110,11 @@ script_toSource(JSContext *cx, uintN argc, jsval *vp) return JS_FALSE; indent = 0; - if (argc != 0 && !js_ValueToECMAUint32(cx, vp[2], &indent)) - return JS_FALSE; + if (argc != 0) { + indent = js_ValueToECMAUint32(cx, &vp[2]); + if (vp[2] == JSVAL_NULL) + return JS_FALSE; + } script = (JSScript *) JS_GetPrivate(cx, obj); @@ -166,8 +169,11 @@ script_toString(JSContext *cx, uintN argc, jsval *vp) JSString *str; indent = 0; - if (argc != 0 && !js_ValueToECMAUint32(cx, vp[2], &indent)) - return JS_FALSE; + if (argc != 0) { + indent = js_ValueToECMAUint32(cx, &vp[2]); + if (vp[2] == JSVAL_NULL) + return JS_FALSE; + } obj = JS_THIS_OBJECT(cx, vp); if (!JS_InstanceOf(cx, obj, &js_ScriptClass, vp + 2)) diff --git a/js/src/jsxml.c b/js/src/jsxml.c index 21db0439736f..0937e5c0c617 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -1932,7 +1932,7 @@ GetUint32XMLSetting(JSContext *cx, const char *name, uint32 *uip) { jsval v; - return GetXMLSetting(cx, name, &v) && js_ValueToECMAUint32(cx, v, uip); + return GetXMLSetting(cx, name, &v) && JS_ValueToECMAUint32(cx, v, uip); } static JSBool From 63917f381deffca20d4f470828ef201e243f098f Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 13:43:26 -0800 Subject: [PATCH 080/248] Remove unused variable. bug 420966 --- js/src/jsobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/js/src/jsobj.c b/js/src/jsobj.c index c2541ea525ec..5909075bab50 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -1139,7 +1139,6 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) JSStackFrame *fp, *caller; JSBool indirectCall; JSObject *scopeobj; - JSClass *clasp; JSString *str; const char *file; uintN line; From a0ed2b812858a0f48431b3c8c7ba25caa4cd8545 Mon Sep 17 00:00:00 2001 From: "enndeakin@sympatico.ca" Date: Thu, 6 Mar 2008 13:43:43 -0800 Subject: [PATCH 081/248] Bug 419725, hovering over autocomplete entry then opening the context menu selects the text, fix by not selecting text during the focus event, r=mconnor --- toolkit/content/widgets/autocomplete.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index 0c5598a1152e..9131adf59a36 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -537,9 +537,6 @@ - -
@@ -873,8 +870,11 @@ this._normalMaxRows = -1; // If the list was being navigated and then closed, make sure // we fire accessible focus event back to textbox - if (isListActive) + if (isListActive) { + this.mInput.mIgnoreFocus = true; this.mInput._focus(); + this.mInput.mIgnoreFocus = false; + } ]]> From 22ce9740ca802e3b4e871ec40d841c94a380ace6 Mon Sep 17 00:00:00 2001 From: "karlt+@karlt.net" Date: Thu, 6 Mar 2008 13:59:03 -0800 Subject: [PATCH 082/248] =?UTF-8?q?Bug=20416549=20-=20MathML=20does=20not?= =?UTF-8?q?=20render=20properly=20with=20text-align:justify.=20Patch=20by?= =?UTF-8?q?=20Fr=C3=A9d=C3=A9ric=20WANG=20,=20r=3Dkarlt?= =?UTF-8?q?,=20sr=3Droc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/mathml/content/src/mathml.css | 1 + 1 file changed, 1 insertion(+) diff --git a/layout/mathml/content/src/mathml.css b/layout/mathml/content/src/mathml.css index 89600ce3bb85..30416d9ce52d 100644 --- a/layout/mathml/content/src/mathml.css +++ b/layout/mathml/content/src/mathml.css @@ -409,6 +409,7 @@ semantics > :not(:first-child) { *|*::-moz-mathml-anonymous-block { display: inline-block !important; position: static !important; + text-indent: 0; } /*****************************************/ From 2ad4b8c4f36991c1ccd1f562dc9fda2b8ae5c8ce Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Thu, 6 Mar 2008 14:03:55 -0800 Subject: [PATCH 083/248] typo fix --- content/canvas/src/nsCanvasRenderingContext2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index f77f7d8369c1..aacf9bbad60d 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -442,7 +442,7 @@ protected: FINISH: if (perDevPixel) *perDevPixel = devPixel; - if (cssPixel) + if (perCSSPixel) *perCSSPixel = cssPixel; } }; From 6620201b36ec1dc60bef6bdda60e37a5a527efa6 Mon Sep 17 00:00:00 2001 From: "karlt+@karlt.net" Date: Thu, 6 Mar 2008 14:21:07 -0800 Subject: [PATCH 084/248] Don't try to Place() invisible operators. b=420420 r+sr=roc a=beltzner --- layout/mathml/base/src/nsMathMLmoFrame.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/layout/mathml/base/src/nsMathMLmoFrame.cpp b/layout/mathml/base/src/nsMathMLmoFrame.cpp index 176dc4fcb3a8..84a792163a4e 100644 --- a/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -758,12 +758,15 @@ nsMathMLmoFrame::Stretch(nsIRenderingContext& aRenderingContext, } } - // Place our children using the default method - // This will allow our child text frame to get its DidReflow() - nsresult rv = Place(aRenderingContext, PR_TRUE, aDesiredStretchSize); - if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { - // Make sure the child frames get their DidReflow() calls. - DidReflowChildren(mFrames.FirstChild()); + // Child frames of invisble operators are not reflowed + if (!NS_MATHML_OPERATOR_IS_INVISIBLE(mFlags)) { + // Place our children using the default method + // This will allow our child text frame to get its DidReflow() + nsresult rv = Place(aRenderingContext, PR_TRUE, aDesiredStretchSize); + if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { + // Make sure the child frames get their DidReflow() calls. + DidReflowChildren(mFrames.FirstChild()); + } } if (useMathMLChar) { From fbedac71343112b8da3d33bac3e1ba7b6010d0f3 Mon Sep 17 00:00:00 2001 From: "myk@mozilla.org" Date: Thu, 6 Mar 2008 14:39:41 -0800 Subject: [PATCH 085/248] bug 421190: report exceptions in progress listeners; followup to fix for bug 376222; r=gavin,a=beltzner --- browser/base/content/tabbrowser.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index cae3012c231e..1032790fd763 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -303,6 +303,7 @@ aCurTotalProgress, aMaxTotalProgress); } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } @@ -411,6 +412,7 @@ p.onUpdateCurrentBrowser(aStateFlags, aStatus, "", 0); } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } @@ -446,6 +448,7 @@ p.onLocationChange(aWebProgress, aRequest, aLocation); } catch (e) { // don't inhibit other listeners + Components.utils.reportError(e); } } } @@ -464,6 +467,7 @@ p.onStatusChange(aWebProgress, aRequest, aStatus, aMessage); } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } @@ -481,6 +485,7 @@ p.onSecurityChange(aWebProgress, aRequest, aState); } catch (e) { // don't inhibit other listeners + Components.utils.reportError(e); } } } @@ -497,6 +502,7 @@ allowRefresh = false; } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } @@ -544,6 +550,7 @@ p.onLinkIconAvailable(browser); } catch (e) { // don't inhibit other listeners + Components.utils.reportError(e); } } ]]> @@ -781,6 +788,7 @@ } } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } @@ -802,6 +810,7 @@ p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_START | nsIWebProgressListener.STATE_IS_NETWORK, 0); } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } @@ -818,6 +827,7 @@ p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0); } catch (e) { // don't inhibit other listeners or following code + Components.utils.reportError(e); } } } From 833ed276baa06e844257534c20ba6b203d95fc81 Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Thu, 6 Mar 2008 14:47:46 -0800 Subject: [PATCH 086/248] bug=421266 r=brendan a1.9=beltzner js_Interpret now takes just single cx argument. --- js/src/jsinterp.c | 91 +++++++++++++++++++++++------------------------ js/src/jsinterp.h | 2 +- js/src/jsiter.c | 19 ++++------ 3 files changed, 52 insertions(+), 60 deletions(-) diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 21374b86fd02..eff7b4749954 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -1288,7 +1288,7 @@ have_fun: goto out; } } - ok = js_Interpret(cx, script->code, &v); + ok = js_Interpret(cx); } else { /* fun might be onerror trying to report a syntax error in itself. */ frame.scopeChain = NULL; @@ -1512,11 +1512,7 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script, cx->debugHooks->executeHookData); } - /* - * Use frame.rval, not result, so the last result stays rooted across any - * GC activations nested within this js_Interpret. - */ - ok = js_Interpret(cx, script->code, &frame.rval); + ok = js_Interpret(cx); *result = frame.rval; if (hookData) { @@ -2451,20 +2447,21 @@ JS_STATIC_ASSERT(JSOP_DEFFUN_LENGTH == JSOP_CLOSURE_LENGTH); JS_STATIC_ASSERT((JSVAL_TO_INT(JSVAL_VOID) & 31) == 0); JSBool -js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) +js_Interpret(JSContext *cx) { JSRuntime *rt; JSStackFrame *fp; JSScript *script; uintN inlineCallCount; JSAtom **atoms; - JSObject *obj, *obj2, *parent; JSVersion currentVersion, originalVersion; + void *mark; + jsval *sp; + jsbytecode *pc; + JSObject *obj, *obj2, *parent; JSBool ok, cond; JSTrapHandler interruptHandler; jsint len; - jsval *sp; - void *mark; jsbytecode *endpc, *pc2; JSOp op, op2; jsatomid index; @@ -2541,7 +2538,6 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) /* Check for too deep a C stack. */ JS_CHECK_RECURSION(cx, return JS_FALSE); - *result = JSVAL_VOID; rt = cx->runtime; /* Set registerized frame pointer and derived script pointer. */ @@ -2593,27 +2589,6 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) } \ JS_END_MACRO - /* - * Load the debugger's interrupt hook here and after calling out to native - * functions (but not to getters, setters, or other native hooks), so we do - * not have to reload it each time through the interpreter loop -- we hope - * the compiler can keep it in a register when it is non-null. - */ -#if JS_THREADED_INTERP -# define LOAD_JUMP_TABLE() \ - (jumpTable = interruptHandler ? interruptJumpTable : normalJumpTable) -#else -# define LOAD_JUMP_TABLE() /* nothing */ -#endif - -#define LOAD_INTERRUPT_HANDLER(cx) \ - JS_BEGIN_MACRO \ - interruptHandler = (cx)->debugHooks->interruptHandler; \ - LOAD_JUMP_TABLE(); \ - JS_END_MACRO - - LOAD_INTERRUPT_HANDLER(cx); - /* * Optimized Get and SetVersion for proper script language versioning. * @@ -2633,27 +2608,53 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result) fp->pcDisabledSave = JS_PROPERTY_CACHE(cx).disabled; #endif - /* From this point the control must flow through the label exit. + /* + * From this point the control must flow through the label exit. * - * Allocate operand stack slots for the script's worst-case depth, unless - * we're resuming a generator. + * Load the debugger's interrupt hook here and after calling out to native + * functions (but not to getters, setters, or other native hooks), so we do + * not have to reload it each time through the interpreter loop -- we hope + * the compiler can keep it in a register when it is non-null. + */ +#if JS_THREADED_INTERP +# define LOAD_JUMP_TABLE() \ + (jumpTable = interruptHandler ? interruptJumpTable : normalJumpTable) +#else +# define LOAD_JUMP_TABLE() ((void) 0) +#endif + +#define LOAD_INTERRUPT_HANDLER(cx) \ + JS_BEGIN_MACRO \ + interruptHandler = (cx)->debugHooks->interruptHandler; \ + LOAD_JUMP_TABLE(); \ + JS_END_MACRO + + LOAD_INTERRUPT_HANDLER(cx); + + /* + * Initialize the pc register and allocate operand stack slots for the + * script's worst-case depth, unless we're resuming a generator. */ if (JS_LIKELY(!fp->spbase)) { ASSERT_NOT_THROWING(cx); + JS_ASSERT(!fp->pc); JS_ASSERT(!fp->sp); - sp = js_AllocRawStack(cx, script->depth, &mark); - if (!sp) { + JS_ASSERT(!fp->spbase); + fp->spbase = js_AllocRawStack(cx, script->depth, &mark); + if (!fp->spbase) { mark = NULL; ok = JS_FALSE; goto exit; } JS_ASSERT(mark); - fp->spbase = sp; - SAVE_SP(fp); + fp->pc = script->code; + fp->sp = fp->spbase; + RESTORE_SP_AND_PC(fp); } else { JS_ASSERT(fp->flags & JSFRAME_GENERATOR); mark = NULL; - RESTORE_SP(fp); + RESTORE_SP_AND_PC(fp); + JS_ASSERT((size_t) (pc - script->code) <= script->length); JS_ASSERT((size_t) (sp - fp->spbase) <= script->depth); JS_ASSERT(JS_PROPERTY_CACHE(cx).disabled >= 0); JS_PROPERTY_CACHE(cx).disabled += js_CountWithBlocks(cx, fp); @@ -2814,8 +2815,10 @@ interrupt: sp[-2] = rtmp; END_CASE(JSOP_SWAP) + BEGIN_CASE(JSOP_SETRVAL) BEGIN_CASE(JSOP_POPV) - *result = POP_OPND(); + ASSERT_NOT_THROWING(cx); + fp->rval = POP_OPND(); END_CASE(JSOP_POPV) BEGIN_CASE(JSOP_ENTERWITH) @@ -2842,11 +2845,6 @@ interrupt: js_LeaveWith(cx); END_CASE(JSOP_LEAVEWITH) - BEGIN_CASE(JSOP_SETRVAL) - ASSERT_NOT_THROWING(cx); - fp->rval = POP_OPND(); - END_CASE(JSOP_SETRVAL) - BEGIN_CASE(JSOP_RETURN) CHECK_BRANCH(-1); fp->rval = POP_OPND(); @@ -7041,7 +7039,6 @@ interrupt: JS_ASSERT(!(fp->flags & JSFRAME_GENERATOR)); JS_ASSERT(fp->spbase); JS_ASSERT(fp->spbase <= fp->sp); - JS_ASSERT(sp == fp->spbase); fp->sp = fp->spbase = NULL; js_FreeRawStack(cx, mark); } diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index 80981c6aaebf..f3a7128a501e 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -455,7 +455,7 @@ extern JSBool js_InvokeConstructor(JSContext *cx, jsval *vp, uintN argc); extern JSBool -js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result); +js_Interpret(JSContext *cx); #define JSPROP_INITIALIZER 0x100 /* NB: Not a valid property attribute. */ diff --git a/js/src/jsiter.c b/js/src/jsiter.c index bc5ea08db393..549be152831a 100644 --- a/js/src/jsiter.c +++ b/js/src/jsiter.c @@ -832,10 +832,9 @@ typedef enum JSGeneratorOp { */ static JSBool SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj, - JSGenerator *gen, jsval arg, jsval *rval) + JSGenerator *gen, jsval arg) { JSStackFrame *fp; - jsval junk; JSArena *arena; JSBool ok; @@ -883,7 +882,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj, fp = cx->fp; cx->fp = &gen->frame; gen->frame.down = fp; - ok = js_Interpret(cx, gen->frame.pc, &junk); + ok = js_Interpret(cx); cx->fp = fp; gen->frame.down = NULL; @@ -902,18 +901,15 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj, JS_ASSERT(op != JSGENOP_CLOSE); gen->frame.flags &= ~JSFRAME_YIELDING; gen->state = JSGEN_OPEN; - *rval = gen->frame.rval; return JS_TRUE; } + gen->frame.rval = JSVAL_VOID; gen->state = JSGEN_CLOSED; - if (ok) { /* Returned, explicitly or by falling off the end. */ - if (op == JSGENOP_CLOSE) { - *rval = JSVAL_VOID; + if (op == JSGENOP_CLOSE) return JS_TRUE; - } return js_ThrowStopIteration(cx); } @@ -928,7 +924,6 @@ static JSBool CloseGenerator(JSContext *cx, JSObject *obj) { JSGenerator *gen; - jsval junk; JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_GeneratorClass); gen = (JSGenerator *) JS_GetPrivate(cx, obj); @@ -940,8 +935,7 @@ CloseGenerator(JSContext *cx, JSObject *obj) if (gen->state == JSGEN_CLOSED) return JS_TRUE; - /* SendToGenerator always sets *rval to JSVAL_VOID for JSGENOP_CLOSE. */ - return SendToGenerator(cx, JSGENOP_CLOSE, obj, gen, JSVAL_VOID, &junk); + return SendToGenerator(cx, JSGENOP_CLOSE, obj, gen, JSVAL_VOID); } /* @@ -1001,8 +995,9 @@ generator_op(JSContext *cx, JSGeneratorOp op, jsval *vp) arg = (op == JSGENOP_SEND || op == JSGENOP_THROW) ? vp[2] : JSVAL_VOID; - if (!SendToGenerator(cx, op, obj, gen, arg, vp)) + if (!SendToGenerator(cx, op, obj, gen, arg)) return JS_FALSE; + *vp = gen->frame.rval; return JS_TRUE; } From e73c273de40d8ef06f59991a0551acb1606e5e02 Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Thu, 6 Mar 2008 14:51:14 -0800 Subject: [PATCH 087/248] bug=421314 r=myself a1.9=beltzner Patch from Mike Moening to fix VC2005 warnings that my recent changes introduced. --- js/src/jsgc.c | 6 +++--- js/src/jsxml.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/jsgc.c b/js/src/jsgc.c index 077a9183e5d3..08d84be354f9 100644 --- a/js/src/jsgc.c +++ b/js/src/jsgc.c @@ -1022,8 +1022,8 @@ InitGCArenaLists(JSRuntime *rt) thingSize = GC_FREELIST_NBYTES(i); JS_ASSERT((size_t)(uint16)thingSize == thingSize); arenaList->last = NULL; - arenaList->lastCount = THINGS_PER_ARENA(thingSize); - arenaList->thingSize = (uint16)thingSize; + arenaList->lastCount = (uint16) THINGS_PER_ARENA(thingSize); + arenaList->thingSize = (uint16) thingSize; arenaList->freeList = NULL; } rt->gcDoubleArenaList.first = NULL; @@ -3346,7 +3346,7 @@ js_GC(JSContext *cx, JSGCInvocationKind gckind) */ freeList = arenaList->freeList; if (a == arenaList->last) - arenaList->lastCount = indexLimit; + arenaList->lastCount = (uint16) indexLimit; *ap = a->prev; a->prev = emptyArenas; emptyArenas = a; diff --git a/js/src/jsxml.c b/js/src/jsxml.c index 0937e5c0c617..460b4937f482 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -3434,7 +3434,7 @@ DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags) /* Our caller must be protecting newborn objects. */ JS_ASSERT(cx->localRootStack); - JS_CHECK_RECURSION(cx, return JS_FALSE); + JS_CHECK_RECURSION(cx, return NULL); copy = js_NewXML(cx, (JSXMLClass) xml->xml_class); if (!copy) From f51e9810133e2e1009e2c1752008233aa43473e6 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 14:52:58 -0800 Subject: [PATCH 088/248] Don't assume that chrome:// implies system principals. bug 419848, r=brendan sr=jst --- dom/src/base/nsJSTimeoutHandler.cpp | 7 +---- dom/src/base/nsJSUtils.cpp | 42 ++++++++++++----------------- dom/src/base/nsJSUtils.h | 3 ++- js/src/jsfun.c | 8 +----- js/src/jsobj.c | 25 ++++++++++++----- js/src/jsobj.h | 4 +++ js/src/jsscript.c | 3 +-- 7 files changed, 44 insertions(+), 48 deletions(-) diff --git a/dom/src/base/nsJSTimeoutHandler.cpp b/dom/src/base/nsJSTimeoutHandler.cpp index ffa2579b9c9a..03fe3681703f 100644 --- a/dom/src/base/nsJSTimeoutHandler.cpp +++ b/dom/src/base/nsJSTimeoutHandler.cpp @@ -254,17 +254,12 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, PRBool *aIsInterval, mExpr = expr; nsIPrincipal *prin = aWindow->GetPrincipal(); - JSPrincipals *jsprins; - rv = prin->GetJSPrincipals(cx, &jsprins); - NS_ENSURE_SUCCESS(rv, rv); // Get the calling location. const char *filename; - if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo, jsprins)) { + if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo, prin)) { mFileName.Assign(filename); } - - JSPRINCIPALS_DROP(cx, jsprins); } else if (funobj) { rv = NS_HOLD_JS_OBJECTS(this, nsJSScriptTimeoutHandler); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/src/base/nsJSUtils.cpp b/dom/src/base/nsJSUtils.cpp index 7da71a8bd6a0..068cf4c0df27 100644 --- a/dom/src/base/nsJSUtils.cpp +++ b/dom/src/base/nsJSUtils.cpp @@ -62,7 +62,7 @@ JSBool nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename, - PRUint32* aLineno, JSPrincipals* aPrincipals) + PRUint32* aLineno, nsIPrincipal* aPrincipal) { // Get the current filename and line number JSStackFrame* frame = nsnull; @@ -78,32 +78,24 @@ nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename, if (script) { // If aPrincipals is non-null then our caller is asking us to ensure // that the filename we return does not have elevated privileges. - if (aPrincipals) { - // The principals might not be in the script, but we can always - // find the right principals in the frame's callee. - JSPrincipals* scriptPrins = JS_GetScriptPrincipals(aContext, script); - if (!scriptPrins) { - JSObject *callee = JS_GetFrameCalleeObject(aContext, frame); - nsCOMPtr prin; + if (aPrincipal) { + uint32 flags = JS_GetScriptFilenameFlags(script); + + // Use the principal for the filename if it shouldn't be receiving + // implicit XPCNativeWrappers. + PRBool system; + if (flags & JSFILENAME_PROTECTED) { nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager(); - if (NS_FAILED(ssm->GetObjectPrincipal(aContext, callee, - getter_AddRefs(prin))) || - !prin) { - return JS_FALSE; + + if (NS_FAILED(ssm->IsSystemPrincipal(aPrincipal, &system)) || !system) { + JSPrincipals* jsprins; + aPrincipal->GetJSPrincipals(aContext, &jsprins); + + *aFilename = jsprins->codebase; + *aLineno = 0; + JSPRINCIPALS_DROP(aContext, jsprins); + return JS_TRUE; } - - prin->GetJSPrincipals(aContext, &scriptPrins); - - // The script has a reference to the principals. - JSPRINCIPALS_DROP(aContext, scriptPrins); - } - - // Return the weaker of the two principals if they differ. - if (scriptPrins != aPrincipals && - scriptPrins->subsume(scriptPrins, aPrincipals)) { - *aFilename = aPrincipals->codebase; - *aLineno = 0; - return JS_TRUE; } } diff --git a/dom/src/base/nsJSUtils.h b/dom/src/base/nsJSUtils.h index faacd0e067dc..9c3d990402e0 100644 --- a/dom/src/base/nsJSUtils.h +++ b/dom/src/base/nsJSUtils.h @@ -52,12 +52,13 @@ class nsIDOMEventListener; class nsIScriptContext; class nsIScriptGlobalObject; +class nsIPrincipal; class nsJSUtils { public: static JSBool GetCallingLocation(JSContext* aContext, const char* *aFilename, - PRUint32* aLineno, JSPrincipals* aPrincipals); + PRUint32* aLineno, nsIPrincipal* aPrincipal); static jsval ConvertStringToJSVal(const nsString& aProp, JSContext* aContext); diff --git a/js/src/jsfun.c b/js/src/jsfun.c index a584e62374e9..072aba0f2e42 100644 --- a/js/src/jsfun.c +++ b/js/src/jsfun.c @@ -1758,13 +1758,7 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) caller = JS_GetScriptedCaller(cx, fp); if (caller) { principals = JS_EvalFramePrincipals(cx, fp, caller); - if (principals == caller->script->principals) { - filename = caller->script->filename; - lineno = js_PCToLineNumber(cx, caller->script, caller->pc); - } else { - filename = principals->codebase; - lineno = 0; - } + filename = js_ComputeFilename(cx, caller, principals, &lineno); } else { filename = NULL; lineno = 0; diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 5909075bab50..22ccb2f99f0b 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -1133,6 +1133,23 @@ bad: return NULL; } +const char * +js_ComputeFilename(JSContext *cx, JSStackFrame *caller, + JSPrincipals *principals, uintN *linenop) +{ + uint32 flags; + + flags = JS_GetScriptFilenameFlags(caller->script); + if ((flags & JSFILENAME_PROTECTED) && + strcmp(principals->codebase, "[System Principal]")) { + *linenop = 0; + return principals->codebase; + } + + *linenop = js_PCToLineNumber(cx, caller->script, caller->pc); + return caller->script->filename; +} + static JSBool obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { @@ -1271,13 +1288,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) str = JSVAL_TO_STRING(argv[0]); if (caller) { principals = JS_EvalFramePrincipals(cx, fp, caller); - if (principals == caller->script->principals) { - file = caller->script->filename; - line = js_PCToLineNumber(cx, caller->script, caller->pc); - } else { - file = principals->codebase; - line = 0; - } + file = js_ComputeFilename(cx, caller, principals, &line); } else { file = NULL; line = 0; diff --git a/js/src/jsobj.h b/js/src/jsobj.h index ba7506eb23a3..c9d411319609 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -699,6 +699,10 @@ js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj, extern JSObject * js_GetWrappedObject(JSContext *cx, JSObject *obj); +/* NB: Infallible. */ +extern const char * +js_ComputeFilename(JSContext *cx, JSStackFrame *caller, + JSPrincipals *principals, uintN *linenop); JS_END_EXTERN_C #endif /* jsobj_h___ */ diff --git a/js/src/jsscript.c b/js/src/jsscript.c index 7dc9dbc50bee..54f0589472d1 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -241,9 +241,8 @@ script_compile_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, fp->scopeChain = scopeobj; /* for the compiler's benefit */ } - file = caller->script->filename; - line = js_PCToLineNumber(cx, caller->script, caller->pc); principals = JS_EvalFramePrincipals(cx, fp, caller); + file = js_ComputeFilename(cx, caller, principals, &line); } else { file = NULL; line = 0; From f809a4326be788b6b0ee986decb3a89300ead02d Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 6 Mar 2008 15:00:01 -0800 Subject: [PATCH 089/248] Fix compile warnings. No bug, debug only, r+rs=jst --- dom/src/base/nsGlobalWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index fea9503949a3..8ce5e5a49fee 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -660,7 +660,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) #ifdef DEBUG printf("++DOMWINDOW == %d (%p) [serial = %d] [Outer = %p]\n", gRefCnt, static_cast(static_cast(this)), - ++gSerialCounter, aOuterWindow); + ++gSerialCounter, static_cast(aOuterWindow)); mSerial = gSerialCounter; #endif @@ -682,7 +682,7 @@ nsGlobalWindow::~nsGlobalWindow() #ifdef DEBUG printf("--DOMWINDOW == %d (%p) [serial = %d] [Outer = %p]\n", gRefCnt, static_cast(static_cast(this)), - mSerial, mOuterWindow); + mSerial, static_cast(mOuterWindow)); #endif #ifdef PR_LOGGING From d7e5cb7c5b828c1165d84be9b8d05ca463ce017f Mon Sep 17 00:00:00 2001 From: "dbaron@dbaron.org" Date: Thu, 6 Mar 2008 15:03:50 -0800 Subject: [PATCH 090/248] Fix -Wconversion warnings that prevent compiling netwerk/cookie/src/ (which makes warnings fatal) with gcc 4.3 on x86_64. b=409384 r=bsmedberg a=beltzner --- xpcom/glue/nsISupportsImpl.h | 8 ++++---- xpcom/glue/nsVoidArray.h | 2 +- xpcom/string/public/nsCharTraits.h | 2 +- xpcom/string/public/nsTDependentString.h | 8 ++++---- xpcom/string/public/nsTDependentSubstring.h | 4 ++-- xpcom/string/public/nsTString.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/xpcom/glue/nsISupportsImpl.h b/xpcom/glue/nsISupportsImpl.h index 663d916d6af0..a9e151d34318 100644 --- a/xpcom/glue/nsISupportsImpl.h +++ b/xpcom/glue/nsISupportsImpl.h @@ -433,18 +433,18 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ #define NS_INTERFACE_TABLE_ENTRY(_class, _interface) \ { &_interface::COMTypeInfo::kIID, \ - reinterpret_cast( \ + PROffset32(reinterpret_cast( \ static_cast<_interface*>((_class*) 0x1000)) - \ - reinterpret_cast((_class*) 0x1000) \ + reinterpret_cast((_class*) 0x1000)) \ }, #define NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, _interface, _implClass) \ { &_interface::COMTypeInfo::kIID, \ - reinterpret_cast( \ + PROffset32(reinterpret_cast( \ static_cast<_interface*>( \ static_cast<_implClass*>( \ (_class*) 0x1000))) - \ - reinterpret_cast((_class*) 0x1000) \ + reinterpret_cast((_class*) 0x1000)) \ }, #define NS_INTERFACE_TABLE_END_WITH_PTR(_ptr) \ diff --git a/xpcom/glue/nsVoidArray.h b/xpcom/glue/nsVoidArray.h index c8950b4b71e5..acd2075d3669 100644 --- a/xpcom/glue/nsVoidArray.h +++ b/xpcom/glue/nsVoidArray.h @@ -406,7 +406,7 @@ private: PRBool HasSingle() const { - return reinterpret_cast(mImpl) & 0x1; + return !!(reinterpret_cast(mImpl) & 0x1); } void* GetSingle() const { diff --git a/xpcom/string/public/nsCharTraits.h b/xpcom/string/public/nsCharTraits.h index 9667b4f6bcbf..3a1397958230 100644 --- a/xpcom/string/public/nsCharTraits.h +++ b/xpcom/string/public/nsCharTraits.h @@ -671,7 +671,7 @@ struct nsCharSourceTraits readable_distance( const InputIterator& first, const InputIterator& last ) { // assumes single fragment - return last.get() - first.get(); + return PRUint32(last.get() - first.get()); } static diff --git a/xpcom/string/public/nsTDependentString.h b/xpcom/string/public/nsTDependentString.h index 7789988692e4..1c800ab1c058 100644 --- a/xpcom/string/public/nsTDependentString.h +++ b/xpcom/string/public/nsTDependentString.h @@ -73,7 +73,7 @@ class nsTDependentString_CharT : public nsTString_CharT */ nsTDependentString_CharT( const char_type* start, const char_type* end ) - : string_type(const_cast(start), end - start, F_TERMINATED) + : string_type(const_cast(start), PRUint32(end - start), F_TERMINATED) { AssertValid(); } @@ -86,7 +86,7 @@ class nsTDependentString_CharT : public nsTString_CharT explicit nsTDependentString_CharT( const char_type* data ) - : string_type(const_cast(data), char_traits::length(data), F_TERMINATED) + : string_type(const_cast(data), PRUint32(char_traits::length(data)), F_TERMINATED) { AssertValid(); } @@ -114,14 +114,14 @@ class nsTDependentString_CharT : public nsTString_CharT void Rebind( const char_type* data ) { - Rebind(data, char_traits::length(data)); + Rebind(data, PRUint32(char_traits::length(data))); } NS_COM void Rebind( const char_type* data, size_type length ); void Rebind( const char_type* start, const char_type* end ) { - Rebind(start, end - start); + Rebind(start, PRUint32(end - start)); } private: diff --git a/xpcom/string/public/nsTDependentSubstring.h b/xpcom/string/public/nsTDependentSubstring.h index 1a3f136e5217..0a86a6cec900 100644 --- a/xpcom/string/public/nsTDependentSubstring.h +++ b/xpcom/string/public/nsTDependentSubstring.h @@ -71,10 +71,10 @@ class nsTDependentSubstring_CharT : public nsTSubstring_CharT } nsTDependentSubstring_CharT( const char_type* start, const char_type* end ) - : substring_type(const_cast(start), end - start, F_NONE) {} + : substring_type(const_cast(start), PRUint32(end - start), F_NONE) {} nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end ) - : substring_type(const_cast(start.get()), end.get() - start.get(), F_NONE) {} + : substring_type(const_cast(start.get()), PRUint32(end.get() - start.get()), F_NONE) {} // Create a nsTDependentSubstring to be bound later nsTDependentSubstring_CharT() diff --git a/xpcom/string/public/nsTString.h b/xpcom/string/public/nsTString.h index 7ce960d55e0e..ceb833d4cbb0 100644 --- a/xpcom/string/public/nsTString.h +++ b/xpcom/string/public/nsTString.h @@ -449,7 +449,7 @@ class nsTFixedString_CharT : public nsTString_CharT */ nsTFixedString_CharT( char_type* data, size_type storageSize ) - : string_type(data, char_traits::length(data), F_TERMINATED | F_FIXED | F_CLASS_FIXED) + : string_type(data, PRUint32(char_traits::length(data)), F_TERMINATED | F_FIXED | F_CLASS_FIXED) , mFixedCapacity(storageSize - 1) , mFixedBuf(data) {} From d244cc0126bf804ea861bff2e3db877d6a33c958 Mon Sep 17 00:00:00 2001 From: "Olli.Pettay@helsinki.fi" Date: Thu, 6 Mar 2008 15:05:35 -0800 Subject: [PATCH 091/248] Bug 421294, Crash [@ DocumentViewerImpl::GetCopyable], r+sr=jst, a=beltzner --- layout/base/nsDocumentViewer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 3b128881c4d3..c791de42feea 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2451,6 +2451,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetCopyable(PRBool *aCopyable) NS_ENSURE_ARG_POINTER(aCopyable); *aCopyable = PR_FALSE; + NS_ENSURE_STATE(mPresShell); nsCOMPtr selection; nsresult rv = mPresShell->GetSelectionForCopy(getter_AddRefs(selection)); if (NS_FAILED(rv)) From f94c50c5ff46e0f817228678c2f336316cd3372b Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Thu, 6 Mar 2008 15:24:08 -0800 Subject: [PATCH 092/248] bug=421154 r=brendan a1.9=blockin1.9 Faster number conversions --- js/src/jsapi.c | 35 +++++++--- js/src/jsarray.c | 85 +++++++++++++---------- js/src/jsdate.c | 18 +++-- js/src/jsexn.c | 6 +- js/src/jsfun.c | 2 +- js/src/jsinterp.c | 48 +++++++------ js/src/jsmath.c | 57 ++++++++++------ js/src/jsnum.c | 169 ++++++++++++++++++++++++++-------------------- js/src/jsnum.h | 28 +++----- js/src/jsparse.c | 2 +- js/src/jsregexp.c | 4 +- js/src/jsscript.c | 4 +- js/src/jsstr.c | 39 +++++++---- js/src/jsxml.c | 2 +- 14 files changed, 292 insertions(+), 207 deletions(-) diff --git a/js/src/jsapi.c b/js/src/jsapi.c index 6abdee6c1200..c5375b4f6a2d 100644 --- a/js/src/jsapi.c +++ b/js/src/jsapi.c @@ -203,7 +203,7 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, *va_arg(ap, JSBool *) = js_ValueToBoolean(*sp); break; case 'c': - if (!js_ValueToUint16(cx, *sp, va_arg(ap, uint16 *))) + if (!JS_ValueToUint16(cx, *sp, va_arg(ap, uint16 *))) return JS_FALSE; break; case 'i': @@ -215,15 +215,15 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, return JS_FALSE; break; case 'j': - if (!js_ValueToInt32(cx, *sp, va_arg(ap, int32 *))) + if (!JS_ValueToInt32(cx, *sp, va_arg(ap, int32 *))) return JS_FALSE; break; case 'd': - if (!js_ValueToNumber(cx, *sp, va_arg(ap, jsdouble *))) + if (!JS_ValueToNumber(cx, *sp, va_arg(ap, jsdouble *))) return JS_FALSE; break; case 'I': - if (!js_ValueToNumber(cx, *sp, &d)) + if (!JS_ValueToNumber(cx, *sp, &d)) return JS_FALSE; *va_arg(ap, jsdouble *) = js_DoubleToInteger(d); break; @@ -487,7 +487,7 @@ JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp) *vp = STRING_TO_JSVAL(str); break; case JSTYPE_NUMBER: - ok = js_ValueToNumber(cx, v, &d); + ok = JS_ValueToNumber(cx, v, &d); if (ok) { dp = js_NewDouble(cx, d); ok = (dp != NULL); @@ -541,8 +541,13 @@ JS_ValueToString(JSContext *cx, jsval v) JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp) { + JSTempValueRooter tvr; + CHECK_REQUEST(cx); - return js_ValueToNumber(cx, v, dp); + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + *dp = js_ValueToNumber(cx, &tvr.u.value); + JS_POP_TEMP_ROOT(cx, &tvr); + return !JSVAL_IS_NULL(tvr.u.value); } JS_PUBLIC_API(JSBool) @@ -554,7 +559,7 @@ JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip) JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); *ip = js_ValueToECMAInt32(cx, &tvr.u.value); JS_POP_TEMP_ROOT(cx, &tvr); - return tvr.u.value != JSVAL_NULL; + return !JSVAL_IS_NULL(tvr.u.value); } JS_PUBLIC_API(JSBool) @@ -566,21 +571,31 @@ JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip) JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); *ip = js_ValueToECMAUint32(cx, &tvr.u.value); JS_POP_TEMP_ROOT(cx, &tvr); - return tvr.u.value != JSVAL_NULL; + return !JSVAL_IS_NULL(tvr.u.value); } JS_PUBLIC_API(JSBool) JS_ValueToInt32(JSContext *cx, jsval v, int32 *ip) { + JSTempValueRooter tvr; + CHECK_REQUEST(cx); - return js_ValueToInt32(cx, v, ip); + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + *ip = js_ValueToInt32(cx, &tvr.u.value); + JS_POP_TEMP_ROOT(cx, &tvr); + return !JSVAL_IS_NULL(tvr.u.value); } JS_PUBLIC_API(JSBool) JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip) { + JSTempValueRooter tvr; + CHECK_REQUEST(cx); - return js_ValueToUint16(cx, v, ip); + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + *ip = js_ValueToUint16(cx, &tvr.u.value); + JS_POP_TEMP_ROOT(cx, &tvr); + return !JSVAL_IS_NULL(tvr.u.value); } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsarray.c b/js/src/jsarray.c index 862357fcd807..a480d1e07c32 100644 --- a/js/src/jsarray.c +++ b/js/src/jsarray.c @@ -184,37 +184,36 @@ js_IdIsIndex(jsval id, jsuint *indexp) return JS_FALSE; } -static JSBool -ValueIsLength(JSContext *cx, jsval v, jsuint *lengthp) +static jsuint +ValueIsLength(JSContext *cx, jsval* vp) { jsint i; jsdouble d; + jsuint length; - if (JSVAL_IS_INT(v)) { - i = JSVAL_TO_INT(v); - if (i < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, - JSMSG_BAD_ARRAY_LENGTH); - return JS_FALSE; - } - *lengthp = (jsuint) i; - return JS_TRUE; + if (JSVAL_IS_INT(*vp)) { + i = JSVAL_TO_INT(*vp); + if (i < 0) + goto error; + return (jsuint) i; } - if (!js_ValueToNumber(cx, v, &d)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, - JSMSG_BAD_ARRAY_LENGTH); - return JS_FALSE; - } + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) + goto error; - *lengthp = js_DoubleToECMAUint32(d); + if (JSDOUBLE_IS_NaN(d)) + goto error; + length = (jsuint) d; + if (d != (jsdouble) length) + goto error; + return length; - if (JSDOUBLE_IS_NaN(d) || d != *lengthp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, - JSMSG_BAD_ARRAY_LENGTH); - return JS_FALSE; - } - return JS_TRUE; + error: + JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, + JSMSG_BAD_ARRAY_LENGTH); + *vp = JSVAL_NULL; + return 0; } JSBool @@ -239,7 +238,7 @@ js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp) *lengthp = (jsuint)i; /* jsuint cast does ToUint32 */ } else { *lengthp = js_ValueToECMAUint32(cx, &tvr.u.value); - ok = (tvr.u.value != JSVAL_NULL); + ok = !JSVAL_IS_NULL(tvr.u.value); } } JS_POP_TEMP_ROOT(cx, &tvr); @@ -520,8 +519,10 @@ js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp) id = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom); ok = OBJ_GET_PROPERTY(cx, obj, id, &tvr.u.value); JS_SetErrorReporter(cx, older); - if (ok) - ok = ValueIsLength(cx, tvr.u.value, lengthp); + if (ok) { + *lengthp = ValueIsLength(cx, &tvr.u.value); + ok = !JSVAL_IS_NULL(tvr.u.value); + } JS_POP_TEMP_ROOT(cx, &tvr); return ok; } @@ -579,7 +580,8 @@ array_length_setter(JSContext *cx, JSObject *obj, jsval id, jsval *vp) JSPROP_ENUMERATE, NULL); } - if (!ValueIsLength(cx, *vp, &newlen)) + newlen = ValueIsLength(cx, vp); + if (JSVAL_IS_NULL(*vp)) return JS_FALSE; oldlen = obj->fslots[JSSLOT_ARRAY_LENGTH]; @@ -1725,10 +1727,12 @@ sort_compare(void *arg, const void *a, const void *b, int *result) *sp++ = av; *sp++ = bv; - if (!js_Invoke(cx, 2, invokevp, JSINVOKE_INTERNAL) || - !js_ValueToNumber(cx, *invokevp, &cmp)) { + if (!js_Invoke(cx, 2, invokevp, JSINVOKE_INTERNAL)) + return JS_FALSE; + + cmp = js_ValueToNumber(cx, invokevp); + if (JSVAL_IS_NULL(*invokevp)) return JS_FALSE; - } /* Clamp cmp to -1, 0, 1. */ *result = 0; @@ -2231,7 +2235,8 @@ array_splice(JSContext *cx, uintN argc, jsval *vp) return JS_FALSE; /* Convert the first argument into a starting index. */ - if (!js_ValueToNumber(cx, *argv, &d)) + d = js_ValueToNumber(cx, argv); + if (JSVAL_IS_NULL(*argv)) return JS_FALSE; d = js_DoubleToInteger(d); if (d < 0) { @@ -2251,7 +2256,8 @@ array_splice(JSContext *cx, uintN argc, jsval *vp) count = delta; end = length; } else { - if (!js_ValueToNumber(cx, *argv, &d)) + d = js_ValueToNumber(cx, argv); + if (JSVAL_IS_NULL(*argv)) return JS_FALSE; d = js_DoubleToInteger(d); if (d < 0) @@ -2398,7 +2404,8 @@ array_concat(JSContext *cx, uintN argc, jsval *vp) &tvr.u.value); if (!ok) goto out; - ok = ValueIsLength(cx, tvr.u.value, &alength); + alength = ValueIsLength(cx, &tvr.u.value); + ok = !JSVAL_IS_NULL(tvr.u.value); if (!ok) goto out; for (slot = 0; slot < alength; slot++) { @@ -2456,7 +2463,8 @@ array_slice(JSContext *cx, uintN argc, jsval *vp) end = length; if (argc > 0) { - if (!js_ValueToNumber(cx, argv[0], &d)) + d = js_ValueToNumber(cx, &argv[0]); + if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; d = js_DoubleToInteger(d); if (d < 0) { @@ -2469,7 +2477,8 @@ array_slice(JSContext *cx, uintN argc, jsval *vp) begin = (jsuint)d; if (argc > 1) { - if (!js_ValueToNumber(cx, argv[1], &d)) + d = js_ValueToNumber(cx, &argv[1]); + if (JSVAL_IS_NULL(argv[1])) return JS_FALSE; d = js_DoubleToInteger(d); if (d < 0) { @@ -2542,7 +2551,8 @@ array_indexOfHelper(JSContext *cx, JSBool isLast, uintN argc, jsval *vp) } else { jsdouble start; - if (!js_ValueToNumber(cx, vp[3], &start)) + start = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; start = js_DoubleToInteger(start); if (start < 0) { @@ -2902,7 +2912,8 @@ Array(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) length = 1; vector = argv; } else { - if (!ValueIsLength(cx, argv[0], &length)) + length = ValueIsLength(cx, &argv[0]); + if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; vector = NULL; } diff --git a/js/src/jsdate.c b/js/src/jsdate.c index 60805a890661..378e7a9dde5c 100644 --- a/js/src/jsdate.c +++ b/js/src/jsdate.c @@ -573,7 +573,8 @@ date_msecFromArgs(JSContext *cx, uintN argc, jsval *argv, jsdouble *rval) for (loop = 0; loop < MAXARGS; loop++) { if (loop < argc) { - if (!js_ValueToNumber(cx, argv[loop], &d)) + d = js_ValueToNumber(cx, &argv[loop]); + if (JSVAL_IS_NULL(argv[loop])) return JS_FALSE; /* return NaN if any arg is not finite */ if (!JSDOUBLE_IS_FINITE(d)) { @@ -1262,7 +1263,8 @@ date_setTime(JSContext *cx, uintN argc, jsval *vp) { jsdouble result; - if (!js_ValueToNumber(cx, vp[2], &result)) + result = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; result = TIMECLIP(result); @@ -1311,7 +1313,8 @@ date_makeTime(JSContext *cx, uintN maxargs, JSBool local, uintN argc, jsval *vp) argv = vp + 2; for (i = 0; i < argc; i++) { - if (!js_ValueToNumber(cx, argv[i], &args[i])) + args[i] = js_ValueToNumber(cx, &argv[i]); + if (JSVAL_IS_NULL(argv[i])) return JS_FALSE; if (!JSDOUBLE_IS_FINITE(args[i])) { if (!SetUTCTimePtr(cx, obj, NULL, cx->runtime->jsNaN)) @@ -1438,7 +1441,8 @@ date_makeDate(JSContext *cx, uintN maxargs, JSBool local, uintN argc, jsval *vp) argv = vp + 2; for (i = 0; i < argc; i++) { - if (!js_ValueToNumber(cx, argv[i], &args[i])) + args[i] = js_ValueToNumber(cx, &argv[i]); + if (JSVAL_IS_NULL(argv[i])) return JS_FALSE; if (!JSDOUBLE_IS_FINITE(args[i])) { if (!SetUTCTimePtr(cx, obj, NULL, cx->runtime->jsNaN)) @@ -1538,7 +1542,8 @@ date_setYear(JSContext *cx, uintN argc, jsval *vp) if (!GetUTCTime(cx, obj, vp, &result)) return JS_FALSE; - if (!js_ValueToNumber(cx, vp[2], &year)) + year = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; if (!JSDOUBLE_IS_FINITE(year)) { if (!SetUTCTimePtr(cx, obj, NULL, cx->runtime->jsNaN)) @@ -2071,7 +2076,8 @@ Date(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) } else if (argc == 1) { if (!JSVAL_IS_STRING(argv[0])) { /* the argument is a millisecond number */ - if (!js_ValueToNumber(cx, argv[0], &d)) + d = js_ValueToNumber(cx, &argv[0]); + if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; date = date_constructor(cx, obj); if (!date) diff --git a/js/src/jsexn.c b/js/src/jsexn.c index c812f1588ca9..a4984216d9e4 100644 --- a/js/src/jsexn.c +++ b/js/src/jsexn.c @@ -794,7 +794,7 @@ Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) /* Set the 'lineNumber' property. */ if (argc > 2) { lineno = js_ValueToECMAUint32(cx, &argv[2]); - if (argv[2] == JSVAL_NULL) + if (JSVAL_IS_NULL(argv[2])) return JS_FALSE; } else { if (!fp) @@ -914,7 +914,7 @@ exn_toSource(JSContext *cx, uintN argc, jsval *vp) if (!ok) goto out; lineno = js_ValueToECMAUint32 (cx, &localroots[2]); - ok = (localroots[2] != JSVAL_NULL); + ok = !JSVAL_IS_NULL(localroots[2]); if (!ok) goto out; @@ -1344,7 +1344,7 @@ js_ReportUncaughtException(JSContext *cx) if (!ok) goto out; lineno = js_ValueToECMAUint32 (cx, &roots[4]); - ok = (roots[4] != JSVAL_NULL); + ok = !JSVAL_IS_NULL(roots[4]); if (!ok) goto out; diff --git a/js/src/jsfun.c b/js/src/jsfun.c index 072aba0f2e42..7bf87924834d 100644 --- a/js/src/jsfun.c +++ b/js/src/jsfun.c @@ -1456,7 +1456,7 @@ fun_toStringHelper(JSContext *cx, uint32 indent, uintN argc, jsval *vp) obj = JSVAL_TO_OBJECT(fval); if (argc != 0) { indent = js_ValueToECMAUint32(cx, &vp[2]); - if (vp[2] == JSVAL_NULL) + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; } diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index eff7b4749954..49ec0d4cecf7 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -2022,7 +2022,8 @@ js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, jsval *vp, jsval *vp2) } else if (JSVAL_IS_INT(v)) { d = JSVAL_TO_INT(v); } else { - if (!js_ValueToNumber(cx, v, &d)) + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) return JS_FALSE; /* Store the result of v conversion back in vp for post increments. */ @@ -2255,7 +2256,7 @@ js_DumpOpMeters() jsval v_; \ \ v_ = FETCH_OPND(n); \ - VALUE_TO_NUMBER(cx, v_, d); \ + VALUE_TO_NUMBER(cx, n, v_, d); \ JS_END_MACRO #define FETCH_INT(cx, n, i) \ @@ -2268,7 +2269,7 @@ js_DumpOpMeters() } else { \ SAVE_SP_AND_PC(fp); \ i = js_ValueToECMAInt32(cx, &sp[n]); \ - if (sp[n] == JSVAL_NULL) \ + if (JSVAL_IS_NULL(sp[n])) \ goto error; \ } \ JS_END_MACRO @@ -2283,7 +2284,7 @@ js_DumpOpMeters() } else { \ SAVE_SP_AND_PC(fp); \ ui = js_ValueToECMAUint32(cx, &sp[n]); \ - if (sp[n] == JSVAL_NULL) \ + if (JSVAL_IS_NULL(sp[n])) \ goto error; \ } \ JS_END_MACRO @@ -2292,15 +2293,17 @@ js_DumpOpMeters() * Optimized conversion macros that test for the desired type in v before * homing sp and calling a conversion function. */ -#define VALUE_TO_NUMBER(cx, v, d) \ +#define VALUE_TO_NUMBER(cx, n, v, d) \ JS_BEGIN_MACRO \ + JS_ASSERT(v == sp[n]); \ if (JSVAL_IS_INT(v)) { \ d = (jsdouble)JSVAL_TO_INT(v); \ } else if (JSVAL_IS_DOUBLE(v)) { \ d = *JSVAL_TO_DOUBLE(v); \ } else { \ SAVE_SP_AND_PC(fp); \ - if (!js_ValueToNumber(cx, v, &d)) \ + d = js_ValueToNumber(cx, &sp[n]); \ + if (JSVAL_IS_NULL(sp[n])) \ goto error; \ } \ JS_END_MACRO @@ -3448,8 +3451,8 @@ interrupt: str2 = JSVAL_TO_STRING(rval); \ cond = js_CompareStrings(str, str2) OP 0; \ } else { \ - VALUE_TO_NUMBER(cx, lval, d); \ - VALUE_TO_NUMBER(cx, rval, d2); \ + VALUE_TO_NUMBER(cx, -2, lval, d); \ + VALUE_TO_NUMBER(cx, -1, rval, d2); \ cond = JSDOUBLE_COMPARE(d, OP, d2, JS_FALSE); \ } \ } \ @@ -3537,8 +3540,8 @@ interrupt: str2 = JSVAL_TO_STRING(rval); \ cond = js_EqualStrings(str, str2) OP JS_TRUE; \ } else { \ - VALUE_TO_NUMBER(cx, lval, d); \ - VALUE_TO_NUMBER(cx, rval, d2); \ + VALUE_TO_NUMBER(cx, -2, lval, d); \ + VALUE_TO_NUMBER(cx, -1, rval, d2); \ cond = JSDOUBLE_COMPARE(d, OP, d2, IFNAN); \ } \ } \ @@ -3628,7 +3631,7 @@ interrupt: } else { \ SAVE_SP_AND_PC(fp); \ shift = js_ValueToECMAInt32(cx, &sp[-1]); \ - if (sp[-1] == JSVAL_NULL) \ + if (JSVAL_IS_NULL(sp[-1])) \ goto error; \ } \ shift &= 31; \ @@ -3709,8 +3712,8 @@ interrupt: sp--; STORE_OPND(-1, STRING_TO_JSVAL(str)); } else { - VALUE_TO_NUMBER(cx, lval, d); - VALUE_TO_NUMBER(cx, rval, d2); + VALUE_TO_NUMBER(cx, -2, lval, d); + VALUE_TO_NUMBER(cx, -1, rval, d2); d += d2; sp--; STORE_NUMBER(cx, -1, d); @@ -3797,12 +3800,16 @@ interrupt: i = -i; JS_ASSERT(INT_FITS_IN_JSVAL(i)); rval = INT_TO_JSVAL(i); + STORE_OPND(-1, rval); } else { SAVE_SP_AND_PC(fp); - if (JSVAL_IS_DOUBLE(rval)) + if (JSVAL_IS_DOUBLE(rval)) { d = *JSVAL_TO_DOUBLE(rval); - else if (!js_ValueToNumber(cx, rval, &d)) - goto error; + } else { + d = js_ValueToNumber(cx, &sp[-1]); + if (JSVAL_IS_NULL(sp[-1])) + goto error; + } #ifdef HPUX /* * Negation of a zero doesn't produce a negative @@ -3813,21 +3820,20 @@ interrupt: #else d = -d; #endif - if (!js_NewNumberValue(cx, d, &rval)) + if (!js_NewNumberValue(cx, d, &sp[-1])) goto error; } - STORE_OPND(-1, rval); END_CASE(JSOP_NEG) BEGIN_CASE(JSOP_POS) rval = FETCH_OPND(-1); if (!JSVAL_IS_NUMBER(rval)) { SAVE_SP_AND_PC(fp); - if (!js_ValueToNumber(cx, rval, &d)) + d = js_ValueToNumber(cx, &sp[-1]); + if (JSVAL_IS_NULL(sp[-1])) goto error; - if (!js_NewNumberValue(cx, d, &rval)) + if (!js_NewNumberValue(cx, d, &sp[-1])) goto error; - sp[-1] = rval; } END_CASE(JSOP_POS) diff --git a/js/src/jsmath.c b/js/src/jsmath.c index 015869321418..5ec7c83db81d 100644 --- a/js/src/jsmath.c +++ b/js/src/jsmath.c @@ -105,7 +105,8 @@ math_abs(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_fabs(x); return js_NewNumberValue(cx, z, vp); @@ -116,7 +117,8 @@ math_acos(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_acos(x); return js_NewNumberValue(cx, z, vp); @@ -127,7 +129,8 @@ math_asin(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_asin(x); return js_NewNumberValue(cx, z, vp); @@ -138,7 +141,8 @@ math_atan(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_atan(x); return js_NewNumberValue(cx, z, vp); @@ -149,9 +153,11 @@ math_atan2(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, y, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; - if (!js_ValueToNumber(cx, vp[3], &y)) + y = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; #if !JS_USE_FDLIBM_MATH && defined(_MSC_VER) /* @@ -177,7 +183,8 @@ math_ceil(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_ceil(x); return js_NewNumberValue(cx, z, vp); @@ -188,7 +195,8 @@ math_cos(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_cos(x); return js_NewNumberValue(cx, z, vp); @@ -199,7 +207,8 @@ math_exp(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; #ifdef _WIN32 if (!JSDOUBLE_IS_NaN(x)) { @@ -222,7 +231,8 @@ math_floor(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_floor(x); return js_NewNumberValue(cx, z, vp); @@ -233,7 +243,8 @@ math_log(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_log(x); return js_NewNumberValue(cx, z, vp); @@ -252,7 +263,8 @@ math_max(JSContext *cx, uintN argc, jsval *vp) } argv = vp + 2; for (i = 0; i < argc; i++) { - if (!js_ValueToNumber(cx, argv[i], &x)) + x = js_ValueToNumber(cx, &argv[i]); + if (JSVAL_IS_NULL(argv[i])) return JS_FALSE; if (JSDOUBLE_IS_NaN(x)) { *vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN); @@ -279,7 +291,8 @@ math_min(JSContext *cx, uintN argc, jsval *vp) } argv = vp + 2; for (i = 0; i < argc; i++) { - if (!js_ValueToNumber(cx, argv[i], &x)) + x = js_ValueToNumber(cx, &argv[i]); + if (JSVAL_IS_NULL(argv[i])) return JS_FALSE; if (JSDOUBLE_IS_NaN(x)) { *vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN); @@ -298,9 +311,11 @@ math_pow(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, y, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; - if (!js_ValueToNumber(cx, vp[3], &y)) + y = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; #if !JS_USE_FDLIBM_MATH /* @@ -428,7 +443,8 @@ math_round(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_copysign(fd_floor(x + 0.5), x); return js_NewNumberValue(cx, z, vp); @@ -439,7 +455,8 @@ math_sin(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_sin(x); return js_NewNumberValue(cx, z, vp); @@ -450,7 +467,8 @@ math_sqrt(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_sqrt(x); return js_NewNumberValue(cx, z, vp); @@ -461,7 +479,8 @@ math_tan(JSContext *cx, uintN argc, jsval *vp) { jsdouble x, z; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; z = fd_tan(x); return js_NewNumberValue(cx, z, vp); diff --git a/js/src/jsnum.c b/js/src/jsnum.c index 83f10b0ff906..cece2f1b4019 100644 --- a/js/src/jsnum.c +++ b/js/src/jsnum.c @@ -71,7 +71,8 @@ num_isNaN(JSContext *cx, uintN argc, jsval *vp) { jsdouble x; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; *vp = BOOLEAN_TO_JSVAL(JSDOUBLE_IS_NaN(x)); return JS_TRUE; @@ -82,7 +83,8 @@ num_isFinite(JSContext *cx, uintN argc, jsval *vp) { jsdouble x; - if (!js_ValueToNumber(cx, vp[2], &x)) + x = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; *vp = BOOLEAN_TO_JSVAL(JSDOUBLE_IS_FINITE(x)); return JS_TRUE; @@ -119,7 +121,7 @@ num_parseInt(JSContext *cx, uintN argc, jsval *vp) if (argc > 1) { radix = js_ValueToECMAInt32(cx, &vp[3]); - if (vp[3] == JSVAL_NULL) + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; } else { radix = 0; @@ -177,7 +179,8 @@ Number(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) jsval v; if (argc != 0) { - if (!js_ValueToNumber(cx, argv[0], &d)) + d = js_ValueToNumber(cx, &argv[0]); + if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; } else { d = 0.0; @@ -264,7 +267,7 @@ num_toString(JSContext *cx, uintN argc, jsval *vp) base = 10; if (argc != 0 && !JSVAL_IS_VOID(vp[2])) { base = js_ValueToECMAInt32(cx, &vp[2]); - if (vp[2] == JSVAL_NULL) + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; if (base < 2 || base > 36) { char numBuf[12]; @@ -431,7 +434,8 @@ num_to(JSContext *cx, JSDToStrMode zeroArgMode, JSDToStrMode oneArgMode, precision = 0.0; oneArgMode = zeroArgMode; } else { - if (!js_ValueToNumber(cx, vp[2], &precision)) + precision = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; precision = js_DoubleToInteger(precision); if (precision < precisionMin || precision > precisionMax) { @@ -728,49 +732,73 @@ js_NumberToString(JSContext *cx, jsdouble d) return JS_NewStringCopyZ(cx, numStr); } -JSBool -js_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp) +jsdouble +js_ValueToNumber(JSContext *cx, jsval *vp) { - JSObject *obj; + jsval v; JSString *str; const jschar *bp, *end, *ep; + jsdouble d; + JSObject *obj; + JSTempValueRooter tvr; - if (JSVAL_IS_OBJECT(v)) { - obj = JSVAL_TO_OBJECT(v); - if (!obj) { - *dp = 0; - return JS_TRUE; + v = *vp; + for (;;) { + if (JSVAL_IS_INT(v)) + return (jsdouble) JSVAL_TO_INT(v); + if (JSVAL_IS_DOUBLE(v)) + return *JSVAL_TO_DOUBLE(v); + if (JSVAL_IS_STRING(v)) { + str = JSVAL_TO_STRING(v); + + /* + * Note that ECMA doesn't treat a string beginning with a '0' as + * an octal number here. This works because all such numbers will + * be interpreted as decimal by js_strtod and will never get + * passed to js_strtointeger (which would interpret them as + * octal). + */ + JSSTRING_CHARS_AND_END(str, bp, end); + if ((!js_strtod(cx, bp, end, &ep, &d) || + js_SkipWhiteSpace(ep, end) != end) && + (!js_strtointeger(cx, bp, end, &ep, 0, &d) || + js_SkipWhiteSpace(ep, end) != end)) { + break; + } + return d; } - if (!OBJ_DEFAULT_VALUE(cx, obj, JSTYPE_NUMBER, &v)) - return JS_FALSE; - } - if (JSVAL_IS_INT(v)) { - *dp = (jsdouble)JSVAL_TO_INT(v); - } else if (JSVAL_IS_DOUBLE(v)) { - *dp = *JSVAL_TO_DOUBLE(v); - } else if (JSVAL_IS_STRING(v)) { - str = JSVAL_TO_STRING(v); + if (JSVAL_IS_BOOLEAN(v)) + return JSVAL_TO_BOOLEAN(v) ? 1.0 : 0.0; + if (JSVAL_IS_NULL(v)) { + *vp = JSVAL_ZERO; + return 0.0; + } + if (JSVAL_IS_VOID(v)) + break; + + JS_ASSERT(!JSVAL_IS_PRIMITIVE(v)); + obj = JSVAL_TO_OBJECT(v); /* - * Note that ECMA doesn't treat a string beginning with a '0' as an - * octal number here. This works because all such numbers will be - * interpreted as decimal by js_strtod and will never get passed to - * js_strtointeger (which would interpret them as octal). + * vp roots obj so we cannot use it as an extra root for + * OBJ_DEFAULT_VALUE result when calling the hook. */ - JSSTRING_CHARS_AND_END(str, bp, end); - if ((!js_strtod(cx, bp, end, &ep, dp) || - js_SkipWhiteSpace(ep, end) != end) && - (!js_strtointeger(cx, bp, end, &ep, 0, dp) || - js_SkipWhiteSpace(ep, end) != end)) { - goto badstr; + JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr); + if (!OBJ_DEFAULT_VALUE(cx, obj, JSTYPE_NUMBER, &tvr.u.value)) + obj = NULL; + else + v = *vp = tvr.u.value; + JS_POP_TEMP_ROOT(cx, &tvr); + if (!obj) { + *vp = JSVAL_NULL; + return 0.0; } - } else if (JSVAL_IS_BOOLEAN(v)) { - *dp = JSVAL_TO_BOOLEAN(v) ? 1 : 0; - } else { -badstr: - *dp = *cx->runtime->jsNaN; + if (!JSVAL_IS_PRIMITIVE(v)) + break; } - return JS_TRUE; + + JS_ASSERT(!JSVAL_IS_NULL(*vp)); + return *cx->runtime->jsNaN; } int32 @@ -785,11 +813,9 @@ js_ValueToECMAInt32(JSContext *cx, jsval *vp) if (JSVAL_IS_DOUBLE(v)) { d = *JSVAL_TO_DOUBLE(v); } else { - if (!js_ValueToNumber(cx, v, &d)) { - *vp = JSVAL_NULL; + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) return 0; - } - *vp = JSVAL_ZERO; } return js_DoubleToECMAInt32(d); } @@ -826,11 +852,9 @@ js_ValueToECMAUint32(JSContext *cx, jsval *vp) if (JSVAL_IS_DOUBLE(v)) { d = *JSVAL_TO_DOUBLE(v); } else { - if (!js_ValueToNumber(cx, v, &d)) { - *vp = JSVAL_NULL; + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) return 0; - } - *vp = JSVAL_ZERO; } return js_DoubleToECMAUint32(d); } @@ -864,53 +888,50 @@ js_DoubleToECMAUint32(jsdouble d) return (uint32) (d >= 0 ? d : d + two32); } -JSBool -js_ValueToInt32(JSContext *cx, jsval v, int32 *ip) +int32 +js_ValueToInt32(JSContext *cx, jsval *vp) { + jsval v; jsdouble d; - if (JSVAL_IS_INT(v)) { - *ip = JSVAL_TO_INT(v); - return JS_TRUE; - } - if (!js_ValueToNumber(cx, v, &d)) - return JS_FALSE; + v = *vp; + if (JSVAL_IS_INT(v)) + return JSVAL_TO_INT(v); + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) + return 0; if (JSDOUBLE_IS_NaN(d) || d <= -2147483649.0 || 2147483648.0 <= d) { js_ReportValueError(cx, JSMSG_CANT_CONVERT, JSDVG_SEARCH_STACK, v, NULL); - return JS_FALSE; + *vp = JSVAL_NULL; + return 0; } - *ip = (int32)floor(d + 0.5); /* Round to nearest */ - return JS_TRUE; + return (int32) floor(d + 0.5); /* Round to nearest */ } -JSBool -js_ValueToUint16(JSContext *cx, jsval v, uint16 *ip) +uint16 +js_ValueToUint16(JSContext *cx, jsval *vp) { jsdouble d; jsuint i, m; JSBool neg; - if (!js_ValueToNumber(cx, v, &d)) - return JS_FALSE; - if (d == 0 || !JSDOUBLE_IS_FINITE(d)) { - *ip = 0; - return JS_TRUE; - } - i = (jsuint)d; - if ((jsdouble)i == d) { - *ip = (uint16)i; - return JS_TRUE; - } + d = js_ValueToNumber(cx, vp); + if (JSVAL_IS_NULL(*vp)) + return 0; + if (d == 0 || !JSDOUBLE_IS_FINITE(d)) + return 0; + i = (jsuint) d; + if ((jsdouble) i == d) + return (uint16) i; neg = (d < 0); d = floor(neg ? -d : d); d = neg ? -d : d; m = JS_BIT(16); - d = fmod(d, (double)m); + d = fmod(d, (double) m); if (d < 0) d += m; - *ip = (uint16) d; - return JS_TRUE; + return (uint16) d; } jsdouble diff --git a/js/src/jsnum.h b/js/src/jsnum.h index e4e0924ed4b7..fe7c436678cc 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -197,16 +197,15 @@ char * js_NumberToCString(JSContext *cx, jsdouble d, char *buf, size_t bufSize); /* - * Convert a value to a number, returning false after reporting any error, - * otherwise returning true with *dp set. + * Convert a value to a number. On exit JSVAL_IS_NULL(*vp) iff there was an + * error. */ -extern JSBool -js_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp); +extern jsdouble +js_ValueToNumber(JSContext *cx, jsval* vp); /* * Convert a value to an int32 or uint32, according to the ECMA rules for - * ToInt32 and ToUint32. On failure the functions sets *vp to JSVAL_NULL. Any - * other value in *vp on exit indicates a success. + * ToInt32 and ToUint32. On exit JSVAL_IS_NULL(*vp) iff there was an error. */ extern int32 js_ValueToECMAInt32(JSContext *cx, jsval *vp); @@ -223,25 +222,20 @@ js_DoubleToECMAInt32(jsdouble d); extern uint32 js_DoubleToECMAUint32(jsdouble d); -/* - * Convert a value or a double to a uint32, according to the ECMA rules - * for ToUint32. - */ - /* * Convert a value to a number, then to an int32 if it fits by rounding to * nearest; but failing with an error report if the double is out of range - * or unordered. + * or unordered. On exit JSVAL_IS_NULL(*vp) iff there was an error. */ -extern JSBool -js_ValueToInt32(JSContext *cx, jsval v, int32 *ip); +extern int32 +js_ValueToInt32(JSContext *cx, jsval *vp); /* * Convert a value to a number, then to a uint16 according to the ECMA rules - * for ToUint16. + * for ToUint16. On exit JSVAL_IS_NULL(*vp) iff there was an error. */ -extern JSBool -js_ValueToUint16(JSContext *cx, jsval v, uint16 *ip); +extern uint16 +js_ValueToUint16(JSContext *cx, jsval *vp); /* * Convert a jsdouble to an integral number, stored in a jsdouble. diff --git a/js/src/jsparse.c b/js/src/jsparse.c index 60b87c5298eb..da360852385c 100644 --- a/js/src/jsparse.c +++ b/js/src/jsparse.c @@ -5897,7 +5897,7 @@ FoldType(JSContext *cx, JSParseNode *pn, JSTokenType type) case TOK_NUMBER: if (pn->pn_type == TOK_STRING) { jsdouble d; - if (!js_ValueToNumber(cx, ATOM_KEY(pn->pn_atom), &d)) + if (!JS_ValueToNumber(cx, ATOM_KEY(pn->pn_atom), &d)) return JS_FALSE; pn->pn_dval = d; pn->pn_type = TOK_NUMBER; diff --git a/js/src/jsregexp.c b/js/src/jsregexp.c index a1494c7c29a8..b39ffd45e148 100644 --- a/js/src/jsregexp.c +++ b/js/src/jsregexp.c @@ -3646,7 +3646,7 @@ regexp_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return ok; slot = JSVAL_TO_INT(id); if (slot == REGEXP_LAST_INDEX) { - if (!js_ValueToNumber(cx, *vp, &lastIndex)) + if (!JS_ValueToNumber(cx, *vp, &lastIndex)) return JS_FALSE; lastIndex = js_DoubleToInteger(lastIndex); ok = js_NewNumberValue(cx, lastIndex, vp) && @@ -4321,7 +4321,7 @@ js_GetLastIndex(JSContext *cx, JSObject *obj, jsdouble *lastIndex) jsval v; return JS_GetReservedSlot(cx, obj, 0, &v) && - js_ValueToNumber(cx, v, lastIndex); + JS_ValueToNumber(cx, v, lastIndex); } JSBool diff --git a/js/src/jsscript.c b/js/src/jsscript.c index 54f0589472d1..2f18de8ad929 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -112,7 +112,7 @@ script_toSource(JSContext *cx, uintN argc, jsval *vp) indent = 0; if (argc != 0) { indent = js_ValueToECMAUint32(cx, &vp[2]); - if (vp[2] == JSVAL_NULL) + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; } @@ -171,7 +171,7 @@ script_toString(JSContext *cx, uintN argc, jsval *vp) indent = 0; if (argc != 0) { indent = js_ValueToECMAUint32(cx, &vp[2]); - if (vp[2] == JSVAL_NULL) + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; } diff --git a/js/src/jsstr.c b/js/src/jsstr.c index e1a9e60627e0..03b6cd114696 100644 --- a/js/src/jsstr.c +++ b/js/src/jsstr.c @@ -312,7 +312,8 @@ js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval mask = URL_XALPHAS | URL_XPALPHAS | URL_PATH; if (argc > 1) { - if (!js_ValueToNumber(cx, argv[1], &d)) + d = js_ValueToNumber(cx, &argv[1]); + if (JSVAL_IS_NULL(argv[1])) return JS_FALSE; if (!JSDOUBLE_IS_FINITE(d) || (mask = (jsint)d) != d || @@ -707,7 +708,8 @@ str_substring(JSContext *cx, uintN argc, jsval *vp) NORMALIZE_THIS(cx, vp, str); if (argc != 0) { - if (!js_ValueToNumber(cx, vp[2], &d)) + d = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; length = JSSTRING_LENGTH(str); begin = js_DoubleToInteger(d); @@ -719,7 +721,8 @@ str_substring(JSContext *cx, uintN argc, jsval *vp) if (argc == 1) { end = length; } else { - if (!js_ValueToNumber(cx, vp[3], &d)) + d = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; end = js_DoubleToInteger(d); if (end < 0) @@ -867,7 +870,8 @@ str_charAt(JSContext *cx, uintN argc, jsval *vp) if (argc == 0) { d = 0.0; } else { - if (!js_ValueToNumber(cx, v, &d)) + d = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; d = js_DoubleToInteger(d); } @@ -911,7 +915,8 @@ str_charCodeAt(JSContext *cx, uintN argc, jsval *vp) if (argc == 0) { d = 0.0; } else { - if (!js_ValueToNumber(cx, v, &d)) + d = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; d = js_DoubleToInteger(d); } @@ -992,7 +997,8 @@ str_indexOf(JSContext *cx, uintN argc, jsval *vp) patlen = (jsint) JSSTRING_LENGTH(str2); if (argc > 1) { - if (!js_ValueToNumber(cx, vp[3], &d)) + d = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; d = js_DoubleToInteger(d); if (d < 0) @@ -1055,7 +1061,8 @@ str_lastIndexOf(JSContext *cx, uintN argc, jsval *vp) patlen = (jsint) JSSTRING_LENGTH(str2); if (argc > 1) { - if (!js_ValueToNumber(cx, vp[3], &d)) + d = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; if (JSDOUBLE_IS_NaN(d)) { i = textlen; @@ -1829,7 +1836,8 @@ str_split(JSContext *cx, uintN argc, jsval *vp) limited = (argc > 1) && !JSVAL_IS_VOID(vp[3]); limit = 0; /* Avoid warning. */ if (limited) { - if (!js_ValueToNumber(cx, vp[3], &d)) + d = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; /* Clamp limit between 0 and 1 + string length. */ @@ -1890,7 +1898,8 @@ str_substr(JSContext *cx, uintN argc, jsval *vp) NORMALIZE_THIS(cx, vp, str); if (argc != 0) { - if (!js_ValueToNumber(cx, vp[2], &d)) + d = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; length = JSSTRING_LENGTH(str); begin = js_DoubleToInteger(d); @@ -1905,7 +1914,8 @@ str_substr(JSContext *cx, uintN argc, jsval *vp) if (argc == 1) { end = length; } else { - if (!js_ValueToNumber(cx, vp[3], &d)) + d = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; end = js_DoubleToInteger(d); if (end < 0) @@ -1988,7 +1998,8 @@ str_slice(JSContext *cx, uintN argc, jsval *vp) if (argc != 0) { double begin, end, length; - if (!js_ValueToNumber(cx, v, &begin)) + begin = js_ValueToNumber(cx, &vp[2]); + if (JSVAL_IS_NULL(vp[2])) return JS_FALSE; begin = js_DoubleToInteger(begin); length = JSSTRING_LENGTH(str); @@ -2003,7 +2014,8 @@ str_slice(JSContext *cx, uintN argc, jsval *vp) if (argc == 1) { end = length; } else { - if (!js_ValueToNumber(cx, vp[3], &end)) + end = js_ValueToNumber(cx, &vp[3]); + if (JSVAL_IS_NULL(vp[3])) return JS_FALSE; end = js_DoubleToInteger(end); if (end < 0) { @@ -2279,7 +2291,8 @@ str_fromCharCode(JSContext *cx, uintN argc, jsval *vp) if (!chars) return JS_FALSE; for (i = 0; i < argc; i++) { - if (!js_ValueToUint16(cx, argv[i], &code)) { + code = js_ValueToUint16(cx, &argv[i]); + if (JSVAL_IS_NULL(argv[i])) { JS_free(cx, chars); return JS_FALSE; } diff --git a/js/src/jsxml.c b/js/src/jsxml.c index 460b4937f482..cf67626d535e 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -5482,7 +5482,7 @@ xml_equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp) } else if (JSVAL_IS_STRING(v)) { *bp = js_EqualStrings(str, JSVAL_TO_STRING(v)); } else { - ok = js_ValueToNumber(cx, STRING_TO_JSVAL(str), &d); + ok = JS_ValueToNumber(cx, STRING_TO_JSVAL(str), &d); if (ok) { d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v); From cbae14cf8e62020593b3e4ff96156c221e6a88e0 Mon Sep 17 00:00:00 2001 From: "jruderman@hmc.edu" Date: Thu, 6 Mar 2008 15:59:35 -0800 Subject: [PATCH 093/248] Fix XML parsing errors in tests: apparently comments have to go *after* the ?xml version? thing Fix XML parsing errors in tests: apparently comments have to come *after* the '?xml version="1.0"?' thing. --- layout/reftests/svg/bugs/bug314244.xul | 4 ++-- layout/reftests/svg/bugs/bug337408.xul | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layout/reftests/svg/bugs/bug314244.xul b/layout/reftests/svg/bugs/bug314244.xul index 85977613065d..e801ca70e8d0 100755 --- a/layout/reftests/svg/bugs/bug314244.xul +++ b/layout/reftests/svg/bugs/bug314244.xul @@ -1,7 +1,7 @@ - - + + - Date: Thu, 6 Mar 2008 16:14:56 -0800 Subject: [PATCH 094/248] Backing out previous revision (b=420420) due to reftest hang on qm-centos5-01 --- layout/mathml/base/src/nsMathMLmoFrame.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/layout/mathml/base/src/nsMathMLmoFrame.cpp b/layout/mathml/base/src/nsMathMLmoFrame.cpp index 84a792163a4e..176dc4fcb3a8 100644 --- a/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -758,15 +758,12 @@ nsMathMLmoFrame::Stretch(nsIRenderingContext& aRenderingContext, } } - // Child frames of invisble operators are not reflowed - if (!NS_MATHML_OPERATOR_IS_INVISIBLE(mFlags)) { - // Place our children using the default method - // This will allow our child text frame to get its DidReflow() - nsresult rv = Place(aRenderingContext, PR_TRUE, aDesiredStretchSize); - if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { - // Make sure the child frames get their DidReflow() calls. - DidReflowChildren(mFrames.FirstChild()); - } + // Place our children using the default method + // This will allow our child text frame to get its DidReflow() + nsresult rv = Place(aRenderingContext, PR_TRUE, aDesiredStretchSize); + if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { + // Make sure the child frames get their DidReflow() calls. + DidReflowChildren(mFrames.FirstChild()); } if (useMathMLChar) { From 04e4c0cf75ec8df5f76143ba0d5c64853c781245 Mon Sep 17 00:00:00 2001 From: "karlt+@karlt.net" Date: Thu, 6 Mar 2008 16:19:00 -0800 Subject: [PATCH 095/248] Backing out previous revision (b=416549) due to a reftest hang on qm-centos5-01 --- layout/mathml/content/src/mathml.css | 1 - 1 file changed, 1 deletion(-) diff --git a/layout/mathml/content/src/mathml.css b/layout/mathml/content/src/mathml.css index 30416d9ce52d..89600ce3bb85 100644 --- a/layout/mathml/content/src/mathml.css +++ b/layout/mathml/content/src/mathml.css @@ -409,7 +409,6 @@ semantics > :not(:first-child) { *|*::-moz-mathml-anonymous-block { display: inline-block !important; position: static !important; - text-indent: 0; } /*****************************************/ From 8c0ad51acf7ef146cf449d2b63b89d173c07ea7c Mon Sep 17 00:00:00 2001 From: "surkov.alexander@gmail.com" Date: Thu, 6 Mar 2008 16:33:47 -0800 Subject: [PATCH 096/248] Bug 417018 Array allocation mistakes in IA2, r=aaronlev, a=beltzner --- accessible/src/msaa/CAccessibleAction.cpp | 12 +++--- accessible/src/msaa/CAccessibleTable.cpp | 12 +++--- .../src/msaa/nsAccessibleRelationWrap.cpp | 37 ++++++++++--------- accessible/src/msaa/nsAccessibleWrap.cpp | 14 ++++--- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/accessible/src/msaa/CAccessibleAction.cpp b/accessible/src/msaa/CAccessibleAction.cpp index 772dc5fa20e7..e0bc118083ab 100755 --- a/accessible/src/msaa/CAccessibleAction.cpp +++ b/accessible/src/msaa/CAccessibleAction.cpp @@ -177,8 +177,6 @@ STDMETHODIMP CAccessibleAction::get_name(long aActionIndex, BSTR *aName) { __try { - *aName = NULL; - nsCOMPtr acc(do_QueryInterface(this)); if (!acc) return E_FAIL; @@ -188,11 +186,10 @@ __try { if (NS_FAILED(acc->GetActionName(index, name))) return E_FAIL; - if (!name.IsVoid()) { - INT result = ::SysReAllocStringLen(aName, name.get(), name.Length()); - if (!result) - return E_OUTOFMEMORY; - } + INT result = ::SysReAllocStringLen(aName, name.get(), name.Length()); + if (!result) + return E_OUTOFMEMORY; + } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; @@ -201,6 +198,7 @@ __try { STDMETHODIMP CAccessibleAction::get_localizedName(long aActionIndex, BSTR *aLocalizedName) { + ::SysFreeString(*aLocalizedName); return E_NOTIMPL; } diff --git a/accessible/src/msaa/CAccessibleTable.cpp b/accessible/src/msaa/CAccessibleTable.cpp index fdb4a477c6e0..0b5fbc311a95 100755 --- a/accessible/src/msaa/CAccessibleTable.cpp +++ b/accessible/src/msaa/CAccessibleTable.cpp @@ -160,8 +160,6 @@ STDMETHODIMP CAccessibleTable::get_columnDescription(long aColumn, BSTR *aDescription) { __try { - *aDescription = NULL; - nsCOMPtr tableAcc(do_QueryInterface(this)); NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG); if (!tableAcc) @@ -174,6 +172,7 @@ __try { if (!::SysReAllocStringLen(aDescription, descr.get(), descr.Length())) return E_OUTOFMEMORY; + } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; } @@ -371,8 +370,6 @@ STDMETHODIMP CAccessibleTable::get_rowDescription(long aRow, BSTR *aDescription) { __try { - *aDescription = NULL; - nsCOMPtr tableAcc(do_QueryInterface(this)); NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG); if (!tableAcc) @@ -385,6 +382,7 @@ __try { if (!::SysReAllocStringLen(aDescription, descr.get(), descr.Length())) return E_OUTOFMEMORY; + } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; } @@ -736,9 +734,13 @@ CAccessibleTable::GetSelectedItems(long aMaxItems, long **aItems, if (size == 0 || !items) return S_OK; - PRUint32 maxSize = size < (PRUint32)aMaxItems ? size : aMaxItems; + PRUint32 maxSize = size < static_cast(aMaxItems) ? size : aMaxItems; *aItemsCount = maxSize; + *aItems = static_cast(nsMemory::Alloc((maxSize) * sizeof(long))); + if (!*aItems) + return E_OUTOFMEMORY; + for (PRUint32 index = 0; index < maxSize; ++index) (*aItems)[index] = items[index]; diff --git a/accessible/src/msaa/nsAccessibleRelationWrap.cpp b/accessible/src/msaa/nsAccessibleRelationWrap.cpp index d5ea9c9bac09..a878cf1296b5 100755 --- a/accessible/src/msaa/nsAccessibleRelationWrap.cpp +++ b/accessible/src/msaa/nsAccessibleRelationWrap.cpp @@ -86,65 +86,65 @@ STDMETHODIMP nsAccessibleRelationWrap::get_relationType(BSTR *aRelationType) { __try { - *aRelationType = NULL; - PRUint32 type = 0; nsresult rv = GetRelationType(&type); if (NS_FAILED(rv)) return E_FAIL; + INT res; switch (type) { case RELATION_CONTROLLED_BY: - *aRelationType = ::SysAllocString(IA2_RELATION_CONTROLLED_BY); + res = ::SysReAllocString(aRelationType, IA2_RELATION_CONTROLLED_BY); break; case RELATION_CONTROLLER_FOR: - *aRelationType = ::SysAllocString(IA2_RELATION_CONTROLLER_FOR); + res = ::SysReAllocString(aRelationType, IA2_RELATION_CONTROLLER_FOR); break; case RELATION_DESCRIBED_BY: - *aRelationType = ::SysAllocString(IA2_RELATION_DESCRIBED_BY); + res = ::SysReAllocString(aRelationType, IA2_RELATION_DESCRIBED_BY); break; case RELATION_DESCRIPTION_FOR: - *aRelationType = ::SysAllocString(IA2_RELATION_DESCRIPTION_FOR); + res = ::SysReAllocString(aRelationType, IA2_RELATION_DESCRIPTION_FOR); break; case RELATION_EMBEDDED_BY: - *aRelationType = ::SysAllocString(IA2_RELATION_EMBEDDED_BY); + res = ::SysReAllocString(aRelationType, IA2_RELATION_EMBEDDED_BY); break; case RELATION_EMBEDS: - *aRelationType = ::SysAllocString(IA2_RELATION_EMBEDS); + res = ::SysReAllocString(aRelationType, IA2_RELATION_EMBEDS); break; case RELATION_FLOWS_FROM: - *aRelationType = ::SysAllocString(IA2_RELATION_FLOWS_FROM); + res = ::SysReAllocString(aRelationType, IA2_RELATION_FLOWS_FROM); break; case RELATION_FLOWS_TO: - *aRelationType = ::SysAllocString(IA2_RELATION_FLOWS_TO); + res = ::SysReAllocString(aRelationType, IA2_RELATION_FLOWS_TO); break; case RELATION_LABEL_FOR: - *aRelationType = ::SysAllocString(IA2_RELATION_LABEL_FOR); + res = ::SysReAllocString(aRelationType, IA2_RELATION_LABEL_FOR); break; case RELATION_LABELLED_BY: - *aRelationType = ::SysAllocString(IA2_RELATION_LABELED_BY); + res = ::SysReAllocString(aRelationType, IA2_RELATION_LABELED_BY); break; case RELATION_MEMBER_OF: - *aRelationType = ::SysAllocString(IA2_RELATION_MEMBER_OF); + res = ::SysReAllocString(aRelationType, IA2_RELATION_MEMBER_OF); break; case RELATION_NODE_CHILD_OF: - *aRelationType = ::SysAllocString(IA2_RELATION_NODE_CHILD_OF); + res = ::SysReAllocString(aRelationType, IA2_RELATION_NODE_CHILD_OF); break; case RELATION_PARENT_WINDOW_OF: - *aRelationType = ::SysAllocString(IA2_RELATION_PARENT_WINDOW_OF); + res = ::SysReAllocString(aRelationType, IA2_RELATION_PARENT_WINDOW_OF); break; case RELATION_POPUP_FOR: - *aRelationType = ::SysAllocString(IA2_RELATION_POPUP_FOR); + res = ::SysReAllocString(aRelationType, IA2_RELATION_POPUP_FOR); break; case RELATION_SUBWINDOW_OF: - *aRelationType = ::SysAllocString(IA2_RELATION_SUBWINDOW_OF); + res = ::SysReAllocString(aRelationType, IA2_RELATION_SUBWINDOW_OF); break; default: return E_FAIL; } - if (!aRelationType) + if (!res) return E_OUTOFMEMORY; + } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; @@ -153,6 +153,7 @@ __try { STDMETHODIMP nsAccessibleRelationWrap::get_localizedRelationType(BSTR *aLocalizedRelationType) { + ::SysFreeString(*aLocalizedRelationType); return E_NOTIMPL; } diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index ee3adfbb40d2..f72806fb2a13 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -1381,7 +1381,7 @@ STDMETHODIMP nsAccessibleWrap::get_uniqueID(long *uniqueID) { __try { - void *id; + void *id = nsnull; if (NS_SUCCEEDED(GetUniqueID(&id))) { *uniqueID = - reinterpret_cast(id); return S_OK; @@ -1470,8 +1470,6 @@ nsAccessibleWrap::get_attributes(BSTR *aAttributes) // The format is name:value;name:value; with \ for escaping these // characters ":;=,\". __try { - *aAttributes = NULL; - nsCOMPtr attributes; if (NS_FAILED(GetAttributes(getter_AddRefs(attributes)))) return E_FAIL; @@ -1523,7 +1521,11 @@ __try { strAttrs.Append(';'); } - *aAttributes = ::SysAllocString(strAttrs.get()); + INT res = ::SysReAllocStringLen(aAttributes, strAttrs.get(), + strAttrs.Length()); + if (!res) + return E_OUTOFMEMORY; + } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } return S_OK; } @@ -1672,7 +1674,7 @@ PRInt32 nsAccessibleWrap::GetChildIDFor(nsIAccessible* aAccessible) // so that the 3rd party application can call back and get the IAccessible // the event occured on. - void *uniqueID; + void *uniqueID = nsnull; nsCOMPtr accessNode(do_QueryInterface(aAccessible)); if (!accessNode) { return 0; @@ -1741,7 +1743,7 @@ IDispatch *nsAccessibleWrap::NativeAccessible(nsIAccessible *aXPAccessible) nsCOMPtr accObject(do_QueryInterface(aXPAccessible)); if (accObject) { - void* hwnd; + void* hwnd = nsnull; accObject->GetHwnd(&hwnd); if (hwnd) { IDispatch *retval = nsnull; From e91b973e5220d51e5f17f3470d6887f2a2e184ea Mon Sep 17 00:00:00 2001 From: "dveditz@cruzio.com" Date: Thu, 6 Mar 2008 17:20:44 -0800 Subject: [PATCH 097/248] bug 417086 fix regression with ':' in chrome URI fragments, r/sr=bsmedberg, blocking-firefox3+ bug 415191 rdf/chrome version of bug 413250, r/sr=neil --- chrome/src/nsChromeRegistry.cpp | 1 + rdf/chrome/src/nsChromeRegistry.cpp | 36 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index c95156d8df2d..42c05868774b 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -700,6 +700,7 @@ nsChromeRegistry::Canonify(nsIURL* aChromeURL) return NS_ERROR_DOM_BAD_URI; break; case '?': + case '#': pos = end; continue; } diff --git a/rdf/chrome/src/nsChromeRegistry.cpp b/rdf/chrome/src/nsChromeRegistry.cpp index 20a44370c0a3..4281940bbd83 100644 --- a/rdf/chrome/src/nsChromeRegistry.cpp +++ b/rdf/chrome/src/nsChromeRegistry.cpp @@ -389,16 +389,34 @@ SplitURL(nsIURI *aChromeURI, nsCString& aPackage, nsCString& aProvider, nsCStrin } else { // Protect against URIs containing .. that reach up out of the // chrome directory to grant chrome privileges to non-chrome files. - PRInt32 origLen = aFile.Length(); - PRInt32 newLen = nsUnescapeCount(aFile.BeginWriting()); - if (origLen != newLen) { - aFile.SetLength(newLen); - nofile = PR_TRUE; // let caller know path is modified + // XXX: If we find %-escaped dot or % in a chrome URI we assume + // someone is trying to trick us. + const char* pos = aFile.BeginReading(); + const char* end = aFile.EndReading(); + while (pos < end) { + switch (*pos) { + case ':': + return NS_ERROR_FAILURE; + case '.': + if (pos[1] == '.') + return NS_ERROR_FAILURE; + break; + case '%': + // chrome: URIs with escaped dots are trying to trick us. + // Double-escapes (%25) doubly so + if (pos[1] == '2' && + ( pos[2] == 'e' || pos[2] == 'E' || + pos[2] == '5' )) + return NS_ERROR_FAILURE; + break; + case '?': + case '#': + // leave any query or ref section alone + pos = end; + continue; + } + ++pos; } - - if (aFile.Find(NS_LITERAL_CSTRING("..")) != kNotFound || - aFile.FindChar(':') != kNotFound) - return NS_ERROR_FAILURE; } if (aModified) *aModified = nofile; From 1a0eb83437584681b3db410ad2e889589de8668c Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Thu, 6 Mar 2008 17:54:48 -0800 Subject: [PATCH 098/248] Bug 315609: Display something other than a blank window when no extensions are installed. r=robstrong, a=beltzner --- toolkit/mozapps/extensions/content/extensions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index c64e04de6ea5..72184f860700 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -1127,7 +1127,7 @@ function Startup() !document.getElementById(viewGroup.getAttribute("last-selected") + "-view").hidden) showView(viewGroup.getAttribute("last-selected")); else - showView("extensions"); + showView("search"); if (gExtensionsView.selectedItem) gExtensionsView.scrollBoxObject.scrollToElement(gExtensionsView.selectedItem); From a78b3f47297abe87e58d88106aa4047fc1c2b7a9 Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Thu, 6 Mar 2008 17:56:20 -0800 Subject: [PATCH 099/248] Bug 414481: Get Add-ons Tab: make EULA text selectable. r=robstrong, a=beltzner --- toolkit/mozapps/extensions/content/eula.js | 2 +- toolkit/mozapps/extensions/content/eula.xul | 4 +--- .../pinstripe/mozapps/extensions/eula.css | 19 +++++++++++-------- .../winstripe/mozapps/extensions/eula.css | 17 +++++++++-------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/toolkit/mozapps/extensions/content/eula.js b/toolkit/mozapps/extensions/content/eula.js index f665e9a08835..9765fac98686 100644 --- a/toolkit/mozapps/extensions/content/eula.js +++ b/toolkit/mozapps/extensions/content/eula.js @@ -39,5 +39,5 @@ function Startup() { var bundle = document.getElementById("extensionsStrings"); var label = document.createTextNode(bundle.getFormattedString("eulaHeader", [window.arguments[0].name])); document.getElementById("heading").appendChild(label); - document.getElementById("eula").appendChild(document.createTextNode(window.arguments[0].text)); + document.getElementById("eula").value = window.arguments[0].text; } diff --git a/toolkit/mozapps/extensions/content/eula.xul b/toolkit/mozapps/extensions/content/eula.xul index 163234b825d0..f8531e29e940 100644 --- a/toolkit/mozapps/extensions/content/eula.xul +++ b/toolkit/mozapps/extensions/content/eula.xul @@ -61,8 +61,6 @@
+ + if (event.originalTarget == this) + this.textbox.focus(); // Forward focus to actual textbox + + if (event.originalTarget == this.textbox.inputField) { this.startSearch(); From 69b1dc156436e025c17040ef485fa8504dc39951 Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Fri, 7 Mar 2008 03:10:06 -0800 Subject: [PATCH 120/248] Bug 414795: Progress text should read "connecting" rather than "installing". r=robstrong, a=beltzner --- .../chrome/mozapps/extensions/extensions.dtd | 1 + .../mozapps/extensions/content/extensions.css | 7 +++- .../mozapps/extensions/content/extensions.js | 42 +++++++++++-------- .../mozapps/extensions/content/extensions.xml | 4 ++ 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd index 65591894a480..6f2c9035f122 100644 --- a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd +++ b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd @@ -138,6 +138,7 @@ + diff --git a/toolkit/mozapps/extensions/content/extensions.css b/toolkit/mozapps/extensions/content/extensions.css index 356849ee1826..78dd16a3f7c9 100644 --- a/toolkit/mozapps/extensions/content/extensions.css +++ b/toolkit/mozapps/extensions/content/extensions.css @@ -205,10 +205,15 @@ richlistitem[action] .addonInstallButton { display: none; } -.searchResultInstalling, .searchResultFailed, .searchResultInstalled { +.searchResultInstalling, .searchResultFailed, +.searchResultInstalled, .searchResultConnecting { display: none; } +richlistitem[action="connecting"] .searchResultConnecting { + display: -moz-box; +} + richlistitem[action="installing"] .searchResultInstalling { display: -moz-box; } diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 8a0b78409fae..8eec99a1066e 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -73,7 +73,7 @@ var gShowGetAddonsPane = false; var gRetrievedResults = false; var gRecommendedAddons = null; var gRDF = null; -var gPendingInstalls = []; +var gPendingInstalls = {}; const PREF_EM_CHECK_COMPATIBILITY = "extensions.checkCompatibility"; const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity"; @@ -1222,11 +1222,17 @@ XPInstallDownloadManager.prototype = { var certName = aParams.GetString(i++); // Check whether the install was triggered from the Get Add-ons pane. - var pos = gPendingInstalls.indexOf(url); - if (pos >= 0) - gPendingInstalls.splice(pos, 1); - else + if (url in gPendingInstalls) { + // Update the installation status + gSearchDS.Assert(gRDF.GetResource(gPendingInstalls[url]), + gRDF.GetResource(PREFIX_NS_EM + "action"), + gRDF.GetLiteral("installing"), + true); + delete gPendingInstalls[url]; + } + else { switchPane = true; + } } gExtensionManager.addDownloads(items, items.length, aManager); @@ -2217,31 +2223,33 @@ function confirmOperation(aName, aTitle, aQueryMsg, aAcceptBtn, aCancelBtn, function installCallback(item, status) { var resultNode = gRDF.GetResource(item.id); + var actionArc = gRDF.GetResource(PREFIX_NS_EM + "action"); // Strip out old status - gSearchDS.Unassert(resultNode, - gRDF.GetResource(PREFIX_NS_EM + "action"), - gRDF.GetLiteral("installing"), - true); + var targets = gSearchDS.GetTargets(resultNode, actionArc, true); + while (targets.hasMoreElements()) { + var value = targets.getNext().QueryInterface(Components.interfaces.nsIRDFNode); + if (value) + gSearchDS.Unassert(resultNode, actionArc, value); + } if (status == -210) { // User cancelled - var pos = gPendingInstalls.indexOf(item.getAttribute("xpiURL")); - if (pos >= 0) - gPendingInstalls.splice(pos, 1); + if (item.getAttribute("xpiURL") in gPendingInstalls) + delete gPendingInstalls[item.getAttribute("xpiURL")]; return; } if (status < 0) { // Some other failure gSearchDS.Assert(resultNode, - gRDF.GetResource(PREFIX_NS_EM + "action"), + actionArc, gRDF.GetLiteral("failed"), true); } else { // Success gSearchDS.Assert(resultNode, - gRDF.GetResource(PREFIX_NS_EM + "action"), + actionArc, gRDF.GetLiteral("installed"), true); } @@ -2385,10 +2393,10 @@ var gExtensionsViewController = { gSearchDS.Assert(gRDF.GetResource(aSelectedItem.id), gRDF.GetResource(PREFIX_NS_EM + "action"), - gRDF.GetLiteral("installing"), + gRDF.GetLiteral("connecting"), true); - // Remember that we don't want to change panes for this install - gPendingInstalls.push(details.URL); + // Remember this install so we can update the status when install starts + gPendingInstalls[details.URL] = aSelectedItem.id; InstallTrigger.install(params, function(url, status) { installCallback(aSelectedItem, status); }); }, diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/extensions/content/extensions.xml index 0372abc707b1..6648c39ca219 100644 --- a/toolkit/mozapps/extensions/content/extensions.xml +++ b/toolkit/mozapps/extensions/content/extensions.xml @@ -506,6 +506,10 @@ + + + + From 15d0b60dfe763d33d706842b0d7821f45164882b Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Fri, 7 Mar 2008 03:16:48 -0800 Subject: [PATCH 121/248] Bug 417606: See all search results always number 10. r=gavin.sharp, r=robstrong --- .../urlformatter/src/nsURLFormatter.js | 8 +- .../tests/unit/test_urlformatter.js | 6 +- .../extensions/src/nsAddonRepository.js | 48 +++- .../test/unit/data/test_bug404024.xml | 158 +++++++++++++ .../test/unit/data/test_bug417606.xml | 152 +++++++++++++ .../extensions/test/unit/test_bug404024.js | 209 ++++++++++++++++++ .../extensions/test/unit/test_bug417606.js | 209 ++++++++++++++++++ 7 files changed, 773 insertions(+), 17 deletions(-) create mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug404024.xml create mode 100644 toolkit/mozapps/extensions/test/unit/data/test_bug417606.xml create mode 100644 toolkit/mozapps/extensions/test/unit/test_bug404024.js create mode 100644 toolkit/mozapps/extensions/test/unit/test_bug417606.js diff --git a/toolkit/components/urlformatter/src/nsURLFormatter.js b/toolkit/components/urlformatter/src/nsURLFormatter.js index ff3357e2236c..ecd25ce47202 100644 --- a/toolkit/components/urlformatter/src/nsURLFormatter.js +++ b/toolkit/components/urlformatter/src/nsURLFormatter.js @@ -61,7 +61,9 @@ nsURLFormatterService.prototype = { _defaults: { get appInfo() { if (!this._appInfo) - this._appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); + this._appInfo = Cc["@mozilla.org/xre/app-info;1"]. + getService(Ci.nsIXULAppInfo). + QueryInterface(Ci.nsIXULRuntime); return this._appInfo; }, @@ -74,7 +76,9 @@ nsURLFormatterService.prototype = { APPBUILDID: function() this.appInfo.appBuildID, PLATFORMVERSION: function() this.appInfo.platformVersion, PLATFORMBUILDID: function() this.appInfo.platformBuildID, - APP: function() this.appInfo.name.toLowerCase().replace(/ /, "") + APP: function() this.appInfo.name.toLowerCase().replace(/ /, ""), + OS: function() this.appInfo.OS, + XPCOMABI: function() this.appInfo.XPCOMABI }, formatURL: function uf_formatURL(aFormat) { diff --git a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js index 92a803835d30..32e020bbeead 100644 --- a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js +++ b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js @@ -42,10 +42,10 @@ function run_test() { var prefs = Cc['@mozilla.org/preferences-service;1']. getService(Ci.nsIPrefBranch); - var upperUrlRaw = "http://%LOCALE%.%VENDOR%.foo/?name=%NAME%&id=%ID%&version=%VERSION%&platversion=%PLATFORMVERSION%&abid=%APPBUILDID%&pbid=%PLATFORMBUILDID%&app=%APP%"; - var lowerUrlRaw = "http://%locale%.%vendor%.foo/?name=%name%&id=%id%&version=%version%&platversion=%platformversion%&abid=%appbuildid%&pbid=%platformbuildid%&app=%app%"; + var upperUrlRaw = "http://%LOCALE%.%VENDOR%.foo/?name=%NAME%&id=%ID%&version=%VERSION%&platversion=%PLATFORMVERSION%&abid=%APPBUILDID%&pbid=%PLATFORMBUILDID%&app=%APP%&os=%OS%&abi=%XPCOMABI%"; + var lowerUrlRaw = "http://%locale%.%vendor%.foo/?name=%name%&id=%id%&version=%version%&platversion=%platformversion%&abid=%appbuildid%&pbid=%platformbuildid%&app=%app%&os=%os%&abi=%xpcomabi%"; //XXX %APP%'s RegExp is not global, so it only replaces the first space - var ulUrlRef = "http://" + locale + ".Mozilla.foo/?name=Url Formatter Test&id=urlformattertest@test.mozilla.org&version=1&platversion=2.0&abid=2007122405&pbid=2007122406&app=urlformatter test"; + var ulUrlRef = "http://" + locale + ".Mozilla.foo/?name=Url Formatter Test&id=urlformattertest@test.mozilla.org&version=1&platversion=2.0&abid=2007122405&pbid=2007122406&app=urlformatter test&os=XPCShell&abi=noarch-spidermonkey"; var multiUrl = "http://%VENDOR%.%VENDOR%.%NAME%.%VENDOR%.%NAME%"; var multiUrlRef = "http://Mozilla.Mozilla.Url Formatter Test.Mozilla.Url Formatter Test"; diff --git a/toolkit/mozapps/extensions/src/nsAddonRepository.js b/toolkit/mozapps/extensions/src/nsAddonRepository.js index 16b2d1a793fe..75e1719d9761 100644 --- a/toolkit/mozapps/extensions/src/nsAddonRepository.js +++ b/toolkit/mozapps/extensions/src/nsAddonRepository.js @@ -51,6 +51,8 @@ const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml"; +const API_VERSION = "1"; + function AddonSearchResult() { } @@ -140,10 +142,14 @@ AddonRepository.prototype = { this._recommended = true; this._maxResults = aMaxResults; + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); var urlf = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"] .getService(Components.interfaces.nsIURLFormatter); - var uri = urlf.formatURLPref(PREF_GETADDONS_GETRECOMMENDED); + var uri = prefs.getCharPref(PREF_GETADDONS_GETRECOMMENDED); + uri = uri.replace(/%API_VERSION%/g, API_VERSION); + uri = urlf.formatURL(uri); this._loadList(uri); }, @@ -163,6 +169,7 @@ AddonRepository.prototype = { .getService(Components.interfaces.nsIURLFormatter); var uri = prefs.getCharPref(PREF_GETADDONS_GETSEARCHRESULTS); + uri = uri.replace(/%API_VERSION%/g, API_VERSION); uri = uri.replace(/%TERMS%/g, encodeURIComponent(aSearchTerms)); uri = urlf.formatURL(uri); this._loadList(uri); @@ -211,18 +218,22 @@ AddonRepository.prototype = { return; // Ignore add-ons not compatible with this OS - var compatible = false; var os = element.getElementsByTagName("compatible_os"); - var i = 0; - while (i < os.length && !compatible) { - if (os[i].textContent == "ALL" || os[i].textContent == app.OS) { - compatible = true; - break; + // Only the version 0 schema included compatible_os if it isn't there then + // we will see os compatibility on the install elements. + if (os.length > 0) { + var compatible = false; + var i = 0; + while (i < os.length && !compatible) { + if (os[i].textContent == "ALL" || os[i].textContent == app.OS) { + compatible = true; + break; + } + i++; } - i++; + if (!compatible) + return; } - if (!compatible) - return; // Ignore add-ons not compatible with this Application compatible = false; @@ -284,6 +295,13 @@ AddonRepository.prototype = { addon.type = Ci.nsIUpdateItem.TYPE_EXTENSION; break; case "install": + // No os attribute means the xpi is compatible with any os + if (node.hasAttribute("os")) { + var os = node.getAttribute("os").toLowerCase(); + // If the os is not ALL and not the current OS then ignore this xpi + if (os != "all" && os != app.OS.toLowerCase()) + break; + } addon.xpiURL = node.textContent; if (node.hasAttribute("hash")) addon.xpiHash = node.getAttribute("hash"); @@ -293,7 +311,9 @@ AddonRepository.prototype = { node = node.nextSibling; } - this._addons.push(addon); + // Add only if there was an xpi compatible with this os + if (addon.xpiURL) + this._addons.push(addon); }, // Called when a single request has completed, parses out any add-ons and @@ -318,7 +338,11 @@ AddonRepository.prototype = { return; } } - this._reportSuccess(elements.length); + + if (responseXML.documentElement.hasAttribute("total_results")) + this._reportSuccess(responseXML.documentElement.getAttribute("total_results")); + else + this._reportSuccess(elements.length); }, // Performs a new request for results diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug404024.xml b/toolkit/mozapps/extensions/test/unit/data/test_bug404024.xml new file mode 100644 index 000000000000..5c9d37bc0ece --- /dev/null +++ b/toolkit/mozapps/extensions/test/unit/data/test_bug404024.xml @@ -0,0 +1,158 @@ + + + + FAIL + Extension + test1@tests.mozilla.org + 1.0 + Sandbox + Should not return sandboxed add-on + + + XPCShell + 1 + 1 + 1 + + + ALL + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + test2@tests.mozilla.org + 1.0 + Public + Should not return an incompatible add-on + + + XPCShell + 1 + 2 + 2 + + + ALL + http://localhost:4444/test.xpi + + + FAIL + Extension + test3@tests.mozilla.org + 1.0 + Public + Should not return an incompatible add-on + + + Firefox + 1 + 2 + 2 + + + ALL + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + test4@tests.mozilla.org + 1.0 + Public + Should not return an add-on for a different OS + + + XPCShell + 1 + 1 + 1 + + + Windows + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + PASS + Extension + test5@tests.mozilla.org + 1.0 + Public + This should work fine + Test description + + + XPCShell + 1 + 1 + 1 + + + ALL + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + bug397778@tests.mozilla.org + 1.0 + Public + Should not return items that are already installed + + + XPCShell + 1 + 1 + 1 + + + ALL + http://localhost:4444/test.xpi + + + FAIL + Extension + test5@tests.mozilla.org + 1.0 + Public + Should not include the same result twice + + + XPCShell + 1 + 1 + 1 + + + ALL + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + PASS + Theme + test6@tests.mozilla.org + 1.0 + Public + 4 + Specific OS should work fine + EULA should be confirmed + http://localhost:4444/test_bug404024/thumbnail.png + http://localhost:4444/test_bug404024/icon.png + + + XPCShell + 1 + 1 + 1 + + + XPCShell + http://localhost:4444/test.xpi + + + diff --git a/toolkit/mozapps/extensions/test/unit/data/test_bug417606.xml b/toolkit/mozapps/extensions/test/unit/data/test_bug417606.xml new file mode 100644 index 000000000000..6fce27015ff6 --- /dev/null +++ b/toolkit/mozapps/extensions/test/unit/data/test_bug417606.xml @@ -0,0 +1,152 @@ + + + + FAIL + Extension + test1@tests.mozilla.org + 1.0 + Sandbox + Should not return sandboxed add-on + + + XPCShell + 1 + 1 + 1 + + + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + test2@tests.mozilla.org + 1.0 + Public + Should not return an incompatible add-on + + + XPCShell + 1 + 2 + 2 + + + http://localhost:4444/test.xpi + + + FAIL + Extension + test3@tests.mozilla.org + 1.0 + Public + Should not return an incompatible add-on + + + Firefox + 1 + 2 + 2 + + + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + test4@tests.mozilla.org + 1.0 + Public + Should not return an add-on for a different OS + + + XPCShell + 1 + 1 + 1 + + + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + PASS + Extension + test5@tests.mozilla.org + 1.0 + Public + This should work fine + Test description + + + XPCShell + 1 + 1 + 1 + + + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + FAIL + Extension + bug397778@tests.mozilla.org + 1.0 + Public + Should not return items that are already installed + + + XPCShell + 1 + 1 + 1 + + + http://localhost:4444/test.xpi + + + FAIL + Extension + test5@tests.mozilla.org + 1.0 + Public + Should not include the same result twice + + + XPCShell + 1 + 1 + 1 + + + https://addons.mozilla.org/addon/5992 + http://localhost:4444/test.xpi + + + PASS + Theme + test6@tests.mozilla.org + 1.0 + Public + 4 + Specific OS should work fine + EULA should be confirmed + http://localhost:4444/test_bug404024/thumbnail.png + http://localhost:4444/test_bug404024/icon.png + + + XPCShell + 1 + 1 + 1 + + + http://localhost:4444/test.xpi + http://localhost:4444/XPCShell.xpi + http://localhost:4444/test.xpi + + + diff --git a/toolkit/mozapps/extensions/test/unit/test_bug404024.js b/toolkit/mozapps/extensions/test/unit/test_bug404024.js new file mode 100644 index 000000000000..5921e5b27c0d --- /dev/null +++ b/toolkit/mozapps/extensions/test/unit/test_bug404024.js @@ -0,0 +1,209 @@ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Dave Townsend . + * + * Portions created by the Initial Developer are Copyright (C) 2007 + * 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 ***** + */ + +const PREF_GETADDONS_BROWSEADDONS = "extensions.getAddons.browseAddons"; +const PREF_GETADDONS_BROWSERECOMMENDED = "extensions.getAddons.recommended.browseURL"; +const PREF_GETADDONS_GETRECOMMENDED = "extensions.getAddons.recommended.url"; +const PREF_GETADDONS_BROWSESEARCHRESULTS = "extensions.getAddons.search.browseURL"; +const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; + +const BROWSE = "http://localhost:4444/"; +const RECOMMENDED = "http://localhost:4444/recommended.html"; +const SEARCH = "http://localhost:4444/search.html?q="; + +var BROWSE_SEARCH_URLS = [ + ["test", SEARCH + "test" ], + ["SEARCH", SEARCH + "SEARCH" ], + ["test search", SEARCH + "test%20search" ], + ["odd=search:with&weird\"characters", SEARCH + "odd%3Dsearch%3Awith%26weird%22characters" ] +]; + +do_import_script("netwerk/test/httpserver/httpd.js"); +var server; +var addonRepo; + +var RESULTS = [ +{ + id: "test5@tests.mozilla.org", + name: "PASS", + version: "1.0", + summary: "This should work fine", + description: "Test description", + rating: -1, + iconURL: null, + thumbnailURL: null, + homepageURL: "https://addons.mozilla.org/addon/5992", + eula: null, + type: Ci.nsIUpdateItem.TYPE_EXTENSION, + xpiURL: "http://localhost:4444/test.xpi", + xpiHash: "sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3" +}, +{ + id: "test6@tests.mozilla.org", + name: "PASS", + version: "1.0", + summary: "Specific OS should work fine", + description: null, + rating: 4, + iconURL: "http://localhost:4444/test_bug404024/icon.png", + thumbnailURL: "http://localhost:4444/test_bug404024/thumbnail.png", + homepageURL: null, + eula: "EULA should be confirmed", + type: Ci.nsIUpdateItem.TYPE_THEME, + xpiURL: "http://localhost:4444/test.xpi", + xpiHash: null +} +]; + +function checkResults(addons, length) { + do_check_eq(addons.length, RESULTS.length); + do_check_eq(addons.length, length); + + for (var i = 0; i < addons.length; i++) { + if (addons[i].name == "FAIL") + do_throw(addons[i].id + " - " + addons[i].summary); + if (addons[i].name != "PASS") + do_throw(addons[i].id + " - " + "invalid add-on name " + addons[i].name); + } + + for (var i = 0; i < addons.length; i++) { + for (var p in RESULTS[i]) { + if (addons[i][p] != RESULTS[i][p]) + do_throw("Failed on property " + p + " on add-on " + addons[i].id + + addons[i][p] + " == " + RESULTS[i][p]); + } + } +} + +var RecommendedCallback = { + searchSucceeded: function(addons, length, total) { + // Search is complete + do_check_false(addonRepo.isSearching); + checkResults(addons, length); + + // "search" for the same results + addonRepo.searchAddons("bug404024", 10, SearchCallback); + // Should be searching now and any attempt to retrieve again should be ignored + do_check_true(addonRepo.isSearching); + addonRepo.searchAddons("test search", 10, FailCallback); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Recommended results failed"); + } +}; + +var SearchCallback = { + searchSucceeded: function(addons, length, total) { + do_check_false(addonRepo.isSearching); + checkResults(addons, length); + + do_test_finished(); + server.stop(); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Search results failed"); + } +}; + +var FailCallback = { + searchSucceeded: function(addons, length, total) { + do_test_finished(); + server.stop(); + do_throw("Should not be called"); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Should not be called"); + } +}; + +function run_test() +{ + // Setup for test + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); + + // Install an add-on so we can check the same add-on isn't returns in the results + startupEM(); + gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE); + restartEM(); + + server = new nsHttpServer(); + server.registerDirectory("/", do_get_file("toolkit/mozapps/extensions/test/unit/data")); + server.start(4444); + + // Point the addons repository to the test server + gPrefs.setCharPref(PREF_GETADDONS_BROWSEADDONS, BROWSE); + gPrefs.setCharPref(PREF_GETADDONS_BROWSERECOMMENDED, RECOMMENDED); + gPrefs.setCharPref(PREF_GETADDONS_GETRECOMMENDED, "http://localhost:4444/test_bug404024.xml"); + gPrefs.setCharPref(PREF_GETADDONS_BROWSESEARCHRESULTS, SEARCH + "%TERMS%"); + gPrefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, "http://localhost:4444/test_%TERMS%.xml"); + + addonRepo = Components.classes["@mozilla.org/extensions/addon-repository;1"] + .getService(Components.interfaces.nsIAddonRepository); + + do_check_neq(addonRepo, null); + // Check the homepage and recommended urls + do_check_eq(addonRepo.homepageURL, BROWSE); + do_check_eq(addonRepo.getRecommendedURL(), RECOMMENDED); + + // Check that search urls are correct + for (var i = 0; i < BROWSE_SEARCH_URLS.length; i++) { + var url = addonRepo.getSearchURL(BROWSE_SEARCH_URLS[i][0]); + if (url != BROWSE_SEARCH_URLS[i][1]) + do_throw("BROWSE_SEARCH_URL[" + i + "] returned " + url); + } + + do_test_pending(); + // This should fail because we cancel it immediately. + addonRepo.retrieveRecommendedAddons(10, FailCallback); + addonRepo.cancelSearch(); + // Pull some results. + addonRepo.retrieveRecommendedAddons(10, RecommendedCallback); + // Should be searching now and any attempt to retrieve again should be ignored + do_check_true(addonRepo.isSearching); + addonRepo.retrieveRecommendedAddons(10, FailCallback); +} + diff --git a/toolkit/mozapps/extensions/test/unit/test_bug417606.js b/toolkit/mozapps/extensions/test/unit/test_bug417606.js new file mode 100644 index 000000000000..ba3f7519b36c --- /dev/null +++ b/toolkit/mozapps/extensions/test/unit/test_bug417606.js @@ -0,0 +1,209 @@ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Dave Townsend . + * + * Portions created by the Initial Developer are Copyright (C) 2007 + * 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 ***** + */ + +const PREF_GETADDONS_BROWSEADDONS = "extensions.getAddons.browseAddons"; +const PREF_GETADDONS_BROWSERECOMMENDED = "extensions.getAddons.recommended.browseURL"; +const PREF_GETADDONS_GETRECOMMENDED = "extensions.getAddons.recommended.url"; +const PREF_GETADDONS_BROWSESEARCHRESULTS = "extensions.getAddons.search.browseURL"; +const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; + +const BROWSE = "http://localhost:4444/"; +const RECOMMENDED = "http://localhost:4444/recommended.html"; +const SEARCH = "http://localhost:4444/search/"; + +var BROWSE_SEARCH_URLS = [ + ["test", SEARCH + "test" ], + ["SEARCH", SEARCH + "SEARCH" ], + ["test search", SEARCH + "test%20search" ], + ["odd=search:with&weird\"characters", SEARCH + "odd%3Dsearch%3Awith%26weird%22characters" ] +]; + +do_import_script("netwerk/test/httpserver/httpd.js"); +var server; +var addonRepo; + +var RESULTS = [ +{ + id: "test5@tests.mozilla.org", + name: "PASS", + version: "1.0", + summary: "This should work fine", + description: "Test description", + rating: -1, + iconURL: null, + thumbnailURL: null, + homepageURL: "https://addons.mozilla.org/addon/5992", + eula: null, + type: Ci.nsIUpdateItem.TYPE_EXTENSION, + xpiURL: "http://localhost:4444/test.xpi", + xpiHash: "sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3" +}, +{ + id: "test6@tests.mozilla.org", + name: "PASS", + version: "1.0", + summary: "Specific OS should work fine", + description: null, + rating: 4, + iconURL: "http://localhost:4444/test_bug404024/icon.png", + thumbnailURL: "http://localhost:4444/test_bug404024/thumbnail.png", + homepageURL: null, + eula: "EULA should be confirmed", + type: Ci.nsIUpdateItem.TYPE_THEME, + xpiURL: "http://localhost:4444/XPCShell.xpi", + xpiHash: null +} +]; + +function checkResults(addons) { + do_check_eq(addons.length, RESULTS.length); + + for (var i = 0; i < addons.length; i++) { + if (addons[i].name == "FAIL") + do_throw(addons[i].id + " - " + addons[i].summary); + if (addons[i].name != "PASS") + do_throw(addons[i].id + " - " + "invalid add-on name " + addons[i].name); + } + + for (var i = 0; i < addons.length; i++) { + for (var p in RESULTS[i]) { + if (addons[i][p] != RESULTS[i][p]) + do_throw("Failed on property " + p + " on add-on " + addons[i].id + + addons[i][p] + " == " + RESULTS[i][p]); + } + } +} + +var RecommendedCallback = { + searchSucceeded: function(addons, length, total) { + // Search is complete + do_check_false(addonRepo.isSearching); + checkResults(addons); + + // "search" for the same results + addonRepo.searchAddons("bug417606", 10, SearchCallback); + // Should be searching now and any attempt to retrieve again should be ignored + do_check_true(addonRepo.isSearching); + addonRepo.searchAddons("test search", 10, FailCallback); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Recommended results failed"); + } +}; + +var SearchCallback = { + searchSucceeded: function(addons, length, total) { + do_check_false(addonRepo.isSearching); + do_check_eq(total, 100); + checkResults(addons); + + do_test_finished(); + server.stop(); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Search results failed"); + } +}; + +var FailCallback = { + searchSucceeded: function(addons, length, total) { + do_test_finished(); + server.stop(); + do_throw("Should not be called"); + }, + + searchFailed: function() { + do_test_finished(); + server.stop(); + do_throw("Should not be called"); + } +}; + +function run_test() +{ + // Setup for test + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); + + // Install an add-on so we can check the same add-on isn't returns in the results + startupEM(); + gEM.installItemFromFile(do_get_addon("test_bug397778"), NS_INSTALL_LOCATION_APPPROFILE); + restartEM(); + + server = new nsHttpServer(); + server.registerDirectory("/", do_get_file("toolkit/mozapps/extensions/test/unit/data")); + server.start(4444); + + // Point the addons repository to the test server + gPrefs.setCharPref(PREF_GETADDONS_BROWSEADDONS, BROWSE); + gPrefs.setCharPref(PREF_GETADDONS_BROWSERECOMMENDED, RECOMMENDED); + gPrefs.setCharPref(PREF_GETADDONS_GETRECOMMENDED, "http://localhost:4444/test_bug417606.xml"); + gPrefs.setCharPref(PREF_GETADDONS_BROWSESEARCHRESULTS, SEARCH + "%TERMS%"); + gPrefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, "http://localhost:4444/test_%TERMS%.xml"); + + addonRepo = Components.classes["@mozilla.org/extensions/addon-repository;1"] + .getService(Components.interfaces.nsIAddonRepository); + + do_check_neq(addonRepo, null); + // Check the homepage and recommended urls + do_check_eq(addonRepo.homepageURL, BROWSE); + do_check_eq(addonRepo.getRecommendedURL(), RECOMMENDED); + + // Check that search urls are correct + for (var i = 0; i < BROWSE_SEARCH_URLS.length; i++) { + var url = addonRepo.getSearchURL(BROWSE_SEARCH_URLS[i][0]); + if (url != BROWSE_SEARCH_URLS[i][1]) + do_throw("BROWSE_SEARCH_URL[" + i + "] returned " + url); + } + + do_test_pending(); + // This should fail because we cancel it immediately. + addonRepo.retrieveRecommendedAddons(10, FailCallback); + addonRepo.cancelSearch(); + // Pull some results. + addonRepo.retrieveRecommendedAddons(10, RecommendedCallback); + // Should be searching now and any attempt to retrieve again should be ignored + do_check_true(addonRepo.isSearching); + addonRepo.retrieveRecommendedAddons(10, FailCallback); +} + From a8e97c45ae4556406dcdcd869e6a6ea2387b790e Mon Sep 17 00:00:00 2001 From: "johnath@mozilla.com" Date: Fri, 7 Mar 2008 05:30:35 -0800 Subject: [PATCH 122/248] Bug 418694 - Have Larry say "(unknown)" instead of "no information provided" r+a=beltzner --- browser/base/content/browser.js | 2 +- browser/base/content/browser.xul | 2 +- browser/locales/en-US/chrome/browser/browser.dtd | 2 +- browser/locales/en-US/chrome/browser/browser.properties | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index fd38e2642dfc..06dfc9cf8023 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6193,7 +6193,7 @@ IdentityHandler.prototype = { // Fail back to the full domain. host = this._lastHost; } - var owner = this._stringBundle.getString("identity.ownerUnknown"); + var owner = this._stringBundle.getString("identity.ownerUnknown2"); verifier = this._identityBox.tooltipText; supplemental = ""; } diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 4d8b158a6e44..2215768261b9 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -176,7 +176,7 @@
From 0eabc71cc497d9b62f6c64e38ae18e09f77b9f84 Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Sat, 8 Mar 2008 16:29:05 -0800 Subject: [PATCH 207/248] Bug 402356: netError pages use hardcoded colors for warnings, patch by KUROSAWA, Takeshi , r=me, ui-r=beltzner --- toolkit/themes/gnomestripe/global/netError.css | 3 ++- toolkit/themes/winstripe/global/netError.css | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/themes/gnomestripe/global/netError.css b/toolkit/themes/gnomestripe/global/netError.css index c142f7a40f34..9f1c45b87701 100644 --- a/toolkit/themes/gnomestripe/global/netError.css +++ b/toolkit/themes/gnomestripe/global/netError.css @@ -109,7 +109,8 @@ body[dir="rtl"] #brand { } #securityOverrideContent { - background-color: #FFF090; /* Pale yellow */ + background-color: InfoBackground; + color: InfoText; padding: 10px; -moz-border-radius: 10px; } diff --git a/toolkit/themes/winstripe/global/netError.css b/toolkit/themes/winstripe/global/netError.css index e8d22b184820..0f886b7713e5 100644 --- a/toolkit/themes/winstripe/global/netError.css +++ b/toolkit/themes/winstripe/global/netError.css @@ -110,7 +110,8 @@ body[dir="rtl"] #brand { } #securityOverrideContent { - background-color: #FFF090; /* Pale yellow */ + background-color: InfoBackground; + color: InfoText; padding: 10px; -moz-border-radius: 10px; } From ad7a9975eda3b1dd35098895b31782b1999b1503 Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Sat, 8 Mar 2008 16:31:39 -0800 Subject: [PATCH 208/248] Bug 409215: can sometimes get 'stuck' when trying to close tabs by repeatedly clicking the tab close button (don't skip more than one 'double click' event), r=mconnor --- browser/base/content/tabbrowser.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 1032790fd763..001482a2b513 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -3168,9 +3168,18 @@ * double click on the tabbar. (bug 378344) * In both cases, it is most likely that the close button area has * been accidentally clicked, therefore we do not close the tab. + * + * We don't want to ignore processing of more than one click event, + * though, since the user might actually be repeatedly clicking to + * close many tabs at once. */ - if (event.detail > 1) + if (event.detail > 1 && !this._ignoredClick) { + this._ignoredClick = true; return; + } + + // Reset the "ignored click" flag + this._ignoredClick = false; tabbedBrowser.removeTab(bindingParent); tabbedBrowser._blockDblClick = true; From 52662b14127eabcd44dd7c363368458178c04e7b Mon Sep 17 00:00:00 2001 From: "edward.lee@engineering.uiuc.edu" Date: Sat, 8 Mar 2008 17:02:06 -0800 Subject: [PATCH 209/248] Bug 412360 - Download Manager remains empty, downloads don't start, with this 3.0b2 downloads.sqlite. r=sdwilsh, r=biesi, sr=biesi, b-ff3=beltzner --- .../src/nsWebBrowserPersist.cpp | 1 + .../downloads/src/nsDownloadManager.cpp | 2 +- .../downloads/tests/browser/Makefile.in | 5 +- .../tests/browser/browser_bug_412360.js | 141 ++++++++++++++++++ 4 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 toolkit/mozapps/downloads/tests/browser/browser_bug_412360.js diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp index 183632fa7aea..f4b964e8ddf4 100644 --- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp @@ -1344,6 +1344,7 @@ nsresult nsWebBrowserPersist::SaveChannelInternal( // Opening failed, but do we care? if (mPersistFlags & PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS) { + SendErrorStatusChange(PR_TRUE, rv, aChannel, aFile); EndDownload(NS_ERROR_FAILURE); return NS_ERROR_FAILURE; } diff --git a/toolkit/components/downloads/src/nsDownloadManager.cpp b/toolkit/components/downloads/src/nsDownloadManager.cpp index d0608d1eaa11..3737f0319af2 100644 --- a/toolkit/components/downloads/src/nsDownloadManager.cpp +++ b/toolkit/components/downloads/src/nsDownloadManager.cpp @@ -895,7 +895,7 @@ nsDownloadManager::Init() NS_ENSURE_SUCCESS(rv, rv); rv = RestoreActiveDownloads(); - NS_ENSURE_SUCCESS(rv, rv); + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to restore all active downloads"); // The following three AddObserver calls must be the last lines in this function, // because otherwise, this function may fail (and thus, this object would be not diff --git a/toolkit/mozapps/downloads/tests/browser/Makefile.in b/toolkit/mozapps/downloads/tests/browser/Makefile.in index ee87401481df..00d8b20cf552 100644 --- a/toolkit/mozapps/downloads/tests/browser/Makefile.in +++ b/toolkit/mozapps/downloads/tests/browser/Makefile.in @@ -47,12 +47,13 @@ include $(topsrcdir)/config/rules.mk _BROWSER_FILES = \ browser_basic_functionality.js \ - browser_bug_411172.js \ browser_bug_394039.js \ + browser_bug_406857.js \ browser_bug_410289.js \ + browser_bug_411172.js \ + browser_bug_412360.js \ browser_bug_413985.js \ browser_bug_416303.js \ - browser_bug_406857.js \ $(NULL) ifneq (,$(filter cocoa, $(MOZ_WIDGET_TOOLKIT))) diff --git a/toolkit/mozapps/downloads/tests/browser/browser_bug_412360.js b/toolkit/mozapps/downloads/tests/browser/browser_bug_412360.js new file mode 100644 index 000000000000..60eeb0b3edc7 --- /dev/null +++ b/toolkit/mozapps/downloads/tests/browser/browser_bug_412360.js @@ -0,0 +1,141 @@ +/* ***** 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 Download Manager UI Test Code. + * + * The Initial Developer of the Original Code is + * Edward Lee . + * 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 ***** */ + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +let didFail = false; + +let promptService = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptService]), + alert: function() { + ok(didFail, "javascript: uri failed and showed a message"); + finish(); + } +}; + +Components.manager.QueryInterface(Ci.nsIComponentRegistrar). +registerFactory(Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"), + "PromptService", "@mozilla.org/embedcomp/prompt-service;1", + { + createInstance: function(aOuter, aIid) { + if (aOuter != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + return promptService.QueryInterface(aIid); + } + }); + +function test() +{ + let dm = Cc["@mozilla.org/download-manager;1"]. + getService(Ci.nsIDownloadManager); + let db = dm.DBConnection; + + // Empty any old downloads + db.executeSimpleSQL("DELETE FROM moz_downloads"); + + let stmt = db.createStatement( + "INSERT INTO moz_downloads (source, target, state) " + + "VALUES (?1, ?2, ?3)"); + + // Saving javascript URIs doesn't work + stmt.bindStringParameter(0, "javascript:5"); + + // Download to a temp local file + let file = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile); + file.append("javascriptURI"); + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); + stmt.bindStringParameter(1, Cc["@mozilla.org/network/io-service;1"]. + getService(Ci.nsIIOService).newFileURI(file).spec); + + // Start it as canceled + stmt.bindInt32Parameter(2, dm.DOWNLOAD_CANCELED); + + // Add it! + stmt.execute(); + stmt.finalize(); + + let listener = { + onDownloadStateChange: function(aState, aDownload) + { + switch (aDownload.state) { + case dm.DOWNLOAD_FAILED: + // Remember that we failed for the prompt service + didFail = true; + + ok(true, "javascript: uri failed instead of getting stuck"); + dm.removeListener(listener); + break; + } + } + }; + dm.addListener(listener); + + // Close the UI if necessary + let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. + getService(Ci.nsIWindowMediator); + let win = wm.getMostRecentWindow("Download:Manager"); + if (win) win.close(); + + // Start the test when the download manager window loads + let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. + getService(Ci.nsIWindowWatcher); + ww.registerNotification({ + observe: function(aSubject, aTopic, aData) { + ww.unregisterNotification(this); + aSubject.QueryInterface(Ci.nsIDOMEventTarget). + addEventListener("DOMContentLoaded", doTest, false); + } + }); + + // Let the Startup method of the download manager UI finish before we test + let doTest = function() setTimeout(function() { + win = wm.getMostRecentWindow("Download:Manager"); + + // Try again if selectedIndex is -1 + if (win.document.getElementById("downloadView").selectedIndex) + return doTest(); + + // Send the enter key to Download Manager to retry the download + EventUtils.synthesizeKey("VK_ENTER", {}, win); + }, 0); + + // Show the Download Manager UI + Cc["@mozilla.org/download-manager-ui;1"]. + getService(Ci.nsIDownloadManagerUI).show(); + + waitForExplicitFinish(); +} From 92964088723ff15dd147210349c7af824dbfa965 Mon Sep 17 00:00:00 2001 From: "edward.lee@engineering.uiuc.edu" Date: Sat, 8 Mar 2008 17:04:28 -0800 Subject: [PATCH 210/248] Bug 418961 - "Save Page As" "Text Files" saves file but Downloads window doesn't show completion. r=biesi, sr=biesi, b-ff3=beltzner --- .../webbrowserpersist/src/nsWebBrowserPersist.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp index f4b964e8ddf4..3d3076344532 100644 --- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp @@ -481,10 +481,12 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveDocument( { // tell the listener we're done mProgressListener->OnStateChange(nsnull, nsnull, - nsIWebProgressListener::STATE_START, + nsIWebProgressListener::STATE_START | + nsIWebProgressListener::STATE_IS_NETWORK, NS_OK); mProgressListener->OnStateChange(nsnull, nsnull, - nsIWebProgressListener::STATE_STOP, + nsIWebProgressListener::STATE_STOP | + nsIWebProgressListener::STATE_IS_NETWORK, rv); } From 0e35e7e7ad127d327e5b9709ca44d9459f1de06a Mon Sep 17 00:00:00 2001 From: "dolske@mozilla.com" Date: Sat, 8 Mar 2008 18:25:40 -0800 Subject: [PATCH 211/248] Bug 421058 - Firefox won't prompt to change stored passwords. r=gavin, a=blocking-ff3+ --- toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js index 39b1c1ba1087..012d600376cb 100644 --- a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js +++ b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js @@ -700,7 +700,7 @@ LoginManagerPrompter.prototype = { * Shows the Change Password notification bar. * */ - _showChangeLoginNotification : function (notifyBox, aOldLogin, aNewLogin) { + _showChangeLoginNotification : function (aNotifyBox, aOldLogin, aNewLogin) { var notificationText; if (aOldLogin.username) notificationText = this._getLocalizedString( From 1120b82dc186eb2037e639b0fb80d522db24c215 Mon Sep 17 00:00:00 2001 From: "brendan@mozilla.org" Date: Sat, 8 Mar 2008 20:49:46 -0800 Subject: [PATCH 212/248] Fix from Sebastian Redl to compile under GCC 4.2 (r=me, a=shaver). --- js/src/jslock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/js/src/jslock.c b/js/src/jslock.c index 50402b4fc533..8d58984d5799 100644 --- a/js/src/jslock.c +++ b/js/src/jslock.c @@ -44,6 +44,7 @@ */ #include "jsstddef.h" #include +#include #include "jspubtd.h" #include "jsutil.h" /* Added by JSIFY */ #include "jstypes.h" From 8ddee95952da7f775dc85e3fb27c524dfcc05785 Mon Sep 17 00:00:00 2001 From: "jruderman@hmc.edu" Date: Sat, 8 Mar 2008 22:32:28 -0800 Subject: [PATCH 213/248] Add crashtest --- layout/mathml/crashtests/420420-1.xhtml | 7 +++++++ layout/mathml/crashtests/crashtests.list | 1 + 2 files changed, 8 insertions(+) create mode 100644 layout/mathml/crashtests/420420-1.xhtml diff --git a/layout/mathml/crashtests/420420-1.xhtml b/layout/mathml/crashtests/420420-1.xhtml new file mode 100644 index 000000000000..db17b277a781 --- /dev/null +++ b/layout/mathml/crashtests/420420-1.xhtml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/layout/mathml/crashtests/crashtests.list b/layout/mathml/crashtests/crashtests.list index 16b42d6e8058..8c1982b45c6d 100644 --- a/layout/mathml/crashtests/crashtests.list +++ b/layout/mathml/crashtests/crashtests.list @@ -35,3 +35,4 @@ load 405187-1.xhtml load 405271-1.xml load 412237-1.xml load 413063-1.xhtml +load 420420-1.xhtml From f128056e1ee38ae52aaa845c9501136827fcfe7d Mon Sep 17 00:00:00 2001 From: "jruderman@hmc.edu" Date: Sat, 8 Mar 2008 22:37:45 -0800 Subject: [PATCH 214/248] Add a crashtest --- layout/tables/crashtests/351327-1.xhtml | 21 +++++++++++++++++++++ layout/tables/crashtests/crashtests.list | 1 + 2 files changed, 22 insertions(+) create mode 100644 layout/tables/crashtests/351327-1.xhtml diff --git a/layout/tables/crashtests/351327-1.xhtml b/layout/tables/crashtests/351327-1.xhtml new file mode 100644 index 000000000000..a9e381a20a8a --- /dev/null +++ b/layout/tables/crashtests/351327-1.xhtml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + +
td
+ + + + diff --git a/layout/tables/crashtests/crashtests.list b/layout/tables/crashtests/crashtests.list index 909ea6da0a79..e74297362c38 100644 --- a/layout/tables/crashtests/crashtests.list +++ b/layout/tables/crashtests/crashtests.list @@ -14,6 +14,7 @@ load 347725-1.xhtml load 348977-1.xhtml load 350524-1.xhtml load 351326-1.xhtml +load 351327-1.xhtml load 351328-1.xhtml load 351628-1.xhtml load 358679-1.xhtml From 17b1dd6657e81ceaf69c32656c0af7a5110352e6 Mon Sep 17 00:00:00 2001 From: "dwitte@stanford.edu" Date: Sun, 9 Mar 2008 01:12:12 -0800 Subject: [PATCH 215/248] improve interface documentation. no bug, npob --- netwerk/dns/public/nsIEffectiveTLDService.idl | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/netwerk/dns/public/nsIEffectiveTLDService.idl b/netwerk/dns/public/nsIEffectiveTLDService.idl index ff75f459da02..23381cd20019 100644 --- a/netwerk/dns/public/nsIEffectiveTLDService.idl +++ b/netwerk/dns/public/nsIEffectiveTLDService.idl @@ -53,8 +53,11 @@ interface nsIEffectiveTLDService : nsISupports * * The public suffix will be returned encoded in ASCII/ACE and will be normalized * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost(). + * If consumers wish to compare the result of this method against the host from + * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost(). + * In the case of nested URIs, the innermost URI will be used. * - * @param aURI The URI to be analyzed + * @param aURI The URI to be analyzed * * @returns the public suffix * @@ -85,6 +88,9 @@ interface nsIEffectiveTLDService : nsISupports * * The base domain will be returned encoded in ASCII/ACE and will be normalized * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost(). + * If consumers wish to compare the result of this method against the host from + * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost(). + * In the case of nested URIs, the innermost URI will be used. * * @param aURI The URI to be analyzed * @param aAdditionalParts Number of domain name parts to be @@ -107,15 +113,31 @@ interface nsIEffectiveTLDService : nsISupports ACString getBaseDomain(in nsIURI aURI, [optional] in PRUint32 aAdditionalParts); /** + * NOTE: It is strongly recommended to use getPublicSuffix() above if a suitable + * nsIURI is available. Only use this method if this is not the case. + * * Returns the public suffix of a host string. Otherwise identical to getPublicSuffix(). * + * @param aHost The host to be analyzed. Any additional parts (e.g. scheme, + * port, or path) will cause this method to throw. ASCII/ACE and + * UTF8 encodings are acceptable as input; normalization will + * be performed as specified in getBaseDomain(). + * * @see getPublicSuffix() */ ACString getPublicSuffixFromHost(in AUTF8String aHost); /** + * NOTE: It is strongly recommended to use getBaseDomain() above if a suitable + * nsIURI is available. Only use this method if this is not the case. + * * Returns the base domain of a host string. Otherwise identical to getBaseDomain(). * + * @param aHost The host to be analyzed. Any additional parts (e.g. scheme, + * port, or path) will cause this method to throw. ASCII/ACE and + * UTF8 encodings are acceptable as input; normalization will + * be performed as specified in getBaseDomain(). + * * @see getBaseDomain() */ ACString getBaseDomainFromHost(in AUTF8String aHost, [optional] in PRUint32 aAdditionalParts); From 4e8a15714c7a76d4f8649173c408dcc9cee1892c Mon Sep 17 00:00:00 2001 From: "dolske@mozilla.com" Date: Sun, 9 Mar 2008 01:27:51 -0800 Subject: [PATCH 216/248] Forgotten packaging changes from bug 417302. r=gavin --- browser/installer/unix/packages-static | 1 + browser/installer/windows/packages-static | 1 + 2 files changed, 2 insertions(+) diff --git a/browser/installer/unix/packages-static b/browser/installer/unix/packages-static index d0358f7a1d58..4096dfe0a1ad 100644 --- a/browser/installer/unix/packages-static +++ b/browser/installer/unix/packages-static @@ -241,6 +241,7 @@ bin/components/nsContentDispatchChooser.js bin/components/nsHandlerService.js bin/components/nsWebHandlerApp.js bin/components/libdbusservice.so +bin/components/aboutRobots.js ; Modules bin/modules/* diff --git a/browser/installer/windows/packages-static b/browser/installer/windows/packages-static index 933515850fc6..ba394058eb52 100644 --- a/browser/installer/windows/packages-static +++ b/browser/installer/windows/packages-static @@ -240,6 +240,7 @@ bin\components\nsContentPrefService.js bin\components\nsContentDispatchChooser.js bin\components\nsHandlerService.js bin\components\nsWebHandlerApp.js +bin\components\aboutRobots.js ; Modules bin\modules\* From 9f36c94fb066b5ca8334cbe9b6c4daef73fcb19e Mon Sep 17 00:00:00 2001 From: "timeless@mozdev.org" Date: Sun, 9 Mar 2008 03:05:29 -0700 Subject: [PATCH 217/248] Bug 421231 js.c needs to call JSDB_TermDebugger r=brendan NPOTB --- js/src/js.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/src/js.c b/js/src/js.c index df59a65cc9e1..1658fa532eb1 100644 --- a/js/src/js.c +++ b/js/src/js.c @@ -3808,6 +3808,9 @@ main(int argc, char **argv, char **envp) #ifdef JSDEBUGGER_JAVA_UI JNIEnv *java_env; #endif +#ifdef JSDEBUGGER_C_UI + JSBool jsdbc; +#endif /* JSDEBUGGER_C_UI */ CheckHelpMessages(); setlocale(LC_ALL, ""); @@ -3888,7 +3891,7 @@ main(int argc, char **argv, char **envp) */ #endif /* JSDEBUGGER_JAVA_UI */ #ifdef JSDEBUGGER_C_UI - JSDB_InitDebugger(rt, _jsdc, 0); + jsdbc = JSDB_InitDebugger(rt, _jsdc, 0); #endif /* JSDEBUGGER_C_UI */ #endif /* JSDEBUGGER */ @@ -3926,8 +3929,13 @@ main(int argc, char **argv, char **envp) result = ProcessArgs(cx, glob, argv, argc); #ifdef JSDEBUGGER - if (_jsdc) + if (_jsdc) { +#ifdef JSDEBUGGER_C_UI + if (jsdbc) + JSDB_TermDebugger(_jsdc); +#endif /* JSDEBUGGER_C_UI */ JSD_DebuggerOff(_jsdc); + } #endif /* JSDEBUGGER */ #ifdef JS_THREADSAFE From 403a9e34b92bebd742d3ef24c11975c9e5456838 Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Sun, 9 Mar 2008 04:19:45 -0700 Subject: [PATCH 218/248] Switch tests to fixed time to avoid DST issue from bug 402434 --- modules/libjar/zipwriter/test/unit/test_bug419769_1.js | 3 ++- modules/libjar/zipwriter/test/unit/test_deflatedata.js | 3 ++- modules/libjar/zipwriter/test/unit/test_storedata.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/libjar/zipwriter/test/unit/test_bug419769_1.js b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js index c97f8206dd82..ac18ae6be8fc 100644 --- a/modules/libjar/zipwriter/test/unit/test_bug419769_1.js +++ b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js @@ -39,7 +39,8 @@ const DATA = ""; const FILENAME = "test.txt"; const CRC = 0x00000000; -const time = Date.now(); +// XXX Must use a constant time here away from DST changes. See bug 402434. +const time = 1199145600000; // Jan 1st 2008 function testpass(source) { diff --git a/modules/libjar/zipwriter/test/unit/test_deflatedata.js b/modules/libjar/zipwriter/test/unit/test_deflatedata.js index 8f87acbd4917..20b67c10aae0 100644 --- a/modules/libjar/zipwriter/test/unit/test_deflatedata.js +++ b/modules/libjar/zipwriter/test/unit/test_deflatedata.js @@ -39,7 +39,8 @@ const DATA = "ZIP WRITER TEST DATA"; const FILENAME = "test.txt"; const CRC = 0xe6164331; -const time = Date.now(); +// XXX Must use a constant time here away from DST changes. See bug 402434. +const time = 1199145600000; // Jan 1st 2008 function run_test() { diff --git a/modules/libjar/zipwriter/test/unit/test_storedata.js b/modules/libjar/zipwriter/test/unit/test_storedata.js index 1c84a9f813b3..8d8fae11be7b 100644 --- a/modules/libjar/zipwriter/test/unit/test_storedata.js +++ b/modules/libjar/zipwriter/test/unit/test_storedata.js @@ -40,7 +40,8 @@ const DATA = "ZIP WRITER TEST DATA"; const FILENAME = "test.txt"; const FILENAME2 = "test2.txt"; const CRC = 0xe6164331; -const time = Date.now(); +// XXX Must use a constant time here away from DST changes. See bug 402434. +const time = 1199145600000; // Jan 1st 2008 function testpass(source) { From baf28387f9ce6fdf5ff2a24ec36df5e87b68591b Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Sun, 9 Mar 2008 06:06:30 -0700 Subject: [PATCH 219/248] Fix test to report what the differences actually were. --- intl/locale/src/unix/tests/unit/test_bug374040.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/intl/locale/src/unix/tests/unit/test_bug374040.js b/intl/locale/src/unix/tests/unit/test_bug374040.js index bee0a757733f..3623dc7fe92d 100644 --- a/intl/locale/src/unix/tests/unit/test_bug374040.js +++ b/intl/locale/src/unix/tests/unit/test_bug374040.js @@ -10,7 +10,7 @@ function test_full() { var dateStrJs = date.toLocaleString(); - return (dateStrXpcom == dateStrJs); + do_check_eq(dateStrXpcom, dateStrJs); } @@ -26,12 +26,12 @@ function test_kTimeFormatSeconds() { var dateStrJs = date.toLocaleDateString() - return (dateStrXpcom == dateStrJs); + do_check_eq(dateStrXpcom, dateStrJs); } function run_test() { - do_check_true(test_full()); - do_check_true(test_kTimeFormatSeconds()); + test_full(); + test_kTimeFormatSeconds(); } From abd273614fdd1da34d65cc673c125fce6eaf0acd Mon Sep 17 00:00:00 2001 From: "dtownsend@oxymoronical.com" Date: Sun, 9 Mar 2008 07:46:17 -0700 Subject: [PATCH 220/248] Disabling test due to bug 421790 --- intl/locale/src/unix/tests/unit/test_bug374040.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intl/locale/src/unix/tests/unit/test_bug374040.js b/intl/locale/src/unix/tests/unit/test_bug374040.js index 3623dc7fe92d..f662c235dbd6 100644 --- a/intl/locale/src/unix/tests/unit/test_bug374040.js +++ b/intl/locale/src/unix/tests/unit/test_bug374040.js @@ -32,6 +32,8 @@ function test_kTimeFormatSeconds() { function run_test() { + // XXX test disabled due to bug 421790 + return; test_full(); test_kTimeFormatSeconds(); } From f13e262e4491ee3bc31431e0b611081a0a9bfb81 Mon Sep 17 00:00:00 2001 From: "mozilla@weilbacher.org" Date: Sun, 9 Mar 2008 10:04:27 -0700 Subject: [PATCH 221/248] [OS/2] Bug 417372: permit RWS to be disabled by environment variable, p/r=Rich Walsh and me --- widget/src/os2/nsRwsService.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/widget/src/os2/nsRwsService.cpp b/widget/src/os2/nsRwsService.cpp index d65d3b6f541a..f107afc49b90 100644 --- a/widget/src/os2/nsRwsService.cpp +++ b/widget/src/os2/nsRwsService.cpp @@ -55,6 +55,7 @@ #include "rwserr.h" #include "nsOS2Uni.h" +#include "prenv.h" #include //------------------------------------------------------------------------ @@ -1120,6 +1121,10 @@ static nsresult nsRwsServiceInit(nsRwsService **aClass) sInit = TRUE; *aClass = 0; + // don't load RWS if "MOZ_NO_RWS" is found in the environment + if (PR_GetEnv("MOZ_NO_RWS")) + return NS_ERROR_NOT_AVAILABLE; + char errBuf[16]; HMODULE hmod; From c3d114bffb54ef08147c9e2d9fb26d9e9857bf46 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 12:49:14 -0700 Subject: [PATCH 222/248] JavaScript Tests - remove timezone dependencies for toLocaleFormat win32 tests, no bug, not part of the build --- js/tests/public-failures.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/tests/public-failures.txt b/js/tests/public-failures.txt index 9a67782bc5b6..21ef04506f24 100644 --- a/js/tests/public-failures.txt +++ b/js/tests/public-failures.txt @@ -353,23 +353,23 @@ TEST_ID=js1_5/extensions/toLocaleFormat-01.js, TEST_BRANCH=1.8.1, TEST_RESULT=FA TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500), TEST_DESCRIPTION=Date.toLocaleFormat("%H:%M") == Date.toLocaleFormat("%R") expected: 20:00 actual: Sat Jun 04 2005 `.``*` reason: Expected value '20:00', Actual value 'Sat Jun 04 2005 `.``*`' TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500), TEST_DESCRIPTION=Date.toLocaleFormat("%H:%M:%S") == Date.toLocaleFormat("%T") expected: 20:00:00 actual: Sat Jun 04 2005 `.``*` reason: Expected value '20:00:00', Actual value 'Sat Jun 04 2005 `.``*`' TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500), TEST_DESCRIPTION=Date.toLocaleFormat("%I:%M:%S %p") == Date.toLocaleFormat("%r") expected: 08:00:00 PM actual: Sat Jun 04 2005 `.``*` reason: Expected value '08:00:00 PM', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%C") expected: 20 actual: Sat Jun 04 2005 `.``*` reason: Expected value '20', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%G") expected: 2005 actual: Sat Jun 04 2005 `.``*` reason: Expected value '2005', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%V") expected: 22 actual: Sat Jun 04 2005 `.``*` reason: Expected value '22', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%Y-%m-%d") == Date.toLocaleFormat("%F") expected: 2005-06-04 actual: Sat Jun 04 2005 `.``*` reason: Expected value '2005-06-04', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%b") == Date.toLocaleFormat("%h") expected: Jun actual: Sat Jun 04 2005 `.``*` reason: Expected value 'Jun', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%e") expected: 4 actual: Sat Jun 04 2005 `.``*` reason: Expected value ' 4', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%g") expected: 05 actual: Sat Jun 04 2005 `.``*` reason: Expected value '05', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%m/%d/%y") == Date.toLocaleFormat("%D") expected: 06/04/05 actual: Sat Jun 04 2005 `.``*` reason: Expected value '06/04/05', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%m/%d/%y) == Date.toLocaleFormat("%x") expected: 06/04/2005 actual: 2005-06-04 reason: Expected value '06/04/2005', Actual value '2005-06-04' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%n") == "NL" expected: NL actual: Sat Jun 04 2005 `.``*` reason: Expected value 'NL', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%t") == "\t" expected: actual: Sat Jun 04 2005 `.``*` reason: Expected value ' ', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0400|-0500|-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%u") expected: 6 actual: Sat Jun 04 2005 `.``*` reason: Expected value '6', Actual value 'Sat Jun 04 2005 `.``*`' TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%H:%M") == Date.toLocaleFormat("%R") expected: 17:00 actual: Sat Jun 04 2005 `.``*` reason: Expected value '17:00', Actual value 'Sat Jun 04 2005 `.``*`' TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%H:%M:%S") == Date.toLocaleFormat("%T") expected: 17:00:00 actual: Sat Jun 04 2005 `.``*` reason: Expected value '17:00:00', Actual value 'Sat Jun 04 2005 `.``*`' TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0700|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%I:%M:%S %p") == Date.toLocaleFormat("%r") expected: 05:00:00 PM actual: Sat Jun 04 2005 `.``*` reason: Expected value '05:00:00 PM', Actual value 'Sat Jun 04 2005 `.``*`' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0500|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%C%y") == Date.toLocaleFormat("%Y") expected: 05 actual: 2005 reason: Expected value '05', Actual value '2005' -TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=(-0500|-0800), TEST_DESCRIPTION=Date.toLocaleFormat("%C%y") == Date.toLocaleFormat("%Y") expected: Sat Jun 04 2005 `.``*` actual: 2005 reason: Expected value 'Sat Jun 04 2005 `.``*`, Actual value '2005' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%C") expected: 20 actual: Sat Jun 04 2005 `.``*` reason: Expected value '20', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%G") expected: 2005 actual: Sat Jun 04 2005 `.``*` reason: Expected value '2005', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%V") expected: 22 actual: Sat Jun 04 2005 `.``*` reason: Expected value '22', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%Y-%m-%d") == Date.toLocaleFormat("%F") expected: 2005-06-04 actual: Sat Jun 04 2005 `.``*` reason: Expected value '2005-06-04', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%b") == Date.toLocaleFormat("%h") expected: Jun actual: Sat Jun 04 2005 `.``*` reason: Expected value 'Jun', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%e") expected: 4 actual: Sat Jun 04 2005 `.``*` reason: Expected value ' 4', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%g") expected: 05 actual: Sat Jun 04 2005 `.``*` reason: Expected value '05', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%m/%d/%y") == Date.toLocaleFormat("%D") expected: 06/04/05 actual: Sat Jun 04 2005 `.``*` reason: Expected value '06/04/05', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%m/%d/%y) == Date.toLocaleFormat("%x") expected: 06/04/2005 actual: 2005-06-04 reason: Expected value '06/04/2005', Actual value '2005-06-04' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%n") == "NL" expected: NL actual: Sat Jun 04 2005 `.``*` reason: Expected value 'NL', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%t") == "\t" expected: actual: Sat Jun 04 2005 `.``*` reason: Expected value ' ', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%u") expected: 6 actual: Sat Jun 04 2005 `.``*` reason: Expected value '6', Actual value 'Sat Jun 04 2005 `.``*`' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%C%y") == Date.toLocaleFormat("%Y") expected: 05 actual: 2005 reason: Expected value '05', Actual value '2005' +TEST_ID=js1_5/extensions/toLocaleFormat-02.js, TEST_BRANCH=1.9.0, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=win32, TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Date.toLocaleFormat("%C%y") == Date.toLocaleFormat("%Y") expected: Sat Jun 04 2005 `.``*` actual: 2005 reason: Expected value 'Sat Jun 04 2005 `.``*`, Actual value '2005' TEST_ID=js1_6/Array/regress-320887.js, TEST_BRANCH=(1.8.1|1.9.0), TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=var x should not throw a ReferenceError expected: No error actual: ReferenceError: x is not defined reason: Expected value 'No error', Actual value 'ReferenceError: x is not defined' TEST_ID=js1_6/Array/regress-386030.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Array.reduce should ignore holes: 1 expected: PASS actual: FAIL, reduce reason: Expected value 'PASS', Actual value 'FAIL, reduce' TEST_ID=js1_6/Array/regress-386030.js, TEST_BRANCH=1.8.1, TEST_RESULT=FAILED, TEST_BUILDTYPE=(debug|opt), TEST_TYPE=(browser|shell), TEST_OS=(linux|mac|win32), TEST_MACHINE=.*, TEST_PROCESSORTYPE=.*, TEST_KERNEL=.*, TEST_DATE=.*, TEST_TIMEZONE=.*, TEST_DESCRIPTION=Array.reduce should ignore holes: 2 expected: PASS actual: FAIL, reduceRight reason: Expected value 'PASS', Actual value 'FAIL, reduceRight' From ca72c859b7b36407134c1d063d908ddf67f2674e Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Sun, 9 Mar 2008 12:56:24 -0700 Subject: [PATCH 223/248] Bug 417302 - "about:robots" (add missing period) [p=reed r=gavin] --- browser/locales/en-US/chrome/browser/aboutRobots.dtd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/locales/en-US/chrome/browser/aboutRobots.dtd b/browser/locales/en-US/chrome/browser/aboutRobots.dtd index eb2a26c9c26b..91ea0d4e3753 100644 --- a/browser/locales/en-US/chrome/browser/aboutRobots.dtd +++ b/browser/locales/en-US/chrome/browser/aboutRobots.dtd @@ -16,7 +16,7 @@ - + From 6f1799c430b607915648185b7be75587a1c4b1c5 Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Sun, 9 Mar 2008 12:58:40 -0700 Subject: [PATCH 224/248] Bug 418791 - "Don't try to discard image data when the image is animating" (Don't start the timer when image is animating) [p=alfredkayser@gmail.com (Alfred Kayser) r=stuart a=blocking1.9+] --- modules/libpr0n/src/imgContainer.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/libpr0n/src/imgContainer.cpp b/modules/libpr0n/src/imgContainer.cpp index 73b93fc24143..4193544bf939 100644 --- a/modules/libpr0n/src/imgContainer.cpp +++ b/modules/libpr0n/src/imgContainer.cpp @@ -652,6 +652,8 @@ NS_IMETHODIMP imgContainer::RestoreDataDone (void) /* void notify(in nsITimer timer); */ NS_IMETHODIMP imgContainer::Notify(nsITimer *timer) { + // Note that as long as the image is animated, it will not be discarded, + // so this should never happen... nsresult rv = RestoreDiscardedData(); NS_ENSURE_SUCCESS(rv, rv); @@ -661,7 +663,7 @@ NS_IMETHODIMP imgContainer::Notify(nsITimer *timer) NS_ASSERTION(mAnim->timer == timer, "imgContainer::Notify() called with incorrect timer"); - if (!(mAnim->animating) || !(mAnim->timer)) + if (!mAnim->animating || !mAnim->timer) return NS_OK; nsCOMPtr observer(do_QueryReferent(mObserver)); @@ -1305,15 +1307,23 @@ imgContainer::sDiscardTimerCallback(nsITimer *aTimer, void *aClosure) nsresult imgContainer::ResetDiscardTimer (void) { - if (!DiscardingEnabled()) + if (!mRestoreDataDone) + return NS_OK; + + if (mDiscardTimer) { + /* Cancel current timer */ + nsresult rv = mDiscardTimer->Cancel(); + NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); + mDiscardTimer = nsnull; + } + + /* Don't activate timer when we are animating... */ + if (mAnim && mAnim->animating) return NS_OK; if (!mDiscardTimer) { mDiscardTimer = do_CreateInstance("@mozilla.org/timer;1"); NS_ENSURE_TRUE(mDiscardTimer, NS_ERROR_OUT_OF_MEMORY); - } else { - nsresult rv = mDiscardTimer->Cancel(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); } return mDiscardTimer->InitWithFuncCallback(sDiscardTimerCallback, From 668946a5fff5733efe7aa006837131cb148c060e Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Sun, 9 Mar 2008 12:59:50 -0700 Subject: [PATCH 225/248] =?UTF-8?q?Bug=20421721=20-=20"remove=20tabs-botto?= =?UTF-8?q?m-spacer,=20it's=20unused"=20[p=3Ddao@mozilla.com=20(D=C3=A3o?= =?UTF-8?q?=20Gottwald)=20r+a1.9=3Dmconnor]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/base/content/tabbrowser.xml | 51 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 001482a2b513..0ea599456f0f 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2588,41 +2588,38 @@ - - + #ifdef XP_MACOSX - - - + + + #endif - - - - - - - - - - + class="tabbrowser-arrowscrollbox"> + + + + + + + + + #ifdef XP_MACOSX - + #endif - + #ifdef XP_MACOSX - -#endif - - +#endif + From a6d3b6e1b7420ed859422d115233e7ade1346839 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 13:00:57 -0700 Subject: [PATCH 226/248] JavaScript Tests - regression test for bug 421325, by Brian Crowder --- js/tests/ecma_3/Array/regress-421325.js | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 js/tests/ecma_3/Array/regress-421325.js diff --git a/js/tests/ecma_3/Array/regress-421325.js b/js/tests/ecma_3/Array/regress-421325.js new file mode 100755 index 000000000000..c869d7bff474 --- /dev/null +++ b/js/tests/ecma_3/Array/regress-421325.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Brian Crowder + * + * 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 ***** */ + +var gTestfile = 'regress-421325.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 421325; +var summary = 'Dense Arrays and holes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + Array.prototype[1] = 'bar'; + + var a = []; + a[0]='foo'; + a[2] = 'baz'; + expect = 'foo,bar,baz'; + actual = a + ''; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} From 72db73153905a10fe4febd8b5a1035d85d3e5d76 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 13:09:09 -0700 Subject: [PATCH 227/248] JavaScript Tests - regression test for bug 420612, by Jesse Ruderman --- js/tests/js1_5/extensions/regress-420612.js | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 js/tests/js1_5/extensions/regress-420612.js diff --git a/js/tests/js1_5/extensions/regress-420612.js b/js/tests/js1_5/extensions/regress-420612.js new file mode 100755 index 000000000000..2524465ffeef --- /dev/null +++ b/js/tests/js1_5/extensions/regress-420612.js @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * 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 ***** */ + +var gTestfile = 'regress-420612.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 420612; +var summary = 'Do not assert: obj == pobj'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); +this.__proto__ = []; +this.unwatch("x"); +reportCompare(expect, actual, summary); From 36dc12fbfbd03357c0fa8bd3e42d468531da8469 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 13:15:14 -0700 Subject: [PATCH 228/248] JavaScript Tests - regression tests for bug 420610, by Jesse Ruderman --- js/tests/ecma_3/Regress/regress-420610.js | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 js/tests/ecma_3/Regress/regress-420610.js diff --git a/js/tests/ecma_3/Regress/regress-420610.js b/js/tests/ecma_3/Regress/regress-420610.js new file mode 100755 index 000000000000..ecd5a2dd4207 --- /dev/null +++ b/js/tests/ecma_3/Regress/regress-420610.js @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * 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 ***** */ + +var gTestfile = 'regress-420610.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 420610; +var summary = 'Do not crash with eval("this.x")'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +(function(){ eval("this.x") })(); + +reportCompare(expect, actual, summary); From 8b01eea5add86ae2142a191524f9051636e64fe1 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 13:32:33 -0700 Subject: [PATCH 229/248] JavaScript Tests - regression test for bug 420399, by Jesse Ruderman --- js/tests/js1_7/regress/regress-420399.js | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 js/tests/js1_7/regress/regress-420399.js diff --git a/js/tests/js1_7/regress/regress-420399.js b/js/tests/js1_7/regress/regress-420399.js new file mode 100755 index 000000000000..643318a53f86 --- /dev/null +++ b/js/tests/js1_7/regress/regress-420399.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * 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 ***** */ + +var gTestfile = 'regress-420399.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 420399; +var summary = 'Let expression error involving undefined'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: \(let \(a = undefined\) a\) (is undefined|has no properties)/; + try + { + (let (a=undefined) a).b = 3; + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} From 5898e57502f2a6b5c8efd52209b045e503658a19 Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 13:49:13 -0700 Subject: [PATCH 230/248] JavaScript Tests - regression test for bug 420087, by Mike Shaver --- js/tests/ecma_3/Regress/regress-420087.js | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 js/tests/ecma_3/Regress/regress-420087.js diff --git a/js/tests/ecma_3/Regress/regress-420087.js b/js/tests/ecma_3/Regress/regress-420087.js new file mode 100755 index 000000000000..1f21d1973997 --- /dev/null +++ b/js/tests/ecma_3/Regress/regress-420087.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Mike Shaver + * + * 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 ***** */ + +var gTestfile = 'regress-420087.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 420087; +var summary = 'Do not assert: PCVCAP_MAKE(sprop->shape, 0, 0) == entry->vcap'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var dict; + + for (var i = 0; i < 2; i++) + dict = {p: 1, q: 1, p:1}; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} From ac451a4ea984365c40e17e2509b4210e9fd9dc9b Mon Sep 17 00:00:00 2001 From: "bclary@bclary.com" Date: Sun, 9 Mar 2008 14:04:14 -0700 Subject: [PATCH 231/248] JavaScript Tests - regression tests for bug 418641, by Igor Bukanov --- js/tests/js1_7/regress/regress-418641.js | 113 +++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 js/tests/js1_7/regress/regress-418641.js diff --git a/js/tests/js1_7/regress/regress-418641.js b/js/tests/js1_7/regress/regress-418641.js new file mode 100755 index 000000000000..7403a2d45e00 --- /dev/null +++ b/js/tests/js1_7/regress/regress-418641.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Igor Bukanov + * + * 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 ***** */ + +var gTestfile = 'regress-418641.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 418641; +var summary = '++ and -- correctness'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function get_pre_check(operand, op) +{ + return "{\n"+ + " "+operand+" = I;\n"+ + " let tmp = "+op+op+operand+";\n"+ + " if ("+operand+" !== Number(I) "+op+" 1)\n"+ + " throw Error('"+op+op+operand+" case 1 for '+uneval(I));\n"+ + " if (tmp !== "+operand+")\n"+ + " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ + "}\n"; +} + +function get_post_check(operand, op) +{ + return "{\n"+ + " "+operand+" = I;\n"+ + " let tmp = "+operand+op+op+";\n"+ + " if ("+operand+" !== Number(I) "+op+" 1)\n"+ + " throw Error('"+operand+op+op+" case 1 for '+uneval(I));\n"+ + " if (tmp !== Number(I))\n"+ + " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ + "}\n"; +} + +function get_check_source(operand) +{ + return get_pre_check(operand, '+')+ + get_pre_check(operand, '-')+ + get_post_check(operand, '+')+ + get_post_check(operand, '-'); +} + +var arg_check = Function('I', 'a', get_check_source('a')); +var let_check = Function('I', 'let a;'+get_check_source('a')); +var var_check = Function('I', 'var a;'+get_check_source('a')); + +var my_name; +var my_obj = {}; +var my_index = 0; +var name_check = Function('I', get_check_source('my_name')); +var prop_check = Function('I', get_check_source('my_obj.x')); +var elem_check = Function('I', get_check_source('my_obj[my_index]')); + +var test_values = [0 , 0.5, -0.0, (1 << 30) - 1, 1 - (1 << 30)]; + +for (let i = 0; i != test_values.length; i = i + 1) { + let x = [test_values[i], String(test_values[i])]; + for (let j = 0; j != x.length; j = j + 1) { + try + { + expect = actual = 'No Error'; + let test_value = x[j]; + arg_check(test_value, 0); + let_check(test_value); + var_check(test_value); + name_check(test_value); + prop_check(test_value); + elem_check(test_value); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + i + ', ' + j); + } +} From b85eb999a0548f95827f6a2895e6a34e0d2603d2 Mon Sep 17 00:00:00 2001 From: "roc+@cs.cmu.edu" Date: Sun, 9 Mar 2008 14:55:05 -0700 Subject: [PATCH 232/248] Bug 403181. Pass the desired source rectangle for background images down into nsThebesImage and ensure we don't sample outside it. Back out a bad pixman patch that caused regressions, and adjust image encoding tests so they don't depend on the regression. Also switchs some reftests to quirks mode so that the 1-appunit width of
s doesn't bite us. r=vlad,sr=dbaron --- gfx/cairo/libpixman/src/pixman-compose.c | 4 +- gfx/public/nsIImage.h | 10 +- gfx/src/thebes/nsThebesImage.cpp | 110 +++++++++++++------ gfx/src/thebes/nsThebesImage.h | 1 + gfx/thebes/public/gfxRect.h | 8 +- gfx/thebes/src/gfxRect.cpp | 15 +++ layout/base/nsCSSRendering.cpp | 9 +- layout/base/nsLayoutUtils.cpp | 11 +- layout/base/nsLayoutUtils.h | 3 +- layout/reftests/bugs/412093-1-ref.html | 1 - layout/reftests/bugs/412093-1.html | 1 - layout/reftests/bugs/reftest.list | 3 +- modules/libpr0n/test/unit/image1png16x16.jpg | Bin 733 -> 733 bytes modules/libpr0n/test/unit/image2jpg16x16.png | Bin 948 -> 948 bytes modules/libpr0n/test/unit/test_imgtools.js | 2 +- widget/src/xpwidgets/nsBaseDragService.cpp | 2 +- 16 files changed, 130 insertions(+), 50 deletions(-) diff --git a/gfx/cairo/libpixman/src/pixman-compose.c b/gfx/cairo/libpixman/src/pixman-compose.c index f56885f5adb7..7cb3d251c2b3 100644 --- a/gfx/cairo/libpixman/src/pixman-compose.c +++ b/gfx/cairo/libpixman/src/pixman-compose.c @@ -4192,8 +4192,8 @@ fbFetchTransformed(bits_image_t * pict, int x, int y, int width, uint32_t *buffe stride = pict->rowstride; /* reference point is the center of the pixel */ - v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1 / 2 - 1; - v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1 / 2 - 1; + v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1 / 2; + v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1 / 2; v.vector[2] = pixman_fixed_1; /* when using convolution filters one might get here without a transform */ diff --git a/gfx/public/nsIImage.h b/gfx/public/nsIImage.h index d02e31ad5aee..ff549e456b7a 100644 --- a/gfx/public/nsIImage.h +++ b/gfx/public/nsIImage.h @@ -72,10 +72,10 @@ typedef enum { #define nsImageUpdateFlags_kBitsChanged 0x2 // IID for the nsIImage interface -// fd31e1f2-bd46-47f1-b8b6-b94ce954f9ce +// 96d9d7ce-e575-4265-8507-35555112a430 #define NS_IIMAGE_IID \ -{ 0xfd31e1f2, 0xbd46, 0x47f1, \ - { 0xb8, 0xb6, 0xb9, 0x4c, 0xe9, 0x54, 0xf9, 0xce } } +{ 0x96d9d7ce, 0xe575, 0x4265, \ + { 0x85, 0x07, 0x35, 0x55, 0x51, 0x12, 0xa4, 0x30 } } // Interface to Images class nsIImage : public nsISupports @@ -190,10 +190,14 @@ public: /** * BitBlit the nsIImage to a device, the source and dest can be scaled * @param aSourceRect source rectangle, in image pixels + * @param aSubimageRect the subimage that we're extracting the contents from. + * It must contain aSourceRect. Pixels outside this rectangle must not + * be sampled. * @param aDestRect destination rectangle, in device pixels */ NS_IMETHOD Draw(nsIRenderingContext &aContext, const gfxRect &aSourceRect, + const gfxRect &aSubimageRect, const gfxRect &aDestRect) = 0; /** diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index c5fea7c6efb4..b857dc70a36e 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -412,6 +412,7 @@ nsThebesImage::UnlockImagePixels(PRBool aMaskPixels) NS_IMETHODIMP nsThebesImage::Draw(nsIRenderingContext &aContext, const gfxRect &aSourceRect, + const gfxRect &aSubimageRect, const gfxRect &aDestRect) { if (NS_UNLIKELY(aDestRect.IsEmpty())) { @@ -452,21 +453,24 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, gfxFloat yscale = aDestRect.size.height / aSourceRect.size.height; gfxRect srcRect(aSourceRect); + gfxRect subimageRect(aSubimageRect); gfxRect destRect(aDestRect); if (!GetIsImageComplete()) { - srcRect = srcRect.Intersect(gfxRect(mDecoded.x, mDecoded.y, - mDecoded.width, mDecoded.height)); + gfxRect decoded = gfxRect(mDecoded.x, mDecoded.y, + mDecoded.width, mDecoded.height); + srcRect = srcRect.Intersect(decoded); + subimageRect = subimageRect.Intersect(decoded); - // This happens when mDecoded.width or height is zero. bug 368427. - if (NS_UNLIKELY(srcRect.size.width == 0 || srcRect.size.height == 0)) - return NS_OK; + // This happens when mDecoded.width or height is zero. bug 368427. + if (NS_UNLIKELY(srcRect.size.width == 0 || srcRect.size.height == 0)) + return NS_OK; - destRect.pos.x += (srcRect.pos.x - aSourceRect.pos.x)*xscale; - destRect.pos.y += (srcRect.pos.y - aSourceRect.pos.y)*yscale; + destRect.pos.x += (srcRect.pos.x - aSourceRect.pos.x)*xscale; + destRect.pos.y += (srcRect.pos.y - aSourceRect.pos.y)*yscale; - destRect.size.width = srcRect.size.width * xscale; - destRect.size.height = srcRect.size.height * yscale; + destRect.size.width = srcRect.size.width * xscale; + destRect.size.height = srcRect.size.height * yscale; } // if either rectangle is empty now (possibly after the image complete check) @@ -477,7 +481,39 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, if (!AllowedImageSize(destRect.size.width + 1, destRect.size.height + 1)) return NS_ERROR_FAILURE; + // Expand the subimageRect to place its edges on integer coordinates. + // Basically, if we're allowed to sample part of a pixel we can + // sample the whole pixel. + subimageRect.RoundOut(); + nsRefPtr pat; + PRBool ctxHasNonTranslation = ctx->CurrentMatrix().HasNonTranslation(); + if ((xscale == 1.0 && yscale == 1.0 && !ctxHasNonTranslation) || + subimageRect == gfxRect(0, 0, mWidth, mHeight)) + { + // No need to worry about sampling outside the subimage rectangle, + // so no need for a temporary + // XXX should we also check for situations where the source rect + // is well inside the subimage so we can't sample outside? + pat = new gfxPattern(ThebesSurface()); + } else { + // Because of the RoundOut above, the subimageRect has + // integer width and height. + gfxIntSize size(PRInt32(subimageRect.Width()), + PRInt32(subimageRect.Height())); + nsRefPtr temp = + gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, mFormat); + if (!temp || temp->CairoStatus() != 0) + return NS_ERROR_FAILURE; + + gfxContext tempctx(temp); + tempctx.SetSource(ThebesSurface(), -subimageRect.pos); + tempctx.SetOperator(gfxContext::OPERATOR_SOURCE); + tempctx.Paint(); + + pat = new gfxPattern(temp); + srcRect.MoveBy(-subimageRect.pos); + } /* See bug 364968 to understand the necessity of this goop; we basically * have to pre-downscale any image that would fall outside of a scaled 16-bit @@ -500,13 +536,12 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, gfxContext tempctx(temp); - gfxPattern srcpat(ThebesSurface()); gfxMatrix mat; mat.Translate(srcRect.pos); mat.Scale(1.0 / xscale, 1.0 / yscale); - srcpat.SetMatrix(mat); + pat->SetMatrix(mat); - tempctx.SetPattern(&srcpat); + tempctx.SetPattern(pat); tempctx.SetOperator(gfxContext::OPERATOR_SOURCE); tempctx.NewPath(); tempctx.Rectangle(gfxRect(0.0, 0.0, dim.width, dim.height)); @@ -523,10 +558,6 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, yscale = 1.0; } - if (!pat) { - pat = new gfxPattern(ThebesSurface()); - } - gfxMatrix mat; mat.Translate(srcRect.pos); mat.Scale(1.0/xscale, 1.0/yscale); @@ -538,25 +569,36 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, pat->SetMatrix(mat); -#if !defined(XP_MACOSX) && !defined(XP_WIN) && !defined(XP_OS2) - // See bug 324698. This is a workaround. - // - // Set the filter to CAIRO_FILTER_FAST if we're scaling up -- otherwise, - // pixman's sampling will sample transparency for the outside edges and we'll - // get blurry edges. CAIRO_EXTEND_PAD would also work here, if - // available - // - // This effectively disables smooth upscaling for images. - if (xscale > 1.0 || yscale > 1.0) - pat->SetFilter(0); -#endif + nsRefPtr target = ctx->CurrentSurface(); + switch (target->GetType()) { + case gfxASurface::SurfaceTypeXlib: + case gfxASurface::SurfaceTypeXcb: + // See bug 324698. This is a workaround for EXTEND_PAD not being + // implemented correctly on linux in the X server. + // + // Set the filter to CAIRO_FILTER_FAST if we're scaling up -- otherwise, + // pixman's sampling will sample transparency for the outside edges and we'll + // get blurry edges. CAIRO_EXTEND_PAD would also work here, if + // available + // + // This effectively disables smooth upscaling for images. + if (xscale > 1.0 || yscale > 1.0 || ctxHasNonTranslation) + pat->SetFilter(0); + break; -#if defined(XP_WIN) || defined(XP_OS2) - // turn on EXTEND_PAD only for win32, and only when scaling; - // it's not implemented correctly on linux in the X server. - if (xscale != 1.0 || yscale != 1.0) - pat->SetExtend(gfxPattern::EXTEND_PAD); -#endif + case gfxASurface::SurfaceTypeQuartz: + case gfxASurface::SurfaceTypeQuartzImage: + // Do nothing, Mac seems to be OK. Really? + break; + + default: + // turn on EXTEND_PAD. + // This is what we really want for all surface types, if the + // implementation was universally good. + if (xscale != 1.0 || yscale != 1.0 || ctxHasNonTranslation) + pat->SetExtend(gfxPattern::EXTEND_PAD); + break; + } gfxContext::GraphicsOperator op = ctx->CurrentOperator(); if (op == gfxContext::OPERATOR_OVER && mFormat == gfxASurface::ImageFormatRGB24) diff --git a/gfx/src/thebes/nsThebesImage.h b/gfx/src/thebes/nsThebesImage.h index 975884bc46fe..b0cfb4a2e77c 100644 --- a/gfx/src/thebes/nsThebesImage.h +++ b/gfx/src/thebes/nsThebesImage.h @@ -77,6 +77,7 @@ public: NS_IMETHOD Draw(nsIRenderingContext &aContext, const gfxRect &aSourceRect, + const gfxRect &aSubimageRect, const gfxRect &aDestRect); nsresult ThebesDrawTile(gfxContext *thebesContext, diff --git a/gfx/thebes/public/gfxRect.h b/gfx/thebes/public/gfxRect.h index 1971bf7238fc..f20386b8f24d 100644 --- a/gfx/thebes/public/gfxRect.h +++ b/gfx/thebes/public/gfxRect.h @@ -115,7 +115,9 @@ struct THEBES_API gfxRect { Outset(sides[0], sides[1], sides[2], sides[3]); } - // Round the rectangle to integer coordinates. + // Round the rectangle edges to integer coordinates, such that the rounded + // rectangle has the same set of pixel centers as the original rectangle. + // Edges at offset 0.5 round up. // Suitable for most places where integral device coordinates // are needed, but note that any translation should be applied first to // avoid pixel rounding errors. @@ -125,6 +127,10 @@ struct THEBES_API gfxRect { // If you need similar method which is using NS_round(), you should create // new |RoundAwayFromZero()| method. void Round(); + + // Snap the rectangle edges to integer coordinates, such that the + // resulting rectangle contains the original rectangle. + void RoundOut(); // grabbing specific points gfxPoint TopLeft() const { return gfxPoint(pos); } diff --git a/gfx/thebes/src/gfxRect.cpp b/gfx/thebes/src/gfxRect.cpp index 88da6a312001..c151b5fcb381 100644 --- a/gfx/thebes/src/gfxRect.cpp +++ b/gfx/thebes/src/gfxRect.cpp @@ -89,6 +89,21 @@ gfxRect::Round() size.height = y1 - y0; } +void +gfxRect::RoundOut() +{ + gfxFloat x0 = NS_floor(X()); + gfxFloat y0 = NS_floor(Y()); + gfxFloat x1 = NS_ceil(XMost()); + gfxFloat y1 = NS_ceil(YMost()); + + pos.x = x0; + pos.y = y0; + + size.width = x1 - x0; + size.height = y1 - y0; +} + /* Clamp r to CAIRO_COORD_MIN .. CAIRO_COORD_MAX * these are to be device coordinates. */ diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 2073851a45f9..2af7b47c7b56 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -3907,7 +3907,14 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext, if (sourceRect.XMost() <= tileWidth && sourceRect.YMost() <= tileHeight) { // The entire drawRect is contained inside a single tile; just // draw the corresponding part of the image once. - nsLayoutUtils::DrawImage(&aRenderingContext, image, absTileRect, drawRect); + // Pass in the subimage rectangle that we expect to be sampled. + // This is the tile rectangle, clipped to the bgClipArea, and then + // passed in relative to the image top-left. + nsRect destRect; // The rectangle we would draw ignoring dirty-rect + destRect.IntersectRect(absTileRect, bgClipArea); + nsRect subimageRect = destRect - aBorderArea.TopLeft() - tileRect.TopLeft(); + nsLayoutUtils::DrawImage(&aRenderingContext, image, + destRect, drawRect, &subimageRect); } else { aRenderingContext.DrawTile(image, absTileRect.x, absTileRect.y, &drawRect); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d271fede78f9..c91e51fe2ed4 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -2314,6 +2314,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext, pxSrc.size.width = gfxFloat(w); pxSrc.size.height = gfxFloat(h); } + gfxRect pxSubimage = pxSrc; nsCOMPtr dc; aRenderingContext->GetDeviceContext(*getter_AddRefs(dc)); @@ -2375,7 +2376,9 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext, imgFrame->GetRect(pxImgFrameRect); if (pxImgFrameRect.x > 0) { - pxSrc.pos.x -= gfxFloat(pxImgFrameRect.x); + gfxFloat fx(pxImgFrameRect.x); + pxSubimage.pos.x -= fx; + pxSrc.pos.x -= fx; gfxFloat scaled_x = pxSrc.pos.x; if (pxDirty.size.width != pxSrc.size.width) { @@ -2396,7 +2399,9 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext, } if (pxImgFrameRect.y > 0) { - pxSrc.pos.y -= gfxFloat(pxImgFrameRect.y); + gfxFloat fy(pxImgFrameRect.y); + pxSubimage.pos.y -= fy; + pxSrc.pos.y -= fy; gfxFloat scaled_y = pxSrc.pos.y; if (pxDirty.size.height != pxSrc.size.height) { @@ -2416,7 +2421,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext, return NS_OK; } - return img->Draw(*aRenderingContext, pxSrc, pxDirty); + return img->Draw(*aRenderingContext, pxSrc, pxSubimage, pxDirty); } void diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 51c0afa30f72..f2fce61227b4 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -715,7 +715,8 @@ public: * @param aDestRect Where to draw the image (app units). * @param aDirtyRect Draw only within this region (rounded to the * nearest pixel); the intersection of - * invalidation and clipping. + * invalidation and clipping (this is the + * destination clip) * @param aSourceRect If null, draw the entire image so it fits in * aDestRect. If non-null, the subregion of the * image that should be drawn (in app units, such diff --git a/layout/reftests/bugs/412093-1-ref.html b/layout/reftests/bugs/412093-1-ref.html index 52b204100a31..799b33723862 100644 --- a/layout/reftests/bugs/412093-1-ref.html +++ b/layout/reftests/bugs/412093-1-ref.html @@ -1,4 +1,3 @@ - diff --git a/layout/reftests/bugs/412093-1.html b/layout/reftests/bugs/412093-1.html index 082161717c1a..9d1ca10ca2ee 100644 --- a/layout/reftests/bugs/412093-1.html +++ b/layout/reftests/bugs/412093-1.html @@ -1,4 +1,3 @@ - diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 30c184950e67..b8598b773d38 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -420,7 +420,7 @@ skip-if(MOZ_WIDGET_TOOLKIT=="windows") == 347496-1.xhtml 347496-1-ref.xhtml # Bu == 367612-1f.html 367612-1-ref.html != 367612-1g.html 367612-1-ref.html == 368020-1.html 368020-1-ref.html -random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 368020-2.html 368020-2-ref.html # bug 368157 (gtk) +random == 368020-2.html 368020-2-ref.html # bug 368157 (gtk), bug 403181 fails == 368020-3.html 368020-3-ref.html # bug 368085 fails == 368020-4.html 368020-4-ref.html # bug 368085 random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 368020-5.html 368020-5-ref.html # bug 388591 @@ -651,6 +651,7 @@ skip-if(MOZ_WIDGET_TOOLKIT!="windows") == 391045.html 391045-ref.html # windows- == 403129-3.html 403129-3-ref.html == 403129-4.html 403129-4-ref.html random == 403134-1.html 403134-1-ref.html # bug 405377 +== 403181-1.xml 403181-1-ref.xml == 403249-1a.html 403249-1-ref.html == 403249-1b.html 403249-1-ref.html == 403249-2a.html 403249-2-ref.html diff --git a/modules/libpr0n/test/unit/image1png16x16.jpg b/modules/libpr0n/test/unit/image1png16x16.jpg index c8088f43aa26de749aed6695cdde30b1efdcd0ae..cfb749ab47a33b3b775dadf0cbf331b1a5046e6b 100644 GIT binary patch delta 114 zcmV-&0FD3M1>FU(a{_8MOB2s-k2|XF65+r&8Nm9}Z*;p2PD{~i4%?WcE}}dyDl&NJ zLC7AwRV_bOhHGSwX4!D7w|)Wob*bA?wbJZwBo{wvzPVkBSLG|lGC<&9AE`CV?PjUC UJM&*p>#@^Pgn5-n{5C)T*&Q1=q5uE@ delta 114 zcmV-&0FD3M1>FU(a{_8sOB2s-k2|XF65+r&8Nm9}Z*;p2PD{~i4%?WcE}}n|l^HyA zAmk5TDwdzCLp8cbGil57e6F_On#n U9r>@P_1NjDLOjZ(ej6YE*=Bw^xBvhE diff --git a/modules/libpr0n/test/unit/image2jpg16x16.png b/modules/libpr0n/test/unit/image2jpg16x16.png index 0418a096d9e51e8b0f54a10d970d64f6467bdcb6..c3a4aee616675d212178f70a97d8ce73fc1813e2 100644 GIT binary patch delta 908 zcmV;719SYe2eb!}Hh;Q;#1)`$mjX(L!Zgx3Yd+x=Z<^bc=FKk+yMuHqLfM?j>rGE7ihl!J-qq|h#-n003t8}SO!P< zL1!els+R2XYVv=r=l-L|OwYt-vQIk#h#*cPic@s|J&fW~6@S4O^(1Rr$nSp0`G!7X zi;Vb3f5FL<8H^0|KfQT2AWksYQpNS+0@g;HChWT#q?Kw(Db;b=JV0jiU6f_@M4rl^ zS{sXPYo5y3u}Q39T`%Xb-xOm35qBg=HuWO?;|vAxhK4 zj@0i7JQhP^@jKkB^5K4;5n;IdCg#t*=!$iuJK710N=nnAMcm2=BI)>1_Wh_uo>PT$ zNIL#GdV5Q(9L!9m@XmQsZ7J1yp*o!1z1!Px_?!RXh~kfmno4P%qc;hUCC^3 z6;^8_SRa$iHbojW1zQ>Klw&OMN9f5@(wXRrB}PI=goL6^_M`@S6LBJwy;(mKa9)FF zP&zNU@5N^M9@f9VhX(Zu#(R7)UEP9Em$DB_f*Tf<6zyhP)GJ>mHQ0}!_%j41T_7|i z3-6Gxd4FNSR%XBc9;Z+2XP`jBaDyvtns9{Q&!*533V)MI4@ckEyfRCBi+M> zc&~-5uybLK;LO}vF2wCxMaxgid1&xpv_F(TYJUq67<)po-v*jLlJJ-64J-;fED9$K zp-Tu~?ZHNuEv%XE&Z+IoXisvbFV~uh{_Wh>?dI`t9|GbucdB(I@S-!;nO3D0L%%JizwTXXb>~2wL_h>4Cuq2sMV|9K$``)Eb?GdO z8-MIE$sK9?(2<(Wo5%{xZsshEStE i$6#+OOh1$D8K`AIvBn&)`#~}s_=>Z}V zIvj?NY=WmeZb!k%-6gq@lLL8_r#mD-#gPQ!csTywUZDB@_wec?Ac8200Eoa0U>cd= zl19(@+MArJszdpQfd`KsGdCZb&pz!4Ac8oHIA_NAa2#1dEq@{TT2iXpQTC0JXBZ&1 zRL|a+Z^_KeW@2pc>CLkNafXo&4ZoFLVPnM4gk8K&MunQx3Jqtv?~&6sOmwAzs2{T_ z%iqHt)ow<6OTjz=hzOXU&~`EuO_C26zmK9KClYmb014+WkbJ#`gOxW)tm`KHf(oBK z-smd4d1UZIUw@T?Xr4sCJi)E6x6yOVna;#F=!kVfeaI1oB8}rEl|<`WiPW}pw5Ao` z^g@D;$I@K3p8MClcreg_FmAd*_ctE&#@S$uvBe~p(0at4hM$5-PD|voOKPMAwK#-k z5m2BdB)6E7oK1|~*hK&BUlE3?Gw4ZKOJB@tOmYcE`G4!Qr+mP7sZks%C`Wp#nuVTn zEH*~4Ip!QbvP|l(cro28MPD9(aJNuS?=dG#u@br>B$Rntksjnp#EBgCD}E<1uLie} zEM9WikLBC@*t}~WhT?aa?)RppXa_=LYB0tmXN+xk7s$WWYZ*6eqe+*6a9{r?I;kD~G6{EOHW&{sL+}3zS+15O zc-Z5<%8^Ba14|b;694fA+OMwTAFV5sgJCq+mwzBI^@KA2Ewlwo7?8h)Nwx};%obhP z8p1cYvej`1@4xCormqW~$xi%zZVA(azTDF8=JEId0^%G)bs8?eyOPG8*4zoP!*s-! zKAD8BxOH?Vy+>D)2R(5PbVOS)_SYJQ8b737lMCW30wORwL(^#mg$^rF*)OKbZUOo& zR)4feZRq^ehOWa_^u#aWVUaZhHE&T<^c6ExW6vR?8^0UP`%S zF;#AsXnmH`5NU%teLWiG38p4TpJV!;vM9ownW^Dn8qc0Vb@%{R{d_3dyAxGnD0M}@ iFw)-+=I0Ut{sU(m$`s?XHgEs{002ovP6b4+LSTYx3%GCq diff --git a/modules/libpr0n/test/unit/test_imgtools.js b/modules/libpr0n/test/unit/test_imgtools.js index 46782b9dd6fa..bfb48030158c 100644 --- a/modules/libpr0n/test/unit/test_imgtools.js +++ b/modules/libpr0n/test/unit/test_imgtools.js @@ -296,7 +296,7 @@ encodedBytes = streamToArray(istream); refName = "image3ico32x32.png"; refFile = do_get_file(TESTDIR + refName); istream = getFileInputStream(refFile); -do_check_eq(istream.available(), 2372); +do_check_eq(istream.available(), 2281); referenceBytes = streamToArray(istream); // compare the encoder's output to the reference file. diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index fe428ecd88ba..11dd6357ac7d 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -566,7 +566,7 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, gfxRect inRect = gfxRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height); gfxRect outRect = gfxRect(destRect.x, destRect.y, destRect.width, destRect.height); - return img->Draw(*rc, inRect, outRect); + return img->Draw(*rc, inRect, inRect, outRect); } void From 4fa241b61a7898db9ea8b3229536971540ceceb2 Mon Sep 17 00:00:00 2001 From: "roc+@cs.cmu.edu" Date: Sun, 9 Mar 2008 15:46:40 -0700 Subject: [PATCH 233/248] Bug 403181, fix test image --- modules/libpr0n/test/unit/image3ico32x32.png | Bin 2372 -> 2281 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/libpr0n/test/unit/image3ico32x32.png b/modules/libpr0n/test/unit/image3ico32x32.png index cffe0e9bee09c35bfdc1d13581f59b5fab53a737..421b9ce30d13399ab7520119b5edb9f737eb2319 100644 GIT binary patch delta 2270 zcmV<42qE{x66q0;BYz06NklJZd{V-ZZz&{ zHX7YTvt~1KQ?n+1`0t0gu(he_`jX8)$w^Lf&%Mv@{-5VO=YKiC|FijgK8w%iQ`+0x z)xyF;)t-=`=0-)S4zpQx*zM}pty|U3&QA60*|X~O^t8ILu%Ik1E?Rz00Oi=RWB#_b zHf`g^jaqtQqNYSeX->0QbEc)1+}xahVPQe}(GE#ku3x{d z%+JrOZns;l*?+my+qQRa@R7<&*5u@{+-haH$;1jFSS!nH%FpNiUAx%t_3})AKTr4f z2OqDl_SQHY>gdqW4_D;+_3O%4Uw!4DpP$#U3|eSQ7Gs;cVH*7fUIm6*sTA$UNN*bA^1U?0Gv0ACc~2Qv7c z44xBUCx5~ab9e=Asd?hOMqWU;5Puj1o$4n*MIe$FbMF10I$m6J2E&fz)JwH0sI1BNPp*J zJ&YFsp0(Tga$6fGeZJsuA;6C%@Jj)HAix);Fw`Z0ZvhPI&cD0?16FF9~XJ@t1(NWgd*Hg{OVM$EPa_POQLo7L{*CDRx5I2Y5K^-DDGLi+WR)4W7BZGY< zB|KAJPQTO1Az9`HA$UfTct8j?o6TW>ix)4_OF-B3HRk{x0@xNA$=3LIwkZlb zs;l`>Z8-}I5?P>FSzA=d=JN6|Ky7U;dwP24^?I3`o6B`V&?8C9085qdQ+@t7fKvdE zM?|p0Xk@R^$mxg({%*wzzG1QO;$3%fASsE5;uCowGM3)NWIkHHjeoU!UEHuMpZ8YX z8>()s4z{$kgty_y$Ovm|Ynhdm#kjaQ<_f`1Nm>rUQYHLapZ^2ky8zD`jjS@8xyfv1 zozcigEf#teh5NT{V^>ubpDrrr@pvbnjJ31Ynas*v`Fw2u!#vp69qjDt^m;s=a3LBV z9%flt8MCso=yW={V}IQ`w#UTq9Kd&Ok@f#X_<$NS8d+jCGs9}-{cF~6TUJ)6V#}6b zLqmhs-rlbD)-`LVez8UCHK%Lk>1NI4%G8b?J*16|jr#+Ez;{b=eSJMUIy!j#_;L0< z{x}=$cDezcxJA}40R$o@;`@>-EP;Ko13-4!NK6f#6-w{_%JK8v$+%D2IR^O zDtr#`1HB{qO|*ek!o*E?-yPapQxiOR@Swk|tLq0hrHb8dSDTxgRiDr29T*r0?rUjb zNopz^^{l?p`F|CJJECzJ>`yasn`~uHN=k71=FQ%&t}dmktLw+N_uNy`;+Df^!j;87WTEHj!#IcZcBMa#|2y?yI-JDZxCQm3Y-H2<^Dva+Ov zRkF+>A(kuRQuhB=0zCpOOIpp+!UC3*lxU@;r9T~DVSiyknVXyQkBp3HH8nL_jl&T< znU@!O-EQYKvzhPfXTceOE`x#j2?=x+7qhOePTR9*&rb(fTwJs)EG#IaqoZm~O^y1r z$K!o@U?BKfTN@|rc8&l%i|~<~Z!$46Ihi}l%IJ2xHMiUS(*bU_B}HC4bxJ#xm!~}g zXwLxJ!&j1|WkyA5Hk(bWsHo6dT3Y-bkLSl<$-d8)6qz0xQimK4^)R3w22?koW=2J+ sDJdzc%jHr%9*@$}((?0NO8=MkZz`<|CB>ZMGynhq07*qoM6N<$f`7Mg_W%F@ delta 2362 zcmV-A3B~s55yTRZBYz1CNklYf_Tph>cZp^m--7YE{;)Tc_03)hWl09aDyfhm~+R+!+psGw;~p z_3PISH*el_M1LX?*Ve6DT_qbg*6ysV9DT^|XR*yjZ$binIvqC(!D3lv<&q_=FD_u`*&v0AThNlxZr zgMp`XIv&z!*e*#tBLq*z$8(=7^C63cWp+C^TCEct&uSGhYY>0GP+5%+{b?CI%IdwP1@-v}@;aLF++FnF}NxoxzlsOb9IoE-WS6Imq$8zhMb03HDN z7{G%7&wmT>T^W2w22TmF4wDc*osK#2@w~@u=Hjd@=H}+A%a78Dfad@X0z3k+MFNis@Tqukd_MTL4E74}03;rOU`^cJ^rTvto}SLR zbLTSIXdJswh~O!}*$aHV78WjC=(^_~n_@Pna)0*h+0y{60AB<6JAh$;&kOJ+8GLCz zcr^jMB)}sQcm#rjka_AZ2dkE>=Bibzn4X@_#U|6lkAxWQ1v-xdU#kVjoH=u9&1Unc zEX&mE^_(wBEQyKXaeyBH{0!j70LKLwk-=wW@T35bN?^AD&kDh-lFTax8#|r3Y*@OK zReuW>uqGja-8vo517nAQ;9k4k_4Mu4q19@Sn$70X`|rR1dO<+}Wm%?0lDIu4hCc!L zXMkTuA>Nn3%L05{fO{qIpa3t);8j`TPle#{3c zbg$E?Jbin0mBm+(@e|bARy+4G+u$M+A6H0>1$G4}k9g9FA5(7r=7@ zd|d|Ll);Mvdu&yG@H#%gu`Lw^y$+q zEG*=rloV#f#nCqlJSBspGI(7~zUU2ruK@flz&`@~J-`no@KXW4C%^#-?8YR-&wl}q zMV)^d9UlVxRa_jOOH1QnyM5w5t93LrHMJ9wNJQ!D>tkVIA+zVtr)SnI)(Y^d41O$w zp9%1<0G|ao1n@5adE58^;FAD@03X(9cyQ)So;Mo#s=>g&&zLd2?^+bDLkMn^WoBC} zDm)&K;`8}fUS7_f1qIxll*BU<_3tK?$XtwzV=y(9MGl9Gyu3Wc=ku|us)}`fKldglvlrmo(Hwqp%LzLG zz6$Vf06)JCpdR1~jfQ5OjtfjCy0WtwTDFWYTdn*<7%6Y`33_Y1lSuD&!@MXuq+Dk62MPx0eByi`Ts!_!aj2*ml}=q zTdjO--8!D|`Ph}6%^q21zYshjNqj^I2K0Irkw`?jaNz>0tE>6_Wy_d#_ucepG~9hl z&ff*t3~&d)qX4hmBC?O7^M5PRwH*M9qIW}~$;9fsJcf#jxO4q_?p&I~x}>`pGU&K{ zPCNs1=T2&%w6v7X&CP7Aujf*`omn~^w`(-hIll&Q1mN@0G8+T<9KiF@aRuOLbnSV7 zCjssOSTl1bcbH7v>2xx*X%j0-d|a_KkxQNNEY4fbfX_Fnf#Tv~?tkCEpP^8QcDtR6 zgkZHK@j?_}suO-3oljN8p_mxfX|+6{)$(UCF?@Z-48CYE@W&<-4<{#cuPKoYGmQ); z&gXXDT9#B4a9Pn}=J*#+_{;s{fk2=O;c!^#>+9nK4?Mty3m4L4GSMysLy|O|f~ijU zS#1Ew>vC3^|>wzxQ4?`u*IW=i?z$Huo6QSdyK>!lK38 zQD4PJns<)}8|vx;fj}lAk%)5o^l5s%US?!uFefL6>lZEJuGzDB65yL(q52z`yr9l& zwOp^))0&XL+@vI~O;4XF^mxX%Y}umL*4C;`n;%p=zqdwh(tlf2pGB`06lAC^Eqm1d z{=u&P{=vys?D2RMuh+}6vNDE3A-1)(@v+)kmRl^W1o-$@sD29IVoVH+v|8pSC9%Zg zVW6~hd`n45U0GR~I}{4Jn@YF2JLNU*CViUQm!^07d>QVRmVNI2{=v-t{(j@sWz?CL zmZk;*0kylkdw*6EiKKxZQC|?dwYAZqoZTAzPg(Esj1u&RrMzT{}pxqGQa@=UX;PM zR2|pK@wBC+jOVXjUDwdikQoYvjNcYu+S=ROT^$`A%74Q4Y`JfhLp}DN9fPbr(c%&q!7~`aZ3H?B=8{t zdXw+s`rIYV&(Bx$^YgzufTAeQa5&s~_Uu`;q@+YG&dM4)l9@R%ykG&xAVPT;=5C~*e gR8-u#`u~^qZxWRVT))jf5C8xG07*qoM6N<$f^j34{{R30 From b81493537551aa24ade31f586359ece549e430fb Mon Sep 17 00:00:00 2001 From: "roc+@cs.cmu.edu" Date: Sun, 9 Mar 2008 16:53:48 -0700 Subject: [PATCH 234/248] Bug 403181, revert more bogus test images --- .../tests/unit/expected-favicon-big32.jpg.png | Bin 948 -> 948 bytes .../tests/unit/expected-favicon-big4.jpg.png | Bin 364 -> 245 bytes .../tests/unit/expected-favicon-big64.png.png | Bin 866 -> 866 bytes .../unit/expected-favicon-scale160x3.jpg.png | Bin 140 -> 131 bytes .../unit/expected-favicon-scale3x160.jpg.png | Bin 134 -> 124 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/toolkit/components/places/tests/unit/expected-favicon-big32.jpg.png b/toolkit/components/places/tests/unit/expected-favicon-big32.jpg.png index 0418a096d9e51e8b0f54a10d970d64f6467bdcb6..c3a4aee616675d212178f70a97d8ce73fc1813e2 100644 GIT binary patch delta 908 zcmV;719SYe2eb!}Hh;Q;#1)`$mjX(L!Zgx3Yd+x=Z<^bc=FKk+yMuHqLfM?j>rGE7ihl!J-qq|h#-n003t8}SO!P< zL1!els+R2XYVv=r=l-L|OwYt-vQIk#h#*cPic@s|J&fW~6@S4O^(1Rr$nSp0`G!7X zi;Vb3f5FL<8H^0|KfQT2AWksYQpNS+0@g;HChWT#q?Kw(Db;b=JV0jiU6f_@M4rl^ zS{sXPYo5y3u}Q39T`%Xb-xOm35qBg=HuWO?;|vAxhK4 zj@0i7JQhP^@jKkB^5K4;5n;IdCg#t*=!$iuJK710N=nnAMcm2=BI)>1_Wh_uo>PT$ zNIL#GdV5Q(9L!9m@XmQsZ7J1yp*o!1z1!Px_?!RXh~kfmno4P%qc;hUCC^3 z6;^8_SRa$iHbojW1zQ>Klw&OMN9f5@(wXRrB}PI=goL6^_M`@S6LBJwy;(mKa9)FF zP&zNU@5N^M9@f9VhX(Zu#(R7)UEP9Em$DB_f*Tf<6zyhP)GJ>mHQ0}!_%j41T_7|i z3-6Gxd4FNSR%XBc9;Z+2XP`jBaDyvtns9{Q&!*533V)MI4@ckEyfRCBi+M> zc&~-5uybLK;LO}vF2wCxMaxgid1&xpv_F(TYJUq67<)po-v*jLlJJ-64J-;fED9$K zp-Tu~?ZHNuEv%XE&Z+IoXisvbFV~uh{_Wh>?dI`t9|GbucdB(I@S-!;nO3D0L%%JizwTXXb>~2wL_h>4Cuq2sMV|9K$``)Eb?GdO z8-MIE$sK9?(2<(Wo5%{xZsshEStE i$6#+OOh1$D8K`AIvBn&)`#~}s_=>Z}V zIvj?NY=WmeZb!k%-6gq@lLL8_r#mD-#gPQ!csTywUZDB@_wec?Ac8200Eoa0U>cd= zl19(@+MArJszdpQfd`KsGdCZb&pz!4Ac8oHIA_NAa2#1dEq@{TT2iXpQTC0JXBZ&1 zRL|a+Z^_KeW@2pc>CLkNafXo&4ZoFLVPnM4gk8K&MunQx3Jqtv?~&6sOmwAzs2{T_ z%iqHt)ow<6OTjz=hzOXU&~`EuO_C26zmK9KClYmb014+WkbJ#`gOxW)tm`KHf(oBK z-smd4d1UZIUw@T?Xr4sCJi)E6x6yOVna;#F=!kVfeaI1oB8}rEl|<`WiPW}pw5Ao` z^g@D;$I@K3p8MClcreg_FmAd*_ctE&#@S$uvBe~p(0at4hM$5-PD|voOKPMAwK#-k z5m2BdB)6E7oK1|~*hK&BUlE3?Gw4ZKOJB@tOmYcE`G4!Qr+mP7sZks%C`Wp#nuVTn zEH*~4Ip!QbvP|l(cro28MPD9(aJNuS?=dG#u@br>B$Rntksjnp#EBgCD}E<1uLie} zEM9WikLBC@*t}~WhT?aa?)RppXa_=LYB0tmXN+xk7s$WWYZ*6eqe+*6a9{r?I;kD~G6{EOHW&{sL+}3zS+15O zc-Z5<%8^Ba14|b;694fA+OMwTAFV5sgJCq+mwzBI^@KA2Ewlwo7?8h)Nwx};%obhP z8p1cYvej`1@4xCormqW~$xi%zZVA(azTDF8=JEId0^%G)bs8?eyOPG8*4zoP!*s-! zKAD8BxOH?Vy+>D)2R(5PbVOS)_SYJQ8b737lMCW30wORwL(^#mg$^rF*)OKbZUOo& zR)4feZRq^ehOWa_^u#aWVUaZhHE&T<^c6ExW6vR?8^0UP`%S zF;#AsXnmH`5NU%teLWiG38p4TpJV!;vM9ownW^Dn8qc0Vb@%{R{d_3dyAxGnD0M}@ iFw)-+=I0Ut{sU(m$`s?XHgEs{002ovP6b4+LSTYx3%GCq diff --git a/toolkit/components/places/tests/unit/expected-favicon-big4.jpg.png b/toolkit/components/places/tests/unit/expected-favicon-big4.jpg.png index 01d99891caaabbe52a95e460479e02c7729b4dde..1175ba32034339ca14228d18eab23747e411a58f 100644 GIT binary patch delta 218 zcmV<0044wI0`&oqBYyzANklDC2naRC3 z&p9vl-pou!1kLPI(0k{clU2oY4*$+MhgHQnCwuSzQgFS*>oZt<8 delta 338 zcmV-Y0j>V^0qg>hBYy!iNkl-FMs9Fc9?7($@;p4Qs;K$c}}+m_3+@Hh_s zJm-0GT~~Hp$2`yfWgtycHci720=I4Bd7hDd-#O3o-;b!ZW>r-jhJhgjuIn0^=b7U; z{{4+#gXEl}_e-8#*G0Vdbk6bleEvR2LI^6QXpEt?mU*5>thF@8P$|X7;}HeIwHW73 kJAfJZT*+|N?wA3LAL}=sgg3AYxBvhE07*qoM6N<$g1F0{@&Et; diff --git a/toolkit/components/places/tests/unit/expected-favicon-big64.png.png b/toolkit/components/places/tests/unit/expected-favicon-big64.png.png index 4814280b0a255ba62537ea857a61cab66326fe77..afe2c2dffe16faaf70a0d09979b0aaccc3d75b83 100644 GIT binary patch delta 826 zcmV-A1I7H}2I2;gHGj`L5)Zo09fDNZTJ3gl0_9~?n< zBW-OgXGXOMo117bbrPaLz!WrGx!~Fka5w_)cT%RYUQ}~=$Hyna5<^X7R( z?jf60KVw_9t1d3%{pxsmbLG8!cWGI{=Vv!{PV(-lIlAT-_O@nWOn+^)Qhw|-6{jYsIDL+7!;_Q`hIt{-&bp6|aiv$!wZ0TY#3mwQjs|bR z3Yw}gQ|aV#Q$B4U*HLmj#Fp++EH4EpZa;&!!u)(*Y5W9l%L$5FPO!SF72~7D7?aoIF7R`0$N<-?7~k!Qz=*XSh#*s&+!kR8kH)M^4W^}(Nq@` zUK`VE1b_mKt z%-1SBo&F*zu11!aJhXe0iPpGSXccZQHZgwGx_=-d##>WR&ZO!Hd6EdPOF*l05b-6T z`JF`HdWdL!8d}YABAX4w=B>oe8xaxD9c#=GSwE62^q36{*o} zsWtOUuaPTbIv!K>?}&)*u1~~?WFHZ^+HbcokZ5Bt$;NQHm9u$EnJl*uZbB1Y}kuV8KXDyBwcr+XX?st+Uqc_!D9FzR?g5_pr&+F%TzT0=7 zN8~=T$nIw>8$Jv@kl$LDF13aC^WCGBB}cz2?;7X53o}G!=YRQR>?igO&9Lt6c66rd z&i@R3zT52+kz8|K7d!hVsX05rp|1xxuFmnr%nkf~lT@`HBUqZt;-G=&^JMK^1<6|H z@7J4(h;@V+{w&0=haRIg@(tB}SE%S3r6o2^sDG5TPrk+b*k#@N`@$=1U?+>C0t6?GvZ77-C+GQ0*= z$wF0}sEU)RT03+5U*y=4dMbNIspuZT^imV$otN;n4bri%m{iw;SoHFoT&{okXtHVb zov^Anxz^yqQyZrIoT4 z2D5vdxbt4X z)ID~R?>Nm;+iN$)wm1wOB2p?M)_FaQ7m07*qoM6N<$ Ef|4Gg761SM diff --git a/toolkit/components/places/tests/unit/expected-favicon-scale160x3.jpg.png b/toolkit/components/places/tests/unit/expected-favicon-scale160x3.jpg.png index 5df53e60919f7ccc82d78b126a50bfb5feec988c..1b121e9951835972d5540b4f85eff512c0d83e8e 100644 GIT binary patch delta 102 zcmV-s0Ga=c0fPaMBwtENL_t(Ijjhu$5dc951i^8GBqSl>r6A#?AmKt@#9YuRRlqL5 zCvhaM5)o^VnQKs0YtY?mFf(iT0eS^}MEyn`Bpu}!Wm0wi0oH`)FwNC$DgXcg07*qo IM6N<$g41*-i2wiq delta 111 zcmZo>>|vask`e6b;uvDlyYz4%XR{)M+r`;#J}PQL!ab^jVEpIJ+vtw!2Ml{s?2P)O zygEIzb=8u4W~|woRCKQMi09wSSDYp?)O}4s&>Htnf7P1|Lmd94K6Hq)$07*qoM6N<$f~Ddl ALI3~& delta 104 zcmV-u0GI!Kh5?WyVogazK~y-6?aWaLz%UF&(W@p@QK+I)1!GD|6pSeeQ84!R=412- zH~ Date: Sun, 9 Mar 2008 18:10:03 -0700 Subject: [PATCH 235/248] Test selector serialization too. --- layout/style/test/test_selectors.html | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/layout/style/test/test_selectors.html b/layout/style/test/test_selectors.html index 5ecc85245a07..37014d6895c1 100644 --- a/layout/style/test/test_selectors.html +++ b/layout/style/test/test_selectors.html @@ -50,6 +50,7 @@ function run() { if (should_match.length + should_not_match.length == 0) { ok(false, "nothing to check"); } + for (var i = 0; i < should_match.length; ++i) { var e = should_match[i]; is(ifwin.getComputedStyle(e, "").zIndex, zi, @@ -60,6 +61,33 @@ function run() { is(ifwin.getComputedStyle(e, "").zIndex, "auto", "element in " + body_contents + " did not match " + selector); } + + // Now, since we're here, may as well make sure serialization + // works correctly. It need not produce the exact same text, + // but it should produce a selector that matches the same + // elements. + zi = ++gCounter; + var ser1 = style_text.parentNode.sheet.cssRules[0].selectorText; + style_text.data = ser1 + "{ z-index: " + zi + " }"; + for (var i = 0; i < should_match.length; ++i) { + var e = should_match[i]; + is(ifwin.getComputedStyle(e, "").zIndex, zi, + "element in " + body_contents + " matched " + ser1 + + " which is the reserialization of " + selector); + } + for (var i = 0; i < should_not_match.length; ++i) { + var e = should_not_match[i]; + is(ifwin.getComputedStyle(e, "").zIndex, "auto", + "element in " + body_contents + " did not match " + ser1 + + " which is the reserialization of " + selector); + } + + // But when we serialize the serialized result, we should get + // the same text. + var ser2 = style_text.parentNode.sheet.cssRules[0].selectorText; + is(ser2, ser1, "parse+serialize of selector \"" + selector + + "\" is idempotent"); + ifdoc.body.innerHTML = ""; style_text.data = ""; } From 5c296c36562ebbb9453d869fe68c81df5134441f Mon Sep 17 00:00:00 2001 From: "aaronleventhal@moonset.net" Date: Sun, 9 Mar 2008 19:24:00 -0700 Subject: [PATCH 236/248] Backing out part of bug 417018 which caused bug 421650. --- accessible/src/msaa/nsAccessibleWrap.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index f72806fb2a13..036c72c47f75 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -1470,6 +1470,8 @@ nsAccessibleWrap::get_attributes(BSTR *aAttributes) // The format is name:value;name:value; with \ for escaping these // characters ":;=,\". __try { + *aAttributes = NULL; + nsCOMPtr attributes; if (NS_FAILED(GetAttributes(getter_AddRefs(attributes)))) return E_FAIL; @@ -1521,9 +1523,8 @@ __try { strAttrs.Append(';'); } - INT res = ::SysReAllocStringLen(aAttributes, strAttrs.get(), - strAttrs.Length()); - if (!res) + *aAttributes = ::SysAllocString(strAttrs.get()); + if (!*aAttributes) return E_OUTOFMEMORY; } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { } From 4030db1be364c49d3b4994fdb94e3e8f50810627 Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Sun, 9 Mar 2008 22:09:24 -0700 Subject: [PATCH 237/248] Bug 399925 - "GIF decoder needs to allow its data to be discarded" [p=alfredkayser@gmail.com (Alfred Kayser) r=stuart sr=tor a=blocking1.9+] --- .../libpr0n/decoders/gif/nsGIFDecoder2.cpp | 30 +++++++++++++++---- modules/libpr0n/decoders/gif/nsGIFDecoder2.h | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp index 4dcd9738314a..3972baae8292 100644 --- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp @@ -142,8 +142,18 @@ NS_IMETHODIMP nsGIFDecoder2::Init(imgILoad *aLoad) { mObserver = do_QueryInterface(aLoad); - mImageContainer = do_CreateInstance("@mozilla.org/image/container;1"); - aLoad->SetImage(mImageContainer); + /* The image container may already exist if it is reloading itself from us. + */ + aLoad->GetImage(getter_AddRefs(mImageContainer)); + if (!mImageContainer) { + mImageContainer = do_CreateInstance("@mozilla.org/image/container;1"); + if (!mImageContainer) + return NS_ERROR_OUT_OF_MEMORY; + + aLoad->SetImage(mImageContainer); + nsresult rv = mImageContainer->SetDiscardable("image/gif"); + NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); + } // Start with the version (GIF89a|GIF87a) mGIFStruct.state = gif_type; @@ -174,7 +184,7 @@ NS_IMETHODIMP nsGIFDecoder2::Close() /* void flush (); */ NS_IMETHODIMP nsGIFDecoder2::Flush() { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_OK; } //****************************************************************************** @@ -187,7 +197,7 @@ static NS_METHOD ReadDataOut(nsIInputStream* in, PRUint32 *writeCount) { nsGIFDecoder2 *decoder = static_cast(closure); - nsresult rv = decoder->ProcessData((unsigned char*)fromRawSegment, count, writeCount); + nsresult rv = decoder->ProcessData(fromRawSegment, count, writeCount); if (NS_FAILED(rv)) { *writeCount = 0; return rv; @@ -236,11 +246,11 @@ nsGIFDecoder2::FlushImageData() } //****************************************************************************** -nsresult nsGIFDecoder2::ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval) +nsresult nsGIFDecoder2::ProcessData(const char *data, PRUint32 count, PRUint32 *_retval) { // Push the data to the GIF decoder - nsresult rv = GifWrite(data, count); + nsresult rv = GifWrite((const PRUint8*)data, count); NS_ENSURE_SUCCESS(rv, rv); // Flushing is only needed for first frame @@ -250,6 +260,13 @@ nsresult nsGIFDecoder2::ProcessData(unsigned char *data, PRUint32 count, PRUint3 mLastFlushedPass = mCurrentPass; } + // We should just disable the 'restore' when AddRestoreData fails, so that we still load the image... + rv = mImageContainer->AddRestoreData(data, count); + if (NS_FAILED(rv)) { + mGIFStruct.state = gif_oom; + return rv; + } + *_retval = count; return NS_OK; @@ -310,6 +327,7 @@ void nsGIFDecoder2::EndGIF() mImageContainer->SetLoopCount(mGIFStruct.loop_count); mImageContainer->DecodingComplete(); + (void)mImageContainer->RestoreDataDone(); // Discard error code mGIFOpen = PR_FALSE; } diff --git a/modules/libpr0n/decoders/gif/nsGIFDecoder2.h b/modules/libpr0n/decoders/gif/nsGIFDecoder2.h index 570cca2e1f56..2c43bed1f0a3 100644 --- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.h +++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.h @@ -68,7 +68,7 @@ public: nsGIFDecoder2(); ~nsGIFDecoder2(); - nsresult ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval); + nsresult ProcessData(const char *data, PRUint32 count, PRUint32 *_retval); private: /* These functions will be called when the decoder has a decoded row, From a4bea78921147b89f78405ea2aa578d3b925d96b Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Sun, 9 Mar 2008 23:09:37 -0700 Subject: [PATCH 238/248] Back out Alfred Kayser's patch from bug 399925 due to Tp crashes. --- .../libpr0n/decoders/gif/nsGIFDecoder2.cpp | 30 ++++--------------- modules/libpr0n/decoders/gif/nsGIFDecoder2.h | 2 +- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp index 3972baae8292..4dcd9738314a 100644 --- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp @@ -142,18 +142,8 @@ NS_IMETHODIMP nsGIFDecoder2::Init(imgILoad *aLoad) { mObserver = do_QueryInterface(aLoad); - /* The image container may already exist if it is reloading itself from us. - */ - aLoad->GetImage(getter_AddRefs(mImageContainer)); - if (!mImageContainer) { - mImageContainer = do_CreateInstance("@mozilla.org/image/container;1"); - if (!mImageContainer) - return NS_ERROR_OUT_OF_MEMORY; - - aLoad->SetImage(mImageContainer); - nsresult rv = mImageContainer->SetDiscardable("image/gif"); - NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - } + mImageContainer = do_CreateInstance("@mozilla.org/image/container;1"); + aLoad->SetImage(mImageContainer); // Start with the version (GIF89a|GIF87a) mGIFStruct.state = gif_type; @@ -184,7 +174,7 @@ NS_IMETHODIMP nsGIFDecoder2::Close() /* void flush (); */ NS_IMETHODIMP nsGIFDecoder2::Flush() { - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } //****************************************************************************** @@ -197,7 +187,7 @@ static NS_METHOD ReadDataOut(nsIInputStream* in, PRUint32 *writeCount) { nsGIFDecoder2 *decoder = static_cast(closure); - nsresult rv = decoder->ProcessData(fromRawSegment, count, writeCount); + nsresult rv = decoder->ProcessData((unsigned char*)fromRawSegment, count, writeCount); if (NS_FAILED(rv)) { *writeCount = 0; return rv; @@ -246,11 +236,11 @@ nsGIFDecoder2::FlushImageData() } //****************************************************************************** -nsresult nsGIFDecoder2::ProcessData(const char *data, PRUint32 count, PRUint32 *_retval) +nsresult nsGIFDecoder2::ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval) { // Push the data to the GIF decoder - nsresult rv = GifWrite((const PRUint8*)data, count); + nsresult rv = GifWrite(data, count); NS_ENSURE_SUCCESS(rv, rv); // Flushing is only needed for first frame @@ -260,13 +250,6 @@ nsresult nsGIFDecoder2::ProcessData(const char *data, PRUint32 count, PRUint32 * mLastFlushedPass = mCurrentPass; } - // We should just disable the 'restore' when AddRestoreData fails, so that we still load the image... - rv = mImageContainer->AddRestoreData(data, count); - if (NS_FAILED(rv)) { - mGIFStruct.state = gif_oom; - return rv; - } - *_retval = count; return NS_OK; @@ -327,7 +310,6 @@ void nsGIFDecoder2::EndGIF() mImageContainer->SetLoopCount(mGIFStruct.loop_count); mImageContainer->DecodingComplete(); - (void)mImageContainer->RestoreDataDone(); // Discard error code mGIFOpen = PR_FALSE; } diff --git a/modules/libpr0n/decoders/gif/nsGIFDecoder2.h b/modules/libpr0n/decoders/gif/nsGIFDecoder2.h index 2c43bed1f0a3..570cca2e1f56 100644 --- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.h +++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.h @@ -68,7 +68,7 @@ public: nsGIFDecoder2(); ~nsGIFDecoder2(); - nsresult ProcessData(const char *data, PRUint32 count, PRUint32 *_retval); + nsresult ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval); private: /* These functions will be called when the decoder has a decoded row, From ac80174534ce1ed50d7038a5aa04e71271a7bda0 Mon Sep 17 00:00:00 2001 From: "masayuki@d-toybox.com" Date: Mon, 10 Mar 2008 00:07:15 -0700 Subject: [PATCH 239/248] Bug 420285 Internationalize plugin tag and plugin host r=jst, sr=bzbarsky, b1.9=jst --- modules/plugin/base/public/nsIPluginTag.idl | 8 +- modules/plugin/base/src/nsPluginHostImpl.cpp | 384 ++++++++++--------- modules/plugin/base/src/nsPluginHostImpl.h | 16 +- 3 files changed, 221 insertions(+), 187 deletions(-) diff --git a/modules/plugin/base/public/nsIPluginTag.idl b/modules/plugin/base/public/nsIPluginTag.idl index 67353ef271ab..4e8f7798b2ad 100644 --- a/modules/plugin/base/public/nsIPluginTag.idl +++ b/modules/plugin/base/public/nsIPluginTag.idl @@ -38,12 +38,12 @@ #include "nsISupports.idl" -[scriptable, uuid(e8b85cb4-6281-40b1-b54d-da825487b73a)] +[scriptable, uuid(af36bf4d-5652-413f-a78c-745b702f2381)] interface nsIPluginTag : nsISupports { - readonly attribute ACString description; - readonly attribute ACString filename; - readonly attribute ACString name; + readonly attribute AUTF8String description; + readonly attribute AUTF8String filename; + readonly attribute AUTF8String name; attribute boolean disabled; attribute boolean blocklisted; }; diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 68b03a9ccf81..e20cf13b8a55 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -21,7 +21,7 @@ * * Contributor(s): * Sean Echevarria - * Håkan Waara + * HÃ¥kan Waara * Josh Aas * * Alternatively, the contents of this file may be used under the terms of @@ -201,7 +201,8 @@ // 0.06 strip off suffixes in mime description strings, bug 53895 // 0.07 changed nsIRegistry to flat file support for caching plugins info // 0.08 mime entry point on MachO, bug 137535 -static const char *kPluginRegistryVersion = "0.08"; +// 0.09 the file encoding is changed to UTF-8, bug 420285 +static const char *kPluginRegistryVersion = "0.09"; //////////////////////////////////////////////////////////////////////// // CID's && IID's static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); @@ -729,11 +730,11 @@ inline char* new_str(const char* str) //////////////////////////////////////////////////////////////////////// nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag) : mPluginHost(nsnull), - mName(new_str(aPluginTag->mName)), - mDescription(new_str(aPluginTag->mDescription)), + mName(aPluginTag->mName), + mDescription(aPluginTag->mDescription), mVariants(aPluginTag->mVariants), mMimeTypeArray(nsnull), - mMimeDescriptionArray(nsnull), + mMimeDescriptionArray(aPluginTag->mMimeDescriptionArray), mExtensionsArray(nsnull), mLibrary(nsnull), mEntryPoint(nsnull), @@ -741,8 +742,8 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag) mXPConnected(PR_FALSE), mIsJavaPlugin(aPluginTag->mIsJavaPlugin), mIsNPRuntimeEnabledJavaPlugin(aPluginTag->mIsNPRuntimeEnabledJavaPlugin), - mFileName(new_str(aPluginTag->mFileName)), - mFullPath(new_str(aPluginTag->mFullPath)), + mFileName(aPluginTag->mFileName), + mFullPath(aPluginTag->mFullPath), mLastModifiedTime(0), mFlags(NS_PLUGIN_FLAG_ENABLED) { @@ -753,13 +754,6 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag) mMimeTypeArray[i] = new_str(aPluginTag->mMimeTypeArray[i]); } - if(aPluginTag->mMimeDescriptionArray != nsnull) - { - mMimeDescriptionArray = new char*[mVariants]; - for (int i = 0; i < mVariants; i++) - mMimeDescriptionArray[i] = new_str(aPluginTag->mMimeDescriptionArray[i]); - } - if(aPluginTag->mExtensionsArray != nsnull) { mExtensionsArray = new char*[mVariants]; @@ -772,11 +766,10 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag) //////////////////////////////////////////////////////////////////////// nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo) : mPluginHost(nsnull), - mName(new_str(aPluginInfo->fName)), - mDescription(new_str(aPluginInfo->fDescription)), + mName(aPluginInfo->fName), + mDescription(aPluginInfo->fDescription), mVariants(aPluginInfo->fVariantCount), mMimeTypeArray(nsnull), - mMimeDescriptionArray(nsnull), mExtensionsArray(nsnull), mLibrary(nsnull), mEntryPoint(nsnull), @@ -788,8 +781,8 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo) mXPConnected(PR_FALSE), mIsJavaPlugin(PR_FALSE), mIsNPRuntimeEnabledJavaPlugin(PR_FALSE), - mFileName(new_str(aPluginInfo->fFileName)), - mFullPath(new_str(aPluginInfo->fFullPath)), + mFileName(aPluginInfo->fFileName), + mFullPath(aPluginInfo->fFullPath), mLastModifiedTime(0), mFlags(NS_PLUGIN_FLAG_ENABLED) { @@ -817,7 +810,6 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo) if(aPluginInfo->fMimeDescriptionArray != nsnull) { - mMimeDescriptionArray = new char*[mVariants]; for (int i = 0; i < mVariants; i++) { // we should cut off the list of suffixes which the mime // description string may have, see bug 53895 @@ -836,13 +828,16 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo) } } - mMimeDescriptionArray[i] = new_str(aPluginInfo->fMimeDescriptionArray[i]); + mMimeDescriptionArray.AppendElement( + aPluginInfo->fMimeDescriptionArray[i]); // restore the original string if (cur != '\0') *p = cur; if (pre != '\0') *(p - 1) = pre; } + } else { + mMimeDescriptionArray.SetLength(mVariants); } if(aPluginInfo->fExtensionArray != nsnull) @@ -851,6 +846,8 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo) for (int i = 0; i < mVariants; i++) mExtensionsArray[i] = new_str(aPluginInfo->fExtensionArray[i]); } + + EnsureMembersAreUTF8(); } @@ -865,13 +862,13 @@ nsPluginTag::nsPluginTag(const char* aName, const char* const* aExtensions, PRInt32 aVariants, PRInt64 aLastModifiedTime, - PRBool aCanUnload) + PRBool aCanUnload, + PRBool aArgsAreUTF8) : mPluginHost(nsnull), - mName(new_str(aName)), - mDescription(new_str(aDescription)), + mName(aName), + mDescription(aDescription), mVariants(aVariants), mMimeTypeArray(nsnull), - mMimeDescriptionArray(nsnull), mExtensionsArray(nsnull), mLibrary(nsnull), mEntryPoint(nsnull), @@ -879,14 +876,13 @@ nsPluginTag::nsPluginTag(const char* aName, mXPConnected(PR_FALSE), mIsJavaPlugin(PR_FALSE), mIsNPRuntimeEnabledJavaPlugin(PR_FALSE), - mFileName(new_str(aFileName)), - mFullPath(new_str(aFullPath)), + mFileName(aFileName), + mFullPath(aFullPath), mLastModifiedTime(aLastModifiedTime), mFlags(0) // Caller will read in our flags from cache { if (aVariants) { mMimeTypeArray = new char*[mVariants]; - mMimeDescriptionArray = new char*[mVariants]; mExtensionsArray = new char*[mVariants]; for (PRInt32 i = 0; i < aVariants; ++i) { @@ -902,12 +898,15 @@ nsPluginTag::nsPluginTag(const char* aName, } mMimeTypeArray[i] = new_str(aMimeTypes[i]); - mMimeDescriptionArray[i] = new_str(aMimeDescriptions[i]); + mMimeDescriptionArray.AppendElement(aMimeDescriptions[i]); mExtensionsArray[i] = new_str(aExtensions[i]); if (nsPluginHostImpl::IsJavaMIMEType(mMimeTypeArray[i])) mIsJavaPlugin = PR_TRUE; } } + + if (!aArgsAreUTF8) + EnsureMembersAreUTF8(); } nsPluginTag::~nsPluginTag() @@ -920,12 +919,6 @@ nsPluginTag::~nsPluginTag() RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister); } - delete[] (mName); - mName = nsnull; - - delete[] (mDescription); - mDescription = nsnull; - if (mMimeTypeArray) { for (int i = 0; i < mVariants; i++) delete[] mMimeTypeArray[i]; @@ -934,14 +927,6 @@ nsPluginTag::~nsPluginTag() mMimeTypeArray = nsnull; } - if (mMimeDescriptionArray) { - for (int i = 0; i < mVariants; i++) - delete[] mMimeDescriptionArray[i]; - - delete[] (mMimeDescriptionArray); - mMimeDescriptionArray = nsnull; - } - if (mExtensionsArray) { for (int i = 0; i < mVariants; i++) delete[] mExtensionsArray[i]; @@ -949,16 +934,72 @@ nsPluginTag::~nsPluginTag() delete[] (mExtensionsArray); mExtensionsArray = nsnull; } - - delete [] mFileName; - mFileName = nsnull; - - delete [] mFullPath; - mFullPath = nsnull; } NS_IMPL_ISUPPORTS1(nsPluginTag, nsIPluginTag) +static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder, + nsAFlatCString& aString) +{ + nsresult rv; + + PRInt32 numberOfBytes = aString.Length(); + PRInt32 outUnicodeLen; + nsAutoString buffer; + rv = aUnicodeDecoder->GetMaxLength(aString.get(), numberOfBytes, + &outUnicodeLen); + NS_ENSURE_SUCCESS(rv, rv); + if (!EnsureStringLength(buffer, outUnicodeLen)) + return NS_ERROR_OUT_OF_MEMORY; + rv = aUnicodeDecoder->Convert(aString.get(), &numberOfBytes, + buffer.BeginWriting(), &outUnicodeLen); + NS_ENSURE_SUCCESS(rv, rv); + buffer.SetLength(outUnicodeLen); + CopyUTF16toUTF8(buffer, aString); + + return NS_OK; +} + +nsresult nsPluginTag::EnsureMembersAreUTF8() +{ + nsresult rv; + + nsCOMPtr pcs = + do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr decoder; + nsCOMPtr ccm = + do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + nsCAutoString charset; + rv = pcs->GetCharset(kPlatformCharsetSel_FileName, charset); + NS_ENSURE_SUCCESS(rv, rv); + if (!charset.LowerCaseEqualsLiteral("utf-8")) { + rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder)); + NS_ENSURE_SUCCESS(rv, rv); + + ConvertToUTF8(decoder, mFileName); + ConvertToUTF8(decoder, mFullPath); + } + + // The description of the plug-in and the various MIME type descriptions + // should be encoded in the standard plain text file encoding for this system. + // XXX should we add kPlatformCharsetSel_PluginResource? + rv = pcs->GetCharset(kPlatformCharsetSel_PlainTextInFile, charset); + NS_ENSURE_SUCCESS(rv, rv); + if (!charset.LowerCaseEqualsLiteral("utf-8")) { + rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder)); + NS_ENSURE_SUCCESS(rv, rv); + + ConvertToUTF8(decoder, mDescription); + for (PRInt32 i = 0; i < mMimeDescriptionArray.Length(); ++i) { + ConvertToUTF8(decoder, mMimeDescriptionArray[i]); + } + } + return NS_OK; +} + void nsPluginTag::SetHost(nsPluginHostImpl * aHost) { mPluginHost = aHost; @@ -967,27 +1008,21 @@ void nsPluginTag::SetHost(nsPluginHostImpl * aHost) NS_IMETHODIMP nsPluginTag::GetDescription(nsACString& aDescription) { - aDescription.Truncate(); - if (mDescription) - aDescription.Assign(nsDependentCString(mDescription)); + aDescription = mDescription; return NS_OK; } NS_IMETHODIMP nsPluginTag::GetFilename(nsACString& aFileName) { - aFileName.Truncate(); - if (mFileName) - aFileName.Assign(nsDependentCString(mFileName)); + aFileName = mFileName; return NS_OK; } NS_IMETHODIMP nsPluginTag::GetName(nsACString& aName) { - aName.Truncate(); - if (mName) - aName.Assign(nsDependentCString(mName)); + aName = mName; return NS_OK; } @@ -1130,8 +1165,8 @@ PRBool nsPluginTag::Equals(nsPluginTag *aPluginTag) { NS_ENSURE_TRUE(aPluginTag, PR_FALSE); - if ( (PL_strcmp(mName, aPluginTag->mName) != 0) || - (PL_strcmp(mDescription, aPluginTag->mDescription) != 0) || + if ( (!mName.Equals(aPluginTag->mName)) || + (!mDescription.Equals(aPluginTag->mDescription)) || (mVariants != aPluginTag->mVariants) ) return PR_FALSE; @@ -2712,7 +2747,7 @@ nsPluginHostImpl::GetPluginName(nsIPluginInstance *aPluginInstance) gActivePluginList ? gActivePluginList->find(aPluginInstance) : nsnull; if (plugin && plugin->mPluginTag) { - return plugin->mPluginTag->mName; + return plugin->mPluginTag->mName.get(); } return nsnull; @@ -3801,7 +3836,7 @@ nsPluginTag::RegisterWithCategoryManager(PRBool aOverrideInternalTypes, PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsPluginTag::RegisterWithCategoryManager plugin=%s, removing = %s\n", - mFileName, aType == ePluginUnregister ? "yes" : "no")); + mFileName.get(), aType == ePluginUnregister ? "yes" : "no")); nsCOMPtr catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID); if (!catMan) @@ -3862,7 +3897,7 @@ nsPluginTag::RegisterWithCategoryManager(PRBool aOverrideInternalTypes, PLUGIN_LOG(PLUGIN_LOG_NOISY, ("nsPluginTag::RegisterWithCategoryManager mime=%s, plugin=%s\n", - mMimeTypeArray[i], mFileName)); + mMimeTypeArray[i], mFileName.get())); } } @@ -4238,69 +4273,21 @@ nsPluginHostImpl::IsPluginEnabledForExtension(const char* aExtension, } -//////////////////////////////////////////////////////////////////////// -// Utility functions for a charset convertor -// which converts platform charset to unicode. - -static nsresult CreateUnicodeDecoder(nsIUnicodeDecoder **aUnicodeDecoder) -{ - nsresult rv; - // get the charset - nsCAutoString platformCharset; - nsCOMPtr platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - rv = platformCharsetService->GetCharset(kPlatformCharsetSel_FileName, platformCharset); - NS_ENSURE_SUCCESS(rv, rv); - - // get the decoder - nsCOMPtr ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - rv = ccm->GetUnicodeDecoderRaw(platformCharset.get(), - aUnicodeDecoder); - - return rv; -} - -static nsresult DoCharsetConversion(nsIUnicodeDecoder *aUnicodeDecoder, - const char* aANSIString, nsAString& aUnicodeString) -{ - NS_ENSURE_TRUE(aUnicodeDecoder, NS_ERROR_FAILURE); - NS_ENSURE_TRUE(aANSIString, NS_ERROR_FAILURE); - nsresult rv; - - PRInt32 numberOfBytes = strlen(aANSIString); - PRInt32 outUnicodeLen; - nsAutoString buffer; - rv = aUnicodeDecoder->GetMaxLength(aANSIString, numberOfBytes, &outUnicodeLen); - NS_ENSURE_SUCCESS(rv, rv); - if (!EnsureStringLength(buffer, outUnicodeLen)) - return NS_ERROR_OUT_OF_MEMORY; - rv = aUnicodeDecoder->Convert(aANSIString, &numberOfBytes, buffer.BeginWriting(), &outUnicodeLen); - NS_ENSURE_SUCCESS(rv, rv); - buffer.SetLength(outUnicodeLen); - aUnicodeString = buffer; - - return rv; -} - //////////////////////////////////////////////////////////////////////// class DOMMimeTypeImpl : public nsIDOMMimeType { public: NS_DECL_ISUPPORTS - DOMMimeTypeImpl(nsPluginTag* aPluginTag, PRUint32 aMimeTypeIndex) + DOMMimeTypeImpl(nsPluginTag* aTag, PRUint32 aMimeTypeIndex) { - (void) CreateUnicodeDecoder(getter_AddRefs(mUnicodeDecoder)); - if (aPluginTag) { - if (aPluginTag->mMimeDescriptionArray) - (void) DoCharsetConversion(mUnicodeDecoder, - aPluginTag->mMimeDescriptionArray[aMimeTypeIndex], mDescription); - if (aPluginTag->mExtensionsArray) - mSuffixes.AssignWithConversion(aPluginTag->mExtensionsArray[aMimeTypeIndex]); - if (aPluginTag->mMimeTypeArray) - mType.AssignWithConversion(aPluginTag->mMimeTypeArray[aMimeTypeIndex]); - } + if (!aTag) + return; + CopyUTF8toUTF16(aTag->mMimeDescriptionArray[aMimeTypeIndex], mDescription); + if (aTag->mExtensionsArray) + CopyUTF8toUTF16(aTag->mExtensionsArray[aMimeTypeIndex], mSuffixes); + if (aTag->mMimeTypeArray) + CopyUTF8toUTF16(aTag->mMimeTypeArray[aMimeTypeIndex], mType); } virtual ~DOMMimeTypeImpl() { @@ -4335,7 +4322,6 @@ private: nsString mDescription; nsString mSuffixes; nsString mType; - nsCOMPtr mUnicodeDecoder; }; @@ -4348,7 +4334,6 @@ public: DOMPluginImpl(nsPluginTag* aPluginTag) : mPluginTag(aPluginTag) { - (void) CreateUnicodeDecoder(getter_AddRefs(mUnicodeDecoder)); } virtual ~DOMPluginImpl() { @@ -4356,7 +4341,7 @@ public: NS_METHOD GetDescription(nsAString& aDescription) { - DoCharsetConversion(mUnicodeDecoder, mPluginTag.mDescription, aDescription); + CopyUTF8toUTF16(mPluginTag.mDescription, aDescription); return NS_OK; } @@ -4371,39 +4356,36 @@ public: // only show the full path if people have set the pref, // the default should not reveal path information (bug 88183) #if defined(XP_MACOSX) - return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFullPath, aFilename); + CopyUTF8toUTF16(mPluginTag.mFullPath, aFilename); #else - return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFileName, aFilename); + CopyUTF8toUTF16(mPluginTag.mFileName, aFilename); #endif + return NS_OK; } - const char* spec; - if (mPluginTag.mFullPath) + nsAutoString spec; + if (!mPluginTag.mFullPath.IsEmpty()) { #if !defined(XP_MACOSX) NS_ERROR("Only MAC should be using nsPluginTag::mFullPath!"); #endif - spec = mPluginTag.mFullPath; + CopyUTF8toUTF16(mPluginTag.mFullPath, spec); } else { - spec = mPluginTag.mFileName; + CopyUTF8toUTF16(mPluginTag.mFileName, spec); } nsCString leafName; nsCOMPtr pluginPath; - NS_NewNativeLocalFile(nsDependentCString(spec), PR_TRUE, - getter_AddRefs(pluginPath)); + NS_NewLocalFile(spec, PR_TRUE, getter_AddRefs(pluginPath)); - pluginPath->GetNativeLeafName(leafName); - - nsresult rv = DoCharsetConversion(mUnicodeDecoder, leafName.get(), aFilename); - return rv; + return pluginPath->GetLeafName(aFilename); } NS_METHOD GetName(nsAString& aName) { - DoCharsetConversion(mUnicodeDecoder, mPluginTag.mName, aName); + CopyUTF8toUTF16(mPluginTag.mName, aName); return NS_OK; } @@ -4423,16 +4405,15 @@ public: NS_METHOD NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn) { - for (int index = mPluginTag.mVariants - 1; index >= 0; --index) { - if (aName.Equals(NS_ConvertASCIItoUTF16(mPluginTag.mMimeTypeArray[index]))) - return Item(index, aReturn); + for (int i = mPluginTag.mVariants - 1; i >= 0; --i) { + if (aName.Equals(NS_ConvertUTF8toUTF16(mPluginTag.mMimeTypeArray[i]))) + return Item(i, aReturn); } return NS_OK; } private: nsPluginTag mPluginTag; - nsCOMPtr mUnicodeDecoder; }; //////////////////////////////////////////////////////////////////////// @@ -4681,6 +4662,60 @@ inline PRBool IsCompatibleExecutable(const char* path) { return PR_TRUE; } #endif +static nsresult ConvertToNative(nsIUnicodeEncoder *aEncoder, + const nsACString& aUTF8String, + nsACString& aNativeString) +{ + NS_ConvertUTF8toUTF16 utf16(aUTF8String); + PRInt32 len = utf16.Length(); + PRInt32 outLen; + nsresult rv = aEncoder->GetMaxLength(utf16.get(), len, &outLen); + NS_ENSURE_SUCCESS(rv, rv); + if (!EnsureStringLength(aNativeString, outLen)) + return NS_ERROR_OUT_OF_MEMORY; + rv = aEncoder->Convert(utf16.get(), &len, + aNativeString.BeginWriting(), &outLen); + NS_ENSURE_SUCCESS(rv, rv); + aNativeString.SetLength(outLen); + return NS_OK; +} + +static nsresult Create4xPlugin(nsIServiceManagerObsolete* aServiceManager, + const nsPluginTag *aPluginTag, + nsIPlugin **aOut4xPlugnin) +{ + nsresult rv; + nsCOMPtr pcs = + do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + nsCAutoString charset; + rv = pcs->GetCharset(kPlatformCharsetSel_FileName, charset); + NS_ENSURE_SUCCESS(rv, rv); + + nsCAutoString fileName, fullPath; + if (!charset.LowerCaseEqualsLiteral("utf-8")) { + nsCOMPtr encoder; + nsCOMPtr ccm = + do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + rv = ccm->GetUnicodeEncoderRaw(charset.get(), getter_AddRefs(encoder)); + NS_ENSURE_SUCCESS(rv, rv); + rv = ConvertToNative(encoder, aPluginTag->mFileName, fileName); + NS_ENSURE_SUCCESS(rv, rv); + rv = ConvertToNative(encoder, aPluginTag->mFullPath, fullPath); + NS_ENSURE_SUCCESS(rv, rv); + } else { + fileName = aPluginTag->mFileName; + fullPath = aPluginTag->mFullPath; + } + + return ns4xPlugin::CreatePlugin(aServiceManager, + fileName.get(), + fullPath.get(), + aPluginTag->mLibrary, + aOut4xPlugnin); +} //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin) @@ -4700,11 +4735,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi rv = NS_OK; PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsPluginHostImpl::GetPluginFactory Begin mime=%s, plugin=%s\n", - aMimeType, pluginTag->mFileName)); + aMimeType, pluginTag->mFileName.get())); #ifdef NS_DEBUG - if(aMimeType && pluginTag->mFileName) - printf("For %s found plugin %s\n", aMimeType, pluginTag->mFileName); + if(aMimeType && !pluginTag->mFileName.IsEmpty()) + printf("For %s found plugin %s\n", aMimeType, pluginTag->mFileName.get()); #endif if (nsnull == pluginTag->mLibrary) // if we haven't done this yet @@ -4712,11 +4747,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi nsCOMPtr file = do_CreateInstance("@mozilla.org/file/local;1"); #if !defined(XP_MACOSX) - file->InitWithNativePath(nsDependentCString(pluginTag->mFileName)); + file->InitWithPath(NS_ConvertUTF8toUTF16(pluginTag->mFileName)); #else - if (nsnull == pluginTag->mFullPath) + if (pluginTag->mFullPath.IsEmpty()) return NS_ERROR_FAILURE; - file->InitWithNativePath(nsDependentCString(pluginTag->mFullPath)); + file->InitWithPath(NS_ConvertUTF8toUTF16(pluginTag->mFullPath)); #endif nsPluginFile pluginFile(file); PRLibrary* pluginLibrary = NULL; @@ -4762,7 +4797,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi #else nsGetFactory = (nsFactoryProc) PR_FindFunctionSymbol(pluginTag->mLibrary, "NSGetFactory"); #endif - if(nsGetFactory != nsnull && IsCompatibleExecutable(pluginTag->mFullPath)) + if(nsGetFactory && IsCompatibleExecutable(pluginTag->mFullPath.get())) { // XPCOM-style plugins (or at least the OJI one) cause crashes on // on windows GCC builds, so we're just turning them off for now. @@ -4777,7 +4812,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi #ifdef XP_OS2 // on OS2, first check if this might be legacy XPCOM module. else if (PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory") && - IsCompatibleExecutable(pluginTag->mFullPath)) + IsCompatibleExecutable(pluginTag->mFullPath.get())) { // Possibly a legacy XPCOM module. We'll need to create a calling // vtable/calling convention wrapper for it. @@ -4795,16 +4830,10 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi #endif else { - // Now lets try to get the entry point from a 4.x plugin - rv = NS_ERROR_FAILURE; - if (NS_FAILED(rv)) - rv = ns4xPlugin::CreatePlugin(serviceManager, - pluginTag->mFileName, - pluginTag->mFullPath, - pluginTag->mLibrary, - &pluginTag->mEntryPoint); - - plugin = pluginTag->mEntryPoint; + // Now lets try to get the entry point from a 4.x plugin + rv = Create4xPlugin(serviceManager, pluginTag, &plugin); + if (NS_SUCCEEDED(rv)) + pluginTag->mEntryPoint = plugin; pluginTag->Mark(NS_PLUGIN_FLAG_OLDSCHOOL); // no need to initialize, already done by CreatePlugin() } @@ -4815,9 +4844,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi which turn off all our inline IME. Turn it back after the plugin initializtion and hope that future versions will be fixed. See bug 159016 */ - if (pluginTag->mDescription && - !PL_strncasecmp(pluginTag->mDescription, "Shockwave Flash 6.0", 19)) { - int ver = atoi(pluginTag->mDescription + 21); + if (StringBeginsWith(pluginTag->mDescription, + NS_LITERAL_CSTRING("Shockwave Flash 6.0"), + nsCaseInsensitiveCStringComparator()) && + pluginTag->mDescription.Length() > 21) { + int ver = atoi(pluginTag->mDescription.get() + 21); if (ver && ver <= 50) { ::UseInputWindow(NULL, false); } @@ -4834,7 +4865,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsPluginHostImpl::GetPluginFactory End mime=%s, rv=%d, plugin=%p name=%s\n", - aMimeType, rv, *aPlugin, (pluginTag ? pluginTag->mFileName : "(not found)"))); + aMimeType, rv, *aPlugin, + (pluginTag ? pluginTag->mFileName.get() : "(not found)"))); return rv; } @@ -4846,7 +4878,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi // Acrobat, Flash, Quicktime and Shockwave static PRBool isUnwantedPlugin(nsPluginTag * tag) { - if(tag->mFileName == nsnull) + if(tag->mFileName.IsEmpty()) return PR_TRUE; for (PRInt32 i = 0; i < tag->mVariants; ++i) { @@ -4862,7 +4894,7 @@ static PRBool isUnwantedPlugin(nsPluginTag * tag) // On Windows, we also want to include the Quicktime plugin from the 4.x directory // But because it spans several DLL's, the best check for now is by filename - if (PL_strcasestr(tag->mFileName,"npqtplugin") != nsnull) + if (tag->mFileName.Find("npqtplugin", PR_TRUE, 0, -1) != kNotFound) return PR_FALSE; return PR_TRUE; @@ -4907,12 +4939,12 @@ PRBool nsPluginHostImpl::IsDuplicatePlugin(nsPluginTag * aPluginTag) // mFileName contains full path on Windows and Unix and leaf name on Mac // if those are not equal, we have the same plugin with different path, // i.e. duplicate, return true - if (PL_strcmp(tag->mFileName, aPluginTag->mFileName)) + if (!tag->mFileName.Equals(aPluginTag->mFileName)) return PR_TRUE; // if they are equal, compare mFullPath fields just in case // mFileName contained leaf name only, and if not equal, return true - if (tag->mFullPath && aPluginTag->mFullPath && PL_strcmp(tag->mFullPath, aPluginTag->mFullPath)) + if (!tag->mFullPath.Equals(aPluginTag->mFullPath)) return PR_TRUE; } @@ -5595,10 +5627,10 @@ nsPluginHostImpl::WritePluginInfo() // filename & fullpath are on separate line // because they can contain field delimiter char PR_fprintf(fd, "%s%c%c\n%s%c%c\n", - (tag->mFileName ? tag->mFileName : ""), + (!tag->mFileName.IsEmpty() ? tag->mFileName.get() : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, PLUGIN_REGISTRY_END_OF_LINE_MARKER, - (tag->mFullPath ? tag->mFullPath : ""), + (!tag->mFullPath.IsEmpty() ? tag->mFullPath.get() : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, PLUGIN_REGISTRY_END_OF_LINE_MARKER); @@ -5614,10 +5646,10 @@ nsPluginHostImpl::WritePluginInfo() //description, name & mtypecount are on separate line PR_fprintf(fd, "%s%c%c\n%s%c%c\n%d\n", - (tag->mDescription ? tag->mDescription : ""), + (!tag->mDescription.IsEmpty() ? tag->mDescription.get() : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, PLUGIN_REGISTRY_END_OF_LINE_MARKER, - (tag->mName ? tag->mName : ""), + (!tag->mName.IsEmpty() ? tag->mName.get() : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, PLUGIN_REGISTRY_END_OF_LINE_MARKER, tag->mVariants + (tag->mIsNPRuntimeEnabledJavaPlugin ? 1 : 0)); @@ -5628,7 +5660,7 @@ nsPluginHostImpl::WritePluginInfo() i,PLUGIN_REGISTRY_FIELD_DELIMITER, (tag->mMimeTypeArray && tag->mMimeTypeArray[i] ? tag->mMimeTypeArray[i] : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, - (tag->mMimeDescriptionArray && tag->mMimeDescriptionArray[i] ? tag->mMimeDescriptionArray[i] : ""), + (!tag->mMimeDescriptionArray[i].IsEmpty() ? tag->mMimeDescriptionArray[i].get() : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, (tag->mExtensionsArray && tag->mExtensionsArray[i] ? tag->mExtensionsArray[i] : ""), PLUGIN_REGISTRY_FIELD_DELIMITER, @@ -5819,7 +5851,7 @@ nsPluginHostImpl::ReadPluginInfo() (const char* const*)mimetypes, (const char* const*)mimedescriptions, (const char* const*)extensions, - mimetypecount, lastmod, canunload); + mimetypecount, lastmod, canunload, PR_TRUE); if (heapalloced) { delete [] heapalloced; } @@ -5856,8 +5888,7 @@ nsPluginHostImpl::RemoveCachedPluginsInfo(const char *filename, nsPluginTag **re // mFullPath for fullpath and mFileName for just the leafname of fullpath. // On win and unix, mFullPath is never used and mFileName is contains the // full pathname. All this should move to using nsIFile. - if (!PL_strcmp(tag->mFileName, filename) || - (tag->mFullPath && !PL_strcmp(tag->mFullPath, filename))) + if (tag->mFileName.Equals(filename) || tag->mFullPath.Equals(filename)) { // Found it. Remove it from our list if (prev) @@ -6549,20 +6580,19 @@ nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginInstance *aInsta return rv; // add plugin name to the message - char * pluginname = nsnull; + nsCString pluginname; nsActivePlugin * p = mActivePluginList.find(aInstance); if (p) { nsPluginTag * tag = p->mPluginTag; if (tag) { - if (tag->mName) + if (!tag->mName.IsEmpty()) pluginname = tag->mName; else pluginname = tag->mFileName; } } - nsAutoString msg; - msg.AssignWithConversion(pluginname); + NS_ConvertUTF8toUTF16 msg(pluginname); msg.AppendLiteral("\n\n"); msg.Append(message); diff --git a/modules/plugin/base/src/nsPluginHostImpl.h b/modules/plugin/base/src/nsPluginHostImpl.h index 99fd081bbcf0..16091ba110a3 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.h +++ b/modules/plugin/base/src/nsPluginHostImpl.h @@ -68,6 +68,7 @@ #include "nsIPrefBranch.h" #include "nsWeakReference.h" #include "nsThreadUtils.h" +#include "nsTArray.h" // XXX this file really doesn't think this is possible, but ... #include "nsIFactory.h" @@ -108,7 +109,8 @@ public: const char* const* aExtensions, PRInt32 aVariants, PRInt64 aLastModifiedTime = 0, - PRBool aCanUnload = PR_TRUE); + PRBool aCanUnload = PR_TRUE, + PRBool aArgsAreUTF8 = PR_FALSE); ~nsPluginTag(); @@ -143,11 +145,11 @@ public: nsRefPtr mNext; nsPluginHostImpl *mPluginHost; - char *mName; - char *mDescription; + nsCString mName; // UTF-8 + nsCString mDescription; // UTF-8 PRInt32 mVariants; char **mMimeTypeArray; - char **mMimeDescriptionArray; + nsTArray mMimeDescriptionArray; // UTF-8 char **mExtensionsArray; PRLibrary *mLibrary; nsIPlugin *mEntryPoint; @@ -155,11 +157,13 @@ public: PRPackedBool mXPConnected; PRPackedBool mIsJavaPlugin; PRPackedBool mIsNPRuntimeEnabledJavaPlugin; - char *mFileName; - char *mFullPath; + nsCString mFileName; // UTF-8 + nsCString mFullPath; // UTF-8 PRInt64 mLastModifiedTime; private: PRUint32 mFlags; + + nsresult EnsureMembersAreUTF8(); }; struct nsActivePlugin From be6fb851efa5764315c380d2e864ed266f4c3f42 Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Mon, 10 Mar 2008 00:35:37 -0700 Subject: [PATCH 240/248] Bug 421715: canvas crash passing undefined to putImageData, r+a=vlad --- content/canvas/crashtests/421715-1.html | 41 +++++++++++++++++++ content/canvas/crashtests/crashtests.list | 1 + .../canvas/src/nsCanvasRenderingContext2D.cpp | 3 ++ testing/crashtest/crashtests.list | 1 + 4 files changed, 46 insertions(+) create mode 100644 content/canvas/crashtests/421715-1.html create mode 100644 content/canvas/crashtests/crashtests.list diff --git a/content/canvas/crashtests/421715-1.html b/content/canvas/crashtests/421715-1.html new file mode 100644 index 000000000000..74f0be23b637 --- /dev/null +++ b/content/canvas/crashtests/421715-1.html @@ -0,0 +1,41 @@ + + + + + + + No canvas support. + + diff --git a/content/canvas/crashtests/crashtests.list b/content/canvas/crashtests/crashtests.list new file mode 100644 index 000000000000..cf7b0b6c30e5 --- /dev/null +++ b/content/canvas/crashtests/crashtests.list @@ -0,0 +1 @@ +load 421715-1.html diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index aacf9bbad60d..cf338fce9418 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -2548,6 +2548,9 @@ nsCanvasRenderingContext2D::PutImageData() if (!JS_ConvertArguments (ctx, argc, argv, "ojj", &dataObject, &x, &y)) return NS_ERROR_DOM_SYNTAX_ERR; + if (!dataObject) + return NS_ERROR_DOM_SYNTAX_ERR; + int32 w, h; JSObject *dataArray; jsval v; diff --git a/testing/crashtest/crashtests.list b/testing/crashtest/crashtests.list index 496941251f18..76b772b8efe3 100644 --- a/testing/crashtest/crashtests.list +++ b/testing/crashtest/crashtests.list @@ -4,6 +4,7 @@ include ../../testing/crashtest/sanity/crashtests.list include ../../content/base/crashtests/crashtests.list +include ../../content/canvas/crashtests/crashtests.list include ../../content/html/document/crashtests/crashtests.list include ../../content/html/content/crashtests/crashtests.list include ../../content/svg/content/src/crashtests/crashtests.list From 690afd3fb9f9e818551e73fa3639e30033408aeb Mon Sep 17 00:00:00 2001 From: "gavin@gavinsharp.com" Date: Mon, 10 Mar 2008 01:28:51 -0700 Subject: [PATCH 241/248] Back out the patch from bug 420642 because it broke gmail (bug 421571) --- js/src/xpconnect/src/XPCCrossOriginWrapper.cpp | 7 +++++++ js/src/xpconnect/src/XPCWrapper.cpp | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp index bee52c8f01f6..08810107a451 100644 --- a/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp +++ b/js/src/xpconnect/src/XPCCrossOriginWrapper.cpp @@ -381,6 +381,13 @@ WrapSameOriginProp(JSContext *cx, JSObject *outerObj, jsval *vp) return XPC_XOW_WrapObject(cx, STOBJ_GET_PARENT(outerObj), vp); } + if (JS_ObjectIsFunction(cx, wrappedObj) && + JS_GetFunctionNative(cx, reinterpret_cast + (xpc_GetJSPrivate(wrappedObj))) == + XPCWrapper::sEvalNative) { + return XPC_XOW_WrapFunction(cx, outerObj, wrappedObj, vp); + } + return JS_TRUE; } diff --git a/js/src/xpconnect/src/XPCWrapper.cpp b/js/src/xpconnect/src/XPCWrapper.cpp index cc66b9b6a61a..63369a2bf77f 100644 --- a/js/src/xpconnect/src/XPCWrapper.cpp +++ b/js/src/xpconnect/src/XPCWrapper.cpp @@ -353,6 +353,20 @@ XPCWrapper::NewResolve(JSContext *cx, JSObject *wrapperObj, OBJ_DROP_PROPERTY(cx, innerObjp, prop); + // Hack alert: we only do this for same-origin calls on XOWs: we want + // to preserve 'eval' function wrapper on the wrapper object itself + // to preserve eval's identity. + if (!preserveVal && isXOW && !JSVAL_IS_PRIMITIVE(v)) { + JSObject *obj = JSVAL_TO_OBJECT(v); + if (JS_ObjectIsFunction(cx, obj)) { + JSFunction *fun = reinterpret_cast(xpc_GetJSPrivate(obj)); + if (JS_GetFunctionNative(cx, fun) == sEvalNative && + !WrapFunction(cx, wrapperObj, obj, &v, JS_FALSE)) { + return JS_FALSE; + } + } + } + jsval oldSlotVal; if (!::JS_GetReservedSlot(cx, wrapperObj, sResolvingSlot, &oldSlotVal) || !::JS_SetReservedSlot(cx, wrapperObj, sResolvingSlot, JSVAL_TRUE)) { From 188566b7bf929e353e83278a2d0f690a9e221ab3 Mon Sep 17 00:00:00 2001 From: "dietrich@mozilla.com" Date: Mon, 10 Mar 2008 09:41:52 -0700 Subject: [PATCH 242/248] Bug 384370 - test perf run (r=mano) --- browser/app/profile/firefox.js | 7 +- browser/base/content/browser-menubar.inc | 2 +- browser/base/content/browser-places.js | 56 +- browser/base/content/browser.js | 16 +- browser/base/content/nsContextMenu.js | 6 +- browser/components/nsBrowserGlue.js | 131 +- .../places/content/bookmarkProperties.js | 76 +- .../places/content/bookmarksPanel.js | 2 +- .../components/places/content/controller.js | 91 +- .../places/content/editBookmarkOverlay.js | 68 +- .../places/content/history-panel.js | 2 +- browser/components/places/content/menu.xml | 6 +- .../places/content/moveBookmarks.js | 8 +- browser/components/places/content/places.js | 152 +-- browser/components/places/content/places.xul | 2 +- .../places/content/placesOverlay.xul | 9 +- .../components/places/content/sidebarUtils.js | 4 +- browser/components/places/content/toolbar.xml | 6 +- browser/components/places/content/tree.xml | 2 +- browser/components/places/content/treeView.js | 20 +- browser/components/places/content/utils.js | 1194 +++-------------- browser/components/places/src/Makefile.in | 2 + .../src/nsPlacesImportExportService.cpp | 44 +- .../places/src/nsPlacesTransactionsService.js | 17 +- .../places/tests/unit/head_bookmarks.js | 2 + .../places/tests/unit/test_384370.js | 283 +++- .../places/tests/unit/test_398914.js | 7 +- .../places/tests/unit/test_bookmarks_html.js | 1 - browser/components/sidebar/src/nsSidebar.js | 2 +- toolkit/components/places/src/Makefile.in | 4 + .../components/places/src/nsTaggingService.js | 15 +- 31 files changed, 841 insertions(+), 1396 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index da37da6f98d5..52b05b6847f7 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -322,9 +322,10 @@ pref("browser.tabs.selectOwnerOnClose", true); pref("browser.bookmarks.sort.direction", "descending"); pref("browser.bookmarks.sort.resource", "rdf:http://home.netscape.com/NC-rdf#Name"); -// By default, do not overwrite bookmarks.html in the profile directory -// See bug #381216 for details -pref("browser.bookmarks.overwrite", false); +// By default, do not export HTML at shutdown. +// If true, at shutdown the bookmarks in your menu and toolbar will +// be exported as HTML to the bookmarks.html file. +pref("browser.bookmarks.autoExportHTML", false); // Scripts & Windows prefs pref("dom.disable_open_during_load", true); diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index 544b2e5a64fc..be13cb0199f3 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -331,7 +331,7 @@ diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index f0fa2595d47d..5b0bca16478f 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -105,7 +105,7 @@ var StarUI = { this._itemId = -1; this._uri = null; if (this._batching) { - PlacesUtils.ptm.endBatch(); + PlacesUIUtils.ptm.endBatch(); this._batching = false; } } @@ -188,11 +188,11 @@ var StarUI = { // Otherwise, if no changes were done in the edit-item panel, the last // transaction on the undo stack may be the initial createItem transaction, // or worse, the batched editing of some other item. - PlacesUtils.ptm.doTransaction({ doTransaction: function() { }, - undoTransaction: function() { }, - redoTransaction: function() { }, - isTransient: false, - merge: function() { return false; } }); + PlacesUIUtils.ptm.doTransaction({ doTransaction: function() { }, + undoTransaction: function() { }, + redoTransaction: function() { }, + isTransient: false, + merge: function() { return false; } }); if (this.panel.state == "closed") { // Consume dismiss clicks, see bug 400924 @@ -271,7 +271,7 @@ var StarUI = { cancelButtonOnCommand: function SU_cancelButtonOnCommand() { this.endBatch(); - PlacesUtils.ptm.undoTransaction(); + PlacesUIUtils.ptm.undoTransaction(); this.panel.hidePopup(); }, @@ -282,8 +282,8 @@ var StarUI = { // a "Bookmark Removed" notification along with an Undo button is // shown if (this._batching) { - PlacesUtils.ptm.endBatch(); - PlacesUtils.ptm.beginBatch(); // allow undo from within the notification + PlacesUIUtils.ptm.endBatch(); + PlacesUIUtils.ptm.beginBatch(); // allow undo from within the notification var bundle = this._element("bundle_browser"); // "Bookmark Removed" title (the description field is already empty in @@ -308,8 +308,8 @@ var StarUI = { // the tags for the url var itemIds = PlacesUtils.getBookmarksForURI(this._uri); for (var i=0; i < itemIds.length; i++) { - var txn = PlacesUtils.ptm.removeItem(itemIds[i]); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.removeItem(itemIds[i]); + PlacesUIUtils.ptm.doTransaction(txn); } #ifdef ADVANCED_STARRING_UI @@ -324,21 +324,21 @@ var StarUI = { // restore the bookmark by undoing the last transaction and go back // to the edit state this.endBatch(); - PlacesUtils.ptm.undoTransaction(); + PlacesUIUtils.ptm.undoTransaction(); this._itemId = PlacesUtils.getMostRecentBookmarkForURI(this._uri); this.showEditBookmarkPopup(); }, beginBatch: function SU_beginBatch() { if (!this._batching) { - PlacesUtils.ptm.beginBatch(); + PlacesUIUtils.ptm.beginBatch(); this._batching = true; } }, endBatch: function SU_endBatch() { if (this._batching) { - PlacesUtils.ptm.endBatch(); + PlacesUIUtils.ptm.endBatch(); this._batching = false; } } @@ -372,7 +372,7 @@ var PlacesCommandHook = { var description; try { title = webNav.document.title || url.spec; - description = PlacesUtils.getDescriptionFromDocument(webNav.document); + description = PlacesUIUtils.getDescriptionFromDocument(webNav.document); } catch (e) { } @@ -386,9 +386,9 @@ var PlacesCommandHook = { var parent = aParent != undefined ? aParent : PlacesUtils.unfiledBookmarksFolderId; var descAnno = { name: DESCRIPTION_ANNO, value: description }; - var txn = PlacesUtils.ptm.createItem(uri, parent, -1, - title, null, [descAnno]); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.createItem(uri, parent, -1, + title, null, [descAnno]); + PlacesUIUtils.ptm.doTransaction(txn); itemId = PlacesUtils.getMostRecentBookmarkForURI(uri); } @@ -432,8 +432,8 @@ var PlacesCommandHook = { var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI); if (itemId == -1) { StarUI.beginBatch(); - var txn = PlacesUtils.ptm.createItem(linkURI, aParent, -1, aTitle); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.createItem(linkURI, aParent, -1, aTitle); + PlacesUIUtils.ptm.doTransaction(txn); itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI); } @@ -474,7 +474,7 @@ var PlacesCommandHook = { */ bookmarkCurrentPages: function PCH_bookmarkCurrentPages() { var tabURIs = this._getUniqueTabInfo(); - PlacesUtils.showMinimalAddMultiBookmarkUI(tabURIs); + PlacesUIUtils.showMinimalAddMultiBookmarkUI(tabURIs); }, @@ -500,12 +500,12 @@ var PlacesCommandHook = { if (arguments.length > 2) description = feedSubtitle; else - description = PlacesUtils.getDescriptionFromDocument(doc); + description = PlacesUIUtils.getDescriptionFromDocument(doc); var toolbarIP = new InsertionPoint(PlacesUtils.bookmarks.toolbarFolder, -1); - PlacesUtils.showMinimalAddLivemarkUI(feedURI, gBrowser.currentURI, - title, description, toolbarIP, true); + PlacesUIUtils.showMinimalAddLivemarkUI(feedURI, gBrowser.currentURI, + title, description, toolbarIP, true); }, /** @@ -581,7 +581,7 @@ var BookmarksEventHandler = { return; var target = aEvent.originalTarget; - var view = PlacesUtils.getViewForNode(target); + var view = PlacesUIUtils.getViewForNode(target); if (target.node && PlacesUtils.nodeIsFolder(target.node)) { // Don't open the root folder in tabs when the empty area on the toolbar // is middle-clicked or when a non-bookmark item except for Open in Tabs) @@ -625,7 +625,7 @@ var BookmarksEventHandler = { onCommand: function BM_onCommand(aEvent) { var target = aEvent.originalTarget; if (target.node) - PlacesUtils.openNodeWithEvent(target.node, aEvent); + PlacesUIUtils.openNodeWithEvent(target.node, aEvent); }, /** @@ -685,7 +685,7 @@ var BookmarksEventHandler = { openHomePage.setAttribute("onclick", "checkForMiddleClick(this, event); event.stopPropagation();"); openHomePage.setAttribute("label", - PlacesUtils.getFormattedString("menuOpenLivemarkOrigin.label", + PlacesUIUtils.getFormattedString("menuOpenLivemarkOrigin.label", [target.parentNode.getAttribute("label")])); target.appendChild(openHomePage); } @@ -694,7 +694,7 @@ var BookmarksEventHandler = { var openInTabs = document.createElement("menuitem"); openInTabs.setAttribute("openInTabs", "true"); openInTabs.setAttribute("oncommand", - "PlacesUtils.openContainerNodeInTabs(this.parentNode._resultNode, event);"); + "PlacesUIUtils.openContainerNodeInTabs(this.parentNode._resultNode, event);"); openInTabs.setAttribute("label", gNavigatorBundle.getString("menuOpenAllInTabs.label")); target.appendChild(openInTabs); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 7462d63280db..e1fa6ac91a74 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2616,7 +2616,7 @@ var bookmarksButtonObserver = { var split = aXferData.data.split("\n"); var url = split[0]; if (url != aXferData.data) // do nothing if it's not a valid URL - PlacesUtils.showMinimalAddBookmarkUI(makeURI(url), split[1]); + PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), split[1]); }, onDragOver: function (aEvent, aFlavour, aDragSession) @@ -3091,7 +3091,7 @@ function addToUrlbarHistory(aUrlToAdd) try { if (aUrlToAdd.indexOf(" ") == -1) { - PlacesUtils.markPageAsTyped(aUrlToAdd); + PlacesUIUtils.markPageAsTyped(aUrlToAdd); } } catch(ex) { @@ -4724,9 +4724,9 @@ function asyncOpenWebPanel(event) // This is the Opera convention for a special link that - when clicked - allows // you to add a sidebar panel. We support the Opera convention here. The link's // title attribute contains the title that should be used for the sidebar panel. - PlacesUtils.showMinimalAddBookmarkUI(makeURI(wrapper.href), - wrapper.getAttribute("title"), - null, null, true, true); + PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(wrapper.href), + wrapper.getAttribute("title"), + null, null, true, true); event.preventDefault(); return false; } @@ -5690,9 +5690,9 @@ function AddKeywordForSearchField() else spec += "?" + formData.join("&"); - var description = PlacesUtils.getDescriptionFromDocument(node.ownerDocument); - PlacesUtils.showMinimalAddBookmarkUI(makeURI(spec), "", description, null, - null, null, "", postData); + var description = PlacesUIUtils.getDescriptionFromDocument(node.ownerDocument); + PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(spec), "", description, null, + null, null, "", postData); } function SwitchDocumentDirection(aWindow) { diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index bd82882c613a..b08b46fdc584 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -1191,13 +1191,13 @@ nsContextMenu.prototype = { var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri); if (itemId == -1) { var title = doc.title; - var description = PlacesUtils.getDescriptionFromDocument(doc); + var description = PlacesUIUtils.getDescriptionFromDocument(doc); var descAnno = { name: DESCRIPTION_ANNO, value: description }; - var txn = PlacesUtils.ptm.createItem(uri, + var txn = PlacesUIUtils.ptm.createItem(uri, PlacesUtils.bookmarksMenuFolderId, -1, title, null, [descAnno]); - PlacesUtils.ptm.doTransaction(txn); + PlacesUIUtils.ptm.doTransaction(txn); itemId = PlacesUtils.getMostRecentBookmarkForURI(uri); StarUI.beginBatch(); } diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index 4f4997021904..9ce52e6d64f8 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -47,6 +47,13 @@ Cu.import("resource:///modules/distribution.js"); const PREF_EM_NEW_ADDONS_LIST = "extensions.newAddons"; +// Check to see if bookmarks need backing up once per +// day on 1 hour idle. +const BOOKMARKS_ARCHIVE_IDLE_TIME = 60 * 60; + +// Backup bookmarks once every 24 hours. +const BOOKMARKS_ARCHIVE_INTERVAL = 86400 * 1000; + // Factory object const BrowserGlueServiceFactory = { _instance: null, @@ -108,15 +115,23 @@ BrowserGlue.prototype = { if (this._saveSession) { this._setPrefToSaveSession(); } + this._shutdownPlaces(); + this.idleService.removeIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME); break; case "session-save": this._setPrefToSaveSession(); subject.QueryInterface(Ci.nsISupportsPRBool); subject.data = true; break; + case "idle": + if (this.idleService.idleTime > BOOKMARKS_ARCHIVE_IDLE_TIME * 1000) { + // Back up bookmarks. + this._archiveBookmarks(); + } + break; } - } -, + }, + // initialization (called on application startup) _init: function() { @@ -357,6 +372,14 @@ BrowserGlue.prototype = { return Sanitizer; }, + _idleService: null, + get idleService() { + if (!this._idleService) + this._idleService = Cc["@mozilla.org/widget/idleservice;1"]. + getService(Ci.nsIIdleService); + return this._idleService; + }, + /** * Initialize Places * - imports the bookmarks html file if bookmarks datastore is empty @@ -369,10 +392,11 @@ BrowserGlue.prototype = { var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. getService(Ci.nsINavHistoryService); + var prefBranch = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefBranch); + var importBookmarks = false; try { - var prefBranch = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); importBookmarks = prefBranch.getBoolPref("browser.places.importBookmarksHTML"); } catch(ex) {} @@ -380,55 +404,86 @@ BrowserGlue.prototype = { // Call it here for Fx3 profiles created before the Places folder // has been added, otherwise it's called during import. this.ensurePlacesDefaultQueriesInitialized(); - return; } + else { + // get latest backup + Cu.import("resource://gre/modules/utils.js"); + var bookmarksFile = PlacesUtils.getMostRecentBackup(); - var dirService = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties); - - var bookmarksFile = dirService.get("BMarks", Ci.nsILocalFile); - - if (bookmarksFile.exists()) { - // import the file - try { - var importer = - Cc["@mozilla.org/browser/places/import-export-service;1"]. - getService(Ci.nsIPlacesImportExportService); - importer.importHTMLFromFile(bookmarksFile, true); - } catch(ex) { - } finally { - prefBranch.setBoolPref("browser.places.importBookmarksHTML", false); + if (bookmarksFile && bookmarksFile.leafName.match("\.json$")) { + // restore a JSON backup + PlacesUtils.restoreBookmarksFromJSONFile(bookmarksFile); } + else { + // if there's no json backup use bookmarks.html - // only back up pre-places bookmarks.html if we plan on overwriting it - if (prefBranch.getBoolPref("browser.bookmarks.overwrite")) { - // backup pre-places bookmarks.html - // XXXtodo remove this before betas, after import/export is solid - var profDir = dirService.get("ProfD", Ci.nsILocalFile); - var bookmarksBackup = profDir.clone(); - bookmarksBackup.append("bookmarks.preplaces.html"); - if (!bookmarksBackup.exists()) { - // save old bookmarks.html file as bookmarks.preplaces.html - try { - bookmarksFile.copyTo(profDir, "bookmarks.preplaces.html"); - } catch(ex) { - dump("nsBrowserGlue::_initPlaces(): copy of bookmarks.html to bookmarks.preplaces.html failed: " + ex + "\n"); - } + var dirService = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties); + var bookmarksFile = dirService.get("BMarks", Ci.nsILocalFile); + + // import the file + try { + var importer = Cc["@mozilla.org/browser/places/import-export-service;1"]. + getService(Ci.nsIPlacesImportExportService); + importer.importHTMLFromFile(bookmarksFile, true /* overwrite existing */); + } finally { + prefBranch.setBoolPref("browser.places.importBookmarksHTML", false); } } } + + // Initialize bookmark archiving on idle. + // Once a day, either on idle or shutdown, bookmarks are backed up. + this.idleService.addIdleObserver(this, BOOKMARKS_ARCHIVE_IDLE_TIME); }, /** * Places shut-down tasks * - back up and archive bookmarks + * - export bookmarks as HTML, if so configured + * + * Note: quit-application-granted notification is received twice + * so replace this method with a no-op when first called. */ _shutdownPlaces: function bg__shutdownPlaces() { - // backup bookmarks to bookmarks.html - var importer = + // Backup and archive Places bookmarks. + this._archiveBookmarks(); + + // Backup bookmarks to bookmarks.html to support apps that depend + // on the legacy format. + var autoExportHTML = false; + try { + autoExportHTML = prefs.getIntPref("browser.bookmarks.autoExportHTML"); + } catch(ex) {} + + if (autoExportHTML) { Cc["@mozilla.org/browser/places/import-export-service;1"]. - getService(Ci.nsIPlacesImportExportService); - importer.backupBookmarksFile(); + getService(Ci.nsIPlacesImportExportService). + backupBookmarksFile(); + } + }, + + /** + * Back up and archive bookmarks + */ + _archiveBookmarks: function nsBrowserGlue__archiveBookmarks() { + Cu.import("resource://gre/modules/utils.js"); + + var lastBackup = PlacesUtils.getMostRecentBackup(); + + // Backup bookmarks if there aren't any backups or + // they haven't been backed up in the last 24 hrs. + if (!lastBackup || + Date.now() - lastBackup.lastModifiedTime > BOOKMARKS_ARCHIVE_INTERVAL) { + var maxBackups = 5; + var prefs = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefBranch); + try { + maxBackups = prefs.getIntPref("browser.bookmarks.max_backups"); + } catch(ex) {} + + PlacesUtils.archiveBookmarksFile(maxBackups, false /* don't force */); + } }, _migrateUI: function bg__migrateUI() { diff --git a/browser/components/places/content/bookmarkProperties.js b/browser/components/places/content/bookmarkProperties.js index a1dd76f4f4c8..540d67e4c68b 100755 --- a/browser/components/places/content/bookmarkProperties.js +++ b/browser/components/places/content/bookmarkProperties.js @@ -567,8 +567,8 @@ var BookmarkPropertiesPanel = { var itemToSelect = userEnteredNameField; try { this._microsummaries = - PlacesUtils.microsummaries.getMicrosummaries(this._bookmarkURI, - this._bookmarkId); + PlacesUIUtils.microsummaries.getMicrosummaries(this._bookmarkURI, + this._bookmarkId); } catch(ex) { // getMicrosummaries will throw an exception if the page to which the URI @@ -590,8 +590,8 @@ var BookmarkPropertiesPanel = { var menuItem = this._createMicrosummaryMenuItem(microsummary); if (this._action == ACTION_EDIT && - PlacesUtils.microsummaries - .isMicrosummary(this._bookmarkId, microsummary)) + PlacesUIUtils.microsummaries + .isMicrosummary(this._bookmarkId, microsummary)) itemToSelect = menuItem; menupopup.appendChild(menuItem); @@ -713,7 +713,7 @@ var BookmarkPropertiesPanel = { try { var value = this._element(aTextboxID).value; if (value) { - var uri = PlacesUtils.createFixedURI(value); + var uri = PlacesUIUtils.createFixedURI(value); return true; } } catch (e) { } @@ -725,7 +725,7 @@ var BookmarkPropertiesPanel = { */ _getEditTitleTransaction: function BPP__getEditTitleTransaction(aItemId, aNewTitle) { - return PlacesUtils.ptm.editItemTitle(aItemId, aNewTitle); + return PlacesUIUtils.ptm.editItemTitle(aItemId, aNewTitle); }, /** @@ -813,21 +813,21 @@ var BookmarkPropertiesPanel = { // description var description = this._element("descriptionTextfield").value; if (description != this._itemDescription) { - transactions.push(PlacesUtils.ptm. + transactions.push(PlacesUIUtils.ptm. editItemDescription(itemId, description, this._itemType != BOOKMARK_ITEM)); } if (this._itemType == BOOKMARK_ITEM) { // location - var url = PlacesUtils.createFixedURI(this._element("editURLBar").value); + var url = PlacesUIUtils.createFixedURI(this._element("editURLBar").value); if (!this._bookmarkURI.equals(url)) - transactions.push(PlacesUtils.ptm.editBookmarkURI(itemId, url)); + transactions.push(PlacesUIUtils.ptm.editBookmarkURI(itemId, url)); // keyword transactions var newKeyword = this._element("keywordTextfield").value; if (newKeyword != this._bookmarkKeyword) { - transactions.push(PlacesUtils.ptm. + transactions.push(PlacesUIUtils.ptm. editBookmarkKeyword(itemId, newKeyword)); } @@ -841,39 +841,39 @@ var BookmarkPropertiesPanel = { // selected a microsummary which is not the one the bookmark previously // had. if ((newMicrosummary == null && - PlacesUtils.microsummaries.hasMicrosummary(itemId)) || + PlacesUIUtils.microsummaries.hasMicrosummary(itemId)) || (newMicrosummary != null && - !PlacesUtils.microsummaries - .isMicrosummary(itemId, newMicrosummary))) { + !PlacesUIUtils.microsummaries + .isMicrosummary(itemId, newMicrosummary))) { transactions.push( - PlacesUtils.ptm.editBookmarkMicrosummary(itemId, newMicrosummary)); + PlacesUIUtils.ptm.editBookmarkMicrosummary(itemId, newMicrosummary)); } // load in sidebar var loadInSidebarChecked = this._element("loadInSidebarCheckbox").checked; if (loadInSidebarChecked != this._loadBookmarkInSidebar) { transactions.push( - PlacesUtils.ptm.setLoadInSidebar(itemId, loadInSidebarChecked)); + PlacesUIUtils.ptm.setLoadInSidebar(itemId, loadInSidebarChecked)); } } else if (this._itemType == LIVEMARK_CONTAINER) { var feedURIString = this._element("feedLocationTextfield").value; - var feedURI = PlacesUtils.createFixedURI(feedURIString); + var feedURI = PlacesUIUtils.createFixedURI(feedURIString); if (!this._feedURI.equals(feedURI)) { transactions.push( - PlacesUtils.ptm.editLivemarkFeedURI(this._folderId, feedURI)); + PlacesUIUtils.ptm.editLivemarkFeedURI(this._folderId, feedURI)); } // Site Location is empty, we can set its URI to null var newSiteURIString = this._element("feedSiteLocationTextfield").value; var newSiteURI = null; if (newSiteURIString) - newSiteURI = PlacesUtils.createFixedURI(newSiteURIString); + newSiteURI = PlacesUIUtils.createFixedURI(newSiteURIString); if ((!newSiteURI && this._siteURI) || (newSiteURI && (!this._siteURI || !this._siteURI.equals(newSiteURI)))) { transactions.push( - PlacesUtils.ptm.editLivemarkSiteURI(this._folderId, newSiteURI)); + PlacesUIUtils.ptm.editLivemarkSiteURI(this._folderId, newSiteURI)); } } @@ -882,8 +882,8 @@ var BookmarkPropertiesPanel = { if (transactions.length > 0) { window.arguments[0].performed = true; var aggregate = - PlacesUtils.ptm.aggregateTransactions(this._getDialogTitle(), transactions); - PlacesUtils.ptm.doTransaction(aggregate); + PlacesUIUtils.ptm.aggregateTransactions(this._getDialogTitle(), transactions); + PlacesUIUtils.ptm.doTransaction(aggregate); } }, @@ -912,7 +912,7 @@ var BookmarkPropertiesPanel = { */ _getCreateNewBookmarkTransaction: function BPP__getCreateNewBookmarkTransaction(aContainer, aIndex) { - var uri = PlacesUtils.createFixedURI(this._element("editURLBar").value); + var uri = PlacesUIUtils.createFixedURI(this._element("editURLBar").value); var title = this._element("userEnteredName").label; var keyword = this._element("keywordTextfield").value; var annotations = []; @@ -928,20 +928,20 @@ var BookmarkPropertiesPanel = { var microsummary = this._element("namePicker").selectedItem.microsummary; if (microsummary) { childTransactions.push( - PlacesUtils.ptm.editBookmarkMicrosummary(-1, microsummary)); + PlacesUIUtils.ptm.editBookmarkMicrosummary(-1, microsummary)); } if (this._postData) { childTransactions.push( - PlacesUtils.ptm.editBookmarkPostData(-1, this._postData)); + PlacesUIUtils.ptm.editBookmarkPostData(-1, this._postData)); } - var transactions = [PlacesUtils.ptm.createItem(uri, aContainer, aIndex, - title, keyword, - annotations, - childTransactions)]; + var transactions = [PlacesUIUtils.ptm.createItem(uri, aContainer, aIndex, + title, keyword, + annotations, + childTransactions)]; - return PlacesUtils.ptm.aggregateTransactions(this._getDialogTitle(), transactions); + return PlacesUIUtils.ptm.aggregateTransactions(this._getDialogTitle(), transactions); }, /** @@ -953,7 +953,7 @@ var BookmarkPropertiesPanel = { for (var i = 0; i < this._URIList.length; ++i) { var uri = this._URIList[i]; var title = this._getURITitleFromHistory(uri); - transactions.push(PlacesUtils.ptm.createItem(uri, -1, -1, title)); + transactions.push(PlacesUIUtils.ptm.createItem(uri, -1, -1, title)); } return transactions; }, @@ -973,8 +973,8 @@ var BookmarkPropertiesPanel = { if (description) annotations.push(this._getDescriptionAnnotation(description)); - return PlacesUtils.ptm.createFolder(folderName, aContainer, aIndex, - annotations, childItemsTransactions); + return PlacesUIUtils.ptm.createFolder(folderName, aContainer, aIndex, + annotations, childItemsTransactions); }, /** @@ -984,16 +984,16 @@ var BookmarkPropertiesPanel = { _getCreateNewLivemarkTransaction: function BPP__getCreateNewLivemarkTransaction(aContainer, aIndex) { var feedURIString = this._element("feedLocationTextfield").value; - var feedURI = PlacesUtils.createFixedURI(feedURIString); + var feedURI = PlacesUIUtils.createFixedURI(feedURIString); var siteURIString = this._element("feedSiteLocationTextfield").value; var siteURI = null; if (siteURIString) - siteURI = PlacesUtils.createFixedURI(siteURIString); + siteURI = PlacesUIUtils.createFixedURI(siteURIString); var name = this._element("namePicker").value; - return PlacesUtils.ptm.createLivemark(feedURI, siteURI, name, - aContainer, aIndex); + return PlacesUIUtils.ptm.createLivemark(feedURI, siteURI, name, + aContainer, aIndex); }, /** @@ -1018,7 +1018,7 @@ var BookmarkPropertiesPanel = { // perfrom our transaction do via the transaction manager passed by the // opener so it can be undone. window.arguments[0].performed = true; - PlacesUtils.ptm.doTransaction(createTxn); + PlacesUIUtils.ptm.doTransaction(createTxn); }, onNamePickerInput: function BPP_onNamePickerInput() { @@ -1049,7 +1049,7 @@ var BookmarkPropertiesPanel = { if (!this._folderTree.place) { const FOLDER_TREE_PLACE_URI = "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" + - PlacesUtils.allBookmarksFolderId; + PlacesUIUtils.allBookmarksFolderId; this._folderTree.place = FOLDER_TREE_PLACE_URI; } diff --git a/browser/components/places/content/bookmarksPanel.js b/browser/components/places/content/bookmarksPanel.js index 5884a4d22a38..4f0b7de924db 100644 --- a/browser/components/places/content/bookmarksPanel.js +++ b/browser/components/places/content/bookmarksPanel.js @@ -37,7 +37,7 @@ function init() { document.getElementById("bookmarks-view").place = - "place:queryType=1&folder=" + window.top.PlacesUtils.allBookmarksFolderId; + "place:queryType=1&folder=" + window.top.PlacesUIUtils.allBookmarksFolderId; document.getElementById("search-box").focus(); } diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index ff470ae38a71..3ff5a0d1ebb9 100755 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -103,9 +103,9 @@ PlacesController.prototype = { isCommandEnabled: function PC_isCommandEnabled(aCommand) { switch (aCommand) { case "cmd_undo": - return PlacesUtils.ptm.numberOfUndoItems > 0; + return PlacesUIUtils.ptm.numberOfUndoItems > 0; case "cmd_redo": - return PlacesUtils.ptm.numberOfRedoItems > 0; + return PlacesUIUtils.ptm.numberOfRedoItems > 0; case "cmd_cut": case "cmd_delete": return this._hasRemovableSelection(false); @@ -152,7 +152,7 @@ PlacesController.prototype = { case "placesCmd_reloadMicrosummary": var selectedNode = this._view.selectedNode; return selectedNode && PlacesUtils.nodeIsBookmark(selectedNode) && - PlacesUtils.microsummaries.hasMicrosummary(selectedNode.itemId); + PlacesUIUtils.microsummaries.hasMicrosummary(selectedNode.itemId); case "placesCmd_reload": // Livemark containers var selectedNode = this._view.selectedNode; @@ -192,10 +192,10 @@ PlacesController.prototype = { doCommand: function PC_doCommand(aCommand) { switch (aCommand) { case "cmd_undo": - PlacesUtils.ptm.undoTransaction(); + PlacesUIUtils.ptm.undoTransaction(); break; case "cmd_redo": - PlacesUtils.ptm.redoTransaction(); + PlacesUIUtils.ptm.redoTransaction(); break; case "cmd_cut": this.cut(); @@ -213,13 +213,13 @@ PlacesController.prototype = { this.selectAll(); break; case "placesCmd_open": - PlacesUtils.openNodeIn(this._view.selectedNode, "current"); + PlacesUIUtils.openNodeIn(this._view.selectedNode, "current"); break; case "placesCmd_open:window": - PlacesUtils.openNodeIn(this._view.selectedNode, "window"); + PlacesUIUtils.openNodeIn(this._view.selectedNode, "window"); break; case "placesCmd_open:tab": - PlacesUtils.openNodeIn(this._view.selectedNode, "tab"); + PlacesUIUtils.openNodeIn(this._view.selectedNode, "tab"); break; case "placesCmd_new:folder": this.newItem("folder"); @@ -337,8 +337,8 @@ PlacesController.prototype = { // if the clipboard contains TYPE_X_MOZ_PLACE_* data, it is definitely // pasteable, with no need to unwrap all the nodes. - var flavors = PlacesUtils.placesFlavors; - var clipboard = PlacesUtils.clipboard; + var flavors = PlacesUIUtils.placesFlavors; + var clipboard = PlacesUIUtils.clipboard; var hasPlacesData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard); @@ -442,7 +442,7 @@ PlacesController.prototype = { uri = PlacesUtils._uri(node.uri); if (PlacesUtils.nodeIsBookmark(node)) { nodeData["bookmark"] = true; - var mss = PlacesUtils.microsummaries; + var mss = PlacesUIUtils.microsummaries; if (mss.hasMicrosummary(node.itemId)) nodeData["microsummary"] = true; else if (node.parent && @@ -628,9 +628,9 @@ PlacesController.prototype = { return; if (PlacesUtils.nodeIsFolder(node)) - PlacesUtils.showFolderProperties(node.itemId); + PlacesUIUtils.showFolderProperties(node.itemId); else if (PlacesUtils.nodeIsBookmark(node)) - PlacesUtils.showBookmarkProperties(node.itemId); + PlacesUIUtils.showBookmarkProperties(node.itemId); }, /** @@ -656,7 +656,7 @@ PlacesController.prototype = { */ reloadSelectedMicrosummary: function PC_reloadSelectedMicrosummary() { var selectedNode = this._view.selectedNode; - var mss = PlacesUtils.microsummaries; + var mss = PlacesUIUtils.microsummaries; if (mss.hasMicrosummary(selectedNode.itemId)) mss.refreshMicrosummary(selectedNode.itemId); }, @@ -688,14 +688,14 @@ PlacesController.prototype = { GetStringFromName("brandShortName"); var buttonPressed = promptService.confirmEx(window, - PlacesUtils.getString("tabs.openWarningTitle"), - PlacesUtils.getFormattedString(messageKey, + PlacesUIUtils.getString("tabs.openWarningTitle"), + PlacesUIUtils.getFormattedString(messageKey, [numTabsToOpen, brandShortName]), (promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) + (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1), - PlacesUtils.getString(openKey), + PlacesUIUtils.getString(openKey), null, null, - PlacesUtils.getFormattedString("tabs.openWarningPromptMeBranded", + PlacesUIUtils.getFormattedString("tabs.openWarningPromptMeBranded", [brandShortName]), warnOnOpen); @@ -714,9 +714,9 @@ PlacesController.prototype = { openSelectionInTabs: function PC_openLinksInTabs(aEvent) { var node = this._view.selectedNode; if (node && PlacesUtils.nodeIsContainer(node)) - PlacesUtils.openContainerNodeInTabs(this._view.selectedNode, aEvent); + PlacesUIUtils.openContainerNodeInTabs(this._view.selectedNode, aEvent); else - PlacesUtils.openURINodesInTabs(this._view.getSelectionNodes(), aEvent); + PlacesUIUtils.openURINodesInTabs(this._view.getSelectionNodes(), aEvent); }, /** @@ -732,11 +732,11 @@ PlacesController.prototype = { var performed = false; if (aType == "bookmark") - performed = PlacesUtils.showAddBookmarkUI(null, null, null, ip); + performed = PlacesUIUtils.showAddBookmarkUI(null, null, null, ip); else if (aType == "livemark") - performed = PlacesUtils.showAddLivemarkUI(null, null, null, null, ip); + performed = PlacesUIUtils.showAddLivemarkUI(null, null, null, null, ip); else // folder - performed = PlacesUtils.showAddFolderUI(null, ip); + performed = PlacesUIUtils.showAddFolderUI(null, ip); if (performed) { // select the new item @@ -757,7 +757,7 @@ PlacesController.prototype = { throw Cr.NS_ERROR_NOT_AVAILABLE; var performed = false; - performed = PlacesUtils.showAddFolderUI(null, ip); + performed = PlacesUIUtils.showAddFolderUI(null, ip); if (performed) { // select the new item var insertedNodeId = PlacesUtils.bookmarks @@ -773,8 +773,8 @@ PlacesController.prototype = { var ip = this._view.insertionPoint; if (!ip) throw Cr.NS_ERROR_NOT_AVAILABLE; - var txn = PlacesUtils.ptm.createSeparator(ip.itemId, ip.index); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.createSeparator(ip.itemId, ip.index); + PlacesUIUtils.ptm.doTransaction(txn); // select the new item var insertedNodeId = PlacesUtils.bookmarks .getIdForItemAt(ip.itemId, ip.index); @@ -795,8 +795,8 @@ PlacesController.prototype = { */ sortFolderByName: function PC_sortFolderByName() { var itemId = PlacesUtils.getConcreteItemId(this._view.selectedNode); - var txn = PlacesUtils.ptm.sortFolderByName(itemId); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.sortFolderByName(itemId); + PlacesUIUtils.ptm.doTransaction(txn); }, /** @@ -856,7 +856,7 @@ PlacesController.prototype = { if (PlacesUtils.nodeIsFolder(node)) removedFolders.push(node); - transactions.push(PlacesUtils.ptm.removeItem(node.itemId)); + transactions.push(PlacesUIUtils.ptm.removeItem(node.itemId)); } }, @@ -873,8 +873,8 @@ PlacesController.prototype = { for (var i = ranges.length - 1; i >= 0 ; --i) this._removeRange(ranges[i], transactions); if (transactions.length > 0) { - var txn = PlacesUtils.ptm.aggregateTransactions(txnName, transactions); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.aggregateTransactions(txnName, transactions); + PlacesUIUtils.ptm.doTransaction(txn); } }, @@ -997,7 +997,7 @@ PlacesController.prototype = { var data = new TransferData(); function addData(type, overrideURI) { - data.addDataForFlavour(type, PlacesUtils._wrapString( + data.addDataForFlavour(type, PlacesUIUtils._wrapString( PlacesUtils.wrapNode(node, type, overrideURI))); } @@ -1075,7 +1075,7 @@ PlacesController.prototype = { function addData(type, data) { xferable.addDataFlavor(type); - xferable.setTransferData(type, PlacesUtils._wrapString(data), data.length * 2); + xferable.setTransferData(type, PlacesUIUtils._wrapString(data), data.length * 2); } // This order is _important_! It controls how this and other applications // select data to be inserted based on type. @@ -1089,7 +1089,7 @@ PlacesController.prototype = { addData(PlacesUtils.TYPE_HTML, htmlString); if (placeString || unicodeString || htmlString || mozURLString) { - PlacesUtils.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard); + PlacesUIUtils.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard); } } finally { @@ -1116,6 +1116,7 @@ PlacesController.prototype = { // clipboard. We need to get all of that data and build edit transactions // for them. This means asking the clipboard once for each type and // aggregating the results. + dump("PASTING\n"); /** * Constructs a transferable that can receive data of specific types. @@ -1133,7 +1134,7 @@ PlacesController.prototype = { return xferable; } - var clipboard = PlacesUtils.clipboard; + var clipboard = PlacesUIUtils.clipboard; var ip = this._view.insertionPoint; if (!ip) @@ -1161,9 +1162,9 @@ PlacesController.prototype = { // transactions insert differently if index == -1 if (ip.index > -1) index = ip.index + i; - transactions.push(PlacesUtils.makeTransaction(items[i], type.value, - ip.itemId, index, - true)); + transactions.push(PlacesUIUtils.makeTransaction(items[i], type.value, + ip.itemId, index, + true)); } return transactions; } @@ -1182,8 +1183,8 @@ PlacesController.prototype = { var transactions = getTransactions([PlacesUtils.TYPE_X_MOZ_PLACE, PlacesUtils.TYPE_X_MOZ_URL, PlacesUtils.TYPE_UNICODE]); - var txn = PlacesUtils.ptm.aggregateTransactions("Paste", transactions); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.aggregateTransactions("Paste", transactions); + PlacesUIUtils.ptm.doTransaction(txn); // select the pasted items, they should be consecutive var insertedNodeIds = []; @@ -1243,7 +1244,7 @@ var PlacesControllerDragHelper = { canDrop: function PCDH_canDrop() { var session = this.getSession(); if (session) { - var types = PlacesUtils.GENERIC_VIEW_DROP_TYPES; + var types = PlacesUIUtils.GENERIC_VIEW_DROP_TYPES; for (var i = 0; i < types.length; ++i) { if (session.isDataFlavorSupported(types[i])) return true; @@ -1263,7 +1264,7 @@ var PlacesControllerDragHelper = { _initTransferable: function PCDH__initTransferable(session) { var xferable = Cc["@mozilla.org/widget/transferable;1"]. createInstance(Ci.nsITransferable); - var types = PlacesUtils.GENERIC_VIEW_DROP_TYPES; + var types = PlacesUIUtils.GENERIC_VIEW_DROP_TYPES; for (var i = 0; i < types.length; ++i) { if (session.isDataFlavorSupported(types[i])) xferable.addDataFlavor(types[i]); @@ -1306,13 +1307,13 @@ var PlacesControllerDragHelper = { movedCount++; } - transactions.push(PlacesUtils.makeTransaction(unwrapped, + transactions.push(PlacesUIUtils.makeTransaction(unwrapped, flavor.value, insertionPoint.itemId, index, copy)); } - var txn = PlacesUtils.ptm.aggregateTransactions("DropItems", transactions); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.aggregateTransactions("DropItems", transactions); + PlacesUIUtils.ptm.doTransaction(txn); } }; diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index d957f9f3a521..586805568c71 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -145,7 +145,7 @@ var gEditItemOverlay = { // description field this._initTextField("descriptionField", - PlacesUtils.getItemDescription(this._itemId)); + PlacesUIUtils.getItemDescription(this._itemId)); this._showHideRows(); @@ -324,8 +324,8 @@ var gEditItemOverlay = { try { if (this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK && !this._readOnly) - this._microsummaries = PlacesUtils.microsummaries - .getMicrosummaries(this._uri, -1); + this._microsummaries = PlacesUIUtils.microsummaries + .getMicrosummaries(this._uri, -1); } catch(ex) { // getMicrosummaries will throw an exception in at least two cases: @@ -346,8 +346,8 @@ var gEditItemOverlay = { var microsummary = enumerator.getNext() .QueryInterface(Ci.nsIMicrosummary); var menuItem = this._createMicrosummaryMenuItem(microsummary); - if (PlacesUtils.microsummaries - .isMicrosummary(this._itemId, microsummary)) + if (PlacesUIUtils.microsummaries + .isMicrosummary(this._itemId, microsummary)) itemToSelect = menuItem; menupopup.appendChild(menuItem); @@ -449,12 +449,12 @@ var gEditItemOverlay = { } if (tagsToAdd.length > 0) { - var tagTxn = PlacesUtils.ptm.tagURI(this._uri, tagsToAdd); - PlacesUtils.ptm.doTransaction(tagTxn); + var tagTxn = PlacesUIUtils.ptm.tagURI(this._uri, tagsToAdd); + PlacesUIUtils.ptm.doTransaction(tagTxn); } if (tagsToRemove.length > 0) { - var untagTxn = PlacesUtils.ptm.untagURI(this._uri, tagsToRemove); - PlacesUtils.ptm.doTransaction(untagTxn); + var untagTxn = PlacesUIUtils.ptm.untagURI(this._uri, tagsToRemove); + PlacesUIUtils.ptm.doTransaction(untagTxn); } } }, @@ -470,12 +470,12 @@ var gEditItemOverlay = { var namePicker = this._element("namePicker") var txns = []; - const ptm = PlacesUtils.ptm; + const ptm = PlacesUIUtils.ptm; // Here we update either the item title or its cached static title var newTitle = this._element("userEnteredName").label; if (this._getItemStaticTitle() != newTitle) { - if (PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) { + if (PlacesUIUtils.microsummaries.hasMicrosummary(this._itemId)) { // Note: this implicitly also takes care of the microsummary->static // title case, the removeMicorosummary method in the service will set // the item-title to the value of this annotation. @@ -496,10 +496,10 @@ var gEditItemOverlay = { // bookmark previously had one, or the user selected a microsummary which // is not the one the bookmark previously had if ((newMicrosummary == null && - PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) || + PlacesUIUtils.microsummaries.hasMicrosummary(this._itemId)) || (newMicrosummary != null && - !PlacesUtils.microsummaries - .isMicrosummary(this._itemId, newMicrosummary))) { + !PlacesUIUtils.microsummaries + .isMicrosummary(this._itemId, newMicrosummary))) { txns.push(ptm.editBookmarkMicrosummary(this._itemId, newMicrosummary)); } @@ -510,67 +510,67 @@ var gEditItemOverlay = { onDescriptionFieldBlur: function EIO_onDescriptionFieldInput() { var description = this._element("descriptionField").value; if (description != PlacesUtils.getItemDescription(this._itemId)) { - var txn = PlacesUtils.ptm - .editItemDescription(this._itemId, description); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm + .editItemDescription(this._itemId, description); + PlacesUIUtils.ptm.doTransaction(txn); } }, onLocationFieldBlur: function EIO_onLocationFieldBlur() { var uri; try { - uri = PlacesUtils.createFixedURI(this._element("locationField").value); + uri = PlacesUIUtils.createFixedURI(this._element("locationField").value); } catch(ex) { return; } if (!this._uri.equals(uri)) { - var txn = PlacesUtils.ptm.editBookmarkURI(this._itemId, uri); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.editBookmarkURI(this._itemId, uri); + PlacesUIUtils.ptm.doTransaction(txn); } }, onKeywordFieldBlur: function EIO_onKeywordFieldBlur() { var keyword = this._element("keywordField").value; if (keyword != PlacesUtils.bookmarks.getKeywordForBookmark(this._itemId)) { - var txn = PlacesUtils.ptm.editBookmarkKeyword(this._itemId, keyword); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.editBookmarkKeyword(this._itemId, keyword); + PlacesUIUtils.ptm.doTransaction(txn); } }, onFeedLocationFieldBlur: function EIO_onFeedLocationFieldBlur() { var uri; try { - uri = PlacesUtils.createFixedURI(this._element("feedLocationField").value); + uri = PlacesUIUtils.createFixedURI(this._element("feedLocationField").value); } catch(ex) { return; } var currentFeedURI = PlacesUtils.livemarks.getFeedURI(this._itemId); if (!currentFeedURI.equals(uri)) { - var txn = PlacesUtils.ptm.editLivemarkFeedURI(this._itemId, uri); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.editLivemarkFeedURI(this._itemId, uri); + PlacesUIUtils.ptm.doTransaction(txn); } }, onSiteLocationFieldBlur: function EIO_onSiteLocationFieldBlur() { var uri = null; try { - uri = PlacesUtils.createFixedURI(this._element("siteLocationField").value); + uri = PlacesUIUtils.createFixedURI(this._element("siteLocationField").value); } catch(ex) { } var currentSiteURI = PlacesUtils.livemarks.getSiteURI(this._itemId); if (!uri || !currentSiteURI.equals(uri)) { - var txn = PlacesUtils.ptm.editLivemarkSiteURI(this._itemId, uri); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, uri); + PlacesUIUtils.ptm.doTransaction(txn); } }, onLoadInSidebarCheckboxCommand: function EIO_onLoadInSidebarCheckboxCommand() { var loadInSidebarChecked = this._element("loadInSidebarCheckbox").checked; - var txn = PlacesUtils.ptm.setLoadInSidebar(this._itemId, - loadInSidebarChecked); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.setLoadInSidebar(this._itemId, + loadInSidebarChecked); + PlacesUIUtils.ptm.doTransaction(txn); }, toggleFolderTreeVisibility: function EIO_toggleFolderTreeVisibility() { @@ -591,7 +591,7 @@ var gEditItemOverlay = { if (!this._folderTree.place) { const FOLDER_TREE_PLACE_URI = "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" + - window.top.PlacesUtils.allBookmarksFolderId; + window.top.PlacesUIUtils.allBookmarksFolderId; this._folderTree.place = FOLDER_TREE_PLACE_URI; } @@ -651,8 +651,8 @@ var gEditItemOverlay = { // Move the item var container = this._getFolderIdFromMenuList(); if (PlacesUtils.bookmarks.getFolderIdForItem(this._itemId) != container) { - var txn = PlacesUtils.ptm.moveItem(this._itemId, container, -1); - PlacesUtils.ptm.doTransaction(txn); + var txn = PlacesUIUtils.ptm.moveItem(this._itemId, container, -1); + PlacesUIUtils.ptm.doTransaction(txn); // Mark the containing folder as recently-used if it isn't in the // static list diff --git a/browser/components/places/content/history-panel.js b/browser/components/places/content/history-panel.js index cd52ec41c101..e83a049924b0 100644 --- a/browser/components/places/content/history-panel.js +++ b/browser/components/places/content/history-panel.js @@ -104,7 +104,7 @@ function historyAddBookmarks() // or if the selected item is not a URI node var node = gHistoryTree.selectedNode; if (node && PlacesUtils.nodeIsURI(node)) - PlacesUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title); + PlacesUIUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title); } function searchHistory(aInput) diff --git a/browser/components/places/content/menu.xml b/browser/components/places/content/menu.xml index e824d538abeb..29d1477d0e14 100755 --- a/browser/components/places/content/menu.xml +++ b/browser/components/places/content/menu.xml @@ -215,7 +215,7 @@ @@ -601,7 +601,7 @@ + oncommand="PlacesOrganizer.onRestoreBookmarksFromFile();"/>