diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index e40fe2b63d7d..86facf7900e9 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -881,7 +881,7 @@ pref("browser.privatebrowsing.dont_prompt_on_enter", false); pref("browser.bookmarks.editDialog.firstEditField", "namePicker"); // base url for the wifi geolocation network provider -pref("geo.wifi.uri", "https://www.google.com/loc/json"); +pref("geo.wifi.uri", "https://maps.googleapis.com/maps/api/browserlocation/json"); pref("geo.wifi.protocol", 0); // Whether to use a panel that looks like an OS X sheet for customization diff --git a/build/mobile/sutagent/android/watcher/WatcherService.java b/build/mobile/sutagent/android/watcher/WatcherService.java index 2eac1b7a01c9..2b1e4c8695ac 100644 --- a/build/mobile/sutagent/android/watcher/WatcherService.java +++ b/build/mobile/sutagent/android/watcher/WatcherService.java @@ -107,7 +107,6 @@ public class WatcherService extends Service private IWatcherService.Stub stub = new IWatcherService.Stub() { - @Override public int UpdateApplication(String sAppName, String sFileName, String sOutFile, int bReboot) throws RemoteException { return UpdtApp(sAppName, sFileName, sOutFile, bReboot); @@ -874,7 +873,6 @@ public class WatcherService extends Service runner.start(); } - @Override public void run() { bInstalling = true; UpdtApp(msPkgName, msPkgFileName, msOutFile, mbReboot); diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index 423b23590955..4c0e084801e6 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -1737,7 +1737,8 @@ nsScriptSecurityManager::CheckFunctionAccess(JSContext *aCx, void *aFunObj, { #ifdef DEBUG { - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, (JSObject *)aFunObj); + JS_ASSERT(JS_ObjectIsFunction(aCx, (JSObject *)aFunObj)); + JSFunction *fun = (JSFunction *)JS_GetPrivate(aCx, (JSObject *)aFunObj); JSScript *script = JS_GetFunctionScript(aCx, fun); NS_ASSERTION(!script, "Null principal for non-native function!"); @@ -2218,7 +2219,7 @@ nsScriptSecurityManager::GetFunctionObjectPrincipal(JSContext *cx, return result; } - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj); + JSFunction *fun = (JSFunction *)JS_GetPrivate(cx, obj); JSScript *script = JS_GetFunctionScript(cx, fun); if (!script) @@ -2284,7 +2285,7 @@ nsScriptSecurityManager::GetFramePrincipal(JSContext *cx, #ifdef DEBUG if (NS_SUCCEEDED(*rv) && !result) { - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj); + JSFunction *fun = (JSFunction *)JS_GetPrivate(cx, obj); JSScript *script = JS_GetFunctionScript(cx, fun); NS_ASSERTION(!script, "Null principal for non-native function!"); diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 6c94cda7cc92..9a2e4c88f3cb 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -223,7 +223,6 @@ MOZ_XUL = @MOZ_XUL@ MOZ_RDF = @MOZ_RDF@ NECKO_PROTOCOLS = @NECKO_PROTOCOLS@ -NECKO_DISK_CACHE = @NECKO_DISK_CACHE@ NECKO_COOKIES = @NECKO_COOKIES@ NECKO_WIFI = @NECKO_WIFI@ MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@ diff --git a/configure.in b/configure.in index 76c18469ff83..49959d9a08aa 100644 --- a/configure.in +++ b/configure.in @@ -2107,6 +2107,8 @@ case "$target" in # logging code in nsObjCExceptions.h. Currently we only use that in debug # builds. MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling" + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" if test "x$lto_is_enabled" = "xyes"; then echo "Skipping -dead_strip because lto is enabled." @@ -2253,6 +2255,8 @@ ia64*-hpux*) else MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer" fi + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" ;; *-*linux*) @@ -2278,7 +2282,8 @@ ia64*-hpux*) fi MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS" MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS" - MOZ_DEBUG_FLAGS="-g" + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" fi TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"' @@ -2371,7 +2376,8 @@ ia64*-hpux*) CFLAGS="$CFLAGS -we4553" CXXFLAGS="$CXXFLAGS -we4553" LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib" - MOZ_DEBUG_FLAGS='-Zi' + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS='-Zi -Oy-' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' WARNINGS_AS_ERRORS='-WX' # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer. @@ -3588,53 +3594,6 @@ then LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}" fi -dnl ======================================================== -dnl See if mmap sees writes -dnl For cross compiling, just define it as no, which is a safe default -dnl ======================================================== -AC_MSG_CHECKING(whether mmap() sees write()s) - -changequote(,) -mmap_test_prog=' - #include - #include - #include - #include - #include - #include - - char fname[] = "conftest.file"; - char zbuff[1024]; /* Fractional page is probably worst case */ - - int main() { - char *map; - int fd; - int i; - unlink(fname); - fd = open(fname, O_RDWR | O_CREAT, 0660); - if(fd<0) return 1; - unlink(fname); - write(fd, zbuff, sizeof(zbuff)); - lseek(fd, 0, SEEK_SET); - map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0); - if(map==(char*)-1) return 2; - for(i=0; fname[i]; i++) { - int rc = write(fd, &fname[i], 1); - if(map[i]!=fname[i]) return 4; - } - return 0; - } -' -changequote([,]) - -AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes") - -AC_MSG_RESULT("$result") - -if test "$result" = "no"; then - AC_DEFINE(MMAP_MISSES_WRITES) -fi - dnl Checks for library functions. dnl ======================================================== @@ -4778,7 +4737,6 @@ MOZ_DISABLE_DOMCRYPTO= NSS_DISABLE_DBM= NECKO_WIFI=1 NECKO_COOKIES=1 -NECKO_DISK_CACHE=1 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg" USE_ARM_KUSER= BUILD_CTYPES=1 @@ -5194,7 +5152,7 @@ incorrect]) fi MOZ_ENABLE_QTMOBILITY= - PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback, + PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation, MOZ_ENABLE_QTMOBILITY=1, MOZ_ENABLE_QTMOBILITY=) if test "$MOZ_ENABLE_QTMOBILITY"; then @@ -5202,12 +5160,13 @@ incorrect]) MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS" MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS" else - AC_CHECK_LIB(QtSensors QtFeedback, main, [ + AC_CHECK_LIB(QtSensors QtFeedback QtLocation, main, [ MOZ_ENABLE_QTMOBILITY=1 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtMobility" MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtSensors" MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtFeedback" - MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback" + MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtLocation" + MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation" ]) fi if test "$MOZ_ENABLE_QTMOBILITY"; then @@ -8764,19 +8723,6 @@ for p in $NECKO_PROTOCOLS; do AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p) done -dnl -dnl option to disable necko's disk cache -dnl -MOZ_ARG_DISABLE_BOOL(necko-disk-cache, -[ --disable-necko-disk-cache - Disable necko disk cache], - NECKO_DISK_CACHE=, - NECKO_DISK_CACHE=1) -AC_SUBST(NECKO_DISK_CACHE) -if test "$NECKO_DISK_CACHE"; then - AC_DEFINE(NECKO_DISK_CACHE) -fi - dnl dnl option to disable necko's wifi scanner dnl diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index 82ac31748466..688b787baeab 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -95,6 +95,7 @@ CPPSRCS = \ nsDOMAttribute.cpp \ nsDOMAttributeMap.cpp \ nsDOMBlobBuilder.cpp \ + nsDOMCaretPosition.cpp \ nsDOMDocumentType.cpp \ nsDOMEventTargetWrapperCache.cpp \ nsDOMFile.cpp \ diff --git a/content/base/src/nsDOMCaretPosition.cpp b/content/base/src/nsDOMCaretPosition.cpp new file mode 100644 index 000000000000..830d381e1941 --- /dev/null +++ b/content/base/src/nsDOMCaretPosition.cpp @@ -0,0 +1,77 @@ +/* ***** 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. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Brad Lassey + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsDOMCaretPosition.h" +#include "nsDOMClassInfoID.h" +#include "nsIDOMClassInfo.h" + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCaretPosition) + NS_INTERFACE_MAP_ENTRY(nsIDOMCaretPosition) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCaretPosition) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CaretPosition) +NS_INTERFACE_MAP_END + +NS_IMPL_CYCLE_COLLECTION_1(nsDOMCaretPosition, mNode) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCaretPosition) +NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCaretPosition) + +DOMCI_DATA(CaretPosition, nsDOMCaretPosition) + + +nsDOMCaretPosition::nsDOMCaretPosition(nsIDOMNode* aNode, PRUint32 aOffset) + : mNode(aNode), mOffset(aOffset) +{ +} + +nsDOMCaretPosition::~nsDOMCaretPosition() +{ +} + +NS_IMETHODIMP nsDOMCaretPosition::GetOffsetNode(nsIDOMNode** aOffsetNode) +{ + nsCOMPtr node = mNode; + node.forget(aOffsetNode); + return NS_OK; +} + +NS_IMETHODIMP nsDOMCaretPosition::GetOffset(PRUint32* aOffset) +{ + *aOffset = mOffset; + return NS_OK; +} + diff --git a/content/base/src/nsDOMCaretPosition.h b/content/base/src/nsDOMCaretPosition.h new file mode 100644 index 000000000000..63520bf856bf --- /dev/null +++ b/content/base/src/nsDOMCaretPosition.h @@ -0,0 +1,59 @@ +/* ***** 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. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Brad Lassey + * + * 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 ***** */ + +#ifndef nsDOMCaretPosition_h +#define nsDOMCaretPosition_h + +#include "nsIDOMCaretPosition.h" +#include "nsCycleCollectionParticipant.h" +#include "nsCOMPtr.h" + +class nsDOMCaretPosition : public nsIDOMCaretPosition +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMCaretPosition) + NS_DECL_NSIDOMCARETPOSITION + + nsDOMCaretPosition(nsIDOMNode* aNode, PRUint32 aOffset); + +protected: + virtual ~nsDOMCaretPosition(); + PRUint32 mOffset; + nsCOMPtr mNode; +}; +#endif diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index dac6cab89fdc..9cf806b669cb 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -202,9 +202,13 @@ #include "nsDOMTouchEvent.h" #include "mozilla/Preferences.h" +#include "nsFrame.h" #include "imgILoader.h" +#include "nsDOMCaretPosition.h" +#include "nsIDOMHTMLTextAreaElement.h" + using namespace mozilla; using namespace mozilla::dom; @@ -8394,6 +8398,58 @@ nsDocument::CreateTouchList(nsIVariant* aPoints, return NS_OK; } +NS_IMETHODIMP +nsDocument::CaretPositionFromPoint(float aX, float aY, nsIDOMCaretPosition** aCaretPos) +{ + NS_ENSURE_ARG_POINTER(aCaretPos); + *aCaretPos = nsnull; + + nscoord x = nsPresContext::CSSPixelsToAppUnits(aX); + nscoord y = nsPresContext::CSSPixelsToAppUnits(aY); + nsPoint pt(x, y); + + nsIPresShell *ps = GetShell(); + if (!ps) { + return NS_OK; + } + + nsIFrame *rootFrame = ps->GetRootFrame(); + + // XUL docs, unlike HTML, have no frame tree until everything's done loading + if (!rootFrame) { + return NS_OK; // return null to premature XUL callers as a reminder to wait + } + + nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, pt, PR_TRUE, + PR_FALSE); + if (!ptFrame) { + return NS_OK; + } + + nsFrame::ContentOffsets offsets = ptFrame->GetContentOffsetsFromPoint(pt); + nsCOMPtr node = do_QueryInterface(offsets.content); + nsIContent* ptContent = offsets.content; + PRInt32 offset = offsets.offset; + if (ptContent && ptContent->IsInNativeAnonymousSubtree()) { + nsIContent* nonanon = ptContent->FindFirstNonNativeAnonymous(); + nsCOMPtr input = do_QueryInterface(nonanon); + nsCOMPtr textArea = do_QueryInterface(nonanon); + PRBool isText; + if (textArea || (input && + NS_SUCCEEDED(input->MozIsTextField(PR_FALSE, &isText)) && + isText)) { + node = do_QueryInterface(nonanon); + } else { + node = nsnull; + offset = 0; + } + } + + *aCaretPos = new nsDOMCaretPosition(node, offset); + NS_ADDREF(*aCaretPos); + return NS_OK; +} + PRInt64 nsIDocument::SizeOf() const { diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index e90b8a6e9c85..61ef8cd76792 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1059,8 +1059,9 @@ nsINode::AddEventListener(const nsAString& aType, nsEventListenerManager* listener_manager = GetListenerManager(PR_TRUE); NS_ENSURE_STATE(listener_manager); - return listener_manager->AddEventListener(aType, aListener, aUseCapture, - aWantsUntrusted); + listener_manager->AddEventListener(aType, aListener, aUseCapture, + aWantsUntrusted); + return NS_OK; } NS_IMETHODIMP diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index bda60be0cded..54c193d630e8 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -1874,6 +1874,7 @@ GK_ATOM(images_in_menus, "images-in-menus") GK_ATOM(images_in_buttons, "images-in-buttons") GK_ATOM(windows_default_theme, "windows-default-theme") GK_ATOM(mac_graphite_theme, "mac-graphite-theme") +GK_ATOM(mac_lion_theme, "mac-lion-theme") GK_ATOM(windows_compositor, "windows-compositor") GK_ATOM(touch_enabled, "touch-enabled") GK_ATOM(maemo_classic, "maemo-classic") @@ -1899,6 +1900,7 @@ GK_ATOM(_moz_images_in_menus, "-moz-images-in-menus") GK_ATOM(_moz_images_in_buttons, "-moz-images-in-buttons") GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme") GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme") +GK_ATOM(_moz_mac_lion_theme, "-moz-mac-lion-theme") GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor") GK_ATOM(_moz_windows_classic, "-moz-windows-classic") GK_ATOM(_moz_windows_theme, "-moz-windows-theme") diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 3f3fc099b6ee..e60957c82f82 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -503,6 +503,7 @@ _TEST_FILES2 = \ test_bug666604.html \ test_bug675121.html \ file_bug675121.sjs \ + test_bug654352.html \ $(NULL) _CHROME_FILES = \ diff --git a/content/base/test/test_bug654352.html b/content/base/test/test_bug654352.html new file mode 100644 index 000000000000..0cfa0dcc68b7 --- /dev/null +++ b/content/base/test/test_bug654352.html @@ -0,0 +1,50 @@ + + + + + Test for Bug 654352 + + + + + +Mozilla Bug 654352 +

+ +
+
+
+ +
test text
+
+
+
+ + + + + diff --git a/content/base/test/test_copypaste.html b/content/base/test/test_copypaste.html index 448f40af97bf..256b9dc4d782 100644 --- a/content/base/test/test_copypaste.html +++ b/content/base/test/test_copypaste.html @@ -53,8 +53,8 @@ function testCopyPaste () { function copySelectionToClipboard() { documentViewer.copySelection(); - is(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), true); - is(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), true); + ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), "check text/unicode"); + ok(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), "check text/html"); } function copyToClipboard(node) { textarea.blur(); diff --git a/content/events/src/nsDOMEventTargetHelper.cpp b/content/events/src/nsDOMEventTargetHelper.cpp index fe9f7a47de4f..e72de6201d7c 100644 --- a/content/events/src/nsDOMEventTargetHelper.cpp +++ b/content/events/src/nsDOMEventTargetHelper.cpp @@ -126,7 +126,8 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType, nsEventListenerManager* elm = GetListenerManager(PR_TRUE); NS_ENSURE_STATE(elm); - return elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + return NS_OK; } NS_IMETHODIMP diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 546d7bcf3065..87bbf3ff43b5 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -209,14 +209,17 @@ nsEventListenerManager::GetInnerWindowForTarget() return nsnull; } -nsresult +void nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, PRUint32 aType, nsIAtom* aTypeAtom, PRInt32 aFlags) { - NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE); - NS_ENSURE_TRUE(aType, NS_ERROR_FAILURE); + NS_ABORT_IF_FALSE(aType && aTypeAtom, "Missing type"); + + if (!aListener) { + return; + } nsRefPtr kungFuDeathGrip = aListener; @@ -226,7 +229,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, ls = &mListeners.ElementAt(i); if (ls->mListener == aListener && ls->mFlags == aFlags && EVENT_TYPE_EQUALS(ls, aType, aTypeAtom)) { - return NS_OK; + return; } } @@ -291,8 +294,6 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, if (window) window->SetHasTouchEventListeners(); } - - return NS_OK; } void @@ -334,14 +335,14 @@ ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent) (aLs->mEventType == aEvent->message); } -nsresult +void nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener, const nsAString& aType, PRInt32 aFlags) { nsCOMPtr atom = do_GetAtom(NS_LITERAL_STRING("on") + aType); PRUint32 type = nsContentUtils::GetEventId(atom); - return AddEventListener(aListener, type, atom, aFlags); + AddEventListener(aListener, type, atom, aFlags); } void @@ -943,8 +944,7 @@ nsEventListenerManager::Disconnect() RemoveAllListeners(); } -// nsIDOMEventTarget interface -nsresult +void nsEventListenerManager::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture, diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index 506fea2a80dd..84f9186ddc93 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -84,10 +84,10 @@ public: NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsEventListenerManager) - nsresult AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - PRBool aUseCapture, - PRBool aWantsUntrusted); + void AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + PRBool aUseCapture, + PRBool aWantsUntrusted); void RemoveEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture); @@ -96,9 +96,9 @@ public: * Sets events listeners of all types. * @param an event listener */ - nsresult AddEventListenerByType(nsIDOMEventListener *aListener, - const nsAString& type, - PRInt32 aFlags); + void AddEventListenerByType(nsIDOMEventListener *aListener, + const nsAString& type, + PRInt32 aFlags); void RemoveEventListenerByType(nsIDOMEventListener *aListener, const nsAString& type, PRInt32 aFlags); @@ -210,10 +210,10 @@ protected: void *aScopeGlobal, nsIAtom* aName, PRBool aIsString, PRBool aPermitUntrustedEvents); - nsresult AddEventListener(nsIDOMEventListener *aListener, - PRUint32 aType, - nsIAtom* aTypeAtom, - PRInt32 aFlags); + void AddEventListener(nsIDOMEventListener *aListener, + PRUint32 aType, + nsIAtom* aTypeAtom, + PRInt32 aFlags); void RemoveEventListener(nsIDOMEventListener *aListener, PRUint32 aType, nsIAtom* aUserType, diff --git a/content/events/src/nsEventListenerService.cpp b/content/events/src/nsEventListenerService.cpp index 6ed73f56ce85..5336ff95a281 100644 --- a/content/events/src/nsEventListenerService.cpp +++ b/content/events/src/nsEventListenerService.cpp @@ -280,7 +280,8 @@ nsEventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget, NS_EVENT_FLAG_SYSTEM_EVENT : NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_SYSTEM_EVENT; - return manager->AddEventListenerByType(aListener, aType, flags); + manager->AddEventListenerByType(aListener, aType, flags); + return NS_OK; } NS_IMETHODIMP diff --git a/content/events/test/Makefile.in b/content/events/test/Makefile.in index 1a07b15ae0c8..5e815b96337c 100644 --- a/content/events/test/Makefile.in +++ b/content/events/test/Makefile.in @@ -107,6 +107,8 @@ _TEST_FILES = \ test_bug662678.html \ test_bug667919-1.html \ test_bug667919-2.html \ + test_bug667612.html \ + empty.js \ $(NULL) #bug 585630 diff --git a/content/events/test/empty.js b/content/events/test/empty.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/content/events/test/test_bug667612.html b/content/events/test/test_bug667612.html new file mode 100644 index 000000000000..b5d4fe88b7fd --- /dev/null +++ b/content/events/test/test_bug667612.html @@ -0,0 +1,39 @@ + + + + + Test for Bug 667612 + + + + + +Mozilla Bug 667612 +

+ +
+
+
+ + diff --git a/content/media/test/test_delay_load.html b/content/media/test/test_delay_load.html index fc4d14541e0d..c4da3cdc640e 100644 --- a/content/media/test/test_delay_load.html +++ b/content/media/test/test_delay_load.html @@ -96,14 +96,16 @@ v.load(); // Load and move to another document. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); v = createVideo(test.name, test.type, "4"); +v.onloadstart = function(e) { + // Opening a new window to do this is a bit annoying, but if we use an iframe here, + // delaying of the iframe's load event might interfere with the firing of our load event + // in some confusing way. So it's simpler just to open another window. + var w = window.open("", "testWindow", "width=400,height=400"); + w.document.body.appendChild(v); + testWindows.push(w); +}; v.load(); // load started while in this document, this doc's load will block until - // the video's finished loading (in the other document). -// Opening a new window to do this is a bit annoying, but if we use an iframe here, -// delaying of the iframe's load event might interfere with the firing of our load event -// in some confusing way. So it's simpler just to open another window. -var w = window.open("", "testWindow", "width=400,height=400"); -w.document.body.appendChild(v); -testWindows.push(w); + // the video's finished loading (in the other document). if (gRegisteredElements.length > 0) { SimpleTest.waitForExplicitFinish(); diff --git a/docshell/base/Makefile.in b/docshell/base/Makefile.in index 7d3e14277d6f..22d69ab8b26d 100644 --- a/docshell/base/Makefile.in +++ b/docshell/base/Makefile.in @@ -66,7 +66,6 @@ XPIDLSRCS = \ nsIDocShellTreeOwner.idl \ nsIDocShellHistory.idl \ nsIGlobalHistory2.idl \ - nsIGlobalHistory3.idl \ nsIMarkupDocumentViewer.idl \ nsIScrollable.idl \ nsITextScroll.idl \ diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f7e75ae87145..6b7aeea814f9 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -197,7 +197,6 @@ #include "nsISelectionDisplay.h" #include "nsIGlobalHistory2.h" -#include "nsIGlobalHistory3.h" #ifdef DEBUG_DOCSHELL_FOCUS #include "nsEventStateManager.h" diff --git a/docshell/base/nsIGlobalHistory3.idl b/docshell/base/nsIGlobalHistory3.idl deleted file mode 100644 index d54ee56cd82e..000000000000 --- a/docshell/base/nsIGlobalHistory3.idl +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 the Mozilla gecko engine. - * - * The Initial Developer of the Original Code is - * Google Inc. - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Brett Wilson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsISupports.idl" -#include "nsIGlobalHistory2.idl" -interface nsIChannel; - -%{C++ - -// This is NOT part of the interface! It could change. -#define NS_GECKO_FLAG_NEEDS_VERTICAL_SCROLLBAR (1 << 0) - -%} - -/** - * Provides information about global history to gecko, extending GlobalHistory2 - */ -[scriptable, uuid(24306852-c60e-49c3-a455-90f6747118ba)] -interface nsIGlobalHistory3 : nsIGlobalHistory2 -{ - /** - * Notifies the history system that the page loading via aOldChannel - * redirected to aNewChannel. Implementations should generally add the URI for - * aOldChannel to history for link coloring, but are advised not to expose it - * in the history user interface. This function is preferred if - * nsIGlobalHistory3 is available. Otherwise, nsIGlobalHistory2.addURI should - * be called with redirect=true. - * - * This function is preferred to nsIGlobalHistory2.addURI because it provides - * more information (including the redirect destination, channels involved, - * and redirect flags) to the history implementation. - * - * For implementors of nsIGlobalHistory3: The history implementation is - * responsible for sending NS_LINK_VISITED_EVENT_TOPIC to observers for - * redirect pages. This notification must be sent for history consumers for - * all non-redirect pages. - * - * @param aToplevel whether the URI is loaded in a top-level window. If - * false, the load is in a subframe. - * - * The other params to this function are the same as those for - * nsIChannelEventSink::OnChannelRedirect. - * - * Note: Implementors who wish to implement this interface but rely on - * nsIGlobalHistory2.addURI for redirect processing may throw - * NS_ERROR_NOT_IMPLEMENTED from this method. If they do so, then callers - * must call nsIGlobalHistory2.addURI upon getting the - * NS_ERROR_NOT_IMPLEMENTED result. - */ - void addDocumentRedirect(in nsIChannel aOldChannel, - in nsIChannel aNewChannel, - in PRInt32 aFlags, - in boolean aTopLevel); - - /** - * Get the Gecko flags for this URI. These flags are used by Gecko as hints - * to optimize page loading. Not all histories have them; this need not be - * supported (just return NS_ERROR_NOT_IMPLEMENTED. These flags are opaque - * and should not be interpreted by the history engine. - */ - unsigned long getURIGeckoFlags(in nsIURI aURI); - - /** - * Set the Gecko flags for this URI. May fail if the history entry - * doesn't have any flags or if there is no entry for the URI. - */ - void setURIGeckoFlags(in nsIURI aURI, in unsigned long aFlags); -}; diff --git a/docshell/test/chrome/docshell_helpers.js b/docshell/test/chrome/docshell_helpers.js index 249a4a8fc188..7deaf8584f63 100755 --- a/docshell/test/chrome/docshell_helpers.js +++ b/docshell/test/chrome/docshell_helpers.js @@ -323,8 +323,20 @@ function finish() { // Close the test window and signal the framework that the test is done. let opener = window.opener; + let SimpleTest = opener.wrappedJSObject.SimpleTest; + + // Wait for the window to be closed before finishing the test + let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher); + ww.registerNotification(function(subject, topic, data) { + if (topic == "domwindowclosed") { + ww.unregisterNotification(arguments.callee); + SimpleTest.waitForFocus(function() { + SimpleTest.finish(); + }, opener); + } + }); + window.close(); - opener.wrappedJSObject.SimpleTest.finish(); } /** diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 04277248c163..1c79a8d85ac7 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -95,6 +95,7 @@ #include "nsIDOMGlobalPropertyInitializer.h" #include "mozilla/Preferences.h" #include "nsLocation.h" +#include "nsIDOMCaretPosition.h" // Window scriptable helper includes #include "nsIDocShell.h" @@ -665,6 +666,9 @@ static nsDOMClassInfoData sClassInfoData[] = { (DOM_DEFAULT_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE)) + NS_DEFINE_CLASSINFO_DATA(CaretPosition, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(Navigator, nsNavigatorSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::WANT_PRECREATE) @@ -2280,6 +2284,10 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation) DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(CaretPosition, nsIDOMCaretPosition) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMCaretPosition) + DOM_CLASSINFO_MAP_END + if (nsNavigator::HasDesktopNotificationSupport()) { DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator) DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index b6517a1e9539..ef84a51dcda7 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -38,6 +38,7 @@ DOMCI_CLASS(Window) DOMCI_CLASS(Location) +DOMCI_CLASS(CaretPosition) DOMCI_CLASS(Navigator) DOMCI_CLASS(Plugin) DOMCI_CLASS(PluginArray) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index c0e95a79d6a1..d7b0857bf060 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1037,8 +1037,6 @@ nsGlobalWindow::~nsGlobalWindow() CleanUp(PR_TRUE); - NS_ASSERTION(!mHasDeviceMotion, "Window still registered with device motion."); - #ifdef DEBUG nsCycleCollector_DEBUG_wasFreed(static_cast(this)); #endif @@ -1047,6 +1045,9 @@ nsGlobalWindow::~nsGlobalWindow() mURLProperty->ClearWindowReference(); } + DisableDeviceMotionUpdates(); + mHasDeviceMotion = PR_FALSE; + nsLayoutStatics::Release(); } @@ -1165,9 +1166,6 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog) inner->CleanUp(aIgnoreModalDialog); } - DisableDeviceMotionUpdates(); - mHasDeviceMotion = PR_FALSE; - if (mCleanMessageManager) { NS_ABORT_IF_FALSE(mIsChrome, "only chrome should have msg manager cleaned"); nsGlobalChromeWindow *asChrome = static_cast(this); @@ -7376,8 +7374,8 @@ nsGlobalWindow::AddEventListener(const nsAString& aType, nsEventListenerManager* manager = GetListenerManager(PR_TRUE); NS_ENSURE_STATE(manager); - return manager->AddEventListener(aType, aListener, aUseCapture, - aWantsUntrusted); + manager->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + return NS_OK; } nsEventListenerManager* diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index 9dfb91a72b0b..4f5b42a36a12 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -146,7 +146,8 @@ nsWindowRoot::AddEventListener(const nsAString& aType, nsEventListenerManager* elm = GetListenerManager(PR_TRUE); NS_ENSURE_STATE(elm); - return elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + return NS_OK; } nsEventListenerManager* diff --git a/dom/interfaces/core/Makefile.in b/dom/interfaces/core/Makefile.in index a1330a1c28e1..6b8e22de31bd 100644 --- a/dom/interfaces/core/Makefile.in +++ b/dom/interfaces/core/Makefile.in @@ -48,6 +48,7 @@ GRE_MODULE = 1 SDK_XPIDLSRCS = \ nsIDOMAttr.idl \ + nsIDOMCaretPosition.idl \ nsIDOMCDATASection.idl \ nsIDOMCharacterData.idl \ nsIDOMComment.idl \ diff --git a/modules/libreg/src/mmapio.h b/dom/interfaces/core/nsIDOMCaretPosition.idl similarity index 72% rename from modules/libreg/src/mmapio.h rename to dom/interfaces/core/nsIDOMCaretPosition.idl index 5c305dcdddfe..548ce60acc4f 100644 --- a/modules/libreg/src/mmapio.h +++ b/dom/interfaces/core/nsIDOMCaretPosition.idl @@ -11,15 +11,15 @@ * for the specific language governing rights and limitations under the * License. * - * The Original Code is Mozilla Communicator. + * The Original Code is mozilla.org. * * The Initial Developer of the Original Code is - * James L. Nance. - * Portions created by the Initial Developer are Copyright (C) 1999 + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 * the Initial Developer. All Rights Reserved. * * Contributor(s): - * James L. Nance + * Brad Lassey * * 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 @@ -35,13 +35,10 @@ * * ***** END LICENSE BLOCK ***** */ -#include "prio.h" +#include "nsIDOMNode.idl" -typedef struct MmioFileStruct MmioFile; - -PRStatus mmio_FileSeek(MmioFile *file, PRInt32 offset, PRSeekWhence whence); -PRInt32 mmio_FileRead(MmioFile *file, char *dest, PRInt32 count); -PRInt32 mmio_FileWrite(MmioFile *file, const char *src, PRInt32 count); -PRInt32 mmio_FileTell(MmioFile *file); -PRStatus mmio_FileClose(MmioFile *file); -MmioFile *mmio_FileOpen(char *path, PRIntn flags, PRIntn mode); +[scriptable, uuid(cf5ad6cf-6f49-4ca7-9b50-590d7bb27a13)] +interface nsIDOMCaretPosition : nsISupports { + readonly attribute nsIDOMNode offsetNode; + readonly attribute unsigned long offset; +}; diff --git a/dom/interfaces/core/nsIDOMDocument.idl b/dom/interfaces/core/nsIDOMDocument.idl index a4393021968e..1b3de226e967 100644 --- a/dom/interfaces/core/nsIDOMDocument.idl +++ b/dom/interfaces/core/nsIDOMDocument.idl @@ -48,6 +48,7 @@ interface nsIDOMNodeIterator; interface nsIDOMNodeFilter; interface nsIDOMTreeWalker; interface nsIDOMLocation; +interface nsIDOMCaretPosition; /** * The nsIDOMDocument interface represents the entire HTML or XML document. @@ -62,7 +63,7 @@ interface nsIDOMLocation; * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html */ -[scriptable, uuid(10034b87-384e-4e19-902c-c4edafb899be)] +[scriptable, uuid(d19897dc-948a-42e7-8ac6-d8a0bd141b85)] interface nsIDOMDocument : nsIDOMNode { readonly attribute nsIDOMDocumentType doctype; @@ -368,4 +369,6 @@ interface nsIDOMDocument : nsIDOMNode */ void mozSetImageElement(in DOMString aImageElementId, in nsIDOMElement aImageElement); + + nsIDOMCaretPosition caretPositionFromPoint(in float x, in float y); }; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index ec0a4a10b55c..f09136328d3a 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -305,6 +305,7 @@ nsPluginInstanceOwner::nsPluginInstanceOwner() mContentFocused = PR_FALSE; mWidgetVisible = PR_TRUE; mPluginWindowVisible = PR_FALSE; + mPluginDocumentActiveState = PR_TRUE; mNumCachedAttrs = 0; mNumCachedParams = 0; mCachedAttrParamNames = nsnull; @@ -3241,7 +3242,7 @@ void nsPluginInstanceOwner::UpdateWindowPositionAndClipRect(PRBool aSetWindow) mPluginWindow->clipRect.left = 0; mPluginWindow->clipRect.top = 0; - if (mPluginWindowVisible) { + if (mPluginWindowVisible && mPluginDocumentActiveState) { mPluginWindow->clipRect.right = mPluginWindow->width; mPluginWindow->clipRect.bottom = mPluginWindow->height; } else { @@ -3269,6 +3270,12 @@ nsPluginInstanceOwner::UpdateWindowVisibility(PRBool aVisible) UpdateWindowPositionAndClipRect(PR_TRUE); } +void +nsPluginInstanceOwner::UpdateDocumentActiveState(PRBool aIsActive) +{ + mPluginDocumentActiveState = aIsActive; + UpdateWindowPositionAndClipRect(PR_TRUE); +} #endif // XP_MACOSX void diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index 21eeac2bfa7f..8305930bab12 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -202,6 +202,7 @@ public: #else // XP_MACOSX void UpdateWindowPositionAndClipRect(PRBool aSetWindow); void UpdateWindowVisibility(PRBool aVisible); + void UpdateDocumentActiveState(PRBool aIsActive); #endif // XP_MACOSX void CallSetWindow(); @@ -343,6 +344,7 @@ private: PRPackedBool mFlash10Quirks; #endif PRPackedBool mPluginWindowVisible; + PRPackedBool mPluginDocumentActiveState; // If true, destroy the widget on destruction. Used when plugin stop // is being delayed to a safer point in time. diff --git a/dom/src/geolocation/Makefile.in b/dom/src/geolocation/Makefile.in index 82cef08fc159..384204910543 100644 --- a/dom/src/geolocation/Makefile.in +++ b/dom/src/geolocation/Makefile.in @@ -68,6 +68,11 @@ LOCAL_INCLUDES += $(MOZ_PLATFORM_MAEMO_CFLAGS) \ -I$(topsrcdir)/dom/system/unix \ $(NULL) endif +ifdef MOZ_ENABLE_QTMOBILITY +LOCAL_INCLUDES += $(MOZ_QT_CFLAGS) \ + -I$(topsrcdir)/dom/system/unix \ + $(NULL) +endif ifeq ($(MOZ_WIDGET_TOOLKIT),android) LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/android \ diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 3f42dab2f3f6..0d108131ea77 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -80,6 +80,10 @@ #include "MaemoLocationProvider.h" #endif +#ifdef MOZ_ENABLE_QTMOBILITY +#include "QTMLocationProvider.h" +#endif + #ifdef ANDROID #include "AndroidLocationProvider.h" #endif @@ -578,6 +582,12 @@ nsresult nsGeolocationService::Init() mProviders.AppendObject(provider); #endif +#ifdef MOZ_ENABLE_QTMOBILITY + provider = new QTMLocationProvider(); + if (provider) + mProviders.AppendObject(provider); +#endif + #ifdef ANDROID provider = new AndroidLocationProvider(); if (provider) diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js index 8762d8ca70c8..bcf5a2747812 100755 --- a/dom/system/NetworkGeolocationProvider.js +++ b/dom/system/NetworkGeolocationProvider.js @@ -1,15 +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 Network Location Provider for GLS. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Doug Turner + * + * 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 ***** */ + + +// Do not use this API without permission from Google. +// See http://www.google.com/support/enterprise/bin/request.py?contact_type=gme&utm_campaign=en-us-ptr-mz +// for more information. + Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +Components.utils.import("resource://gre/modules/Services.jsm"); const Ci = Components.interfaces; const Cc = Components.classes; -var gLoggingEnabled = false; -var gTestingEnabled = false; - -function nowInSeconds() -{ - return Date.now() / 1000; -} +let gLoggingEnabled = false; +let gTestingEnabled = false; function LOG(aMsg) { if (gLoggingEnabled) @@ -20,408 +58,254 @@ function LOG(aMsg) { } } -function WifiGeoAddressObject(streetNumber, street, premises, city, county, region, country, countryCode, postalCode) { - - this.streetNumber = streetNumber; - this.street = street; - this.premises = premises; - this.city = city; - this.county = county; - this.region = region; - this.country = country; - this.countryCode = countryCode; - this.postalCode = postalCode; -} - -WifiGeoAddressObject.prototype = { - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionAddress]), - - classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionAddress], - flags: Ci.nsIClassInfo.DOM_OBJECT}) -}; - function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) { - this.latitude = lat; - this.longitude = lon; - this.accuracy = acc; - this.altitude = alt; - this.altitudeAccuracy = altacc; -}; + this.latitude = lat; + this.longitude = lon; + this.accuracy = acc; + this.altitude = alt; + this.altitudeAccuracy = altacc; +} WifiGeoCoordsObject.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]), - - classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "wifi geo position coords object"}), - - latitude: 0, - longitude: 0, - accuracy: 0, - altitude: 0, - altitudeAccuracy: 0, + QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]), + classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords], + flags: Ci.nsIClassInfo.DOM_OBJECT, + classDescription: "wifi geo position coords object"}), }; -function WifiGeoPositionObject(location) { - - this.coords = new WifiGeoCoordsObject(location.latitude, - location.longitude, - location.accuracy || 12450, // .5 * circumference of earth. - location.altitude || 0, - location.altitude_accuracy || 0); - - if (location.address) { - let address = location.address; - this.address = new WifiGeoAddressObject(address.street_number || null, - address.street || null, - address.premises || null, - address.city || null, - address.county || null, - address.region || null, - address.country || null, - address.country_code || null, - address.postal_code || null); - } - else - this.address = null; - - this.timestamp = Date.now(); -}; +function WifiGeoPositionObject(lat, lng, acc) { + this.coords = new WifiGeoCoordsObject(lat, lng, acc, 0, 0); + this.address = null; + this.timestamp = Date.now(); +} WifiGeoPositionObject.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]), - // Class Info is required to be able to pass objects back into the DOM. - classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition], - flags: Ci.nsIClassInfo.DOM_OBJECT, - classDescription: "wifi geo location position object"}), - - coords: null, - timestamp: 0, + // Class Info is required to be able to pass objects back into the DOM. + classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition], + flags: Ci.nsIClassInfo.DOM_OBJECT, + classDescription: "wifi geo location position object"}), }; -function HELD() {}; - // For information about the HELD format, see: - // http://tools.ietf.org/html/draft-thomson-geopriv-held-measurements-05 -HELD.encode = function(requestObject) { - // XML Header - var requestString = ""; - // Measurements - if (requestObject.wifi_towers && requestObject.wifi_towers.length > 0) { - requestString += ""; - requestString += ""; - for (var i=0; i < requestObject.wifi_towers.length; ++i) { - requestString += ""; - requestString += "" + requestObject.wifi_towers[i].mac_address + ""; - requestString += "" + requestObject.wifi_towers[i].ssid + ""; - requestString += "" + requestObject.wifi_towers[i].signal_strength + ""; - requestString += ""; - } - // XML Footer - requestString += ""; - } - requestString += ""; - return requestString; -}; - -// Decode a HELD response into a Gears-style object -HELD.decode = function(responseXML) { - // Find a Circle object in PIDF-LO and decode - function nsResolver(prefix) { - var ns = { - 'held': 'urn:ietf:params:xml:ns:geopriv:held', - 'pres': 'urn:ietf:params:xml:ns:pidf', - 'gp': 'urn:ietf:params:xml:ns:pidf:geopriv10', - 'gml': 'http://www.opengis.net/gml', - 'gs': 'http://www.opengis.net/pidflo/1.0', - }; - return ns[prefix] || null; - } - - var xpathEval = Components.classes["@mozilla.org/dom/xpath-evaluator;1"].createInstance(Ci.nsIDOMXPathEvaluator); - - // Grab values out of XML via XPath - var pos = xpathEval.evaluate( - '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gml:pos', - responseXML, - nsResolver, - Ci.nsIDOMXPathResult.STRING_TYPE, - null); - - var rad = xpathEval.evaluate( - '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gs:radius', - responseXML, - nsResolver, - Ci.nsIDOMXPathResult.NUMBER_TYPE, - null ); - - var uom = xpathEval.evaluate( - '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gs:radius/@uom', - responseXML, - nsResolver, - Ci.nsIDOMXPathResult.STRING_TYPE, - null); - - // Bail if we don't have a valid result (all values && uom==meters) - if ((pos.stringValue == null) || - (rad.numberValue == null) || - (uom.stringValue == null) || - (uom.stringValue != "urn:ogc:def:uom:EPSG::9001")) { - return null; - } - - // Split the pos value into lat/long - var coords = pos.stringValue.split(/[ \t\n]+/); - - // Fill out the object to return: - var obj = { - location: { - latitude: parseFloat(coords[0]), - longitude: parseFloat(coords[1]), - accuracy: rad.numberValue - } - }; - return obj; -} - function WifiGeoPositionProvider() { - this.prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch).QueryInterface(Ci.nsIPrefService); - try { - gLoggingEnabled = this.prefService.getBoolPref("geo.wifi.logging.enabled"); - } catch (e) {} + try { + gLoggingEnabled = Services.prefs.getBoolPref("geo.wifi.logging.enabled"); + } catch (e) {} - try { - gTestingEnabled = this.prefService.getBoolPref("geo.wifi.testing"); - } catch (e) {} + try { + gTestingEnabled = Services.prefs.getBoolPref("geo.wifi.testing"); + } catch (e) {} -}; + wifiService = null; + timer = null; + hasSeenWiFi = false; + started = false; +} WifiGeoPositionProvider.prototype = { - classID: Components.ID("{77DA64D3-7458-4920-9491-86CC9914F904}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationProvider, - Ci.nsIWifiListener, - Ci.nsITimerCallback]), + classID: Components.ID("{77DA64D3-7458-4920-9491-86CC9914F904}"), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationProvider, + Ci.nsIWifiListener, + Ci.nsITimerCallback]), + startup: function() { + if (this.started) + return; + this.started = true; + this.hasSeenWiFi = false; - prefService: null, - wifi_service: null, - timer: null, - hasSeenWiFi: false, - started: false, + LOG("startup called. testing mode is" + gTestingEnabled); - startup: function() { - if (this.started == true) - return; + // if we don't see anything in 5 seconds, kick of one IP geo lookup. + // if we are testing, just hammer this callback so that we are more or less + // always sending data. It doesn't matter if we have an access point or not. + this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + if (!gTestingEnabled) + this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT); + else + this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK); + }, - this.started = true; + watch: function(c) { + LOG("watch called"); + if (!this.wifiService) { + this.wifiService = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor); + this.wifiService.startWatching(this); + } + }, - LOG("startup called. testing mode is" + gTestingEnabled); - // if we don't see anything in 5 seconds, kick of one IP geo lookup. - // if we are testing, just hammer this callback so that we are more or less - // always sending data. It doesn't matter if we have an access point or not. - this.hasSeenWiFi = false; - this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - if (gTestingEnabled == false) - this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT); - else - this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK); - }, + shutdown: function() { + LOG("shutdown called"); + if(this.wifiService) { + this.wifiService.stopWatching(this); + this.wifiService = null; + } + if (this.timer != null) { + this.timer.cancel(); + this.timer = null; + } - watch: function(c) { - LOG("watch called"); - if (!this.wifi_service) { - this.wifi_service = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor); - this.wifi_service.startWatching(this); - } - }, + // Although we aren't using cookies, we should err on the side of not + // saving any access tokens if the user asked us not to save cookies or + // has changed the lifetimePolicy. The access token in these cases is + // used and valid for the life of this object (eg. between startup and + // shutdown). + if (Services.prefs.getIntPref("network.cookie.lifetimePolicy") != 0) + Services.prefs.deleteBranch("geo.wifi.access_token."); + this.started = false; + }, - shutdown: function() { - LOG("shutdown called"); - if(this.wifi_service) - this.wifi_service.stopWatching(this); - this.wifi_service = null; + getAccessTokenForURL: function(url) + { + // check to see if we have an access token: + let accessToken = ""; + try { + let accessTokenPrefName = "geo.wifi.access_token." + url; + accessToken = Services.prefs.getCharPref(accessTokenPrefName); - if (this.timer != null) { - this.timer.cancel(); - this.timer = null; - } - - // Although we aren't using cookies, we should err on the side of not - // saving any access tokens if the user asked us not to save cookies or - // has changed the lifetimePolicy. The access token in these cases is - // used and valid for the life of this object (eg. between startup and - // shutdown).e - let prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - if (prefBranch.getIntPref("network.cookie.lifetimePolicy") != 0) - prefBranch.deleteBranch("geo.wifi.access_token."); - - this.started = false; - }, - - getAccessTokenForURL: function(url) - { - // check to see if we have an access token: - var accessToken = ""; - - try { - var accessTokenPrefName = "geo.wifi.access_token." + url; - accessToken = this.prefService.getCharPref(accessTokenPrefName); + // check to see if it has expired + let accessTokenDate = Services.prefs.getIntPref(accessTokenPrefName + ".time"); + + let accessTokenInterval = 1209600; // seconds in 2 weeks + try { + accessTokenInterval = Services.prefs.getIntPref("geo.wifi.access_token.recycle_interval"); + } catch (e) {} - // check to see if it has expired - var accessTokenDate = this.prefService.getIntPref(accessTokenPrefName + ".time"); - - var accessTokenInterval = 1209600; /* seconds in 2 weeks */ - try { - accessTokenInterval = this.prefService.getIntPref("geo.wifi.access_token.recycle_interval"); - } catch (e) {} - - if (nowInSeconds() - accessTokenDate > accessTokenInterval) - accessToken = ""; + if ((Date.now() / 1000) - accessTokenDate > accessTokenInterval) + accessToken = ""; + } + catch (e) { + accessToken = ""; + } + return accessToken; + }, + + onChange: function(accessPoints) { + LOG("onChange called"); + this.hasSeenWiFi = true; + + let providerUrlBase = Services.prefs.getCharPref("geo.wifi.uri"); + let providerUrl; + + let query = providerUrlBase.indexOf("?"); + if (query == -1) + providerUrl = providerUrlBase + "?" + else + providerUrl = providerUrlBase + "&"; + providerUrl = providerUrl + "browser=firefox&sensor=true"; + + + let accessToken = this.getAccessTokenForURL(providerUrlBase); + if (accessToken !== "") + providerUrl = providerUrl + "&access_token="+access_token; + + function sort(a, b) { + return b.signal - a.signal; + }; + + function encode(ap) { + // make sure that the ssid doesn't contain any | chars. + ap.ssid = ap.ssid.replace("|", "\\|"); + // gls service parses the | as fields + return "&wifi=mac:"+ap.mac+"|ssid:"+ap.ssid+"|ss:"+ap.signal; + }; + + if (accessPoints) { + accessPoints.sort(sort).map(encode).join(""); + // max length is 2k. make sure we are under that + let x = providerUrl.length - 2000; + if (x >= 0) { + // we need to trim + let doomed = providerUrl.lastIndexOf("&", 2000); + LOG("Doomed:"+doomed); + providerUrl = providerUrl.substring(0, doomed); } - catch (e) { - accessToken = ""; - } - return accessToken; - }, + } - onChange: function(accessPoints) { + providerUrl = encodeURI(providerUrl); + LOG("************************************* Sending request:\n" + providerUrl + "\n"); - LOG("onChange called"); - this.hasSeenWiFi = true; + // send our request to a wifi geolocation network provider: + let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] + .createInstance(Ci.nsIXMLHttpRequest); - // send our request to a wifi geolocation network provider: - var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] - .createInstance(Ci.nsIXMLHttpRequest); + // This is a background load + xhr.mozBackgroundRequest = true; + xhr.open("GET", providerUrl, false); + xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS; + xhr.onerror = function(req) { + LOG("onerror: " + req); + }; + xhr.onload = function (req) { + LOG("service returned: " + req.target.responseText); + response = JSON.parse(req.target.responseText); + /* + { + "status": "OK", + "accuracy": 150.0, + "location": { + "lat": -33.85702, + "lng": 151.21494 + }, + "access_token": "quijibo" + } + */ - // This is a background load - xhr.mozBackgroundRequest = true; + if (response.status != "OK") + return; - var provider_url = this.prefService.getCharPref("geo.wifi.uri"); - var provider_protocol = 0; - try { - provider_protocol = this.prefService.getIntPref("geo.wifi.protocol"); - } catch (e) {} + if (response.location) { + let newLocation = new WifiGeoPositionObject(response.location.lat, + response.location.lng, + response.accuracy); - LOG("provider url = " + provider_url); - - xhr.open("POST", provider_url, false); - - // set something so that we can strip cookies - xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS; - - xhr.onerror = function(req) { - LOG("onerror: " + req); - }; - - xhr.onload = function (req) { - - LOG("xhr onload..."); - - try { - // if we get a bad response, we will throw and never report a location - var response; - switch (provider_protocol) { - case 1: - LOG("service returned: " + req.target.responseXML); - response = HELD.decode(req.target.responseXML); - break; - case 0: - default: - LOG("service returned: " + req.target.responseText); - response = JSON.parse(req.target.responseText); - } - } catch (e) { - LOG("Parse failed"); - return; - } - - // response looks something like: - // {"location":{"latitude":51.5090332,"longitude":-0.1212726,"accuracy":150.0},"access_token":"2:jVhRZJ-j6PiRchH_:RGMrR0W1BiwdZs12"} - - // Check to see if we have a new access token - var newAccessToken = response.access_token; - if (newAccessToken != undefined) - { - var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - var accessToken = ""; - var accessTokenPrefName = "geo.wifi.access_token." + req.target.channel.URI.spec; - try { accessToken = prefService.getCharPref(accessTokenPrefName); } catch (e) {} - - if (accessToken != newAccessToken) { - // no match, lets cache - LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName); - - try { - prefService.setIntPref(accessTokenPrefName + ".time", nowInSeconds()); - prefService.setCharPref(accessTokenPrefName, newAccessToken); - } catch (x) { - // XXX temporary hack for bug 575346 to allow geolocation to function - } - } - } - - if (response.location) { - var newLocation = new WifiGeoPositionObject(response.location); - - var update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate); - update.update(newLocation); - } - }; - - var accessToken = this.getAccessTokenForURL(provider_url); - - var request = { - version: "1.1.0", - request_address: true, - }; - - if (accessToken != "") - request.access_token = accessToken; - - if (accessPoints != null) { - function filterBlankSSIDs(ap) ap.ssid != "" - function deconstruct(ap) ({ - mac_address: ap.mac, - ssid: ap.ssid, - signal_strength: ap.signal - }) - request.wifi_towers = accessPoints.filter(filterBlankSSIDs).map(deconstruct); + let update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate); + update.update(newLocation); } - var requestString; - switch (provider_protocol) { - case 1: - requestString = HELD.encode(request); - break; - case 0: - default: - requestString = JSON.stringify(request); - } - LOG("client sending: " + requestString); - - try { - xhr.send(requestString); - } catch (e) {} - }, + // Check to see if we have a new access token + let newAccessToken = response.access_token; + if (newAccessToken !== undefined) + { + let accessToken = ""; + let accessTokenPrefName = "geo.wifi.access_token." + providerUrlBase; + try { accessToken = Services.prefs.getCharPref(accessTokenPrefName); } catch (e) {} - onError: function (code) { - LOG("wifi error: " + code); - }, - - notify: function (timer) { - if (!gTestingEnabled) { - if (this.hasSeenWiFi == false) - this.onChange(null); - this.timer = null; - return; + if (accessToken != newAccessToken) { + // no match, lets cache + LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName); + try { + Services.prefs.setIntPref(accessTokenPrefName + ".time", nowInSeconds()); + Services.prefs.setCharPref(accessTokenPrefName, newAccessToken); + } catch (x) { + // XXX temporary hack for bug 575346 to allow geolocation to function + } + } } - // if we are testing, we need to hammer this. + }; + + LOG("************************************* ------>>>> sending."); + xhr.send(null); + }, + + onError: function (code) { + LOG("wifi error: " + code); + }, + + notify: function (timer) { + if (gTestingEnabled) { + // if we are testing, timer is repeating + this.onChange(null); + } + else { + if (!this.hasSeenWiFi) this.onChange(null); - }, - + this.timer = null; + } + }, }; -var NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]); +let NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]); diff --git a/dom/system/unix/Makefile.in b/dom/system/unix/Makefile.in index 1309bd2fc843..ca62e122f4f8 100644 --- a/dom/system/unix/Makefile.in +++ b/dom/system/unix/Makefile.in @@ -50,6 +50,8 @@ FORCE_STATIC_LIB = 1 EXPORT_LIBRARY = 1 include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk + CPPSRCS = \ nsDeviceMotionSystem.cpp \ @@ -67,7 +69,12 @@ CPPSRCS += nsHapticFeedback.cpp LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS) \ $(NULL) ifdef MOZ_ENABLE_QTMOBILITY +MOCSRCS += moc_QTMLocationProvider.cpp +CPPSRCS += $(MOCSRCS) \ + QTMLocationProvider.cpp \ + $(NULL) LOCAL_INCLUDES += $(MOZ_QT_CFLAGS) \ + -I$(topsrcdir)/dom/src/geolocation \ $(NULL) endif endif diff --git a/dom/system/unix/QTMLocationProvider.cpp b/dom/system/unix/QTMLocationProvider.cpp new file mode 100644 index 000000000000..712bf5b50da0 --- /dev/null +++ b/dom/system/unix/QTMLocationProvider.cpp @@ -0,0 +1,118 @@ +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * ***** 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 Qt code. + * + * The Initial Developer of the Original Code is Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Oleg Romashin + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "QTMLocationProvider.h" +#include "nsGeoPosition.h" +#include +using namespace QtMobility; + +using namespace mozilla; + +NS_IMPL_ISUPPORTS1(QTMLocationProvider, nsIGeolocationProvider) + +QTMLocationProvider::QTMLocationProvider() +{ + mLocation = QGeoPositionInfoSource::createDefaultSource(this); + if (mLocation) + connect(mLocation, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); +} + +QTMLocationProvider::~QTMLocationProvider() +{ + delete mLocation; +} + +void +QTMLocationProvider::positionUpdated(const QGeoPositionInfo &geoPosition) +{ + if (!geoPosition.isValid()) { + NS_WARNING("Invalida geoposition received"); + return; + } + + QGeoCoordinate coord = geoPosition.coordinate(); + double latitude = coord.latitude(); + double longitude = coord.longitude(); + double altitude = coord.altitude(); + double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy); + double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy); + double heading = geoPosition.attribute(QGeoPositionInfo::Direction); + + bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed); + double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed); + + nsRefPtr p = + new nsGeoPosition(latitude, longitude, + altitude, accuracy, + altitudeAccuracy, heading, + speed, geoPosition.timestamp().toTime_t()); + if (mCallback) { + mCallback->Update(p); + } +} + +NS_IMETHODIMP +QTMLocationProvider::Startup() +{ + if (!mLocation) + return NS_ERROR_NOT_IMPLEMENTED; + + mLocation->startUpdates(); + + return NS_OK; +} + +NS_IMETHODIMP +QTMLocationProvider::Watch(nsIGeolocationUpdate* aCallback) +{ + mCallback = aCallback; + + return NS_OK; +} + +NS_IMETHODIMP +QTMLocationProvider::Shutdown() +{ + if (!mLocation) + return NS_ERROR_NOT_IMPLEMENTED; + + mLocation->stopUpdates(); + mCallback = nsnull; + + return NS_OK; +} + diff --git a/dom/system/unix/QTMLocationProvider.h b/dom/system/unix/QTMLocationProvider.h new file mode 100644 index 000000000000..8c572e280296 --- /dev/null +++ b/dom/system/unix/QTMLocationProvider.h @@ -0,0 +1,69 @@ +/* ***** 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 Qt code. + * + * The Initial Developer of the Original Code is Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Oleg Romashin + * + * 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 ***** */ + +#ifndef QTMLocationProvider_h +#define QTMLocationProvider_h + +#include +#include "nsGeolocation.h" +#include "nsIGeolocationProvider.h" +#include "nsCOMPtr.h" + +using namespace QtMobility; + +class QTMLocationProvider : public QObject, + public nsIGeolocationProvider +{ + Q_OBJECT + +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIGEOLOCATIONPROVIDER + + QTMLocationProvider(); + +public Q_SLOTS: + // QGeoPositionInfoSource + void positionUpdated(const QGeoPositionInfo&); + +private: + ~QTMLocationProvider(); + + QtMobility::QGeoPositionInfoSource* mLocation; + nsCOMPtr mCallback; +}; + +#endif /* QTMLocationProvider_h */ diff --git a/dom/tests/mochitest/geolocation/geolocation_common.js b/dom/tests/mochitest/geolocation/geolocation_common.js index 3fd8e7c901ff..b1628096288f 100644 --- a/dom/tests/mochitest/geolocation/geolocation_common.js +++ b/dom/tests/mochitest/geolocation/geolocation_common.js @@ -77,15 +77,15 @@ function check_geolocation(location) { ok("latitude" in coords, "Check to see if there is a latitude"); ok("longitude" in coords, "Check to see if there is a longitude"); - ok("altitude" in coords, "Check to see if there is a altitude"); ok("accuracy" in coords, "Check to see if there is a accuracy"); - ok("altitudeAccuracy" in coords, "Check to see if there is a alt accuracy"); - + + // optional ok("altitude" in coords, "Check to see if there is a altitude"); + // optional ok("altitudeAccuracy" in coords, "Check to see if there is a alt accuracy"); // optional ok("heading" in coords, "Check to see if there is a heading"); // optional ok("speed" in coords, "Check to see if there is a speed"); ok (location.coords.latitude == 37.41857, "lat matches known value"); ok (location.coords.longitude == -122.08769, "lon matches known value"); - ok(location.coords.altitude == 42, "alt matches known value"); - ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value"); + // optional ok(location.coords.altitude == 42, "alt matches known value"); + // optional ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value"); } diff --git a/dom/tests/mochitest/geolocation/network_geolocation.sjs b/dom/tests/mochitest/geolocation/network_geolocation.sjs index c4bbb9765fb6..66863480a39f 100644 --- a/dom/tests/mochitest/geolocation/network_geolocation.sjs +++ b/dom/tests/mochitest/geolocation/network_geolocation.sjs @@ -19,35 +19,16 @@ function parseQueryString(str) function getPosition(action) { - // this isn't the w3c data structure, it is the network location provider structure. - - var address = { - street_number: "street_number", - street: "street", - premises: "premises", - city: "city", - county: "county", - region: "region", - country: "country", - country_code: "country_code", - postal_code: "postal_code", - }; - - - var coords = { - latitude: 37.41857, - longitude: -122.08769, - - altitude: 42, + var response = { + status: "OK", + location: { + lat: 37.41857, + lng: -122.08769, + }, accuracy: (action == "worse-accuracy") ? 100 : 42, - altitude_accuracy: 42, }; - var geoposition = { - location: coords, - }; - - return JSON.stringify(geoposition); + return JSON.stringify(response); } function handleRequest(request, response) diff --git a/editor/composer/src/nsComposerCommands.cpp b/editor/composer/src/nsComposerCommands.cpp index 3e56ffb9a348..6c5c005799d1 100644 --- a/editor/composer/src/nsComposerCommands.cpp +++ b/editor/composer/src/nsComposerCommands.cpp @@ -431,7 +431,8 @@ nsRemoveListCommand::IsCommandEnabled(const char * aCommandName, if (editor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) { // It is enabled if we are in any list type @@ -543,7 +544,8 @@ nsOutdentCommand::IsCommandEnabled(const char * aCommandName, if (editor && htmlEditor) { PRBool canIndent, isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return htmlEditor->GetIndentState(&canIndent, outCmdEnabled); } @@ -1051,7 +1053,8 @@ nsAbsolutePositioningCommand::IsCommandEnabled(const char * aCommandName, if (htmlEditor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled); } diff --git a/editor/libeditor/base/nsEditorCommands.cpp b/editor/libeditor/base/nsEditorCommands.cpp index a81012d192e3..590e4cc48bd6 100644 --- a/editor/libeditor/base/nsEditorCommands.cpp +++ b/editor/libeditor/base/nsEditorCommands.cpp @@ -71,7 +71,8 @@ nsUndoCommand::IsCommandEnabled(const char * aCommandName, if (editor) { PRBool isEnabled, isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanUndo(&isEnabled, outCmdEnabled); } @@ -119,7 +120,8 @@ nsRedoCommand::IsCommandEnabled(const char * aCommandName, if (editor) { PRBool isEnabled, isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanRedo(&isEnabled, outCmdEnabled); } @@ -215,7 +217,8 @@ nsCutCommand::IsCommandEnabled(const char * aCommandName, if (editor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanCut(outCmdEnabled); } @@ -319,7 +322,8 @@ nsCopyCommand::IsCommandEnabled(const char * aCommandName, if (editor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanCopy(outCmdEnabled); } @@ -422,7 +426,8 @@ nsPasteCommand::IsCommandEnabled(const char *aCommandName, if (editor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled); } @@ -469,7 +474,8 @@ nsPasteTransferableCommand::IsCommandEnabled(const char *aCommandName, if (editor) { PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (isEditable) return editor->CanPasteTransferable(nsnull, outCmdEnabled); } @@ -580,7 +586,8 @@ nsDeleteCommand::IsCommandEnabled(const char * aCommandName, NS_ENSURE_TRUE(editor, NS_OK); PRBool isEditable = PR_FALSE; - NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable)); + nsresult rv = editor->GetIsSelectionEditable(&isEditable); + NS_ENSURE_SUCCESS(rv, rv); if (!isEditable) return NS_OK; diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index b17d3145c1b2..84817846668b 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -126,78 +126,62 @@ nsEditorEventListener::InstallToEditor() nsCOMPtr piTarget = mEditor->GetDOMEventTarget(); NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE); - nsresult rv; - // register the event listeners with the listener manager nsEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE); NS_ENSURE_STATE(elmP); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("keypress"), - NS_EVENT_FLAG_BUBBLE | - NS_PRIV_EVENT_UNTRUSTED_PERMITTED | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("keypress"), + NS_EVENT_FLAG_BUBBLE | + NS_PRIV_EVENT_UNTRUSTED_PERMITTED | + NS_EVENT_FLAG_SYSTEM_EVENT); // See bug 455215, we cannot use the standard dragstart event yet - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("draggesture"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("dragenter"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("dragover"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("dragexit"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("drop"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("mousedown"), - NS_EVENT_FLAG_CAPTURE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("mouseup"), - NS_EVENT_FLAG_CAPTURE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("click"), - NS_EVENT_FLAG_CAPTURE); - NS_ENSURE_SUCCESS(rv, rv); - // Focus event doesn't bubble so adding the listener to capturing phase. - // Make sure this works after bug 235441 gets fixed. - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("blur"), - NS_EVENT_FLAG_CAPTURE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("focus"), - NS_EVENT_FLAG_CAPTURE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("text"), - NS_EVENT_FLAG_BUBBLE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("compositionstart"), - NS_EVENT_FLAG_BUBBLE); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, - NS_LITERAL_STRING("compositionend"), - NS_EVENT_FLAG_BUBBLE); - NS_ENSURE_SUCCESS(rv, rv); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("draggesture"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("dragenter"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("dragover"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("dragexit"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("drop"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("mousedown"), + NS_EVENT_FLAG_CAPTURE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("mouseup"), + NS_EVENT_FLAG_CAPTURE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("click"), + NS_EVENT_FLAG_CAPTURE); +// Focus event doesn't bubble so adding the listener to capturing phase. +// Make sure this works after bug 235441 gets fixed. + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("blur"), + NS_EVENT_FLAG_CAPTURE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("focus"), + NS_EVENT_FLAG_CAPTURE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("text"), + NS_EVENT_FLAG_BUBBLE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("compositionstart"), + NS_EVENT_FLAG_BUBBLE); + elmP->AddEventListenerByType(this, + NS_LITERAL_STRING("compositionend"), + NS_EVENT_FLAG_BUBBLE); return NS_OK; } diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java index 9a61be3807c1..7c2fad4197bf 100644 --- a/embedding/android/GeckoApp.java +++ b/embedding/android/GeckoApp.java @@ -66,6 +66,8 @@ import android.telephony.*; abstract public class GeckoApp extends Activity { + private static final String LOG_FILE_NAME = "GeckoApp"; + public static final String ACTION_ALERT_CLICK = "org.mozilla.gecko.ACTION_ALERT_CLICK"; public static final String ACTION_ALERT_CLEAR = "org.mozilla.gecko.ACTION_ALERT_CLEAR"; public static final String ACTION_WEBAPP = "org.mozilla.gecko.WEBAPP"; @@ -151,13 +153,13 @@ abstract public class GeckoApp try { unpackComponents(); } catch (FileNotFoundException fnfe) { - Log.e("GeckoApp", "error unpacking components", fnfe); + Log.e(LOG_FILE_NAME, "error unpacking components", fnfe); Looper.prepare(); showErrorDialog(getString(R.string.error_loading_file)); Looper.loop(); return; } catch (IOException ie) { - Log.e("GeckoApp", "error unpacking components", ie); + Log.e(LOG_FILE_NAME, "error unpacking components", ie); String msg = ie.getMessage(); Looper.prepare(); if (msg != null && msg.equalsIgnoreCase("No space left on device")) @@ -175,7 +177,7 @@ abstract public class GeckoApp i.getStringExtra("args"), i.getDataString()); } catch (Exception e) { - Log.e("GeckoApp", "top level exception", e); + Log.e(LOG_FILE_NAME, "top level exception", e); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); GeckoAppShell.reportJavaCrash(sw.toString()); @@ -199,7 +201,7 @@ abstract public class GeckoApp try { Looper.loop(); } catch (Exception e) { - Log.e("GeckoApp", "top level exception", e); + Log.e(LOG_FILE_NAME, "top level exception", e); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); GeckoAppShell.reportJavaCrash(sw.toString()); @@ -215,7 +217,7 @@ abstract public class GeckoApp if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode); - Log.i("GeckoApp", "create"); + Log.i(LOG_FILE_NAME, "create"); super.onCreate(savedInstanceState); if (sGREDir == null) @@ -319,30 +321,30 @@ abstract public class GeckoApp return; if (Intent.ACTION_MAIN.equals(action)) { - Log.i("GeckoApp", "Intent : ACTION_MAIN"); + Log.i(LOG_FILE_NAME, "Intent : ACTION_MAIN"); GeckoAppShell.sendEventToGecko(new GeckoEvent("")); } else if (Intent.ACTION_VIEW.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(new GeckoEvent(uri)); - Log.i("GeckoApp","onNewIntent: "+uri); + Log.i(LOG_FILE_NAME,"onNewIntent: "+uri); } else if (ACTION_WEBAPP.equals(action)) { String uri = intent.getStringExtra("args"); GeckoAppShell.sendEventToGecko(new GeckoEvent(uri)); - Log.i("GeckoApp","Intent : WEBAPP - " + uri); + Log.i(LOG_FILE_NAME,"Intent : WEBAPP - " + uri); } else if (ACTION_BOOKMARK.equals(action)) { String args = intent.getStringExtra("args"); GeckoAppShell.sendEventToGecko(new GeckoEvent(args)); - Log.i("GeckoApp","Intent : BOOKMARK - " + args); + Log.i(LOG_FILE_NAME,"Intent : BOOKMARK - " + args); } } @Override public void onPause() { - Log.i("GeckoApp", "pause"); + Log.i(LOG_FILE_NAME, "pause"); GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_PAUSING)); // The user is navigating away from this activity, but nothing // has come to the foreground yet; for Gecko, we may want to @@ -364,7 +366,7 @@ abstract public class GeckoApp @Override public void onResume() { - Log.i("GeckoApp", "resume"); + Log.i(LOG_FILE_NAME, "resume"); if (checkLaunchState(LaunchState.GeckoRunning)) GeckoAppShell.onResume(); // After an onPause, the activity is back in the foreground. @@ -389,7 +391,7 @@ abstract public class GeckoApp @Override public void onStop() { - Log.i("GeckoApp", "stop"); + Log.i(LOG_FILE_NAME, "stop"); // We're about to be stopped, potentially in preparation for // being destroyed. We're killable after this point -- as I // understand it, in extreme cases the process can be terminated @@ -410,7 +412,7 @@ abstract public class GeckoApp @Override public void onRestart() { - Log.i("GeckoApp", "restart"); + Log.i(LOG_FILE_NAME, "restart"); GeckoAppShell.putChildInForeground(); super.onRestart(); } @@ -418,14 +420,14 @@ abstract public class GeckoApp @Override public void onStart() { - Log.i("GeckoApp", "start"); + Log.i(LOG_FILE_NAME, "start"); super.onStart(); } @Override public void onDestroy() { - Log.i("GeckoApp", "destroy"); + Log.i(LOG_FILE_NAME, "destroy"); // Tell Gecko to shutting down; we'll end up calling System.exit() // in onXreExit. if (isFinishing()) @@ -437,7 +439,7 @@ abstract public class GeckoApp @Override public void onConfigurationChanged(android.content.res.Configuration newConfig) { - Log.i("GeckoApp", "configuration changed"); + Log.i(LOG_FILE_NAME, "configuration changed"); // nothing, just ignore super.onConfigurationChanged(newConfig); } @@ -445,7 +447,7 @@ abstract public class GeckoApp @Override public void onLowMemory() { - Log.e("GeckoApp", "low memory"); + Log.e(LOG_FILE_NAME, "low memory"); if (checkLaunchState(LaunchState.GeckoRunning)) GeckoAppShell.onLowMemory(); super.onLowMemory(); @@ -470,7 +472,7 @@ abstract public class GeckoApp removeFiles(); } catch (Exception ex) { // This file may not be there, so just log any errors and move on - Log.w("GeckoApp", "error removing files", ex); + Log.w(LOG_FILE_NAME, "error removing files", ex); } unpackFile(zip, buf, null, "application.ini"); unpackFile(zip, buf, null, getContentProcessName()); @@ -585,11 +587,11 @@ abstract public class GeckoApp addEnvToIntent(intent); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - Log.i("GeckoAppJava", intent.toString()); + Log.i(LOG_FILE_NAME, intent.toString()); GeckoAppShell.killAnyZombies(); startActivity(intent); } catch (Exception e) { - Log.i("GeckoAppJava", "error doing restart", e); + Log.i(LOG_FILE_NAME, "error doing restart", e); } finish(); // Give the restart process time to start before we die @@ -601,7 +603,7 @@ abstract public class GeckoApp } private void checkAndLaunchUpdate() { - Log.i("GeckoAppJava", "Checking for an update"); + Log.i(LOG_FILE_NAME, "Checking for an update"); int statusCode = 8; // UNEXPECTED_ERROR File baseUpdateDir = null; @@ -621,7 +623,7 @@ abstract public class GeckoApp if (!updateFile.exists()) return; - Log.i("GeckoAppJava", "Update is available!"); + Log.i(LOG_FILE_NAME, "Update is available!"); // Launch APK File updateFileToRun = new File(updateDir, getPackageName() + "-update.apk"); @@ -630,15 +632,15 @@ abstract public class GeckoApp String amCmd = "/system/bin/am start -a android.intent.action.VIEW " + "-n com.android.packageinstaller/.PackageInstallerActivity -d file://" + updateFileToRun.getPath(); - Log.i("GeckoAppJava", amCmd); + Log.i(LOG_FILE_NAME, amCmd); Runtime.getRuntime().exec(amCmd); statusCode = 0; // OK } else { - Log.i("GeckoAppJava", "Cannot rename the update file!"); + Log.i(LOG_FILE_NAME, "Cannot rename the update file!"); statusCode = 7; // WRITE_ERROR } } catch (Exception e) { - Log.i("GeckoAppJava", "error launching installer to update", e); + Log.i(LOG_FILE_NAME, "error launching installer to update", e); } // Update the status file @@ -651,7 +653,7 @@ abstract public class GeckoApp outStream.write(buf, 0, buf.length); outStream.close(); } catch (Exception e) { - Log.i("GeckoAppJava", "error writing status file", e); + Log.i(LOG_FILE_NAME, "error writing status file", e); } if (statusCode == 0) @@ -665,7 +667,7 @@ abstract public class GeckoApp status = reader.readLine(); reader.close(); } catch (Exception e) { - Log.i("GeckoAppJava", "error reading update status", e); + Log.i(LOG_FILE_NAME, "error reading update status", e); } return status; } @@ -682,10 +684,14 @@ abstract public class GeckoApp Intent.createChooser(intent, getString(R.string.choose_file)), FILE_PICKER_REQUEST); String filePickerResult = ""; + try { - filePickerResult = mFilePickerResult.take(); + while (null == (filePickerResult = mFilePickerResult.poll(1, TimeUnit.MILLISECONDS))) { + Log.i("GeckoApp", "processing events from showFilePicker "); + GeckoAppShell.processNextNativeEvent(); + } } catch (InterruptedException e) { - Log.i("GeckoApp", "showing file picker ", e); + Log.i(LOG_FILE_NAME, "showing file picker ", e); } return filePickerResult; @@ -738,13 +744,13 @@ abstract public class GeckoApp fos.close(); filePickerResult = file.getAbsolutePath(); }catch (Exception e) { - Log.e("GeckoApp", "showing file picker", e); + Log.e(LOG_FILE_NAME, "showing file picker", e); } } try { mFilePickerResult.put(filePickerResult); } catch (InterruptedException e) { - Log.i("GeckoApp", "error returning file picker result", e); + Log.i(LOG_FILE_NAME, "error returning file picker result", e); } } } diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index afd5cd0812e8..6cf86e196e0a 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -74,6 +74,8 @@ import android.graphics.Bitmap; public class GeckoAppShell { + private static final String LOG_FILE_NAME = "GeckoAppShell"; + // static members only private GeckoAppShell() { } @@ -117,6 +119,8 @@ public class GeckoAppShell public static native void onChangeNetworkLinkStatus(String status, String type); public static native void reportJavaCrash(String stack); + public static native void processNextNativeEvent(); + // A looper thread, accessed by GeckoAppShell.getHandler private static class LooperThread extends Thread { public SynchronousQueue mHandlerQueue = @@ -190,25 +194,25 @@ public class GeckoAppShell sFreeSpace = cacheStats.getFreeBlocks() * cacheStats.getBlockSize(); } else { - Log.i("GeckoAppShell", "Unable to get cache dir"); + Log.i(LOG_FILE_NAME, "Unable to get cache dir"); } } } catch (Exception e) { - Log.e("GeckoAppShell", "exception while stating cache dir: ", e); + Log.e(LOG_FILE_NAME, "exception while stating cache dir: ", e); } return sFreeSpace; } static boolean moveFile(File inFile, File outFile) { - Log.i("GeckoAppShell", "moving " + inFile + " to " + outFile); + Log.i(LOG_FILE_NAME, "moving " + inFile + " to " + outFile); if (outFile.isDirectory()) outFile = new File(outFile, inFile.getName()); try { if (inFile.renameTo(outFile)) return true; } catch (SecurityException se) { - Log.w("GeckoAppShell", "error trying to rename file", se); + Log.w(LOG_FILE_NAME, "error trying to rename file", se); } try { long lastModified = inFile.lastModified(); @@ -227,11 +231,11 @@ public class GeckoAppShell else return false; } catch (Exception e) { - Log.e("GeckoAppShell", "exception while moving file: ", e); + Log.e(LOG_FILE_NAME, "exception while moving file: ", e); try { outFile.delete(); } catch (SecurityException se) { - Log.w("GeckoAppShell", "error trying to delete file", se); + Log.w(LOG_FILE_NAME, "error trying to delete file", se); } return false; } @@ -244,7 +248,7 @@ public class GeckoAppShell if (from.renameTo(to)) return true; } catch (SecurityException se) { - Log.w("GeckoAppShell", "error trying to rename file", se); + Log.w(LOG_FILE_NAME, "error trying to rename file", se); } File[] files = from.listFiles(); boolean retVal = true; @@ -262,7 +266,7 @@ public class GeckoAppShell } from.delete(); } catch(Exception e) { - Log.e("GeckoAppShell", "error trying to move file", e); + Log.e(LOG_FILE_NAME, "error trying to move file", e); } return retVal; } @@ -310,11 +314,11 @@ public class GeckoAppShell GeckoAppShell.putenv("GRE_HOME=" + GeckoApp.sGREDir.getPath()); Intent i = geckoApp.getIntent(); String env = i.getStringExtra("env0"); - Log.i("GeckoApp", "env0: "+ env); + Log.i(LOG_FILE_NAME, "env0: "+ env); for (int c = 1; env != null; c++) { GeckoAppShell.putenv(env); env = i.getStringExtra("env" + c); - Log.i("GeckoApp", "env"+ c +": "+ env); + Log.i(LOG_FILE_NAME, "env"+ c +": "+ env); } File f = geckoApp.getDir("tmp", Context.MODE_WORLD_READABLE | @@ -346,7 +350,7 @@ public class GeckoAppShell GeckoAppShell.putenv("UPDATES_DIRECTORY=" + updatesDir.getPath()); } catch (Exception e) { - Log.i("GeckoApp", "No download directory has been found: " + e); + Log.i(LOG_FILE_NAME, "No download directory has been found: " + e); } putLocaleEnv(); @@ -1107,7 +1111,7 @@ public class GeckoAppShell // If the network state has changed, notify Gecko if (notifyChanged && (state != sNetworkState || typeCode != sNetworkTypeCode)) { - Log.i("GeckoAppShell", "Network state changed: (" + state + ", " + type + ") "); + Log.i(LOG_FILE_NAME, "Network state changed: (" + state + ", " + type + ") "); sNetworkState = state; sNetworkType = type; sNetworkTypeCode = typeCode; @@ -1191,7 +1195,7 @@ public class GeckoAppShell fos.write(new Integer(pid).toString().getBytes()); fos.close(); } catch(Exception e) { - Log.e("GeckoAppShell", "error putting child in the background", e); + Log.e(LOG_FILE_NAME, "error putting child in the background", e); } } return true; @@ -1212,7 +1216,7 @@ public class GeckoAppShell fos.write(new Integer(pid).toString().getBytes()); fos.close(); } catch(Exception e) { - Log.e("GeckoAppShell", "error putting child in the foreground", e); + Log.e(LOG_FILE_NAME, "error putting child in the foreground", e); } } return true; @@ -1300,7 +1304,7 @@ public class GeckoAppShell in.close(); } catch (Exception e) { - Log.i("GeckoAppShell", "finding procs throws ", e); + Log.i(LOG_FILE_NAME, "finding procs throws ", e); } } @@ -1343,7 +1347,7 @@ public class GeckoAppShell return buf.array(); } catch (Exception e) { - Log.i("GeckoAppShell", "getIconForExtension error: ", e); + Log.i(LOG_FILE_NAME, "getIconForExtension error: ", e); return null; } } diff --git a/embedding/android/GeckoSurfaceView.java b/embedding/android/GeckoSurfaceView.java index 7c940f48ddab..f53d1a84b4fd 100644 --- a/embedding/android/GeckoSurfaceView.java +++ b/embedding/android/GeckoSurfaceView.java @@ -71,6 +71,8 @@ class GeckoSurfaceView extends SurfaceView implements SurfaceHolder.Callback, SensorEventListener, LocationListener { + private static final String LOG_FILE_NAME = "GeckoSurfaceView"; + public GeckoSurfaceView(Context context) { super(context); @@ -107,7 +109,7 @@ class GeckoSurfaceView void drawSplashScreen(SurfaceHolder holder, int width, int height) { Canvas c = holder.lockCanvas(); if (c == null) { - Log.i("GeckoSurfaceView", "canvas is null"); + Log.i(LOG_FILE_NAME, "canvas is null"); return; } Resources res = getResources(); @@ -173,7 +175,7 @@ class GeckoSurfaceView try { if (mInDrawing) { - Log.w("GeckoAppJava", "surfaceChanged while mInDrawing is true!"); + Log.w(LOG_FILE_NAME, "surfaceChanged while mInDrawing is true!"); } boolean invalidSize; @@ -198,7 +200,7 @@ class GeckoSurfaceView mHeight = height; mSurfaceValid = true; - Log.i("GeckoAppJava", "surfaceChanged: fmt: " + format + " dim: " + width + " " + height); + Log.i(LOG_FILE_NAME, "surfaceChanged: fmt: " + format + " dim: " + width + " " + height); DisplayMetrics metrics = new DisplayMetrics(); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); @@ -225,7 +227,7 @@ class GeckoSurfaceView try { syncDrawObject = mSyncDraws.take(); } catch (InterruptedException ie) { - Log.e("GeckoAppJava", "Threw exception while getting sync draw bitmap/buffer: ", ie); + Log.e(LOG_FILE_NAME, "Threw exception while getting sync draw bitmap/buffer: ", ie); } if (syncDrawObject != null) { if (syncDrawObject instanceof Bitmap) @@ -238,7 +240,7 @@ class GeckoSurfaceView } public void surfaceCreated(SurfaceHolder holder) { - Log.i("GeckoAppJava", "surface created"); + Log.i(LOG_FILE_NAME, "surface created"); GeckoEvent e = new GeckoEvent(GeckoEvent.SURFACE_CREATED); GeckoAppShell.sendEventToGecko(e); if (mShowingSplashScreen) @@ -246,7 +248,7 @@ class GeckoSurfaceView } public void surfaceDestroyed(SurfaceHolder holder) { - Log.i("GeckoAppJava", "surface destroyed"); + Log.i(LOG_FILE_NAME, "surface destroyed"); mSurfaceValid = false; mSoftwareBuffer = null; mSoftwareBufferCopy = null; @@ -294,7 +296,7 @@ class GeckoSurfaceView public int beginDrawing() { if (mInDrawing) { - Log.e("GeckoAppJava", "Recursive beginDrawing call!"); + Log.e(LOG_FILE_NAME, "Recursive beginDrawing call!"); return DRAW_ERROR; } @@ -312,7 +314,7 @@ class GeckoSurfaceView mSurfaceLock.lock(); if (!mSurfaceValid) { - Log.e("GeckoAppJava", "Surface not valid"); + Log.e(LOG_FILE_NAME, "Surface not valid"); mSurfaceLock.unlock(); return DRAW_ERROR; } @@ -324,20 +326,20 @@ class GeckoSurfaceView public void endDrawing() { if (!mInDrawing) { - Log.e("GeckoAppJava", "endDrawing without beginDrawing!"); + Log.e(LOG_FILE_NAME, "endDrawing without beginDrawing!"); return; } try { if (!mSurfaceValid) { - Log.e("GeckoAppJava", "endDrawing with false mSurfaceValid"); + Log.e(LOG_FILE_NAME, "endDrawing with false mSurfaceValid"); return; } } finally { mInDrawing = false; if (!mSurfaceLock.isHeldByCurrentThread()) - Log.e("GeckoAppJava", "endDrawing while mSurfaceLock not held by current thread!"); + Log.e(LOG_FILE_NAME, "endDrawing while mSurfaceLock not held by current thread!"); mSurfaceLock.unlock(); } @@ -368,7 +370,7 @@ class GeckoSurfaceView try { mSyncDraws.put(bitmap); } catch (InterruptedException ie) { - Log.e("GeckoAppJava", "Threw exception while getting sync draws queue: ", ie); + Log.e(LOG_FILE_NAME, "Threw exception while getting sync draws queue: ", ie); } return; } @@ -389,7 +391,7 @@ class GeckoSurfaceView try { mSyncDraws.put(buffer); } catch (InterruptedException ie) { - Log.e("GeckoAppJava", "Threw exception while getting sync bitmaps queue: ", ie); + Log.e(LOG_FILE_NAME, "Threw exception while getting sync bitmaps queue: ", ie); } return; } @@ -492,7 +494,7 @@ class GeckoSurfaceView mLastGeoAddress = addresses.get(0); GeckoAppShell.sendEventToGecko(new GeckoEvent(location[0], mLastGeoAddress)); } catch (Exception e) { - Log.w("GeckoSurfaceView", "GeocoderTask "+e); + Log.w(LOG_FILE_NAME, "GeocoderTask "+e); } return null; } diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index fd143147880e..018cfd6c7064 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -887,15 +887,13 @@ nsDocShellTreeOwner::AddChromeListeners() GetDOMEventTarget(mWebBrowser, getter_AddRefs(target)); nsEventListenerManager* elmP = target->GetListenerManager(PR_TRUE); - if (elmP) - { - rv = elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); - NS_ENSURE_SUCCESS(rv, rv); - rv = elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"), - NS_EVENT_FLAG_BUBBLE | - NS_EVENT_FLAG_SYSTEM_EVENT); + if (elmP) { + elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); + elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"), + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); } return rv; diff --git a/gfx/src/nsRenderingContext.h b/gfx/src/nsRenderingContext.h index 301212ca1979..de0d12d33192 100644 --- a/gfx/src/nsRenderingContext.h +++ b/gfx/src/nsRenderingContext.h @@ -70,7 +70,7 @@ public: // These accessors will never return null. gfxContext *ThebesContext() { return mThebes; } nsDeviceContext *DeviceContext() { return mDeviceContext; } - PRUint32 AppUnitsPerDevPixel() { return mP2A; } + PRUint32 AppUnitsPerDevPixel() { return NSToIntRound(mP2A); } // Graphics state diff --git a/js/src/configure.in b/js/src/configure.in index 74dcc1b14cbd..dad130cfa413 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2012,6 +2012,8 @@ case "$target" in # logging code in nsObjCExceptions.h. Currently we only use that in debug # builds. MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling" + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" if test "x$lto_is_enabled" = "xyes"; then echo "Skipping -dead_strip because lto is enabled." @@ -2160,6 +2162,8 @@ ia64*-hpux*) fi # The Maemo builders don't know about this flag MOZ_ARM_VFP_FLAGS="-mfpu=vfp" + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" ;; *-*linux*) @@ -2185,7 +2189,8 @@ ia64*-hpux*) fi MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS" MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS" - MOZ_DEBUG_FLAGS="-g" + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer" fi TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"' @@ -2301,7 +2306,8 @@ ia64*-hpux*) CFLAGS="$CFLAGS -we4553" CXXFLAGS="$CXXFLAGS -we4553" LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib" - MOZ_DEBUG_FLAGS='-Zi' + # Debug builds should always have frame pointers + MOZ_DEBUG_FLAGS='-Zi -Oy-' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' WARNINGS_AS_ERRORS='-WX' # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer. @@ -3494,53 +3500,6 @@ then LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}" fi -dnl ======================================================== -dnl See if mmap sees writes -dnl For cross compiling, just define it as no, which is a safe default -dnl ======================================================== -AC_MSG_CHECKING(whether mmap() sees write()s) - -changequote(,) -mmap_test_prog=' - #include - #include - #include - #include - #include - #include - - char fname[] = "conftest.file"; - char zbuff[1024]; /* Fractional page is probably worst case */ - - int main() { - char *map; - int fd; - int i; - unlink(fname); - fd = open(fname, O_RDWR | O_CREAT, 0660); - if(fd<0) return 1; - unlink(fname); - write(fd, zbuff, sizeof(zbuff)); - lseek(fd, 0, SEEK_SET); - map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0); - if(map==(char*)-1) return 2; - for(i=0; fname[i]; i++) { - int rc = write(fd, &fname[i], 1); - if(map[i]!=fname[i]) return 4; - } - return 0; - } -' -changequote([,]) - -AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes") - -AC_MSG_RESULT("$result") - -if test "$result" = "no"; then - AC_DEFINE(MMAP_MISSES_WRITES) -fi - dnl Checks for library functions. dnl ======================================================== diff --git a/js/src/jit-test/tests/bug666448.js b/js/src/jit-test/tests/basic/bug666448.js similarity index 100% rename from js/src/jit-test/tests/bug666448.js rename to js/src/jit-test/tests/basic/bug666448.js diff --git a/js/src/jit-test/tests/basic/testBug677367.js b/js/src/jit-test/tests/basic/testBug677367.js new file mode 100644 index 000000000000..3dd1d26b52a5 --- /dev/null +++ b/js/src/jit-test/tests/basic/testBug677367.js @@ -0,0 +1,5 @@ +// |jit-test| debug + +function f() {} +trap(f, 0, 'eval("2+2")'); +f(); diff --git a/js/src/jit-test/tests/basic/testErrorInFinalizerCalledWhileUnwinding.js b/js/src/jit-test/tests/basic/testErrorInFinalizerCalledWhileUnwinding.js new file mode 100644 index 000000000000..41b1e3d0ef47 --- /dev/null +++ b/js/src/jit-test/tests/basic/testErrorInFinalizerCalledWhileUnwinding.js @@ -0,0 +1,32 @@ +var finalizerRun = false; +var caught = false; + +function foo(arr) { + finalizerRun = true; + return not_defined; +} + +function gen() { + try { + yield 1; + } finally { + foo(); + } +} + +function test() { + var i_have_locals; + for (i in gen()) { + "this won't work"(); + } +} + +try { + test(); +} catch(e) { + caught = true; + assertEq(''+e, "ReferenceError: not_defined is not defined"); +} + +assertEq(finalizerRun, true); +assertEq(caught, true); diff --git a/js/src/jit-test/tests/basic/testEvalFromTrap.js b/js/src/jit-test/tests/basic/testEvalFromTrap.js new file mode 100644 index 000000000000..ddfdce62058c --- /dev/null +++ b/js/src/jit-test/tests/basic/testEvalFromTrap.js @@ -0,0 +1,4 @@ +// |jit-test| debug +function f() {} +trap(f, 0, 'eval("2+2")'); +f(); diff --git a/js/src/jit-test/tests/basic/testStackIter.js b/js/src/jit-test/tests/basic/testStackIter.js index dc1d018d4ba5..9bd1aa8af3dd 100644 --- a/js/src/jit-test/tests/basic/testStackIter.js +++ b/js/src/jit-test/tests/basic/testStackIter.js @@ -128,6 +128,12 @@ var obj = { valueOf:(function valueOf() { /***********/ +var proxy = Proxy.createFunction({}, function f() { assertStackIs([f, "global-code"]) }); +proxy(); +new proxy(); + +/***********/ + for (var i = 0; i < 10; ++i) { /* No loss for scripts. */ (function f() { diff --git a/js/src/jit-test/tests/debug/Object-deleteProperty-error-01.js b/js/src/jit-test/tests/debug/Object-deleteProperty-error-01.js new file mode 100644 index 000000000000..00647496252b --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-deleteProperty-error-01.js @@ -0,0 +1,16 @@ +// Don't crash when a scripted proxy handler throws Error.prototype. + +var g = newGlobal('new-compartment'); +var dbg = Debugger(g); +dbg.onDebuggerStatement = function (frame) { + try { + frame.arguments[0].deleteProperty("x"); + } catch (exc) { + return; + } + throw new Error("deleteProperty should throw"); +}; + +g.eval("function h(x) { debugger; }"); +g.eval("h(Proxy.create({delete: function () { throw Error.prototype; }}));"); + diff --git a/js/src/jit-test/tests/debug/onDebuggerStatement-04.js b/js/src/jit-test/tests/debug/onDebuggerStatement-04.js new file mode 100644 index 000000000000..f36c35f099d8 --- /dev/null +++ b/js/src/jit-test/tests/debug/onDebuggerStatement-04.js @@ -0,0 +1,10 @@ +var g = newGlobal('new-compartment'); +var dbg = new Debugger(g); +dbg.onDebuggerStatement = function (frame) { + var code = "assertEq(c, 'ok');\n"; + assertEq(frame.evalWithBindings("eval(s)", {s: code, a: 1234}).return, undefined); +}; +g.eval("function first() { return second(); }"); +g.eval("function second() { return eval('third()'); }"); +g.eval("function third() { debugger; }"); +g.evaluate("first();"); diff --git a/js/src/jsapi-tests/testLookup.cpp b/js/src/jsapi-tests/testLookup.cpp index 784ed8b6232a..2d1c4e81a46d 100644 --- a/js/src/jsapi-tests/testLookup.cpp +++ b/js/src/jsapi-tests/testLookup.cpp @@ -26,7 +26,7 @@ BEGIN_TEST(testLookup_bug522590) JSObject *funobj = JSVAL_TO_OBJECT(r); CHECK(funobj->isFunction()); CHECK(!js::IsInternalFunctionObject(funobj)); - CHECK(GET_FUNCTION_PRIVATE(cx, funobj) != (JSFunction *) funobj); + CHECK(funobj->getFunctionPrivate() != (JSFunction *) funobj); return true; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 16b1dfc9e25d..eb17a1bc4006 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -343,7 +343,7 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, const char *format if (!obj) return JS_FALSE; *sp = OBJECT_TO_JSVAL(obj); - *va_arg(ap, JSFunction **) = GET_FUNCTION_PRIVATE(cx, obj); + *va_arg(ap, JSFunction **) = obj->getFunctionPrivate(); break; case 'v': *va_arg(ap, jsval *) = *sp; @@ -2270,10 +2270,10 @@ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, ui JSObject *obj = (JSObject *)thing; Class *clasp = obj->getClass(); if (clasp == &js_FunctionClass) { - JSFunction *fun = GET_FUNCTION_PRIVATE(trc->context, obj); + JSFunction *fun = obj->getFunctionPrivate(); if (!fun) { JS_snprintf(buf, bufsize, ""); - } else if (FUN_OBJECT(fun) != obj) { + } else if (fun != obj) { JS_snprintf(buf, bufsize, "%p", fun); } else { if (fun->atom) @@ -4208,8 +4208,8 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent) return NULL; } - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj); - if (!FUN_FLAT_CLOSURE(fun)) + JSFunction *fun = funobj->getFunctionPrivate(); + if (!fun->isFlatClosure()) return CloneFunctionObject(cx, fun, parent); /* @@ -4254,7 +4254,7 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent) JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun) { - return FUN_OBJECT(fun); + return fun; } JS_PUBLIC_API(JSString *) @@ -4357,7 +4357,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs) * as fun->object lives. */ Value priv = PrivateValue(fs); - if (!js_SetReservedSlot(cx, FUN_OBJECT(fun), 0, priv)) + if (!js_SetReservedSlot(cx, fun, 0, priv)) return JS_FALSE; } @@ -4712,24 +4712,21 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj, funAtom = js_Atomize(cx, name, strlen(name)); if (!funAtom) { fun = NULL; - goto out2; + goto out; } } fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, obj, funAtom); if (!fun) - goto out2; + goto out; { EmptyShape *emptyCallShape = EmptyShape::getEmptyCallShape(cx); - if (!emptyCallShape) { + if (!emptyCallShape) fun = NULL; - goto out2; - } AutoShapeRooter shapeRoot(cx, emptyCallShape); - AutoObjectRooter tvr(cx, FUN_OBJECT(fun)); - MUST_FLOW_THROUGH("out"); + AutoObjectRooter tvr(cx, fun); Bindings bindings(cx, emptyCallShape); AutoBindingsRooter root(cx, bindings); @@ -4737,20 +4734,20 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj, argAtom = js_Atomize(cx, argnames[i], strlen(argnames[i])); if (!argAtom) { fun = NULL; - goto out2; + goto out; } uint16 dummy; if (!bindings.addArgument(cx, argAtom, &dummy)) { fun = NULL; - goto out2; + goto out; } } if (!Compiler::compileFunctionBody(cx, fun, principals, &bindings, chars, length, filename, lineno, version)) { fun = NULL; - goto out2; + goto out; } if (obj && funAtom && @@ -4760,10 +4757,11 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj, } } - out2: + out: LAST_FRAME_CHECKS(cx, fun); return fun; } + JS_PUBLIC_API(JSFunction *) JS_CompileUCFunctionForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *name, @@ -4892,7 +4890,7 @@ JS_ExecuteScript(JSContext *cx, JSObject *obj, JSObject *scriptObj, jsval *rval) CHECK_REQUEST(cx); assertSameCompartment(cx, obj, scriptObj); - JSBool ok = ExternalExecute(cx, scriptObj->getScript(), *obj, Valueify(rval)); + JSBool ok = Execute(cx, scriptObj->getScript(), *obj, Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); return ok; } @@ -4926,7 +4924,7 @@ EvaluateUCScriptForPrincipalsCommon(JSContext *cx, JSObject *obj, } JS_ASSERT(script->getVersion() == compileVersion); - bool ok = ExternalExecute(cx, script, *obj, Valueify(rval)); + bool ok = Execute(cx, script, *obj, Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); js_DestroyScript(cx, script, 5); return ok; @@ -5006,8 +5004,8 @@ JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc, jsval JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment); CHECK_REQUEST(cx); assertSameCompartment(cx, obj, fun, JSValueArray(argv, argc)); - JSBool ok = ExternalInvoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), argc, - Valueify(argv), Valueify(rval)); + JSBool ok = Invoke(cx, ObjectOrNullValue(obj), ObjectValue(*fun), argc, Valueify(argv), + Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); return ok; } @@ -5025,8 +5023,7 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc, JSBool ok = atom && js_GetMethod(cx, obj, ATOM_TO_JSID(atom), JSGET_NO_METHOD_BARRIER, tvr.addr()) && - ExternalInvoke(cx, ObjectOrNullValue(obj), tvr.value(), argc, Valueify(argv), - Valueify(rval)); + Invoke(cx, ObjectOrNullValue(obj), tvr.value(), argc, Valueify(argv), Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); return ok; } @@ -5039,8 +5036,8 @@ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc, jsval CHECK_REQUEST(cx); assertSameCompartment(cx, obj, fval, JSValueArray(argv, argc)); - JSBool ok = ExternalInvoke(cx, ObjectOrNullValue(obj), Valueify(fval), argc, Valueify(argv), - Valueify(rval)); + JSBool ok = Invoke(cx, ObjectOrNullValue(obj), Valueify(fval), argc, Valueify(argv), + Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); return ok; } @@ -5054,7 +5051,7 @@ Call(JSContext *cx, jsval thisv, jsval fval, uintN argc, jsval *argv, jsval *rva CHECK_REQUEST(cx); assertSameCompartment(cx, thisv, fval, JSValueArray(argv, argc)); - ok = ExternalInvoke(cx, Valueify(thisv), Valueify(fval), argc, Valueify(argv), Valueify(rval)); + ok = Invoke(cx, Valueify(thisv), Valueify(fval), argc, Valueify(argv), Valueify(rval)); LAST_FRAME_CHECKS(cx, ok); return ok; } @@ -5070,7 +5067,7 @@ JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv) // This is not a simple variation of JS_CallFunctionValue because JSOP_NEW // is not a simple variation of JSOP_CALL. We have to determine what class // of object to create, create it, and clamp the return value to an object, - // among other details. js_InvokeConstructor does the hard work. + // among other details. InvokeConstructor does the hard work. InvokeArgsGuard args; if (!cx->stack.pushInvokeArgs(cx, argc, &args)) return NULL; diff --git a/js/src/jsbuiltins.cpp b/js/src/jsbuiltins.cpp index fd83b28ecd56..ae0cbe443ce4 100644 --- a/js/src/jsbuiltins.cpp +++ b/js/src/jsbuiltins.cpp @@ -310,7 +310,7 @@ js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* pa JS_ASSERT(JS_ON_TRACE(cx)); JSFunction *fun = (JSFunction*) funobj; - JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun); + JS_ASSERT(funobj->getFunctionPrivate() == fun); JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2); if (!closure) diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index 39c31997cb2e..ee7369ea95d3 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -1083,7 +1083,7 @@ js_ReportMissingArg(JSContext *cx, const Value &v, uintN arg) JS_snprintf(argbuf, sizeof argbuf, "%u", arg); bytes = NULL; if (IsFunctionObject(v)) { - atom = GET_FUNCTION_PRIVATE(cx, &v.toObject())->atom; + atom = v.toObject().getFunctionPrivate()->atom; bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, atom); if (!bytes) diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 674b73f755b9..9e8746f87d10 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -349,7 +349,7 @@ CallSetter(JSContext *cx, JSObject *obj, jsid id, js::StrictPropertyOp op, uintN uintN shortid, JSBool strict, js::Value *vp) { if (attrs & JSPROP_SETTER) - return ExternalGetOrSet(cx, obj, id, CastAsObjectJsval(op), JSACC_WRITE, 1, vp, vp); + return InvokeGetterOrSetter(cx, obj, CastAsObjectJsval(op), 1, vp, vp); if (attrs & JSPROP_GETTER) return js_ReportGetterOnlyAssignment(cx); diff --git a/js/src/jsdbgapi.cpp b/js/src/jsdbgapi.cpp index d59b21b0031e..53cadd94093e 100644 --- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -548,7 +548,7 @@ JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark) JS_PUBLIC_API(JSScript *) JS_GetFunctionScript(JSContext *cx, JSFunction *fun) { - return FUN_SCRIPT(fun); + return fun->maybeScript(); } JS_PUBLIC_API(JSNative) @@ -1095,8 +1095,8 @@ JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun) size_t nbytes; nbytes = sizeof *fun; - nbytes += JS_GetObjectTotalSize(cx, FUN_OBJECT(fun)); - if (FUN_INTERPRETED(fun)) + nbytes += JS_GetObjectTotalSize(cx, fun); + if (fun->isInterpreted()) nbytes += JS_GetScriptTotalSize(cx, fun->script()); if (fun->atom) nbytes += GetAtomTotalSize(cx, fun->atom); diff --git a/js/src/jsemit.cpp b/js/src/jsemit.cpp index 8217d832a780..f1c10414c163 100644 --- a/js/src/jsemit.cpp +++ b/js/src/jsemit.cpp @@ -4815,7 +4815,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) #endif fun = pn->pn_funbox->function(); - JS_ASSERT(FUN_INTERPRETED(fun)); + JS_ASSERT(fun->isInterpreted()); if (fun->script()) { /* * This second pass is needed to emit JSOP_NOP with a source note @@ -4830,7 +4830,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) } JS_ASSERT_IF(pn->pn_funbox->tcflags & TCF_FUN_HEAVYWEIGHT, - FUN_KIND(fun) == JSFUN_INTERPRETED); + fun->kind() == JSFUN_INTERPRETED); /* Generate code for the function's body. */ void *cg2mark = JS_ARENA_MARK(cg->codePool); @@ -4913,7 +4913,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn) return false; if (pn->pn_cookie.isFree()) { CG_SWITCH_TO_PROLOG(cg); - op = FUN_FLAT_CLOSURE(fun) ? JSOP_DEFFUN_FC : JSOP_DEFFUN; + op = fun->isFlatClosure() ? JSOP_DEFFUN_FC : JSOP_DEFFUN; EMIT_INDEX_OP(op, index); /* Make blockChain determination quicker. */ diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index ff528302f294..9ee591518c27 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -528,24 +528,25 @@ js_ErrorFromException(JSContext *cx, jsval exn) } static JSString * -ValueToShortSource(JSContext *cx, jsval v) +ValueToShortSource(JSContext *cx, const Value &v) { JSString *str; /* Avoid toSource bloat and fallibility for object types. */ - if (JSVAL_IS_PRIMITIVE(v)) - return js_ValueToSource(cx, Valueify(v)); + if (!v.isObject()) + return js_ValueToSource(cx, v); - AutoCompartment ac(cx, JSVAL_TO_OBJECT(v)); + JSObject *obj = &v.toObject(); + AutoCompartment ac(cx, obj); if (!ac.enter()) return NULL; - if (VALUE_IS_FUNCTION(cx, v)) { + if (obj->isFunction()) { /* * XXX Avoid function decompilation bloat for now. */ - str = JS_GetFunctionId(JS_ValueToFunction(cx, v)); - if (!str && !(str = js_ValueToSource(cx, Valueify(v)))) { + str = JS_GetFunctionId(obj->getFunctionPrivate()); + if (!str && !(str = js_ValueToSource(cx, v))) { /* * Continue to soldier on if the function couldn't be * converted into a string. @@ -559,8 +560,7 @@ ValueToShortSource(JSContext *cx, jsval v) * memory, for too many classes (see Mozilla bug 166743). */ char buf[100]; - JS_snprintf(buf, sizeof buf, "[object %s]", - JSVAL_TO_OBJECT(v)->getClass()->name); + JS_snprintf(buf, sizeof buf, "[object %s]", obj->getClass()->name); str = JS_NewStringCopyZ(cx, buf); } @@ -638,7 +638,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv) for (i = 0; i != elem->argc; i++, values++) { if (i > 0) APPEND_CHAR_TO_STACK(','); - str = ValueToShortSource(cx, *values); + str = ValueToShortSource(cx, Valueify(*values)); if (!str) goto bad; APPEND_STRING_TO_STACK(str); diff --git a/js/src/jsexn.h b/js/src/jsexn.h index a68e591c851e..3966331e3128 100644 --- a/js/src/jsexn.h +++ b/js/src/jsexn.h @@ -102,7 +102,9 @@ js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale, * Make a copy of errobj parented to scope. * * cx must be in the same compartment as scope. errobj may be in a different - * compartment, but it must be an Error object (not a wrapper of one). + * compartment, but it must be an Error object (not a wrapper of one) and it + * must not be one of the prototype objects created by js_InitExceptionClasses + * (errobj->getPrivate() must not be NULL). */ extern JSObject * js_CopyErrorObject(JSContext *cx, JSObject *errobj, JSObject *scope); diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 7c1476cca1a5..704a8d7af6aa 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -1251,8 +1251,9 @@ StackFrame::getValidCalleeObject(JSContext *cx, Value *vp) JSObject *clone; if (IsFunctionObject(v, &clone) && - GET_FUNCTION_PRIVATE(cx, clone) == fun && - clone->hasMethodObj(*thisp)) { + clone->getFunctionPrivate() == fun && + clone->hasMethodObj(*thisp)) + { JS_ASSERT(clone != &funobj); *vp = v; overwriteCallee(*clone); @@ -1544,8 +1545,8 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) cx = xdr->cx; if (xdr->mode == JSXDR_ENCODE) { - fun = GET_FUNCTION_PRIVATE(cx, *objp); - if (!FUN_INTERPRETED(fun)) { + fun = (*objp)->getFunctionPrivate(); + if (!fun->isInterpreted()) { JSAutoByteString funNameBytes; if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_SCRIPTED_FUNCTION, @@ -1566,11 +1567,11 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, NULL, NULL); if (!fun) return false; - FUN_OBJECT(fun)->clearParent(); - FUN_OBJECT(fun)->clearProto(); + fun->clearParent(); + fun->clearProto(); } - AutoObjectRooter tvr(cx, FUN_OBJECT(fun)); + AutoObjectRooter tvr(cx, fun); if (!JS_XDRUint32(xdr, &firstword)) return false; @@ -1597,7 +1598,7 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) fun->u.i.script = script; if (xdr->mode == JSXDR_DECODE) { - *objp = FUN_OBJECT(fun); + *objp = fun; fun->u.i.script->setOwnerObject(fun); #ifdef CHECK_SCRIPT_OWNER fun->script()->owner = NULL; @@ -1736,7 +1737,7 @@ fun_toStringHelper(JSContext *cx, JSObject *obj, uintN indent) return NULL; } - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj); + JSFunction *fun = obj->getFunctionPrivate(); if (!fun) return NULL; @@ -2029,7 +2030,7 @@ fun_isGenerator(JSContext *cx, uintN argc, Value *vp) return true; } - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj); + JSFunction *fun = funobj->getFunctionPrivate(); bool result = false; if (fun->isInterpreted()) { @@ -2439,7 +2440,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs, fun->atom = atom; /* Set private to self to indicate non-cloned fully initialized function. */ - FUN_OBJECT(fun)->setPrivate(fun); + fun->setPrivate(fun); return fun; } @@ -2653,7 +2654,7 @@ js_ValueToFunction(JSContext *cx, const Value *vp, uintN flags) js_ReportIsNotFunction(cx, vp, flags); return NULL; } - return GET_FUNCTION_PRIVATE(cx, funobj); + return funobj->getFunctionPrivate(); } JSObject * diff --git a/js/src/jsfun.h b/js/src/jsfun.h index 47f84f4a9783..0957b688a1e1 100644 --- a/js/src/jsfun.h +++ b/js/src/jsfun.h @@ -60,14 +60,14 @@ * 10 interpreted, flat closure * 11 interpreted, null closure * - * FUN_FLAT_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset != 0. - * FUN_NULL_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset == 0. + * isFlatClosure() implies isInterpreted() and u.i.script->upvarsOffset != 0. + * isNullClosure() implies isInterpreted() and u.i.script->upvarsOffset == 0. * - * FUN_INTERPRETED but not FUN_FLAT_CLOSURE and u.i.script->upvarsOffset != 0 + * isInterpreted() but not isFlatClosure() and u.i.script->upvarsOffset != 0 * is an Algol-like function expression or nested function, i.e., a function * that never escapes upward or downward (heapward), and is only ever called. * - * Finally, FUN_INTERPRETED and u.i.script->upvarsOffset == 0 could be either + * Finally, isInterpreted() and u.i.script->upvarsOffset == 0 could be either * a non-closure (a global function definition, or any function that uses no * outer names), or a closure of an escaping function that uses outer names * whose values can't be snapshot (because the outer names could be reassigned @@ -80,8 +80,8 @@ * NB: JSFUN_EXPR_CLOSURE reuses JSFUN_STUB_GSOPS, which is an API request flag * bit only, never stored in fun->flags. * - * If we need more bits in the future, all flags for FUN_INTERPRETED functions - * can move to u.i.script->flags. For now we use function flag bits to minimize + * If we need more bits in the future, all flags for interpreted functions can + * move to u.i.script->flags. For now we use function flag bits to minimize * pointer-chasing. */ #define JSFUN_JOINABLE 0x0001 /* function is null closure that does not @@ -101,19 +101,6 @@ #define JSFUN_KINDMASK 0xc000 /* encode interp vs. native and closure optimization level -- see above */ -#define FUN_OBJECT(fun) (static_cast(fun)) -#define FUN_KIND(fun) ((fun)->flags & JSFUN_KINDMASK) -#define FUN_SET_KIND(fun,k) ((fun)->flags = ((fun)->flags & ~JSFUN_KINDMASK) | (k)) -#define FUN_INTERPRETED(fun) (FUN_KIND(fun) >= JSFUN_INTERPRETED) -#define FUN_FLAT_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_FLAT_CLOSURE) -#define FUN_NULL_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_NULL_CLOSURE) -#define FUN_SCRIPT(fun) (FUN_INTERPRETED(fun) ? (fun)->script() : NULL) -#define FUN_CLASP(fun) (JS_ASSERT(!FUN_INTERPRETED(fun)), \ - fun->u.n.clasp) -#define FUN_TRCINFO(fun) (JS_ASSERT(!FUN_INTERPRETED(fun)), \ - JS_ASSERT((fun)->flags & JSFUN_TRCINFO), \ - fun->u.n.trcinfo) - struct JSFunction : public JSObject_Slots2 { /* Functions always have two fixed slots (FUN_CLASS_RESERVED_SLOTS). */ @@ -145,16 +132,25 @@ struct JSFunction : public JSObject_Slots2 } u; JSAtom *atom; /* name for diagnostics and decompiling */ - bool optimizedClosure() const { return FUN_KIND(this) > JSFUN_INTERPRETED; } - bool isInterpreted() const { return FUN_INTERPRETED(this); } - bool isNative() const { return !FUN_INTERPRETED(this); } + bool optimizedClosure() const { return kind() > JSFUN_INTERPRETED; } + bool isInterpreted() const { return kind() >= JSFUN_INTERPRETED; } + bool isNative() const { return !isInterpreted(); } bool isConstructor() const { return flags & JSFUN_CONSTRUCTOR; } bool isHeavyweight() const { return JSFUN_HEAVYWEIGHT_TEST(flags); } - bool isFlatClosure() const { return FUN_KIND(this) == JSFUN_FLAT_CLOSURE; } + bool isNullClosure() const { return kind() == JSFUN_NULL_CLOSURE; } + bool isFlatClosure() const { return kind() == JSFUN_FLAT_CLOSURE; } bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; } bool isInterpretedConstructor() const { return isInterpreted() && !isFunctionPrototype(); } + + uint16 kind() const { return flags & JSFUN_KINDMASK; } + void setKind(uint16 k) { + JS_ASSERT(!(k & ~JSFUN_KINDMASK)); + flags = (flags & ~JSFUN_KINDMASK) | k; + } + /* Returns the strictness of this function, which must be interpreted. */ inline bool inStrictMode() const; + void setArgCount(uint16 nargs) { JS_ASSERT(this->nargs == 0); this->nargs = nargs; @@ -210,6 +206,10 @@ struct JSFunction : public JSObject_Slots2 return u.i.script; } + JSScript * maybeScript() const { + return isInterpreted() ? script() : NULL; + } + js::Native native() const { JS_ASSERT(isNative()); return u.n.native; @@ -227,6 +227,23 @@ struct JSFunction : public JSObject_Slots2 /* Number of extra fixed function object slots. */ static const uint32 CLASS_RESERVED_SLOTS = JSObject::FUN_CLASS_RESERVED_SLOTS; + + + js::Class *getConstructorClass() const { + JS_ASSERT(isNative()); + return u.n.clasp; + } + + void setConstructorClass(js::Class *clasp) { + JS_ASSERT(isNative()); + u.n.clasp = clasp; + } + + JSNativeTraceInfo *getTraceInfo() const { + JS_ASSERT(isNative()); + JS_ASSERT(flags & JSFUN_TRCINFO); + return u.n.trcinfo; + } }; /* @@ -269,12 +286,6 @@ JSObject::getFunctionPrivate() const namespace js { -/* - * NB: jsapi.h and jsobj.h must be included before any call to this macro. - */ -#define VALUE_IS_FUNCTION(cx, v) \ - (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction()) - static JS_ALWAYS_INLINE bool IsFunctionObject(const js::Value &v) { @@ -354,14 +365,6 @@ SameTraceType(const Value &lhs, const Value &rhs) lhs.toObject().isFunction() == rhs.toObject().isFunction()); } -/* - * Macro to access the private slot of the function object after the slot is - * initialized. - */ -#define GET_FUNCTION_PRIVATE(cx, funobj) \ - (JS_ASSERT((funobj)->isFunction()), \ - (JSFunction *) (funobj)->getPrivate()) - /* * Return true if this is a compiler-created internal function accessed by * its own object. Such a function object must not be accessible to script diff --git a/js/src/jsfuninlines.h b/js/src/jsfuninlines.h index 05d3a4cae830..9abf7cbacf9b 100644 --- a/js/src/jsfuninlines.h +++ b/js/src/jsfuninlines.h @@ -52,7 +52,7 @@ JSFunction::inStrictMode() const inline void JSFunction::setJoinable() { - JS_ASSERT(FUN_INTERPRETED(this)); + JS_ASSERT(isInterpreted()); setSlot(METHOD_ATOM_SLOT, js::NullValue()); flags |= JSFUN_JOINABLE; } diff --git a/js/src/jshashtable.h b/js/src/jshashtable.h index 437067f15908..fc8fc44190fc 100644 --- a/js/src/jshashtable.h +++ b/js/src/jshashtable.h @@ -298,7 +298,8 @@ class HashTable : private AllocPolicy static const unsigned sMinSizeLog2 = 4; static const unsigned sMinSize = 1 << sMinSizeLog2; - static const unsigned sSizeLimit = JS_BIT(24); + static const unsigned sMaxInit = JS_BIT(23); + static const unsigned sMaxCapacity = JS_BIT(24); static const unsigned sHashBits = tl::BitSize::result; static const uint8 sMinAlphaFrac = 64; /* (0x100 * .25) taken from jsdhash.h */ static const uint8 sMaxAlphaFrac = 192; /* (0x100 * .75) taken from jsdhash.h */ @@ -308,6 +309,14 @@ class HashTable : private AllocPolicy static const HashNumber sRemovedKey = Entry::sRemovedKey; static const HashNumber sCollisionBit = Entry::sCollisionBit; + static void staticAsserts() + { + /* Rely on compiler "constant overflow warnings". */ + JS_STATIC_ASSERT(((sMaxInit * sInvMaxAlpha) >> 7) < sMaxCapacity); + JS_STATIC_ASSERT((sMaxCapacity * sInvMaxAlpha) <= UINT32_MAX); + JS_STATIC_ASSERT((sMaxCapacity * sizeof(Entry)) <= UINT32_MAX); + } + static bool isLiveHash(HashNumber hash) { return Entry::isLiveHash(hash); @@ -365,7 +374,10 @@ class HashTable : private AllocPolicy * Correct for sMaxAlphaFrac such that the table will not resize * when adding 'length' entries. */ - JS_ASSERT(length < (uint32(1) << 23)); + if (length > sMaxInit) { + this->reportAllocOverflow(); + return false; + } uint32 capacity = (length * sInvMaxAlpha) >> 7; if (capacity < sMinSize) @@ -379,10 +391,7 @@ class HashTable : private AllocPolicy } capacity = roundUp; - if (capacity >= sSizeLimit) { - this->reportAllocOverflow(); - return false; - } + JS_ASSERT(capacity <= sMaxCapacity); table = createTable(*this, capacity); if (!table) @@ -536,7 +545,7 @@ class HashTable : private AllocPolicy uint32 oldCap = tableCapacity; uint32 newLog2 = sHashBits - hashShift + deltaLog2; uint32 newCapacity = JS_BIT(newLog2); - if (newCapacity >= sSizeLimit) { + if (newCapacity > sMaxCapacity) { this->reportAllocOverflow(); return false; } diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 5f138007fc5f..86b7a0f58b0a 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -512,7 +512,7 @@ Class js_NoSuchMethodClass = { * the base object, we search for the __noSuchMethod__ method in the base. * If it exists, we store the method and the property's id into an object of * NoSuchMethod class and store this object into the callee's stack slot. - * Later, js_Invoke will recognise such an object and transfer control to + * Later, Invoke will recognise such an object and transfer control to * NoSuchMethod that invokes the method like: * * this.__noSuchMethod__(id, args) @@ -621,7 +621,7 @@ RunScript(JSContext *cx, JSScript *script, StackFrame *fp) * when done. Then push the return value. */ JS_REQUIRES_STACK bool -Invoke(JSContext *cx, const CallArgs &argsRef, MaybeConstruct construct) +InvokeKernel(JSContext *cx, const CallArgs &argsRef, MaybeConstruct construct) { /* N.B. Must be kept in sync with InvokeSessionGuard::start/invoke */ @@ -781,8 +781,8 @@ InvokeSessionGuard::start(JSContext *cx, const Value &calleev, const Value &this } bool -ExternalInvoke(JSContext *cx, const Value &thisv, const Value &fval, - uintN argc, Value *argv, Value *rval) +Invoke(JSContext *cx, const Value &thisv, const Value &fval, uintN argc, Value *argv, + Value *rval) { LeaveTrace(cx); @@ -814,8 +814,7 @@ ExternalInvoke(JSContext *cx, const Value &thisv, const Value &fval, } bool -ExternalInvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, - Value *rval) +InvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, Value *rval) { LeaveTrace(cx); @@ -835,18 +834,18 @@ ExternalInvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *a } bool -ExternalGetOrSet(JSContext *cx, JSObject *obj, jsid id, const Value &fval, - JSAccessMode mode, uintN argc, Value *argv, Value *rval) +InvokeGetterOrSetter(JSContext *cx, JSObject *obj, const Value &fval, uintN argc, Value *argv, + Value *rval) { LeaveTrace(cx); /* - * ExternalInvoke could result in another try to get or set the same id - * again, see bug 355497. + * Invoke could result in another try to get or set the same id again, see + * bug 355497. */ JS_CHECK_RECURSION(cx, return false); - return ExternalInvoke(cx, ObjectValue(*obj), fval, argc, argv, rval); + return Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval); } #if JS_HAS_SHARP_VARS @@ -878,8 +877,8 @@ InitSharpSlots(JSContext *cx, StackFrame *fp) #endif bool -Execute(JSContext *cx, JSScript *script, JSObject &scopeChain, const Value &thisv, - ExecuteType type, StackFrame *evalInFrame, Value *result) +ExecuteKernel(JSContext *cx, JSScript *script, JSObject &scopeChain, const Value &thisv, + ExecuteType type, StackFrame *evalInFrame, Value *result) { JS_ASSERT_IF(evalInFrame, type == EXECUTE_DEBUG); @@ -919,7 +918,7 @@ Execute(JSContext *cx, JSScript *script, JSObject &scopeChain, const Value &this } bool -ExternalExecute(JSContext *cx, JSScript *script, JSObject &scopeChainArg, Value *rval) +Execute(JSContext *cx, JSScript *script, JSObject &scopeChainArg, Value *rval) { /* The scope chain could be anything, so innerize just in case. */ JSObject *scopeChain = &scopeChainArg; @@ -944,8 +943,8 @@ ExternalExecute(JSContext *cx, JSScript *script, JSObject &scopeChainArg, Value return false; Value thisv = ObjectValue(*thisObj); - return Execute(cx, script, *scopeChain, thisv, EXECUTE_GLOBAL, - NULL /* evalInFrame */, rval); + return ExecuteKernel(cx, script, *scopeChain, thisv, EXECUTE_GLOBAL, + NULL /* evalInFrame */, rval); } bool @@ -1190,7 +1189,7 @@ TypeOfValue(JSContext *cx, const Value &vref) } JS_REQUIRES_STACK bool -InvokeConstructor(JSContext *cx, const CallArgs &argsRef) +InvokeConstructorKernel(JSContext *cx, const CallArgs &argsRef) { JS_ASSERT(!js_FunctionClass.construct); CallArgs args = argsRef; @@ -1212,7 +1211,7 @@ InvokeConstructor(JSContext *cx, const CallArgs &argsRef) if (!fun->isInterpretedConstructor()) goto error; - if (!Invoke(cx, args, CONSTRUCT)) + if (!InvokeKernel(cx, args, CONSTRUCT)) return false; JS_ASSERT(args.rval().isObject()); @@ -3986,7 +3985,7 @@ BEGIN_CASE(JSOP_EVAL) if (!DirectEval(cx, args)) goto error; } else { - if (!Invoke(cx, args)) + if (!InvokeKernel(cx, args)) goto error; } CHECK_INTERRUPT_HANDLER(); @@ -4010,10 +4009,10 @@ BEGIN_CASE(JSOP_FUNAPPLY) /* Don't bother trying to fast-path calls to scripted non-constructors. */ if (!IsFunctionObject(args.calleev(), &callee, &fun) || !fun->isInterpretedConstructor()) { if (construct) { - if (!InvokeConstructor(cx, args)) + if (!InvokeConstructorKernel(cx, args)) goto error; } else { - if (!Invoke(cx, args)) + if (!InvokeKernel(cx, args)) goto error; } regs.sp = args.spAfterCall(); @@ -4590,10 +4589,10 @@ BEGIN_CASE(JSOP_DEFFUN) */ JSFunction *fun; LOAD_FUNCTION(0); - JSObject *obj = FUN_OBJECT(fun); + JSObject *obj = fun; JSObject *obj2; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { /* * Even a null closure needs a parent for principals finding. * FIXME: bug 476950, although debugger users may also demand some kind @@ -4730,10 +4729,10 @@ BEGIN_CASE(JSOP_DEFLOCALFUN) JSFunction *fun; LOAD_FUNCTION(SLOTNO_LEN); JS_ASSERT(fun->isInterpreted()); - JS_ASSERT(!FUN_FLAT_CLOSURE(fun)); - JSObject *obj = FUN_OBJECT(fun); + JS_ASSERT(!fun->isFlatClosure()); + JSObject *obj = fun; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { obj = CloneFunctionObject(cx, fun, ®s.fp()->scopeChain()); if (!obj) goto error; @@ -4782,12 +4781,12 @@ BEGIN_CASE(JSOP_LAMBDA) /* Load the specified function object literal. */ JSFunction *fun; LOAD_FUNCTION(0); - JSObject *obj = FUN_OBJECT(fun); + JSObject *obj = fun; /* do-while(0) so we can break instead of using a goto. */ do { JSObject *parent; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { parent = ®s.fp()->scopeChain(); if (obj->getParent() == parent) { @@ -4845,7 +4844,7 @@ BEGIN_CASE(JSOP_LAMBDA) JSObject *callee; if (IsFunctionObject(cref, &callee)) { - JSFunction *calleeFun = GET_FUNCTION_PRIVATE(cx, callee); + JSFunction *calleeFun = callee->getFunctionPrivate(); if (Native native = calleeFun->maybeNative()) { if ((iargc == 1 && native == array_sort) || (iargc == 2 && native == str_replace)) { @@ -6092,7 +6091,7 @@ END_CASE(JSOP_ARRAYPUSH) /* * At this point we are inevitably leaving an interpreted function or a * top-level script, and returning to one of: - * (a) an "out of line" call made through js_Invoke; + * (a) an "out of line" call made through Invoke; * (b) a js_Execute activation; * (c) a generator (SendToGenerator, jsiter.c). * diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index 2ae760c65247..82e7f05ff557 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -145,32 +145,43 @@ inline bool ComputeThis(JSContext *cx, StackFrame *fp); /* - * The js::InvokeArgumentsGuard passed to js_Invoke must come from an - * immediately-enclosing successful call to js::StackSpace::pushInvokeArgs, - * i.e., there must have been no un-popped pushes to cx->stack. Furthermore, - * |args.getvp()[0]| should be the callee, |args.getvp()[1]| should be |this|, - * and the range [args.getvp() + 2, args.getvp() + 2 + args.getArgc()) should - * be initialized actual arguments. + * InvokeKernel assumes that the given args have been pushed on the top of the + * VM stack. Additionally, if 'args' is contained in a CallArgsList, that they + * have already been marked 'active'. */ extern bool -Invoke(JSContext *cx, const CallArgs &args, MaybeConstruct construct = NO_CONSTRUCT); +InvokeKernel(JSContext *cx, const CallArgs &args, MaybeConstruct construct = NO_CONSTRUCT); /* - * For calls to natives, the InvokeArgsGuard object provides a record of the - * call for the debugger's callstack. For this to work, the InvokeArgsGuard - * record needs to know when the call is actually active (because the - * InvokeArgsGuard can be pushed long before and popped long after the actual - * call, during which time many stack-observing things can happen). + * Invoke assumes that 'args' has been pushed (via ContextStack::pushInvokeArgs) + * and is currently at the top of the VM stack. */ inline bool Invoke(JSContext *cx, InvokeArgsGuard &args, MaybeConstruct construct = NO_CONSTRUCT) { args.setActive(); - bool ok = Invoke(cx, ImplicitCast(args), construct); + bool ok = InvokeKernel(cx, args, construct); args.setInactive(); return ok; } +/* + * This Invoke overload places the least requirements on the caller: it may be + * called at any time and it takes care of copying the given callee, this, and + * arguments onto the stack. + */ +extern bool +Invoke(JSContext *cx, const Value &thisv, const Value &fval, uintN argc, Value *argv, + Value *rval); + +/* + * This helper takes care of the infinite-recursion check necessary for + * getter/setter calls. + */ +extern bool +InvokeGetterOrSetter(JSContext *cx, JSObject *obj, const Value &fval, uintN argc, Value *argv, + Value *rval); + /* * Natives like sort/forEach/replace call Invoke repeatedly with the same * callee, this, and number of arguments. To optimize this, such natives can @@ -198,40 +209,34 @@ Invoke(JSContext *cx, InvokeArgsGuard &args, MaybeConstruct construct = NO_CONST class InvokeSessionGuard; /* - * "External" calls may come from C or C++ code using a JSContext on which no - * JS is running (!cx->fp), so they may need to push a dummy StackFrame. + * InvokeConstructor* implement a function call from a constructor context + * (e.g. 'new') handling the the creation of the new 'this' object. */ +extern JS_REQUIRES_STACK bool +InvokeConstructorKernel(JSContext *cx, const CallArgs &args); -extern bool -ExternalInvoke(JSContext *cx, const Value &thisv, const Value &fval, - uintN argc, Value *argv, Value *rval); +/* See the InvokeArgsGuard overload of Invoke. */ +inline bool +InvokeConstructor(JSContext *cx, InvokeArgsGuard &args) +{ + args.setActive(); + bool ok = InvokeConstructorKernel(cx, ImplicitCast(args)); + args.setInactive(); + return ok; +} +/* See the fval overload of Invoke. */ extern bool -ExternalGetOrSet(JSContext *cx, JSObject *obj, jsid id, const Value &fval, - JSAccessMode mode, uintN argc, Value *argv, Value *rval); +InvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, Value *rval); /* - * These two functions invoke a function called from a constructor context - * (e.g. 'new'). InvokeConstructor handles the general case where a new object - * needs to be created for/by the constructor. ConstructWithGivenThis directly - * calls the constructor with the given 'this', hence the caller must - * understand the semantics of the constructor call. + * InvokeConstructorWithGivenThis directly calls the constructor with the given + * 'this'; the caller must choose the semantically correct 'this'. */ - -extern JS_REQUIRES_STACK bool -InvokeConstructor(JSContext *cx, const CallArgs &args); - extern JS_REQUIRES_STACK bool InvokeConstructorWithGivenThis(JSContext *cx, JSObject *thisobj, const Value &fval, uintN argc, Value *argv, Value *rval); -extern bool -ExternalInvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, - Value *rval); - -extern bool -ExternalExecute(JSContext *cx, JSScript *script, JSObject &scopeChain, Value *rval); - /* * Executes a script with the given scopeChain/this. The 'type' indicates * whether this is eval code or global code. To support debugging, the @@ -239,8 +244,12 @@ ExternalExecute(JSContext *cx, JSScript *script, JSObject &scopeChain, Value *rv * stack to simulate executing an eval in that frame. */ extern bool -Execute(JSContext *cx, JSScript *script, JSObject &scopeChain, const Value &thisv, - ExecuteType type, StackFrame *evalInFrame, Value *result); +ExecuteKernel(JSContext *cx, JSScript *script, JSObject &scopeChain, const Value &thisv, + ExecuteType type, StackFrame *evalInFrame, Value *result); + +/* Execute a script with the given scopeChain as global code. */ +extern bool +Execute(JSContext *cx, JSScript *script, JSObject &scopeChain, Value *rval); /* Flags to toggle js::Interpret() execution. */ enum InterpMode diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 08321b179fba..ddaef655e54d 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -362,7 +362,7 @@ GetCustomIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp) /* Otherwise call it and return that object. */ LeaveTrace(cx); Value arg = BooleanValue((flags & JSITER_FOREACH) == 0); - if (!ExternalInvoke(cx, ObjectValue(*obj), *vp, 1, &arg, vp)) + if (!Invoke(cx, ObjectValue(*obj), *vp, 1, &arg, vp)) return false; if (vp->isPrimitive()) { /* @@ -954,7 +954,7 @@ js_IteratorMore(JSContext *cx, JSObject *iterobj, Value *rval) jsid id = ATOM_TO_JSID(cx->runtime->atomState.nextAtom); if (!js_GetMethod(cx, iterobj, id, JSGET_METHOD_BARRIER, rval)) return false; - if (!ExternalInvoke(cx, ObjectValue(*iterobj), *rval, 0, NULL, rval)) { + if (!Invoke(cx, ObjectValue(*iterobj), *rval, 0, NULL, rval)) { /* Check for StopIteration. */ if (!cx->isExceptionPending() || !js_ValueIsStopIteration(cx->getPendingException())) return false; diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 50926dc83ae3..96e33176e45f 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1191,7 +1191,6 @@ EvalKernel(JSContext *cx, const CallArgs &call, EvalType evalType, StackFrame *c #ifdef DEBUG jsbytecode *callerPC = caller->pcQuadratic(cx); - JS_ASSERT_IF(caller->isFunctionFrame(), caller->fun()->isHeavyweight()); JS_ASSERT(callerPC && js_GetOpcode(cx, caller->script(), callerPC) == JSOP_EVAL); #endif } else { @@ -1275,8 +1274,8 @@ EvalKernel(JSContext *cx, const CallArgs &call, EvalType evalType, StackFrame *c esg.setNewScript(compiled); } - return Execute(cx, esg.script(), scopeobj, thisv, ExecuteType(evalType), - NULL /* evalInFrame */, &call.rval()); + return ExecuteKernel(cx, esg.script(), scopeobj, thisv, ExecuteType(evalType), + NULL /* evalInFrame */, &call.rval()); } /* @@ -1405,8 +1404,8 @@ obj_watch_handler(JSContext *cx, JSObject *obj, jsid id, jsval old, return true; Value argv[] = { IdToValue(id), Valueify(old), Valueify(*nvp) }; - return ExternalInvoke(cx, ObjectValue(*obj), ObjectOrNullValue(callable), - JS_ARRAY_LENGTH(argv), argv, Valueify(nvp)); + return Invoke(cx, ObjectValue(*obj), ObjectOrNullValue(callable), JS_ARRAY_LENGTH(argv), argv, + Valueify(nvp)); } static JSBool @@ -3919,7 +3918,7 @@ DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAt js_NewFunction(cx, NULL, constructor, nargs, JSFUN_CONSTRUCTOR, obj, atom); if (!fun) goto bad; - FUN_CLASP(fun) = clasp; + fun->setConstructorClass(clasp); AutoValueRooter tvr2(cx, ObjectValue(*fun)); if (!DefineStandardSlot(cx, obj, key, atom, tvr2.value(), 0, named)) @@ -3931,7 +3930,7 @@ DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAt * different object, as is done for operator new -- and as at least * XML support requires. */ - ctor = FUN_OBJECT(fun); + ctor = fun; if (clasp->flags & JSCLASS_CONSTRUCT_PROTOTYPE) { Value rval; if (!InvokeConstructorWithGivenThis(cx, proto, ObjectOrNullValue(ctor), @@ -4709,7 +4708,7 @@ DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value, JS_ASSERT(!getter && !setter); JSObject *funobj = &value.toObject(); - if (FUN_OBJECT(GET_FUNCTION_PRIVATE(cx, funobj)) == funobj) { + if (funobj->getFunctionPrivate() == funobj) { flags |= Shape::METHOD; getter = CastAsPropertyOp(funobj); } @@ -5449,7 +5448,7 @@ JSObject::callMethod(JSContext *cx, jsid id, uintN argc, Value *argv, Value *vp) { Value fval; return js_GetMethod(cx, this, id, JSGET_NO_METHOD_BARRIER, &fval) && - ExternalInvoke(cx, ObjectValue(*this), fval, argc, argv, vp); + Invoke(cx, ObjectValue(*this), fval, argc, argv, vp); } JSBool @@ -5662,7 +5661,7 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow, JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER))); JSObject *funobj = &vp->toObject(); - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj); + JSFunction *fun = funobj->getFunctionPrivate(); if (fun == funobj) { flags |= Shape::METHOD; getter = CastAsPropertyOp(funobj); @@ -5797,7 +5796,7 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str JSObject *funobj; if (IsFunctionObject(v, &funobj)) { - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj); + JSFunction *fun = funobj->getFunctionPrivate(); if (fun != funobj) { for (StackFrame *fp = cx->maybefp(); fp; fp = fp->prev()) { @@ -5854,7 +5853,7 @@ MaybeCallMethod(JSContext *cx, JSObject *obj, jsid id, Value *vp) *vp = ObjectValue(*obj); return true; } - return ExternalInvoke(cx, ObjectValue(*obj), *vp, 0, NULL, vp); + return Invoke(cx, ObjectValue(*obj), *vp, 0, NULL, vp); } JSBool @@ -6492,7 +6491,7 @@ dumpValue(const Value &v) dumpString(v.toString()); else if (v.isObject() && v.toObject().isFunction()) { JSObject *funobj = &v.toObject(); - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj); + JSFunction *fun = funobj->getFunctionPrivate(); if (fun->atom) { fputs("atom, 0); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 7c477501aeb7..4d8ad24d7ea8 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -218,7 +218,7 @@ JSObject::methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp JSObject *funobj = &vp->toObject(); JSFunction *fun = funobj->getFunctionPrivate(); JS_ASSERT(fun == funobj); - JS_ASSERT(FUN_NULL_CLOSURE(fun)); + JS_ASSERT(fun->isNullClosure()); funobj = CloneFunctionObject(cx, fun, funobj->getParent()); if (!funobj) @@ -550,7 +550,7 @@ inline void JSObject::setFlatClosureUpvars(js::Value *upvars) { JS_ASSERT(isFunction()); - JS_ASSERT(FUN_FLAT_CLOSURE(getFunctionPrivate())); + JS_ASSERT(getFunctionPrivate()->isFlatClosure()); setSlot(JSSLOT_FLAT_CLOSURE_UPVARS, PrivateValue(upvars)); } diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 37ebdfc81dcb..e7d3df9b4912 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -396,7 +396,7 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes) } if (clasp == &js_FunctionClass) { - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj); + JSFunction *fun = obj->getFunctionPrivate(); JSString *str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT); if (!str) return false; @@ -4972,7 +4972,7 @@ js_DecompileFunctionBody(JSPrinter *jp) JS_ASSERT(jp->fun); JS_ASSERT(!jp->script); - if (!FUN_INTERPRETED(jp->fun)) { + if (!jp->fun->isInterpreted()) { js_printf(jp, native_code_str); return JS_TRUE; } @@ -5011,7 +5011,7 @@ js_DecompileFunction(JSPrinter *jp) return JS_FALSE; js_puts(jp, "("); - if (!FUN_INTERPRETED(fun)) { + if (!fun->isInterpreted()) { js_printf(jp, ") {\n"); jp->indent += 4; js_printf(jp, native_code_str); diff --git a/js/src/jsparse.cpp b/js/src/jsparse.cpp index dee6585a9b9e..d07e89c38d4f 100644 --- a/js/src/jsparse.cpp +++ b/js/src/jsparse.cpp @@ -313,7 +313,7 @@ Parser::newFunctionBox(JSObject *obj, JSParseNode *fn, JSTreeContext *tc) bool JSFunctionBox::joinable() const { - return FUN_NULL_CLOSURE(function()) && + return function()->isNullClosure() && !(tcflags & (TCF_FUN_USES_ARGUMENTS | TCF_FUN_USES_OWN_NAME)); } @@ -990,7 +990,7 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF * function captured in case it refers to an upvar, and someone * wishes to decompile it while it's running. */ - JSObjectBox *funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun())); + JSObjectBox *funbox = parser.newObjectBox(callerFrame->fun()); if (!funbox) goto out; funbox->emitLink = cg.objectList.lastbox; @@ -1978,8 +1978,8 @@ Parser::newFunction(JSTreeContext *tc, JSAtom *atom, FunctionSyntaxKind kind) JSFUN_INTERPRETED | (kind == Expression ? JSFUN_LAMBDA : 0), parent, atom); if (fun && !tc->compileAndGo()) { - FUN_OBJECT(fun)->clearParent(); - FUN_OBJECT(fun)->clearProto(); + fun->clearParent(); + fun->clearProto(); } return fun; } @@ -2461,12 +2461,12 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) JSFunction *fun = funbox->function(); - JS_ASSERT(FUN_KIND(fun) == JSFUN_INTERPRETED); + JS_ASSERT(fun->kind() == JSFUN_INTERPRETED); if (funbox->tcflags & TCF_FUN_HEAVYWEIGHT) { /* nothing to do */ } else if (funbox->inAnyDynamicScope()) { - JS_ASSERT(!FUN_NULL_CLOSURE(fun)); + JS_ASSERT(!fun->isNullClosure()); } else if (pn->pn_type != TOK_UPVARS) { /* * No lexical dependencies => null closure, for best performance. @@ -2484,7 +2484,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) * * FIXME: bug 476950. */ - FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE); + fun->setKind(JSFUN_NULL_CLOSURE); } else { AtomDefnMapPtr upvars = pn->pn_names; JS_ASSERT(!upvars->empty()); @@ -2512,7 +2512,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) } if (r.empty()) - FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE); + fun->setKind(JSFUN_NULL_CLOSURE); } else { uintN nupvars = 0, nflattened = 0; @@ -2550,13 +2550,13 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) } if (nupvars == 0) { - FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE); + fun->setKind(JSFUN_NULL_CLOSURE); } else if (nflattened == nupvars) { /* * We made it all the way through the upvar loop, so it's * safe to optimize to a flat closure. */ - FUN_SET_KIND(fun, JSFUN_FLAT_CLOSURE); + fun->setKind(JSFUN_FLAT_CLOSURE); switch (PN_OP(fn)) { case JSOP_DEFFUN: fn->pn_op = JSOP_DEFFUN_FC; @@ -2575,7 +2575,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) } } - if (FUN_KIND(fun) == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) { + if (fun->kind() == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) { /* * One or more upvars cannot be safely snapshot into a flat * closure's non-reserved slot (see JSOP_GETFCSLOT), so we loop @@ -2621,7 +2621,7 @@ Parser::markExtensibleScopeDescendants(JSFunctionBox *funbox, bool hasExtensible { for (; funbox; funbox = funbox->siblings) { /* - * It would be nice to use FUN_KIND(fun) here to recognize functions + * It would be nice to use fun->kind() here to recognize functions * that will never consult their parent chains, and thus don't need * their 'extensible parents' flag set. Filed as bug 619750. */ @@ -2663,7 +2663,7 @@ EnterFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL, return NULL; /* Create box for fun->object early to protect against last-ditch GC. */ - JSFunctionBox *funbox = tc->parser->newFunctionBox(FUN_OBJECT(fun), fn, tc); + JSFunctionBox *funbox = tc->parser->newFunctionBox(fun, fn, tc); if (!funbox) return NULL; diff --git a/js/src/jsprobes.cpp b/js/src/jsprobes.cpp index 5239025b8e4e..2bd500ba2321 100644 --- a/js/src/jsprobes.cpp +++ b/js/src/jsprobes.cpp @@ -90,10 +90,10 @@ FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString* bytes) static const char * FunctionClassname(const JSFunction *fun) { - if (!fun || FUN_INTERPRETED(fun)) + if (!fun || fun->isInterpreted()) return Probes::nullName; - if (!(fun->flags & JSFUN_TRCINFO) && FUN_CLASP(fun)) - return (char *)FUN_CLASP(fun)->name; + if (!(fun->flags & JSFUN_TRCINFO) && fun->getConstructorClass()) + return fun->getConstructorClass()->name; return Probes::nullName; } diff --git a/js/src/jspropertycache.cpp b/js/src/jspropertycache.cpp index 98b709f2050a..3aed109fcded 100644 --- a/js/src/jspropertycache.cpp +++ b/js/src/jspropertycache.cpp @@ -171,7 +171,7 @@ PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, JSObject *po if (!pobj->branded()) { PCMETER(brandfills++); #ifdef DEBUG_notme - JSFunction *fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(v)); + JSFunction *fun = JSVAL_TO_OBJECT(v)->getFunctionPrivate(); JSAutoByteString funNameBytes; if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { fprintf(stderr, diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index d9bbc5832c26..f4c67c44fff7 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -129,10 +129,8 @@ JSProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, *vp = desc.value; return true; } - if (desc.attrs & JSPROP_GETTER) { - return ExternalGetOrSet(cx, receiver, id, CastAsObjectJsval(desc.getter), - JSACC_READ, 0, NULL, vp); - } + if (desc.attrs & JSPROP_GETTER) + return InvokeGetterOrSetter(cx, receiver, CastAsObjectJsval(desc.getter), 0, NULL, vp); if (!(desc.attrs & JSPROP_SHARED)) *vp = desc.value; else @@ -275,8 +273,7 @@ JSProxyHandler::call(JSContext *cx, JSObject *proxy, uintN argc, Value *vp) { JS_ASSERT(OperationInProgress(cx, proxy)); AutoValueRooter rval(cx); - JSBool ok = ExternalInvoke(cx, vp[1], GetCall(proxy), argc, JS_ARGV(cx, vp), - rval.addr()); + JSBool ok = Invoke(cx, vp[1], GetCall(proxy), argc, JS_ARGV(cx, vp), rval.addr()); if (ok) JS_SET_RVAL(cx, vp, rval.value()); return ok; @@ -289,8 +286,8 @@ JSProxyHandler::construct(JSContext *cx, JSObject *proxy, JS_ASSERT(OperationInProgress(cx, proxy)); Value fval = GetConstruct(proxy); if (fval.isUndefined()) - return ExternalInvokeConstructor(cx, GetCall(proxy), argc, argv, rval); - return ExternalInvoke(cx, UndefinedValue(), fval, argc, argv, rval); + return InvokeConstructor(cx, GetCall(proxy), argc, argv, rval); + return Invoke(cx, UndefinedValue(), fval, argc, argv, rval); } bool @@ -359,7 +356,7 @@ GetDerivedTrap(JSContext *cx, JSObject *handler, JSAtom *atom, Value *fvalp) static bool Trap(JSContext *cx, JSObject *handler, Value fval, uintN argc, Value* argv, Value *rval) { - return ExternalInvoke(cx, ObjectValue(*handler), fval, argc, argv, rval); + return Invoke(cx, ObjectValue(*handler), fval, argc, argv, rval); } static bool @@ -1117,9 +1114,7 @@ proxy_Construct(JSContext *cx, uintN argc, Value *vp) { JSObject *proxy = &JS_CALLEE(cx, vp).toObject(); JS_ASSERT(proxy->isProxy()); - Value rval; - bool ok = JSProxy::construct(cx, proxy, argc, JS_ARGV(cx, vp), &rval); - *vp = rval; + bool ok = JSProxy::construct(cx, proxy, argc, JS_ARGV(cx, vp), vp); return ok; } @@ -1315,9 +1310,7 @@ callable_Call(JSContext *cx, uintN argc, Value *vp) JS_ASSERT(callable->getClass() == &CallableObjectClass); const Value &fval = callable->getSlot(JSSLOT_CALLABLE_CALL); const Value &thisval = vp[1]; - Value rval; - bool ok = ExternalInvoke(cx, thisval, fval, argc, JS_ARGV(cx, vp), &rval); - *vp = rval; + bool ok = Invoke(cx, thisval, fval, argc, JS_ARGV(cx, vp), vp); return ok; } @@ -1355,8 +1348,8 @@ callable_Construct(JSContext *cx, uintN argc, Value *vp) /* If the call returns an object, return that, otherwise the original newobj. */ Value rval; - if (!ExternalInvoke(cx, ObjectValue(*newobj), callable->getSlot(JSSLOT_CALLABLE_CALL), - argc, vp + 2, &rval)) { + if (!Invoke(cx, ObjectValue(*newobj), callable->getSlot(JSSLOT_CALLABLE_CALL), + argc, vp + 2, &rval)) { return false; } if (rval.isPrimitive()) @@ -1366,9 +1359,7 @@ callable_Construct(JSContext *cx, uintN argc, Value *vp) return true; } - Value rval; - bool ok = ExternalInvoke(cx, ObjectValue(*thisobj), fval, argc, vp + 2, &rval); - *vp = rval; + bool ok = Invoke(cx, ObjectValue(*thisobj), fval, argc, vp + 2, vp); return ok; } diff --git a/js/src/jsreflect.cpp b/js/src/jsreflect.cpp index bf8a9fca3ede..618712ca916c 100644 --- a/js/src/jsreflect.cpp +++ b/js/src/jsreflect.cpp @@ -231,11 +231,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { NullValue() }; /* no zero-length arrays allowed! */ - return ExternalInvoke(cx, userv, fun, 0, argv, dst); + return Invoke(cx, userv, fun, 0, argv, dst); } bool callback(Value fun, Value v1, TokenPos *pos, Value *dst) { @@ -244,11 +244,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { v1, loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { v1 }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } bool callback(Value fun, Value v1, Value v2, TokenPos *pos, Value *dst) { @@ -257,11 +257,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { v1, v2, loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { v1, v2 }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } bool callback(Value fun, Value v1, Value v2, Value v3, TokenPos *pos, Value *dst) { @@ -270,11 +270,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { v1, v2, v3, loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { v1, v2, v3 }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } bool callback(Value fun, Value v1, Value v2, Value v3, Value v4, TokenPos *pos, Value *dst) { @@ -283,11 +283,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { v1, v2, v3, v4, loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { v1, v2, v3, v4 }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } bool callback(Value fun, Value v1, Value v2, Value v3, Value v4, Value v5, @@ -297,11 +297,11 @@ class NodeBuilder if (!newNodeLoc(pos, &loc)) return false; Value argv[] = { v1, v2, v3, v4, v5, loc }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value argv[] = { v1, v2, v3, v4, v5 }; - return ExternalInvoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); + return Invoke(cx, userv, fun, JS_ARRAY_LENGTH(argv), argv, dst); } Value opt(Value v) { diff --git a/js/src/jsscopeinlines.h b/js/src/jsscopeinlines.h index 7dbca57e741e..915c473eb361 100644 --- a/js/src/jsscopeinlines.h +++ b/js/src/jsscopeinlines.h @@ -267,7 +267,7 @@ Shape::get(JSContext* cx, JSObject *receiver, JSObject* obj, JSObject *pobj, js: if (hasGetterValue()) { JS_ASSERT(!isMethod()); js::Value fval = getterValue(); - return js::ExternalGetOrSet(cx, receiver, propid, fval, JSACC_READ, 0, 0, vp); + return js::InvokeGetterOrSetter(cx, receiver, fval, 0, 0, vp); } if (isMethod()) { @@ -291,7 +291,7 @@ Shape::set(JSContext* cx, JSObject* obj, bool strict, js::Value* vp) const if (attrs & JSPROP_SETTER) { js::Value fval = setterValue(); - return js::ExternalGetOrSet(cx, obj, propid, fval, JSACC_WRITE, 1, vp, vp); + return js::InvokeGetterOrSetter(cx, obj, fval, 1, vp, vp); } if (attrs & JSPROP_GETTER) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 89c1b35bdd5c..77fd4ee2a9ef 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -1234,7 +1234,7 @@ JSScript::NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg) if (cg->inFunction()) { /* * We initialize fun->u.i.script to be the script constructed above - * so that the debugger has a valid FUN_SCRIPT(fun). + * so that the debugger has a valid fun->script(). */ fun = cg->fun(); JS_ASSERT(fun->isInterpreted()); diff --git a/js/src/jsscriptinlines.h b/js/src/jsscriptinlines.h index ad6929e497e5..387185b15905 100644 --- a/js/src/jsscriptinlines.h +++ b/js/src/jsscriptinlines.h @@ -120,7 +120,7 @@ JSScript::getFunction(size_t index) JS_ASSERT(funobj->isFunction()); JS_ASSERT(funobj == (JSObject *) funobj->getPrivate()); JSFunction *fun = (JSFunction *) funobj; - JS_ASSERT(FUN_INTERPRETED(fun)); + JS_ASSERT(fun->isInterpreted()); return fun; } diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 5ac46c7e84c6..fdf53f0e271d 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -3504,7 +3504,7 @@ js_ValueToSource(JSContext *cx, const Value &v) if (!js_GetMethod(cx, &v.toObject(), id, JSGET_NO_METHOD_BARRIER, &fval)) return false; if (js_IsCallable(fval)) { - if (!ExternalInvoke(cx, v, fval, 0, NULL, &rval)) + if (!Invoke(cx, v, fval, 0, NULL, &rval)) return false; } diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 0cfe1142965a..2875ca40e192 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -2810,7 +2810,7 @@ ValueToNative(const Value &v, JSValueType type, double* slot) case JSVAL_TYPE_FUNOBJ: { JS_ASSERT(IsFunctionObject(v)); - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject()); + JSFunction* fun = v.toObject().getFunctionPrivate(); #if defined JS_JIT_SPEW if (LogController.lcbits & LC_TMTracer) { char funName[40]; @@ -3109,7 +3109,7 @@ NativeToValue(JSContext* cx, Value& v, JSValueType type, double* slot) JS_ASSERT(IsFunctionObject(v)); #if defined JS_JIT_SPEW if (LogController.lcbits & LC_TMTracer) { - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject()); + JSFunction* fun = v.toObject().getFunctionPrivate(); char funName[40]; if (fun->atom) JS_PutEscapedFlatString(funName, sizeof funName, fun->atom, 0); @@ -3385,7 +3385,7 @@ GetUpvarOnTrace(JSContext* cx, uint32 upvarLevel, int32 slot, uint32 callDepth, */ stackOffset -= fi->callerHeight; JSObject* callee = *(JSObject**)(&state->stackBase[stackOffset]); - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, callee); + JSFunction* fun = callee->getFunctionPrivate(); uintN calleeLevel = fun->script()->staticLevel; if (calleeLevel == upvarLevel) { /* @@ -10541,7 +10541,7 @@ static JSBool JS_FASTCALL functionProbe(JSContext *cx, JSFunction *fun, int enter) { #ifdef MOZ_TRACE_JSCALLS - JSScript *script = fun ? FUN_SCRIPT(fun) : NULL; + JSScript *script = fun ? fun->maybeScript() : NULL; if (enter > 0) Probes::enterJSFun(cx, fun, script, enter); else @@ -11011,7 +11011,7 @@ TraceRecorder::getClassPrototype(JSObject* ctor, LIns*& proto_ins) { // ctor must be a function created via js_InitClass. #ifdef DEBUG - Class *clasp = FUN_CLASP(GET_FUNCTION_PRIVATE(cx, ctor)); + Class *clasp = ctor->getFunctionPrivate()->getConstructorClass(); JS_ASSERT(clasp); TraceMonitor &localtm = *traceMonitor; @@ -11553,7 +11553,7 @@ TraceRecorder::callNative(uintN argc, JSOp mode) } if (fun->flags & JSFUN_TRCINFO) { - JSNativeTraceInfo *trcinfo = FUN_TRCINFO(fun); + JSNativeTraceInfo *trcinfo = fun->getTraceInfo(); JS_ASSERT(trcinfo && fun->u.n.native == trcinfo->native); /* Try to call a type specialized version of the native. */ @@ -11708,10 +11708,10 @@ TraceRecorder::functionCall(uintN argc, JSOp mode) * Bytecode sequences that push shapeless callees must guard on the callee * class being Function and the function being interpreted. */ - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &fval.toObject()); + JSFunction* fun = fval.toObject().getFunctionPrivate(); if (Probes::callTrackingActive(cx)) { - JSScript *script = FUN_SCRIPT(fun); + JSScript *script = fun->maybeScript(); if (!script || !script->isEmpty()) { LIns* args[] = { w.immi(1), w.nameImmpNonGC(fun), cx_ins }; LIns* call_ins = w.call(&functionProbe_ci, args); @@ -11719,7 +11719,7 @@ TraceRecorder::functionCall(uintN argc, JSOp mode) } } - if (FUN_INTERPRETED(fun)) + if (fun->isInterpreted()) return interpretedFunctionCall(fval, fun, argc, mode == JSOP_NEW); Native native = fun->maybeNative(); @@ -13617,7 +13617,8 @@ TraceRecorder::guardCallee(Value& callee) * private data) case as noted above. */ if (callee_fun->isInterpreted() && - (!FUN_NULL_CLOSURE(callee_fun) || callee_fun->script()->bindings.hasUpvars())) { + (!callee_fun->isNullClosure() || callee_fun->script()->bindings.hasUpvars())) + { JSObject* parent = callee_obj.getParent(); if (parent != globalObj) { @@ -13819,8 +13820,8 @@ TraceRecorder::record_JSOP_FUNAPPLY() RETURN_IF_XML_A(vp[0]); JSObject* obj = &vp[0].toObject(); - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj); - if (FUN_INTERPRETED(fun)) + JSFunction* fun = obj->getFunctionPrivate(); + if (fun->isInterpreted()) return record_JSOP_CALL(); bool apply = fun->u.n.native == js_fun_apply; @@ -15422,7 +15423,7 @@ TraceRecorder::record_JSOP_LAMBDA() JSFunction* fun; fun = cx->fp()->script()->getFunction(getFullIndex()); - if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() != globalObj) + if (fun->isNullClosure() && fun->getParent() != globalObj) RETURN_STOP_A("Null closure function object parent must be global object"); /* @@ -15436,12 +15437,12 @@ TraceRecorder::record_JSOP_LAMBDA() * JSOP_INITMETHOD logic governing the early ARECORD_CONTINUE returns below * must agree with the corresponding break-from-do-while(0) logic there. */ - if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == &cx->fp()->scopeChain()) { + if (fun->isNullClosure() && fun->getParent() == &cx->fp()->scopeChain()) { jsbytecode *pc2 = AdvanceOverBlockchainOp(cx->regs().pc + JSOP_LAMBDA_LENGTH); JSOp op2 = JSOp(*pc2); if (op2 == JSOP_INITMETHOD) { - stack(0, w.immpObjGC(FUN_OBJECT(fun))); + stack(0, w.immpObjGC(fun)); return ARECORD_CONTINUE; } @@ -15449,7 +15450,7 @@ TraceRecorder::record_JSOP_LAMBDA() Value lval = stackval(-1); if (!lval.isPrimitive() && lval.toObject().canHaveMethodBarrier()) { - stack(0, w.immpObjGC(FUN_OBJECT(fun))); + stack(0, w.immpObjGC(fun)); return ARECORD_CONTINUE; } } else if (fun->joinable()) { @@ -15477,7 +15478,7 @@ TraceRecorder::record_JSOP_LAMBDA() if ((iargc == 1 && native == array_sort) || (iargc == 2 && native == str_replace)) { - stack(0, w.immpObjGC(FUN_OBJECT(fun))); + stack(0, w.immpObjGC(fun)); return ARECORD_CONTINUE; } } @@ -15486,7 +15487,7 @@ TraceRecorder::record_JSOP_LAMBDA() op2 = JSOp(*pc2); if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) { - stack(0, w.immpObjGC(FUN_OBJECT(fun))); + stack(0, w.immpObjGC(fun)); return ARECORD_CONTINUE; } } @@ -15497,6 +15498,9 @@ TraceRecorder::record_JSOP_LAMBDA() LIns* args[] = { w.immpObjGC(globalObj), proto_ins, w.immpFunGC(fun), cx_ins }; LIns* x = w.call(&js_NewNullClosure_ci, args); + guard(false, + w.name(w.eqp0(x), "guard(js_NewNullClosure_ci)"), + OOM_EXIT); stack(0, x); return ARECORD_CONTINUE; } @@ -15524,7 +15528,7 @@ TraceRecorder::record_JSOP_LAMBDA_FC() JSFunction* fun; fun = cx->fp()->script()->getFunction(getFullIndex()); - if (FUN_OBJECT(fun)->getParent() != globalObj) + if (fun->getParent() != globalObj) return ARECORD_STOP; if (GetBlockChainFast(cx, cx->fp(), JSOP_LAMBDA_FC, JSOP_LAMBDA_FC_LENGTH)) @@ -15672,9 +15676,9 @@ TraceRecorder::record_JSOP_ARGCNT() JS_REQUIRES_STACK AbortableRecordingStatus TraceRecorder::record_DefLocalFunSetSlot(uint32 slot, JSObject* obj) { - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj); + JSFunction* fun = obj->getFunctionPrivate(); - if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == globalObj) { + if (fun->isNullClosure() && fun->getParent() == globalObj) { LIns *proto_ins; CHECK_STATUS_A(getClassPrototype(JSProto_Function, proto_ins)); @@ -16012,7 +16016,7 @@ TraceRecorder::record_JSOP_CALLPROP() if (pcval.isFunObj()) { if (l.isPrimitive()) { - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &pcval.toFunObj()); + JSFunction* fun = pcval.toFunObj().getFunctionPrivate(); if (fun->isInterpreted() && !fun->inStrictMode()) RETURN_STOP_A("callee does not accept primitive |this|"); } diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index ff1bb1408414..c11daccf883d 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -484,7 +484,7 @@ ErrorCopier::~ErrorCopier() cx->isExceptionPending()) { Value exc = cx->getPendingException(); - if (exc.isObject() && exc.toObject().isError()) { + if (exc.isObject() && exc.toObject().isError() && exc.toObject().getPrivate()) { cx->clearPendingException(); ac.leave(); JSObject *copyobj = js_CopyErrorObject(cx, &exc.toObject(), scope); diff --git a/js/src/jsxml.cpp b/js/src/jsxml.cpp index 984650f5b5d1..5b1f0eb1721a 100644 --- a/js/src/jsxml.cpp +++ b/js/src/jsxml.cpp @@ -1643,7 +1643,7 @@ GetXMLSetting(JSContext *cx, const char *name, jsval *vp) if (!js_FindClassObject(cx, NULL, JSProto_XML, Valueify(&v))) return JS_FALSE; - if (!VALUE_IS_FUNCTION(cx, v)) { + if (JSVAL_IS_PRIMITIVE(v) || !JSVAL_TO_OBJECT(v)->isFunction()) { *vp = JSVAL_VOID; return JS_TRUE; } @@ -5153,7 +5153,8 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp) JSFunction *fun; char numBuf[12]; - JS_ASSERT(VALUE_IS_FUNCTION(cx, *vp)); + JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp)); + JS_ASSERT(JSVAL_TO_OBJECT(*vp)->isFunction()); *objp = ToObject(cx, Valueify(&vp[1])); if (!*objp) @@ -5177,7 +5178,7 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp) } } - fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(*vp)); + fun = JSVAL_TO_OBJECT(*vp)->getFunctionPrivate(); JS_snprintf(numBuf, sizeof numBuf, "%u", xml->xml_kids.length); JSAutoByteString funNameBytes; if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { @@ -7500,7 +7501,7 @@ GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp) for (;;) { if (!js_GetProperty(cx, target, id, Valueify(vp))) return false; - if (VALUE_IS_FUNCTION(cx, *vp)) + if (!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction()) return true; target = target->getProto(); if (target == NULL || !target->isNative()) diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp index 8d43c677bb78..730a5e704e20 100644 --- a/js/src/methodjit/InvokeHelpers.cpp +++ b/js/src/methodjit/InvokeHelpers.cpp @@ -114,6 +114,7 @@ top: continue; jsbytecode *pc = script->main + tn->start + tn->length; + cx->regs().pc = pc; JSBool ok = js_UnwindScope(cx, tn->stackDepth, JS_TRUE); JS_ASSERT(cx->regs().sp == fp->base() + tn->stackDepth); @@ -191,14 +192,14 @@ InlineReturn(VMFrame &f) void JS_FASTCALL stubs::SlowCall(VMFrame &f, uint32 argc) { - if (!Invoke(f.cx, CallArgsFromSp(argc, f.regs.sp))) + if (!InvokeKernel(f.cx, CallArgsFromSp(argc, f.regs.sp))) THROW(); } void JS_FASTCALL stubs::SlowNew(VMFrame &f, uint32 argc) { - if (!InvokeConstructor(f.cx, CallArgsFromSp(argc, f.regs.sp))) + if (!InvokeConstructorKernel(f.cx, CallArgsFromSp(argc, f.regs.sp))) THROW(); } @@ -378,7 +379,7 @@ stubs::UncachedNewHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr) if (!UncachedInlineCall(f, CONSTRUCT, &ucr->codeAddr, &ucr->unjittable, argc)) THROW(); } else { - if (!InvokeConstructor(cx, args)) + if (!InvokeConstructorKernel(cx, args)) THROW(); } } @@ -397,7 +398,7 @@ stubs::Eval(VMFrame &f, uint32 argc) CallArgs args = CallArgsFromSp(argc, f.regs.sp); if (!IsBuiltinEvalForScope(&f.fp()->scopeChain(), args.calleev())) { - if (!Invoke(f.cx, args)) + if (!InvokeKernel(f.cx, args)) THROW(); return; } @@ -419,7 +420,7 @@ stubs::UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr) if (IsFunctionObject(args.calleev(), &ucr->callee)) { ucr->callee = &args.callee(); - ucr->fun = GET_FUNCTION_PRIVATE(cx, ucr->callee); + ucr->fun = ucr->callee->getFunctionPrivate(); if (ucr->fun->isInterpreted()) { if (!UncachedInlineCall(f, NO_CONSTRUCT, &ucr->codeAddr, &ucr->unjittable, argc)) @@ -434,7 +435,7 @@ stubs::UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr) } } - if (!Invoke(f.cx, args)) + if (!InvokeKernel(f.cx, args)) THROW(); return; diff --git a/js/src/methodjit/PolyIC.cpp b/js/src/methodjit/PolyIC.cpp index e08b4a82614b..17e1a9ba96b4 100644 --- a/js/src/methodjit/PolyIC.cpp +++ b/js/src/methodjit/PolyIC.cpp @@ -558,7 +558,7 @@ class SetPropCompiler : public PICStubCompiler return disable("can't have method barrier"); JSObject *funobj = &f.regs.sp[-1].toObject(); - if (funobj != GET_FUNCTION_PRIVATE(cx, funobj)) + if (funobj != funobj->getFunctionPrivate()) return disable("mismatched function"); flags |= Shape::METHOD; diff --git a/js/src/methodjit/StubCalls.cpp b/js/src/methodjit/StubCalls.cpp index 8bb81d97f3dd..61eb31e58207 100644 --- a/js/src/methodjit/StubCalls.cpp +++ b/js/src/methodjit/StubCalls.cpp @@ -704,9 +704,9 @@ stubs::DefFun(VMFrame &f, JSFunction *fun) * a compound statement (not at the top statement level of global code, or * at the top level of a function body). */ - JSObject *obj = FUN_OBJECT(fun); + JSObject *obj = fun; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { /* * Even a null closure needs a parent for principals finding. * FIXME: bug 476950, although debugger users may also demand some kind @@ -1325,10 +1325,10 @@ stubs::DefLocalFun(VMFrame &f, JSFunction *fun) * activation. */ JS_ASSERT(fun->isInterpreted()); - JS_ASSERT(!FUN_FLAT_CLOSURE(fun)); - JSObject *obj = FUN_OBJECT(fun); + JS_ASSERT(!fun->isFlatClosure()); + JSObject *obj = fun; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { obj = CloneFunctionObject(f.cx, fun, &f.fp()->scopeChain()); if (!obj) THROWV(NULL); @@ -1381,8 +1381,8 @@ stubs::RegExp(VMFrame &f, JSObject *regex) JSObject * JS_FASTCALL stubs::LambdaForInit(VMFrame &f, JSFunction *fun) { - JSObject *obj = FUN_OBJECT(fun); - if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) { + JSObject *obj = fun; + if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc))); return obj; } @@ -1392,8 +1392,8 @@ stubs::LambdaForInit(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::LambdaForSet(VMFrame &f, JSFunction *fun) { - JSObject *obj = FUN_OBJECT(fun); - if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) { + JSObject *obj = fun; + if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { const Value &lref = f.regs.sp[-1]; if (lref.isObject() && lref.toObject().canHaveMethodBarrier()) { fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc))); @@ -1406,8 +1406,8 @@ stubs::LambdaForSet(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun) { - JSObject *obj = FUN_OBJECT(fun); - if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) { + JSObject *obj = fun; + if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { /* * Array.prototype.sort and String.prototype.replace are * optimized as if they are special form. We know that they @@ -1443,8 +1443,8 @@ stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun) { - JSObject *obj = FUN_OBJECT(fun); - if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) { + JSObject *obj = fun; + if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { jsbytecode *pc2 = f.regs.pc + JSOP_NULL_LENGTH; JSOp op2 = JSOp(*pc2); @@ -1457,10 +1457,10 @@ stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::Lambda(VMFrame &f, JSFunction *fun) { - JSObject *obj = FUN_OBJECT(fun); + JSObject *obj = fun; JSObject *parent; - if (FUN_NULL_CLOSURE(fun)) { + if (fun->isNullClosure()) { parent = &f.fp()->scopeChain(); } else { parent = GetScopeChainFast(f.cx, f.fp(), JSOP_LAMBDA, JSOP_LAMBDA_LENGTH); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index dce40201f3b2..4c158f44c36c 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1554,7 +1554,7 @@ ValueToScript(JSContext *cx, jsval v) } else if (clasp == Jsvalify(&js_GeneratorClass)) { JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj); fun = gen->floatingFrame()->fun(); - script = FUN_SCRIPT(fun); + script = fun->script(); } } @@ -1562,7 +1562,7 @@ ValueToScript(JSContext *cx, jsval v) fun = JS_ValueToFunction(cx, v); if (!fun) return NULL; - script = FUN_SCRIPT(fun); + script = fun->maybeScript(); if (!script) { JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_SCRIPTS_ONLY); @@ -1992,7 +1992,7 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive, Sprinter *s JSScript *script = ValueToScript(cx, v); if (!script) return false; - if (VALUE_IS_FUNCTION(cx, v)) { + if (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction()) { JSFunction *fun = JS_ValueToFunction(cx, v); if (fun && (fun->flags & ~7U)) { uint16 flags = fun->flags; @@ -2007,10 +2007,10 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive, Sprinter *s #undef SHOW_FLAG - if (FUN_INTERPRETED(fun)) { - if (FUN_NULL_CLOSURE(fun)) + if (fun->isInterpreted()) { + if (fun->isNullClosure()) Sprint(sp, " NULL_CLOSURE"); - else if (FUN_FLAT_CLOSURE(fun)) + else if (fun->isFlatClosure()) Sprint(sp, " FLAT_CLOSURE"); JSScript *script = fun->script(); @@ -2698,7 +2698,7 @@ Clone(JSContext *cx, uintN argc, jsval *vp) return JS_FALSE; argv[0] = OBJECT_TO_JSVAL(obj); } - if (VALUE_IS_FUNCTION(cx, argv[0])) { + if (!JSVAL_IS_PRIMITIVE(argv[0]) && JSVAL_TO_OBJECT(argv[0])->isFunction()) { funobj = JSVAL_TO_OBJECT(argv[0]); } else { JSFunction *fun = JS_ValueToFunction(cx, argv[0]); diff --git a/js/src/tests/ecma_5/extensions/JSON-string-replacer-overflow.js b/js/src/tests/ecma_5/extensions/JSON-string-replacer-overflow.js new file mode 100644 index 000000000000..6eb5c3148c68 --- /dev/null +++ b/js/src/tests/ecma_5/extensions/JSON-string-replacer-overflow.js @@ -0,0 +1,24 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var r1 = [0, 1, 2, 3]; +Object.defineProperty(r1, (1 << 23) - 1, {}); +JSON.stringify({ 0: 0, 1: 1, 2: 2, 3: 3 }, r1) + +var r2 = [0, 1, 2, 3]; +Object.defineProperty(r2, (1 << 30), {}); +try +{ + JSON.stringify({ 0: 0, 1: 1, 2: 2, 3: 3 }, r2) +} +catch (e) +{ + assertEq(""+e, "InternalError: allocation size overflow"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/ecma_5/extensions/jstests.list b/js/src/tests/ecma_5/extensions/jstests.list index e96e4789c764..44a7486f9f8b 100644 --- a/js/src/tests/ecma_5/extensions/jstests.list +++ b/js/src/tests/ecma_5/extensions/jstests.list @@ -16,6 +16,7 @@ script extension-methods-reject-null-undefined-this.js skip-if(!xulRuntime.shell) script function-definition-with.js # needs evaluate() script function-properties.js script iterator-in-catch.js +script JSON-string-replacer-overflow.js skip-if(!xulRuntime.shell) script legacy-JSON.js # needs parseLegacyJSON fails script nested-delete-name-in-evalcode.js # bug 604301, at a minimum script proxy-strict.js diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 2af8e06ef8da..69d97edd44e9 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -520,7 +520,7 @@ Debugger::handleUncaughtException(AutoCompartment &ac, Value *vp, bool callHook) Value exc = cx->getPendingException(); Value rv; cx->clearPendingException(); - if (ExternalInvoke(cx, ObjectValue(*object), fval, 1, &exc, &rv)) + if (Invoke(cx, ObjectValue(*object), fval, 1, &exc, &rv)) return vp ? parseResumptionValue(ac, true, rv, vp, false) : JSTRAP_CONTINUE; } @@ -626,7 +626,7 @@ CallMethodIfPresent(JSContext *cx, JSObject *obj, const char *name, int argc, Va return atom && js_GetMethod(cx, obj, ATOM_TO_JSID(atom), JSGET_NO_METHOD_BARRIER, &fval) && (!js_IsCallable(fval) || - ExternalInvoke(cx, ObjectValue(*obj), fval, argc, argv, rval)); + Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval)); } JSTrapStatus @@ -647,7 +647,7 @@ Debugger::fireDebuggerStatement(JSContext *cx, Value *vp) return handleUncaughtException(ac, vp, false); Value rv; - bool ok = ExternalInvoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv); return parseResumptionValue(ac, ok, rv, vp); } @@ -672,7 +672,7 @@ Debugger::fireExceptionUnwind(JSContext *cx, Value *vp) return handleUncaughtException(ac, vp, false); Value rv; - bool ok = ExternalInvoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, &rv); + bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, &rv); JSTrapStatus st = parseResumptionValue(ac, ok, rv, vp); if (st == JSTRAP_CONTINUE) cx->setPendingException(exc); @@ -697,7 +697,7 @@ Debugger::fireEnterFrame(JSContext *cx) return; } Value rv; - if (!ExternalInvoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv)) + if (!Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv)) handleUncaughtException(ac, NULL, true); } @@ -722,7 +722,7 @@ Debugger::fireNewScript(JSContext *cx, JSScript *script, JSObject *obj, NewScrip Value argv[1]; argv[0].setObject(*dsobj); Value rv; - if (!ExternalInvoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv)) + if (!Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv)) handleUncaughtException(ac, NULL, true); } @@ -2658,6 +2658,10 @@ EvaluateInScope(JSContext *cx, JSObject *scobj, StackFrame *fp, const jschar *ch { assertSameCompartment(cx, scobj, fp); + /* Execute assumes an already-computed 'this" value. */ + if (!ComputeThis(cx, fp)) + return false; + /* * NB: This function breaks the assumption that the compiler can see all * calls and properly compute a static level. In order to get around this, @@ -2672,7 +2676,7 @@ EvaluateInScope(JSContext *cx, JSObject *scobj, StackFrame *fp, const jschar *ch if (!script) return false; - bool ok = Execute(cx, script, *scobj, fp->thisValue(), EXECUTE_DEBUG, fp, rval); + bool ok = ExecuteKernel(cx, script, *scobj, fp->thisValue(), EXECUTE_DEBUG, fp, rval); js_DestroyScript(cx, script, 6); return ok; } @@ -3003,6 +3007,7 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, uintN argc, Value *vp) if (!ac.enter() || !cx->compartment->wrapId(cx, &id)) return false; + ErrorCopier ec(ac, dbg->toJSObject()); if (!GetOwnPropertyDescriptor(cx, obj, id, &desc)) return false; } @@ -3039,6 +3044,7 @@ DebuggerObject_getOwnPropertyNames(JSContext *cx, uintN argc, Value *vp) if (!ac.enter()) return false; + ErrorCopier ec(ac, dbg->toJSObject()); if (!GetPropertyNames(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, &keys)) return false; } @@ -3377,7 +3383,7 @@ ApplyOrCall(JSContext *cx, uintN argc, Value *vp, ApplyOrCallMode mode) * compartment and populate args.rval(). */ Value rval; - bool ok = ExternalInvoke(cx, thisv, calleev, callArgc, callArgv, &rval); + bool ok = Invoke(cx, thisv, calleev, callArgc, callArgv, &rval); return dbg->newCompletionValue(ac, ok, rval, &args.rval()); } diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 07902c147d44..facba994b6d9 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -214,7 +214,7 @@ GlobalObject::createConstructor(JSContext *cx, Native ctor, Class *clasp, JSAtom * Remember the class this function is a constructor for so that we know to * create an object of this class when we call the constructor. */ - FUN_CLASP(fun) = clasp; + fun->setConstructorClass(clasp); return fun; } diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index e761cd3f5f9e..6dab5ec7e99b 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -254,6 +254,13 @@ CallArgsFromSp(uintN argc, Value *sp) /*****************************************************************************/ +/* + * For calls to natives, the InvokeArgsGuard object provides a record of the + * call for the debugger's callstack. For this to work, the InvokeArgsGuard + * record needs to know when the call is actually active (because the + * InvokeArgsGuard can be pushed long before and popped long after the actual + * call, during which time many stack-observing things can happen). + */ class CallArgsList : public CallArgs { friend class StackSegment; diff --git a/js/src/xpconnect/src/xpcwrappednativejsops.cpp b/js/src/xpconnect/src/xpcwrappednativejsops.cpp index 8764bacaa113..d94a47992c1a 100644 --- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp +++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp @@ -1576,7 +1576,7 @@ XPC_WN_CallMethod(JSContext *cx, uintN argc, jsval *vp) #ifdef DEBUG_slimwrappers { - JSFunction* fun = GET_FUNCTION_PRIVATE(cx, funobj); + JSFunction* fun = funobj->getFunctionPrivate(); JSString *funid = JS_GetFunctionId(fun); JSAutoByteString bytes; const char *funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : ""; @@ -1615,7 +1615,7 @@ XPC_WN_GetterSetter(JSContext *cx, uintN argc, jsval *vp) JSAutoByteString bytes; if(JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION) { - JSString *funid = JS_GetFunctionId(GET_FUNCTION_PRIVATE(cx, funobj)); + JSString *funid = JS_GetFunctionId(funobj->getFunctionPrivate()); funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : ""; } SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 3fd45cbd58b7..bf48c436d715 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -9411,6 +9411,16 @@ SetExternalResourceIsActive(nsIDocument* aDocument, void* aClosure) return PR_TRUE; } +static void +SetPluginIsActive(nsIContent* aContent, void* aClosure) +{ + nsIFrame *frame = aContent->GetPrimaryFrame(); + nsIObjectFrame *objectFrame = do_QueryFrame(frame); + if (objectFrame) { + objectFrame->SetIsDocumentActive(*static_cast(aClosure)); + } +} + nsresult PresShell::SetIsActive(PRBool aIsActive) { @@ -9426,6 +9436,8 @@ PresShell::SetIsActive(PRBool aIsActive) // Propagate state-change to my resource documents' PresShells mDocument->EnumerateExternalResources(SetExternalResourceIsActive, &aIsActive); + mDocument->EnumerateFreezableElements(SetPluginIsActive, + &aIsActive); nsresult rv = UpdateImageLockingState(); #ifdef ACCESSIBILITY if (aIsActive) { diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 1f325c26a147..f293ad6e0f23 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -67,7 +67,6 @@ #include "nsISupportsPrimitives.h" #include "nsAutoPtr.h" #include "nsPresState.h" -#include "nsIGlobalHistory3.h" #include "nsDocShellCID.h" #include "nsIHTMLDocument.h" #include "nsEventDispatcher.h" diff --git a/layout/generic/nsIObjectFrame.h b/layout/generic/nsIObjectFrame.h index 1708e5f0bed1..dfb04648094a 100644 --- a/layout/generic/nsIObjectFrame.h +++ b/layout/generic/nsIObjectFrame.h @@ -94,6 +94,13 @@ public: * Get the native widget for the plugin, if any. */ virtual nsIWidget* GetWidget() = 0; + + /** + * Update plugin active state. Frame should update if it is on an active tab + * or not and forward that information to the plugin to make it possible to + * throttle down plugin instance in non active case. + */ + virtual void SetIsDocumentActive(PRBool aIsActive) = 0; }; #endif /* nsIObjectFrame_h___ */ diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 88e33b9877dd..69353db1d651 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -2494,6 +2494,16 @@ nsObjectFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor) return nsObjectFrameSuper::GetCursor(aPoint, aCursor); } +void +nsObjectFrame::SetIsDocumentActive(PRBool aIsActive) +{ +#ifndef XP_MACOSX + if (mInstanceOwner) { + mInstanceOwner->UpdateDocumentActiveState(aIsActive); + } +#endif +} + void nsObjectFrame::NotifyContentObjectWrapper() { diff --git a/layout/generic/nsObjectFrame.h b/layout/generic/nsObjectFrame.h index f1b55af5e7bb..c141125bd584 100644 --- a/layout/generic/nsObjectFrame.h +++ b/layout/generic/nsObjectFrame.h @@ -128,6 +128,7 @@ public: virtual nsresult Instantiate(const char* aMimeType, nsIURI* aURI); virtual void TryNotifyContentObjectWrapper(); virtual void StopPlugin(); + virtual void SetIsDocumentActive(PRBool aIsActive); /* * Stop a plugin instance. If aDelayedStop is true, the plugin will diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index b808d9751e33..8b1200a5f746 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1108,6 +1108,11 @@ InitSystemMetrics() sSystemMetrics->AppendElement(nsGkAtoms::mac_graphite_theme); } + rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MacLionTheme, metricResult); + if (NS_SUCCEEDED(rv) && metricResult) { + sSystemMetrics->AppendElement(nsGkAtoms::mac_lion_theme); + } + rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DWMCompositor, metricResult); if (NS_SUCCEEDED(rv) && metricResult) { sSystemMetrics->AppendElement(nsGkAtoms::windows_compositor); diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index 1d2dc7d95f5e..a5fda1a915f7 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -521,6 +521,13 @@ nsMediaFeatures::features[] = { { &nsGkAtoms::mac_graphite_theme }, GetSystemMetric }, + { + &nsGkAtoms::_moz_mac_lion_theme, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + { &nsGkAtoms::mac_lion_theme }, + GetSystemMetric + }, { &nsGkAtoms::_moz_windows_compositor, nsMediaFeature::eMinMaxNotAllowed, diff --git a/layout/style/test/test_media_queries.html b/layout/style/test/test_media_queries.html index 3ebcfa6f6e2b..a89a2555838d 100644 --- a/layout/style/test/test_media_queries.html +++ b/layout/style/test/test_media_queries.html @@ -550,6 +550,7 @@ function run() { expression_should_be_parseable("-moz-images-in-buttons"); expression_should_be_parseable("-moz-windows-default-theme"); expression_should_be_parseable("-moz-mac-graphite-theme"); + expression_should_be_parseable("-moz-mac-lion-theme"); expression_should_be_parseable("-moz-windows-compositor"); expression_should_be_parseable("-moz-windows-classic"); expression_should_be_parseable("-moz-touch-enabled"); @@ -564,6 +565,7 @@ function run() { expression_should_be_parseable("-moz-images-in-buttons: 0"); expression_should_be_parseable("-moz-windows-default-theme: 0"); expression_should_be_parseable("-moz-mac-graphite-theme: 0"); + expression_should_be_parseable("-moz-mac-lion-theme: 0"); expression_should_be_parseable("-moz-windows-compositor: 0"); expression_should_be_parseable("-moz-windows-classic: 0"); expression_should_be_parseable("-moz-touch-enabled: 0"); @@ -578,6 +580,7 @@ function run() { expression_should_be_parseable("-moz-images-in-buttons: 1"); expression_should_be_parseable("-moz-windows-default-theme: 1"); expression_should_be_parseable("-moz-mac-graphite-theme: 1"); + expression_should_be_parseable("-moz-mac-lion-theme: 1"); expression_should_be_parseable("-moz-windows-compositor: 1"); expression_should_be_parseable("-moz-windows-classic: 1"); expression_should_be_parseable("-moz-touch-enabled: 1"); @@ -592,6 +595,7 @@ function run() { expression_should_not_be_parseable("-moz-images-in-buttons: -1"); expression_should_not_be_parseable("-moz-windows-default-theme: -1"); expression_should_not_be_parseable("-moz-mac-graphite-theme: -1"); + expression_should_not_be_parseable("-moz-mac-lion-theme: -1"); expression_should_not_be_parseable("-moz-windows-compositor: -1"); expression_should_not_be_parseable("-moz-windows-classic: -1"); expression_should_not_be_parseable("-moz-touch-enabled: -1"); @@ -606,6 +610,7 @@ function run() { expression_should_not_be_parseable("-moz-images-in-buttons: true"); expression_should_not_be_parseable("-moz-windows-default-theme: true"); expression_should_not_be_parseable("-moz-mac-graphite-theme: true"); + expression_should_not_be_parseable("-moz-mac-lion-theme: true"); expression_should_not_be_parseable("-moz-windows-compositor: true"); expression_should_not_be_parseable("-moz-windows-classic: true"); expression_should_not_be_parseable("-moz-touch-enabled: true"); diff --git a/mobile/app/mobile.js b/mobile/app/mobile.js index 0b1258685c9a..0ed920e5c6d7 100644 --- a/mobile/app/mobile.js +++ b/mobile/app/mobile.js @@ -372,7 +372,7 @@ pref("plugins.force.wmode", "opaque"); pref("browser.geolocation.warning.infoURL", "http://www.mozilla.com/%LOCALE%/firefox/geolocation/"); // base url for the wifi geolocation network provider -pref("geo.wifi.uri", "https://www.google.com/loc/json"); +pref("geo.wifi.uri", "https://maps.googleapis.com/maps/api/browserlocation/json"); // enable geo pref("geo.enabled", true); diff --git a/mobile/chrome/content/bindings/browser.js b/mobile/chrome/content/bindings/browser.js index 96fe2a135b74..ef82a2dd6bb8 100644 --- a/mobile/chrome/content/bindings/browser.js +++ b/mobile/chrome/content/bindings/browser.js @@ -624,6 +624,13 @@ let ContentScroll = { left: aEvent.x }); + // Send event only after painting to make sure content views in the parent process have + // been updated. + addEventListener("MozAfterPaint", function afterPaint() { + removeEventListener("MozAfterPaint", afterPaint, false); + sendAsyncMessage("Content:UpdateDisplayPort"); + }, false); + break; } } diff --git a/mobile/chrome/content/bindings/browser.xml b/mobile/chrome/content/bindings/browser.xml index cf172b6f64a8..810fac39566e 100644 --- a/mobile/chrome/content/bindings/browser.xml +++ b/mobile/chrome/content/bindings/browser.xml @@ -134,7 +134,7 @@ } break; - case "MozScrolledAreaChanged": + case "MozScrolledAreaChanged": { self._contentDocumentWidth = json.width; self._contentDocumentHeight = json.height; self._contentDocumentLeft = (json.left < 0) ? json.left : 0; @@ -143,6 +143,15 @@ let view = self.getRootView(); view.scrollBy(0, 0); break; + } + + case "Content:UpdateDisplayPort": { + // Recalculate whether the visible area is actually in bounds + let view = self.getRootView(); + view.scrollBy(0, 0); + view._updateCacheViewport(); + break; + } } } }) @@ -572,6 +581,7 @@ this.messageManager.addMessageListener("pagehide", this._messageListenerLocal); this.messageManager.addMessageListener("DOMPopupBlocked", this._messageListenerLocal); this.messageManager.addMessageListener("MozScrolledAreaChanged", this._messageListenerLocal); + this.messageManager.addMessageListener("Content:UpdateDisplayPort", this._messageListenerLocal); this._webProgress._init(); diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index c2cb9f6fea0f..7a4f06ce057a 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -387,12 +387,6 @@ var Browser = { let event = document.createEvent("Events"); event.initEvent("UIReady", true, false); window.dispatchEvent(event); - - // If we have an opener this was not the first window opened and will not - // receive an initial resize event. instead we fire the resize handler manually - // Bug 610834 - if (window.opener) - resizeHandler({ target: window }); }, _alertShown: function _alertShown() { diff --git a/mobile/chrome/content/common-ui.js b/mobile/chrome/content/common-ui.js index b417f60f90ec..6e09b293f845 100644 --- a/mobile/chrome/content/common-ui.js +++ b/mobile/chrome/content/common-ui.js @@ -1343,6 +1343,20 @@ var SelectionHelper = { handleEvent: function handleEvent(aEvent) { switch (aEvent.type) { + case "PanBegin": + window.removeEventListener("PanBegin", this, true); + window.addEventListener("PanFinished", this, true); + this._start.hidden = true; + this._end.hidden = true; + break; + case "PanFinished": + window.removeEventListener("PanFinished", this, true); + try { + this.popupState.target.messageManager.sendAsyncMessage("Browser:SelectionMeasure", {}); + } catch (e) { + Cu.reportError(e); + } + break case "TapDown": if (aEvent.target == this._start || aEvent.target == this._end) { this.target = aEvent.target; @@ -1350,14 +1364,20 @@ var SelectionHelper = { this.deltaY = (aEvent.clientY - this.target.top); window.addEventListener("TapMove", this, true); } else { - this.hide(aEvent); + window.addEventListener("PanBegin", this, true); + this.target = null; } break; case "TapUp": - window.removeEventListener("TapMove", this, true); - this.target = null; - this.deltaX = -1; - this.deltaY = -1; + if (this.target) { + window.removeEventListener("TapMove", this, true); + this.target = null; + this.deltaX = -1; + this.deltaY = -1; + } else { + window.removeEventListener("PanBegin", self, true); + self.hide(aEvent); + } break; case "TapMove": if (this.target) { @@ -1375,10 +1395,18 @@ var SelectionHelper = { } break; case "resize": - case "keypress": - case "URLChanged": case "SizeChanged": case "ZoomChanged": + { + try { + this.popupState.target.messageManager.sendAsyncMessage("Browser:SelectionMeasure", {}); + } catch (e) { + Cu.reportError(e); + } + break + } + case "URLChanged": + case "keypress": this.hide(aEvent); break; } diff --git a/mobile/chrome/content/content.js b/mobile/chrome/content/content.js index 2a23667bf643..771f53990bdb 100644 --- a/mobile/chrome/content/content.js +++ b/mobile/chrome/content/content.js @@ -1351,6 +1351,28 @@ var SelectionHandler = { addMessageListener("Browser:SelectionStart", this); addMessageListener("Browser:SelectionEnd", this); addMessageListener("Browser:SelectionMove", this); + addMessageListener("Browser:SelectionMeasure", this); + }, + + getCurrentWindowAndOffset: function(x, y, offset) { + let utils = Util.getWindowUtils(content); + let elem = utils.elementFromPoint(x, y, true, false); + while (elem && (elem instanceof HTMLIFrameElement || elem instanceof HTMLFrameElement)) { + // adjust client coordinates' origin to be top left of iframe viewport + let rect = elem.getBoundingClientRect(); + scrollOffset = ContentScroll.getScrollOffset(elem.ownerDocument.defaultView); + offset.x += rect.left; + x -= rect.left; + + offset.y += rect.top + scrollOffset.y; + y -= rect.top + scrollOffset.y; + utils = elem.contentDocument.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); + elem = utils.elementFromPoint(x, y, true, false); + } + if (!elem) + return; + + return { contentWindow: elem.ownerDocument.defaultView, offset: offset }; }, receiveMessage: function sh_receiveMessage(aMessage) { @@ -1366,24 +1388,7 @@ var SelectionHandler = { // if this is an iframe, dig down to find the document that was clicked let x = json.x - scrollOffset.x; let y = json.y - scrollOffset.y; - let offset = scrollOffset; - let elem = utils.elementFromPoint(x, y, true, false); - while (elem && (elem instanceof HTMLIFrameElement || elem instanceof HTMLFrameElement)) { - // adjust client coordinates' origin to be top left of iframe viewport - let rect = elem.getBoundingClientRect(); - scrollOffset = ContentScroll.getScrollOffset(elem.ownerDocument.defaultView); - offset.x += rect.left; - x -= rect.left; - - offset.y += rect.top + scrollOffset.y; - y -= rect.top + scrollOffset.y; - utils = elem.contentDocument.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); - elem = utils.elementFromPoint(x, y, true, false); - } - if (!elem) - return; - - let contentWindow = elem.ownerDocument.defaultView; + let { contentWindow: contentWindow, offset: offset } = this.getCurrentWindowAndOffset(x, y, scrollOffset); let currentDocShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); // Remove any previous selected or created ranges. Tapping anywhere on a @@ -1391,13 +1396,13 @@ var SelectionHandler = { let selection = contentWindow.getSelection(); selection.removeAllRanges(); - // Position the caret using a fake mouse click - utils.sendMouseEventToWindow("mousedown", x, y, 0, 1, 0, true); - utils.sendMouseEventToWindow("mouseup", x, y, 0, 1, 0, true); - - // Select the word nearest the caret try { + let caretPos = contentWindow.document.caretPositionFromPoint(json.x - scrollOffset.x, json.y - scrollOffset.y); let selcon = currentDocShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay).QueryInterface(Ci.nsISelectionController); + let sel = selcon.getSelection(1); + sel.collapse(caretPos.offsetNode, caretPos.offset); + + // Select the word nearest the caret selcon.wordMove(false, false); selcon.wordMove(true, true); } catch(e) { @@ -1438,7 +1443,9 @@ var SelectionHandler = { if (this.contentWindow) this.contentWindow.getSelection().removeAllRanges(); this.contentWindow = null; - } catch(e) {} + } catch(e) { + Cu.reportError(e); + } if (pointInSelection && this.selectedText.length) { let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper); @@ -1454,33 +1461,37 @@ var SelectionHandler = { if (!this.contentWindow) return; - // Hack to avoid setting focus in a textbox [Bugs 654352 & 667243] - let elemUnder = elementFromPoint(json.x - scrollOffset.x, json.y - scrollOffset.y); - if (elemUnder && elemUnder instanceof Ci.nsIDOMHTMLInputElement || elemUnder instanceof Ci.nsIDOMHTMLTextAreaElement) + let x = json.x - scrollOffset.x; + let y = json.y - scrollOffset.y; + + try { + let caretPos = this.contentWindow.document.caretPositionFromPoint(x, y); + if (caretPos.offsetNode == null || + caretPos.offsetNode instanceof Ci.nsIDOMHTMLInputElement || + caretPos.offsetNode instanceof Ci.nsIDOMHTMLTextAreaElement || + caretPos.offsetNode.ownerDocument.defaultView != this.contentWindow) + return; + + // Keep the cache in "client" coordinates + if (json.type == "end") + this.cache.end = { x: json.x, y: json.y }; + else + this.cache.start = { x: json.x, y: json.y }; + + let currentDocShell = this.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); + let selcon = currentDocShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay).QueryInterface(Ci.nsISelectionController); + let sel = selcon.getSelection(1); + if (json.type != "end") { + let focusOffset = sel.focusOffset; + let focusNode = sel.focusNode; + sel.collapse(caretPos.offsetNode, caretPos.offset); + sel.extend(focusNode, focusOffset); + } else { + sel.extend(caretPos.offsetNode, caretPos.offset); + } + } catch(e) { + Cu.reportError(e); return; - - // Limit the selection to the initial content window (don't leave or enter iframes) - if (elemUnder && elemUnder.ownerDocument.defaultView != this.contentWindow) - return; - - // Use fake mouse events to update the selection - if (json.type == "end") { - // Keep the cache in "client" coordinates, but translate for the mouse event - this.cache.end = { x: json.x, y: json.y }; - let end = { x: this.cache.end.x - scrollOffset.x, y: this.cache.end.y - scrollOffset.y }; - utils.sendMouseEventToWindow("mousedown", end.x, end.y, 0, 1, Ci.nsIDOMNSEvent.SHIFT_MASK, true); - utils.sendMouseEventToWindow("mouseup", end.x, end.y, 0, 1, Ci.nsIDOMNSEvent.SHIFT_MASK, true); - } else { - // Keep the cache in "client" coordinates, but translate for the mouse event - this.cache.start = { x: json.x, y: json.y }; - let start = { x: this.cache.start.x - scrollOffset.x, y: this.cache.start.y - scrollOffset.y }; - let end = { x: this.cache.end.x - scrollOffset.x, y: this.cache.end.y - scrollOffset.y }; - - utils.sendMouseEventToWindow("mousedown", start.x, start.y, 0, 0, 0, true); - utils.sendMouseEventToWindow("mouseup", start.x, start.y, 0, 0, 0, true); - - utils.sendMouseEventToWindow("mousedown", end.x, end.y, 0, 1, Ci.nsIDOMNSEvent.SHIFT_MASK, true); - utils.sendMouseEventToWindow("mouseup", end.x, end.y, 0, 1, Ci.nsIDOMNSEvent.SHIFT_MASK, true); } // Cache the selected text since the selection might be gone by the time we get the "end" message @@ -1491,6 +1502,26 @@ var SelectionHandler = { let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange); this.cache.rect = this._extractFromRange(range, this.cache.offset).rect; break; + case "Browser:SelectionMeasure": { + let selection = this.contentWindow.getSelection(); + let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange); + if (!range) + return; + + // Cache the selected text since the selection might be gone by the time we get the "end" message + this.selectedText = selection.toString().trim(); + + // If the range didn't have any text, let's bail + if (!this.selectedText.length) { + selection.removeAllRanges(); + return; + } + + this.cache = this._extractFromRange(range, this.cache.offset); + + sendAsyncMessage("Browser:SelectionRange", this.cache); + break; + } } }, diff --git a/mobile/installer/debian/fennec.aegis.in b/mobile/installer/debian/fennec.aegis.in index e98f5640dc19..04cfa2d951ab 100644 --- a/mobile/installer/debian/fennec.aegis.in +++ b/mobile/installer/debian/fennec.aegis.in @@ -2,6 +2,9 @@ + + + diff --git a/modules/libreg/src/Makefile.in b/modules/libreg/src/Makefile.in index f5f27b8c9249..58e5132fae28 100644 --- a/modules/libreg/src/Makefile.in +++ b/modules/libreg/src/Makefile.in @@ -68,11 +68,6 @@ SDK_LIBRARY = $(LIBRARY) include $(topsrcdir)/config/config.mk DEFINES += -DUSE_BUFFERED_REGISTRY_IO -# Memory mapped files are not supported under QNX, Neutrino, HP-UX and BeOS -#ifeq (,$(filter BeOS HP-UX QNX,$(OS_ARCH))) -#CSRCS += mmapio.c -#DEFINES += -DUSE_MMAP_REGISTRY_IO -#endif include $(topsrcdir)/config/rules.mk diff --git a/modules/libreg/src/mmapio.c b/modules/libreg/src/mmapio.c deleted file mode 100644 index fd9d0ca6fd17..000000000000 --- a/modules/libreg/src/mmapio.c +++ /dev/null @@ -1,213 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator. - * - * The Initial Developer of the Original Code is - * James L. Nance. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * James L. Nance - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include -#include "mmapio.h" -#include "prmem.h" -#include "prlog.h" - -struct MmioFileStruct -{ - PRFileDesc *fd; - PRFileMap *fileMap; - PRUint32 fsize; /* The size of the file */ - PRUint32 msize; /* The size of the mmap()ed area */ - PRInt32 pos; /* Our logical position for doing I/O */ - char *addr; /* The base address of our mapping */ - PRBool needSeek; /* Do we need to seek to pos before doing a write() */ -}; - -PRStatus mmio_FileSeek(MmioFile *mmio, PRInt32 offset, PRSeekWhence whence) -{ - mmio->needSeek = PR_TRUE; - - switch(whence) { - case PR_SEEK_SET: - mmio->pos = offset; - break; - case PR_SEEK_END: - mmio->pos = mmio->fsize + offset; - break; - case PR_SEEK_CUR: - mmio->pos = mmio->pos + offset; - break; - default: - return PR_FAILURE; - } - - if(mmio->pos<0) { - mmio->pos = 0; - } - - return PR_SUCCESS; -} - -PRInt32 mmio_FileRead(MmioFile *mmio, char *dest, PRInt32 count) -{ - static PRFileMapProtect prot = PR_PROT_READONLY; - static PRInt64 fsize_l; - - /* First see if we are going to try and read past the end of the file - * and shorten count if we are. - */ - if(mmio->pos+count > mmio->fsize) { - count = mmio->fsize - mmio->pos; - } - - if(count<1) { - return 0; - } - - /* Check to see if we need to remap for this read */ - if(mmio->pos+count > mmio->msize) { - if(mmio->addr && mmio->msize) { - PR_ASSERT(mmio->fileMap); - PR_MemUnmap(mmio->addr, mmio->msize); - PR_CloseFileMap(mmio->fileMap); - mmio->addr = NULL; - mmio->msize = 0; - } - - LL_UI2L(fsize_l, mmio->fsize); - mmio->fileMap = PR_CreateFileMap(mmio->fd, fsize_l, prot); - - if(!mmio->fileMap) { - return -1; - } - - mmio->addr = PR_MemMap(mmio->fileMap, 0, fsize_l); - - if(!mmio->addr) { - return -1; - } - - mmio->msize = mmio->fsize; - } - - memcpy(dest, mmio->addr+mmio->pos, count); - - mmio->pos += count; - mmio->needSeek = PR_TRUE; - - return count; -} - -PRInt32 mmio_FileWrite(MmioFile *mmio, const char *src, PRInt32 count) -{ - PRInt32 wcode; - - if(mmio->needSeek) { - PR_Seek(mmio->fd, mmio->pos, PR_SEEK_SET); - mmio->needSeek = PR_FALSE; - } - - /* If this system does not keep mmap() and write() synchronized, we can - ** force it to by doing an munmap() when we do a write. This will - ** obviously slow things down but fortunatly we do not do that many - ** writes from within mozilla. Platforms which need this may want to - ** use the new USE_BUFFERED_REGISTRY_IO code instead of this code though. - */ -#if MMAP_MISSES_WRITES - if(mmio->addr && mmio->msize) { - PR_ASSERT(mmio->fileMap); - PR_MemUnmap(mmio->addr, mmio->msize); - PR_CloseFileMap(mmio->fileMap); - mmio->addr = NULL; - mmio->msize = 0; - } -#endif - - wcode = PR_Write(mmio->fd, src, count); - - if(wcode>0) { - mmio->pos += wcode; - if(mmio->pos>mmio->fsize) { - mmio->fsize=mmio->pos; - } - } - - return wcode; -} - -PRInt32 mmio_FileTell(MmioFile *mmio) -{ - return mmio->pos; -} - -PRStatus mmio_FileClose(MmioFile *mmio) -{ - if(mmio->addr && mmio->msize) { - PR_ASSERT(mmio->fileMap); - PR_MemUnmap(mmio->addr, mmio->msize); - PR_CloseFileMap(mmio->fileMap); - } - - PR_Close(mmio->fd); - - memset(mmio, 0, sizeof(*mmio)); /* Catch people who try to keep using it */ - - PR_Free(mmio); - - return PR_SUCCESS; -} - -MmioFile *mmio_FileOpen(char *path, PRIntn flags, PRIntn mode) -{ - PRFileDesc *fd = PR_Open(path, flags, mode); - PRFileInfo info; - MmioFile *mmio; - - if(!fd) { - return NULL; - } - - mmio = PR_MALLOC(sizeof(MmioFile)); - - if(!mmio || PR_FAILURE==PR_GetOpenFileInfo(fd, &info)) { - PR_Close(fd); - return NULL; - } - - mmio->fd = fd; - mmio->fileMap = NULL; - mmio->fsize = info.size; - mmio->msize = 0; - mmio->pos = 0; - mmio->addr = NULL; - mmio->needSeek = PR_FALSE; - - return mmio; -} diff --git a/modules/libreg/src/vr_stubs.h b/modules/libreg/src/vr_stubs.h index 50856ad1330a..f6eb75507ef8 100644 --- a/modules/libreg/src/vr_stubs.h +++ b/modules/libreg/src/vr_stubs.h @@ -137,26 +137,7 @@ typedef FILE * XP_File; /* Alternate fileI/O function mappings */ /*-------------------------------------*/ -#if USE_MMAP_REGISTRY_IO - /*-----------------------------------------------*/ - /* NSPR mememory-mapped I/O (write through) */ - /* unfortunately this isn't supported on the Mac */ - /*-----------------------------------------------*/ -#define USE_NSPR_MODES - -#include "mmapio.h" -#define XP_FileSeek(file,offset,whence) mmio_FileSeek((file),(offset),(whence)) -#define XP_FileRead(dest,count,file) mmio_FileRead((file), (dest), (count)) -#define XP_FileWrite(src,count,file) mmio_FileWrite((file), (src), (count)) -#define XP_FileTell(file) mmio_FileTell(file) -#define XP_FileClose(file) mmio_FileClose(file) -#define XP_FileOpen(path, mode) mmio_FileOpen((path), mode ) -#define XP_FileFlush(file) ((void)1) -#define XP_FileSetBufferSize(file, bufsize) (-1) - -typedef MmioFile* XP_File; - -#elif USE_BUFFERED_REGISTRY_IO +#if USE_BUFFERED_REGISTRY_IO /*-----------------------------------------------*/ /* home-grown XP buffering */ /* writes are buffered too so use flush! */ diff --git a/netwerk/build/Makefile.in b/netwerk/build/Makefile.in index a48f05221c50..2843a0efcca0 100644 --- a/netwerk/build/Makefile.in +++ b/netwerk/build/Makefile.in @@ -140,9 +140,6 @@ LOCAL_INCLUDES += -I$(srcdir)/../wifi endif - -DEFINES += -DNECKO_OFFLINE_CACHE - include $(topsrcdir)/config/config.mk include $(topsrcdir)/ipc/chromium/chromium-config.mk include $(topsrcdir)/config/rules.mk diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index c0cb696d1d6f..f74fbd3e6fee 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -215,11 +215,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNestedAboutURI) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutCacheEntry) #endif -#ifdef NECKO_OFFLINE_CACHE NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheDevice, nsOfflineCacheDevice::GetInstance) NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCacheNamespace) NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCache) -#endif #ifdef NECKO_PROTOCOL_file // file @@ -769,11 +767,9 @@ NS_DEFINE_NAMED_CID(NS_SOCKSSOCKETPROVIDER_CID); NS_DEFINE_NAMED_CID(NS_SOCKS4SOCKETPROVIDER_CID); NS_DEFINE_NAMED_CID(NS_UDPSOCKETPROVIDER_CID); NS_DEFINE_NAMED_CID(NS_CACHESERVICE_CID); -#ifdef NECKO_OFFLINE_CACHE NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHESERVICE_CID); NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHENAMESPACE_CID); NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHE_CID); -#endif #ifdef NECKO_COOKIES NS_DEFINE_NAMED_CID(NS_COOKIEMANAGER_CID); NS_DEFINE_NAMED_CID(NS_COOKIESERVICE_CID); @@ -902,11 +898,9 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = { { &kNS_SOCKS4SOCKETPROVIDER_CID, false, NULL, nsSOCKSSocketProvider::CreateV4 }, { &kNS_UDPSOCKETPROVIDER_CID, false, NULL, nsUDPSocketProviderConstructor }, { &kNS_CACHESERVICE_CID, false, NULL, nsCacheService::Create }, -#ifdef NECKO_OFFLINE_CACHE { &kNS_APPLICATIONCACHESERVICE_CID, false, NULL, nsOfflineCacheDeviceConstructor }, { &kNS_APPLICATIONCACHENAMESPACE_CID, false, NULL, nsApplicationCacheNamespaceConstructor }, { &kNS_APPLICATIONCACHE_CID, false, NULL, nsApplicationCacheConstructor }, -#endif #ifdef NECKO_COOKIES { &kNS_COOKIEMANAGER_CID, false, NULL, nsICookieServiceConstructor }, { &kNS_COOKIESERVICE_CID, false, NULL, nsICookieServiceConstructor }, @@ -1044,11 +1038,9 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = { { NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks4", &kNS_SOCKS4SOCKETPROVIDER_CID }, { NS_NETWORK_SOCKET_CONTRACTID_PREFIX "udp", &kNS_UDPSOCKETPROVIDER_CID }, { NS_CACHESERVICE_CONTRACTID, &kNS_CACHESERVICE_CID }, -#ifdef NECKO_OFFLINE_CACHE { NS_APPLICATIONCACHESERVICE_CONTRACTID, &kNS_APPLICATIONCACHESERVICE_CID }, { NS_APPLICATIONCACHENAMESPACE_CONTRACTID, &kNS_APPLICATIONCACHENAMESPACE_CID }, { NS_APPLICATIONCACHE_CONTRACTID, &kNS_APPLICATIONCACHE_CID }, -#endif #ifdef NECKO_COOKIES { NS_COOKIEMANAGER_CONTRACTID, &kNS_COOKIEMANAGER_CID }, { NS_COOKIESERVICE_CONTRACTID, &kNS_COOKIESERVICE_CID }, diff --git a/netwerk/cache/Makefile.in b/netwerk/cache/Makefile.in index 0f5e5d18ed70..929e5e9dd19e 100644 --- a/netwerk/cache/Makefile.in +++ b/netwerk/cache/Makefile.in @@ -72,22 +72,15 @@ CPPSRCS = \ nsCacheService.cpp \ nsCacheSession.cpp \ nsMemoryCacheDevice.cpp \ - nsDiskCacheDeviceSQL.cpp \ - $(NULL) - -ifdef NECKO_DISK_CACHE -CPPSRCS += \ nsDiskCacheBinding.cpp \ nsDiskCacheBlockFile.cpp \ nsDiskCacheDevice.cpp \ + nsDiskCacheDeviceSQL.cpp \ nsDiskCacheEntry.cpp \ nsDiskCacheMap.cpp \ nsDiskCacheStreams.cpp \ nsDeleteDir.cpp \ $(NULL) -endif - -DEFINES += -DNECKO_OFFLINE_CACHE LOCAL_INCLUDES = \ -I$(srcdir)/../base/src \ diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 336d77e7763e..d7fb2743c765 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -52,10 +52,7 @@ #include "nsMemoryCacheDevice.h" #include "nsICacheVisitor.h" #include "nsDiskCacheDevice.h" - -#ifdef NECKO_OFFLINE_CACHE #include "nsDiskCacheDeviceSQL.h" -#endif #include "nsIMemoryReporter.h" #include "nsIObserverService.h" @@ -112,18 +109,14 @@ static const char * observerList[] = { NS_PRIVATE_BROWSING_SWITCH_TOPIC }; static const char * prefList[] = { -#ifdef NECKO_DISK_CACHE DISK_CACHE_ENABLE_PREF, DISK_CACHE_SMART_SIZE_ENABLED_PREF, DISK_CACHE_CAPACITY_PREF, DISK_CACHE_DIR_PREF, DISK_CACHE_MAX_ENTRY_SIZE_PREF, -#endif -#ifdef NECKO_OFFLINE_CACHE OFFLINE_CACHE_ENABLE_PREF, OFFLINE_CACHE_CAPACITY_PREF, OFFLINE_CACHE_DIR_PREF, -#endif MEMORY_CACHE_ENABLE_PREF, MEMORY_CACHE_CAPACITY_PREF, MEMORY_CACHE_MAX_ENTRY_SIZE_PREF @@ -410,7 +403,6 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, if (NS_FAILED(rv)) return rv; -#ifdef NECKO_DISK_CACHE // which preference changed? if (!strcmp(DISK_CACHE_ENABLE_PREF, data.get())) { @@ -478,10 +470,8 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, // XXX notification that the pref change won't take effect until // XXX the next time the profile changes (browser launch) #endif - } else -#endif // !NECKO_DISK_CACHE + } else -#ifdef NECKO_OFFLINE_CACHE // which preference changed? if (!strcmp(OFFLINE_CACHE_ENABLE_PREF, data.get())) { @@ -507,7 +497,6 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, // XXX the next time the profile changes (browser launch) #endif } else -#endif // !NECKO_OFFLINE_CACHE if (!strcmp(MEMORY_CACHE_ENABLE_PREF, data.get())) { @@ -539,39 +528,29 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, nsCacheService::OnEnterExitPrivateBrowsing(); -#ifdef NECKO_DISK_CACHE mDiskCacheEnabled = PR_FALSE; nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled()); -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE mOfflineCacheEnabled = PR_FALSE; nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled()); -#endif // !NECKO_OFFLINE_CACHE } else if (!strcmp(NS_PRIVATE_BROWSING_LEAVE, data.get())) { mInPrivateBrowsing = PR_FALSE; nsCacheService::OnEnterExitPrivateBrowsing(); -#if defined(NECKO_DISK_CACHE) || defined(NECKO_OFFLINE_CACHE) nsCOMPtr branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; -#endif // !NECKO_DISK_CACHE && !NECKO_OFFLINE_CACHE -#ifdef NECKO_DISK_CACHE mDiskCacheEnabled = PR_TRUE; // by default enabled (void) branch->GetBoolPref(DISK_CACHE_ENABLE_PREF, &mDiskCacheEnabled); nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled()); -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE mOfflineCacheEnabled = PR_TRUE; // by default enabled (void) branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF, &mOfflineCacheEnabled); nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled()); -#endif // !NECKO_OFFLINE_CACHE } } @@ -674,7 +653,6 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) { nsresult rv = NS_OK; -#ifdef NECKO_DISK_CACHE // read disk cache device prefs if (!mInPrivateBrowsing) { mDiskCacheEnabled = PR_TRUE; // presume disk cache is enabled @@ -770,9 +748,7 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) NS_WARNING("Failed setting first_run pref in ReadPrefs."); } } -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE // read offline cache device prefs if (!mInPrivateBrowsing) { mOfflineCacheEnabled = PR_TRUE; // presume offline cache is enabled @@ -815,8 +791,7 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) if (directory) mOfflineCacheParentDirectory = do_QueryInterface(directory, &rv); } -#endif // !NECKO_OFFLINE_CACHE - + // read memory cache device prefs (void) branch->GetBoolPref(MEMORY_CACHE_ENABLE_PREF, &mMemoryCacheEnabled); @@ -1121,16 +1096,12 @@ nsCacheService::Shutdown() delete mMemoryDevice; mMemoryDevice = nsnull; -#ifdef NECKO_DISK_CACHE delete mDiskDevice; mDiskDevice = nsnull; -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE NS_IF_RELEASE(mOfflineDevice); -#endif // !NECKO_OFFLINE_CACHE -#if defined(NECKO_DISK_CACHE) && defined(PR_LOGGING) +#ifdef PR_LOGGING LogCacheStatistics(); #endif @@ -1221,7 +1192,6 @@ nsCacheService::EvictEntriesForClient(const char * clientID, nsCacheServiceAutoLock lock; nsresult res = NS_OK; -#ifdef NECKO_DISK_CACHE if (storagePolicy == nsICache::STORE_ANYWHERE || storagePolicy == nsICache::STORE_ON_DISK) { @@ -1234,9 +1204,7 @@ nsCacheService::EvictEntriesForClient(const char * clientID, if (NS_FAILED(rv)) res = rv; } } -#endif // ! NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE // Only clear the offline cache if it has been specifically asked for. if (storagePolicy == nsICache::STORE_OFFLINE) { if (mEnableOfflineDevice) { @@ -1248,7 +1216,6 @@ nsCacheService::EvictEntriesForClient(const char * clientID, if (NS_FAILED(rv)) res = rv; } } -#endif // ! NECKO_OFFLINE_CACHE if (storagePolicy == nsICache::STORE_ANYWHERE || storagePolicy == nsICache::STORE_IN_MEMORY) { @@ -1318,7 +1285,6 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) if (NS_FAILED(rv)) return rv; } -#ifdef NECKO_DISK_CACHE if (mEnableDiskDevice) { if (!mDiskDevice) { rv = CreateDiskDevice(); @@ -1327,9 +1293,7 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) rv = mDiskDevice->Visit(visitor); if (NS_FAILED(rv)) return rv; } -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE if (mEnableOfflineDevice) { if (!mOfflineDevice) { rv = CreateOfflineDevice(); @@ -1338,7 +1302,6 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) rv = mOfflineDevice->Visit(visitor); if (NS_FAILED(rv)) return rv; } -#endif // !NECKO_OFFLINE_CACHE // XXX notify any shutdown process that visitation is complete for THIS visitor. // XXX keep queue of visitors @@ -1369,7 +1332,6 @@ NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget) nsresult nsCacheService::CreateDiskDevice() { -#ifdef NECKO_DISK_CACHE if (!mInitialized) return NS_ERROR_NOT_AVAILABLE; if (!mEnableDiskDevice) return NS_ERROR_NOT_AVAILABLE; if (mDiskDevice) return NS_OK; @@ -1395,16 +1357,11 @@ nsCacheService::CreateDiskDevice() mDiskDevice = nsnull; } return rv; -#else // !NECKO_DISK_CACHE - NS_NOTREACHED("nsCacheService::CreateDiskDevice"); - return NS_ERROR_NOT_IMPLEMENTED; -#endif } nsresult nsCacheService::CreateOfflineDevice() { -#ifdef NECKO_OFFLINE_CACHE CACHE_LOG_ALWAYS(("Creating offline device")); if (!mInitialized) return NS_ERROR_NOT_AVAILABLE; @@ -1430,10 +1387,6 @@ nsCacheService::CreateOfflineDevice() NS_RELEASE(mOfflineDevice); } return rv; -#else // !NECKO_DISK_CACHE - NS_NOTREACHED("nsCacheService::CreateOfflineDevice"); - return NS_ERROR_NOT_IMPLEMENTED; -#endif } nsresult @@ -1820,7 +1773,6 @@ nsCacheService::SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, if (!entry && ((policy == nsICache::STORE_ANYWHERE) || (policy == nsICache::STORE_ON_DISK))) { -#ifdef NECKO_DISK_CACHE if (mEnableDiskDevice) { if (!mDiskDevice) { nsresult rv = CreateDiskDevice(); @@ -1830,14 +1782,12 @@ nsCacheService::SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, entry = mDiskDevice->FindEntry(key, collision); } -#endif // !NECKO_DISK_CACHE } if (!entry && (policy == nsICache::STORE_OFFLINE || (policy == nsICache::STORE_ANYWHERE && gIOService->IsOffline()))) { -#ifdef NECKO_OFFLINE_CACHE if (mEnableOfflineDevice) { if (!mOfflineDevice) { nsresult rv = CreateOfflineDevice(); @@ -1847,7 +1797,6 @@ nsCacheService::SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, entry = mOfflineDevice->FindEntry(key, collision); } -#endif // !NECKO_OFFLINE_CACHE } return entry; @@ -1863,7 +1812,6 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry) if (device || entry->IsDoomed()) return device; PRInt64 predictedDataSize = entry->PredictedDataSize(); -#ifdef NECKO_DISK_CACHE if (entry->IsStreamData() && entry->IsAllowedOnDisk() && mEnableDiskDevice) { // this is the default if (!mDiskDevice) { @@ -1887,7 +1835,6 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry) device = mDiskDevice; } } -#endif // !NECKO_DISK_CACHE // if we can't use mDiskDevice, try mMemoryDevice if (!device && mEnableMemoryDevice && entry->IsAllowedInMemory()) { @@ -1911,7 +1858,6 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry) } } -#ifdef NECKO_OFFLINE_CACHE if (!device && entry->IsStreamData() && entry->IsAllowedOffline() && mEnableOfflineDevice) { if (!mOfflineDevice) { @@ -1926,7 +1872,6 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry) device = mOfflineDevice; } } -#endif // ! NECKO_OFFLINE_CACHE if (device) entry->SetCacheDevice(device); @@ -2004,7 +1949,6 @@ nsCacheService::OnProfileShutdown(PRBool cleanse) // proceeding with destructive actions (bug #620660) (void) SyncWithCacheIOThread(); -#ifdef NECKO_DISK_CACHE if (gService->mDiskDevice && gService->mEnableDiskDevice) { if (cleanse) gService->mDiskDevice->EvictEntries(nsnull); @@ -2012,9 +1956,7 @@ nsCacheService::OnProfileShutdown(PRBool cleanse) gService->mDiskDevice->Shutdown(); } gService->mEnableDiskDevice = PR_FALSE; -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE if (gService->mOfflineDevice && gService->mEnableOfflineDevice) { if (cleanse) gService->mOfflineDevice->EvictEntries(nsnull); @@ -2022,7 +1964,6 @@ nsCacheService::OnProfileShutdown(PRBool cleanse) gService->mOfflineDevice->Shutdown(); } gService->mEnableOfflineDevice = PR_FALSE; -#endif // !NECKO_OFFLINE_CACHE if (gService->mMemoryDevice) { // clear memory cache @@ -2045,7 +1986,6 @@ nsCacheService::OnProfileChanged() gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled(); gService->mEnableMemoryDevice = gService->mObserver->MemoryCacheEnabled(); -#ifdef NECKO_DISK_CACHE if (gService->mDiskDevice) { gService->mDiskDevice->SetCacheParentDirectory(gService->mObserver->DiskCacheParentDirectory()); gService->mDiskDevice->SetCapacity(gService->mObserver->DiskCacheCapacity()); @@ -2058,9 +1998,7 @@ nsCacheService::OnProfileChanged() // XXX delete mDiskDevice? } } -#endif // !NECKO_DISK_CACHE -#ifdef NECKO_OFFLINE_CACHE if (gService->mOfflineDevice) { gService->mOfflineDevice->SetCacheParentDirectory(gService->mObserver->OfflineCacheParentDirectory()); gService->mOfflineDevice->SetCapacity(gService->mObserver->OfflineCacheCapacity()); @@ -2073,8 +2011,7 @@ nsCacheService::OnProfileChanged() // XXX delete mOfflineDevice? } } -#endif // !NECKO_OFFLINE_CACHE - + // If memoryDevice exists, reset its size to the new profile if (gService->mMemoryDevice) { if (gService->mEnableMemoryDevice) { @@ -2108,12 +2045,10 @@ nsCacheService::SetDiskCacheCapacity(PRInt32 capacity) if (!gService) return; nsCacheServiceAutoLock lock; -#ifdef NECKO_DISK_CACHE if (gService->mDiskDevice) { gService->mDiskDevice->SetCapacity(capacity); } -#endif // !NECKO_DISK_CACHE - + if (gService->mObserver) gService->mEnableDiskDevice = gService->mObserver->DiskCacheEnabled(); } @@ -2124,11 +2059,9 @@ nsCacheService::SetDiskCacheMaxEntrySize(PRInt32 maxSize) if (!gService) return; nsCacheServiceAutoLock lock; -#ifdef NECKO_DISK_CACHE if (gService->mDiskDevice) { gService->mDiskDevice->SetMaxEntrySize(maxSize); } -#endif // !NECKO_DISK_CACHE } void @@ -2156,11 +2089,9 @@ nsCacheService::SetOfflineCacheCapacity(PRInt32 capacity) if (!gService) return; nsCacheServiceAutoLock lock; -#ifdef NECKO_OFFLINE_CACHE if (gService->mOfflineDevice) { gService->mOfflineDevice->SetCapacity(capacity); } -#endif // !NECKO_OFFLINE_CACHE gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled(); } diff --git a/netwerk/necko-config.h.in b/netwerk/necko-config.h.in index 0a3cd20c5daf..dd8cb21ab253 100644 --- a/netwerk/necko-config.h.in +++ b/netwerk/necko-config.h.in @@ -37,8 +37,6 @@ #ifndef _NECKO_CONFIG_H_ #define _NECKO_CONFIG_H_ -#undef NECKO_DISK_CACHE - #undef NECKO_COOKIES #undef NECKO_WIFI diff --git a/other-licenses/android/APKOpen.cpp b/other-licenses/android/APKOpen.cpp index 14de579f4f38..a13c7049fbdd 100644 --- a/other-licenses/android/APKOpen.cpp +++ b/other-licenses/android/APKOpen.cpp @@ -233,6 +233,7 @@ Java_org_mozilla_gecko_GeckoAppShell_ ## name(JNIEnv *jenv, jclass jc, type1 one SHELL_WRAPPER0(nativeInit) SHELL_WRAPPER1(nativeRun, jstring) SHELL_WRAPPER1(notifyGeckoOfEvent, jobject) +SHELL_WRAPPER0(processNextNativeEvent) SHELL_WRAPPER1(setSurfaceView, jobject) SHELL_WRAPPER0(onResume) SHELL_WRAPPER0(onLowMemory) @@ -676,6 +677,7 @@ loadLibs(const char *apkName) GETFUNC(nativeInit); GETFUNC(nativeRun); GETFUNC(notifyGeckoOfEvent); + GETFUNC(processNextNativeEvent); GETFUNC(setSurfaceView); GETFUNC(onResume); GETFUNC(onLowMemory); diff --git a/security/manager/pki/resources/content/viewCertDetails.js b/security/manager/pki/resources/content/viewCertDetails.js index 99d61bf2c374..1740befb5660 100644 --- a/security/manager/pki/resources/content/viewCertDetails.js +++ b/security/manager/pki/resources/content/viewCertDetails.js @@ -259,7 +259,7 @@ function DisplayVerificationData(cert, result) verifystr = bundle.GetStringFromName('certNotVerified_Unknown'); } var verified=document.getElementById('verified'); - verified.setAttribute("value", verifystr); + verified.textContent = verifystr; if (count > 0) { var verifyInfoBox = document.getElementById('verify_info_box'); for (var i=0; i profDir; - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, - getter_AddRefs(profDir)); + (void)NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profDir)); nsCOMPtr sqlite_file = do_QueryInterface(profDir); sqlite_file->Append(NS_LITERAL_STRING("places.sqlite")); PRUint32 perms = 0; diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 5f0ccedb6683..602a3337812e 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -2166,10 +2166,6 @@ XPCOMUtils.defineLazyGetter(PlacesUtils, "ghistory2", function() { return PlacesUtils.history.QueryInterface(Ci.nsIGlobalHistory2); }); -XPCOMUtils.defineLazyGetter(PlacesUtils, "ghistory3", function() { - return PlacesUtils.history.QueryInterface(Ci.nsIGlobalHistory3); -}); - XPCOMUtils.defineLazyServiceGetter(PlacesUtils, "favicons", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"); diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 8059fa65676c..1c4ab49379c8 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -212,8 +212,7 @@ NS_IMPL_CLASSINFO(nsNavHistory, NULL, nsIClassInfo::SINGLETON, NS_NAVHISTORYSERVICE_CID) NS_INTERFACE_MAP_BEGIN(nsNavHistory) NS_INTERFACE_MAP_ENTRY(nsINavHistoryService) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIGlobalHistory2, nsIGlobalHistory3) - NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory3) + NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory2) NS_INTERFACE_MAP_ENTRY(nsIDownloadHistory) NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory) NS_INTERFACE_MAP_ENTRY(nsIObserver) @@ -227,10 +226,9 @@ NS_INTERFACE_MAP_BEGIN(nsNavHistory) NS_INTERFACE_MAP_END // We don't care about flattening everything -NS_IMPL_CI_INTERFACE_GETTER5( +NS_IMPL_CI_INTERFACE_GETTER4( nsNavHistory , nsINavHistoryService -, nsIGlobalHistory3 , nsIGlobalHistory2 , nsIDownloadHistory , nsIBrowserHistory @@ -471,8 +469,6 @@ nsNavHistory::Init() NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE), NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mRecentRedirects.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); // Embed visits hash table. NS_ENSURE_TRUE(mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE), @@ -2726,9 +2722,8 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI, // Normally docshell sends the link visited observer notification for us (this // will tell all the documents to update their visited link coloring). - // However, for redirects (since we implement nsIGlobalHistory3) and downloads - // (since we implement nsIDownloadHistory) this will not happen and we need to - // send it ourselves. + // However, for redirects and downloads (since we implement nsIDownloadHistory) + // this will not happen and we need to send it ourselves. if (newItem && (aIsRedirect || aTransitionType == TRANSITION_DOWNLOAD)) { nsCOMPtr obsService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID); @@ -4839,11 +4834,7 @@ nsNavHistory::AddURIInternal(nsIURI* aURI, PRTime aTime, PRBool aRedirect, // (like referring visit ID and typed/bookmarked state). // // This function walks up the referring chain and recursively calls itself, -// each time calling InternalAdd to create a new history entry. (When we -// get notified of redirects, we don't actually add any history entries, just -// save them in mRecentRedirects. This function will add all of them for a -// given destination page when that page is actually visited.) -// See GetRedirectFor for more information about how redirects work. +// each time calling InternalAdd to create a new history entry. nsresult nsNavHistory::AddVisitChain(nsIURI* aURI, @@ -4869,52 +4860,10 @@ nsNavHistory::AddVisitChain(nsIURI* aURI, PRBool isEmbedVisit = !aToplevel && !CheckIsRecentEvent(&mRecentLink, spec); - // Check if this visit came from a redirect. PRUint32 transitionType = 0; - PRTime redirectTime = 0; - nsCAutoString redirectSourceUrl; - if (GetRedirectFor(spec, redirectSourceUrl, &redirectTime, &transitionType)) { - // redirectSourceUrl redirected to aURL, at redirectTime, with - // a transitionType redirect. - nsCOMPtr redirectSourceURI; - rv = NS_NewURI(getter_AddRefs(redirectSourceURI), redirectSourceUrl); - NS_ENSURE_SUCCESS(rv, rv); - // Don't add a new visit if a page redirects to itself. - PRBool redirectIsSame; - if (NS_SUCCEEDED(aURI->Equals(redirectSourceURI, &redirectIsSame)) && - redirectIsSame) - return NS_OK; - - // Recusively call addVisitChain to walk up the chain till the first - // not-redirected URI. - // Ensure that the sources have a visit time smaller than aTime, otherwise - // visits would end up incorrectly ordered. - PRTime sourceTime = NS_MIN(redirectTime, aTime - 1); - PRInt64 sourceVisitId = 0; - rv = AddVisitChain(redirectSourceURI, sourceTime, aToplevel, - PR_TRUE, // Is a redirect. - aReferrerURI, // This one is the originating source. - &sourceVisitId, // Get back the visit id of the source. - aSessionID); - NS_ENSURE_SUCCESS(rv, rv); - - // All the visits for preceding pages in the redirects chain have been - // added, now add the visit to aURI. - if (isEmbedVisit) - transitionType = nsINavHistoryService::TRANSITION_EMBED; - else if (!aToplevel) - transitionType = nsINavHistoryService::TRANSITION_FRAMED_LINK; - - // This page is result of a redirect, save the source page in from_visit, - // to be able to walk up the chain. - // See bug 411966 and bug 428690 for details. - // TODO: Add a closure table with a chain id to easily reconstruct chains - // without having to recurse through the table. See bug 468710. - fromVisitURI = redirectSourceURI; - } - else if (aReferrerURI) { - // This page does not come from a redirect and had a referrer. + if (aReferrerURI) { + // This page had a referrer. // Check if the referrer has a previous visit. PRTime lastVisitTime; @@ -5082,107 +5031,6 @@ nsNavHistory::GetPageTitle(nsIURI* aURI, nsAString& aTitle) return NS_OK; } -// nsNavHistory::GetURIGeckoFlags -// -// FIXME: should we try to use annotations for this stuff? - -NS_IMETHODIMP -nsNavHistory::GetURIGeckoFlags(nsIURI* aURI, PRUint32* aResult) -{ - NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); - NS_ENSURE_ARG(aURI); - NS_ENSURE_ARG_POINTER(aResult); - - return NS_ERROR_NOT_IMPLEMENTED; -} - - -// nsNavHistory::SetURIGeckoFlags -// -// FIXME: should we try to use annotations for this stuff? - -NS_IMETHODIMP -nsNavHistory::SetURIGeckoFlags(nsIURI* aURI, PRUint32 aFlags) -{ - NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); - NS_ENSURE_ARG(aURI); - - return NS_ERROR_NOT_IMPLEMENTED; -} - -// nsIGlobalHistory3 *********************************************************** - -// nsNavHistory::AddDocumentRedirect -// -// This adds a redirect mapping from the destination of the redirect to the -// source, time, and type. This mapping is used by GetRedirectFor when we -// get a page added to reconstruct the redirects that happened when a page -// is visited. See GetRedirectFor for more information - -// this is the expiration callback function that deletes stale entries -PLDHashOperator nsNavHistory::ExpireNonrecentRedirects( - nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg) -{ - PRInt64* threshold = reinterpret_cast(aUserArg); - if (aData.mTimeCreated < *threshold) - return PL_DHASH_REMOVE; - return PL_DHASH_NEXT; -} - -NS_IMETHODIMP -nsNavHistory::AddDocumentRedirect(nsIChannel *aOldChannel, - nsIChannel *aNewChannel, - PRInt32 aFlags, - PRBool aToplevel) -{ - NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); - NS_ENSURE_ARG(aOldChannel); - NS_ENSURE_ARG(aNewChannel); - - // Ignore internal redirects. - // These redirects are not initiated by the remote server, but specific to the - // channel implementation, so they are ignored. - if (aFlags & nsIChannelEventSink::REDIRECT_INTERNAL) - return NS_OK; - - nsresult rv; - nsCOMPtr oldURI, newURI; - rv = aOldChannel->GetURI(getter_AddRefs(oldURI)); - NS_ENSURE_SUCCESS(rv, rv); - rv = aNewChannel->GetURI(getter_AddRefs(newURI)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCString oldSpec, newSpec; - rv = oldURI->GetSpec(oldSpec); - NS_ENSURE_SUCCESS(rv, rv); - rv = newURI->GetSpec(newSpec); - NS_ENSURE_SUCCESS(rv, rv); - - if (mRecentRedirects.Count() > RECENT_EVENT_QUEUE_MAX_LENGTH) { - // Expire outdated cached redirects. - PRInt64 threshold = PR_Now() - RECENT_EVENT_THRESHOLD; - mRecentRedirects.Enumerate(ExpireNonrecentRedirects, - reinterpret_cast(&threshold)); - } - - RedirectInfo info; - - // Remove any old entries for this redirect destination, since they are going - // to be replaced. - if (mRecentRedirects.Get(newSpec, &info)) - mRecentRedirects.Remove(newSpec); - // Save the new redirect info. - info.mSourceURI = oldSpec; - info.mTimeCreated = PR_Now(); - if (aFlags & nsIChannelEventSink::REDIRECT_TEMPORARY) - info.mType = TRANSITION_REDIRECT_TEMPORARY; - else - info.mType = TRANSITION_REDIRECT_PERMANENT; - mRecentRedirects.Put(newSpec, info); - - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// //// mozIStorageVacuumParticipant @@ -6333,77 +6181,6 @@ nsNavHistory::ExpireNonrecentEvents(RecentEventHash* hashTable) } -// nsNavHistory::GetRedirectFor -// -// Given a destination URI, this finds a recent redirect that resulted in -// this URI. If it finds one, it will put the redirect source info into -// the out params and return true. If there is no matching redirect, it will -// return false. -// -// @param aDestination The destination URI spec of the redirect to look for. -// @param aSource Will be filled with the redirect source URI when a -// redirect is found. -// @param aTime Will be filled with the time the redirect happened -// when a redirect is found. -// @param aRedirectType Will be filled with the redirect type when a redirect -// is found. Will be either -// TRANSITION_REDIRECT_PERMANENT or -// TRANSITION_REDIRECT_TEMPORARY -// @returns True if the redirect is found. -// -// HOW REDIRECT TRACKING WORKS -// --------------------------- -// When we get an AddDocumentRedirect message, we store the redirect in -// our mRecentRedirects which maps the destination URI to a source,time pair. -// When we get a new URI, we see if there were any redirects to this page -// in the hash table. If found, we know that the page came through the given -// redirect and add it. -// -// Example: Page S redirects throught R1, then R2, to give page D. Page S -// will have been already added to history. -// - AddDocumentRedirect(R1, R2) -// - AddDocumentRedirect(R2, D) -// - AddURI(uri=D, referrer=S) -// -// When we get the AddURI(D), we see the hash table has a value for D from R2. -// We have to recursively check that source since there could be more than -// one redirect, as in this case. Here we see there was a redirect to R2 from -// R1. The referrer for D is S, so we know S->R1->R2->D. -// -// Alternatively, the user could have typed or followed a bookmark from S. -// In this case, with two redirects we'll get: -// - MarkPageAsTyped(S) -// - AddDocumentRedirect(S, R) -// - AddDocumentRedirect(R, D) -// - AddURI(uri=D, referrer=null) -// We need to be careful to add a visit to S in this case with an incoming -// transition of typed and an outgoing transition of redirect. -// -// Note that this can get confused in some cases where you have a page -// open in more than one window loading at the same time. This should be rare, -// however, and should not affect much. - -PRBool -nsNavHistory::GetRedirectFor(const nsACString& aDestination, - nsACString& aSource, - PRTime* aTime, - PRUint32* aRedirectType) -{ - RedirectInfo info; - if (mRecentRedirects.Get(aDestination, &info)) { - // Consume the redirect entry, it's no longer useful. - mRecentRedirects.Remove(aDestination); - if (info.mTimeCreated < GetNow() - RECENT_EVENT_THRESHOLD) - return PR_FALSE; // too long ago, probably invalid - aSource = info.mSourceURI; - *aTime = info.mTimeCreated; - *aRedirectType = info.mType; - return PR_TRUE; - } - return PR_FALSE; -} - - // nsNavHistory::RowToResult // // Here, we just have a generic row. It could be a query, URL, visit, diff --git a/toolkit/components/places/nsNavHistory.h b/toolkit/components/places/nsNavHistory.h index bbcab98b4b83..90f71dbb0ab1 100644 --- a/toolkit/components/places/nsNavHistory.h +++ b/toolkit/components/places/nsNavHistory.h @@ -47,7 +47,6 @@ #include "nsPIPlacesHistoryListenersNotifier.h" #include "nsIBrowserHistory.h" #include "nsIGlobalHistory.h" -#include "nsIGlobalHistory3.h" #include "nsIDownloadHistory.h" #include "nsIPrefService.h" @@ -101,9 +100,6 @@ // Fired after frecency has been updated. #define TOPIC_FRECENCY_UPDATED "places-frecency-updated" -// Fired after frecency has been updated. -#define TOPIC_FRECENCY_UPDATED "places-frecency-updated" - // Fired when Places is shutting down. Any code should stop accessing Places // APIs after this notification. If you need to listen for Places shutdown // you should only use this notification, next ones are intended only for @@ -171,7 +167,6 @@ class nsNavHistory : public nsSupportsWeakReference , public nsINavHistoryService , public nsIObserver , public nsIBrowserHistory - , public nsIGlobalHistory3 , public nsIDownloadHistory , public nsICharsetResolver , public nsPIPlacesDatabase @@ -187,7 +182,6 @@ public: NS_DECL_NSINAVHISTORYSERVICE NS_DECL_NSIGLOBALHISTORY2 - NS_DECL_NSIGLOBALHISTORY3 NS_DECL_NSIDOWNLOADHISTORY NS_DECL_NSIBROWSERHISTORY NS_DECL_NSIOBSERVER @@ -850,19 +844,6 @@ protected: const nsACString& url); void ExpireNonrecentEvents(RecentEventHash* hashTable); - // redirect tracking. See GetRedirectFor for a description of how this works. - struct RedirectInfo { - nsCString mSourceURI; - PRTime mTimeCreated; - PRUint32 mType; // one of TRANSITION_REDIRECT_[TEMPORARY,PERMANENT] - }; - typedef nsDataHashtable RedirectHash; - RedirectHash mRecentRedirects; - static PLDHashOperator ExpireNonrecentRedirects( - nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg); - PRBool GetRedirectFor(const nsACString& aDestination, nsACString& aSource, - PRTime* aTime, PRUint32* aRedirectType); - // Sessions tracking. PRInt64 mLastSessionID; diff --git a/toolkit/components/places/tests/mochitest/bug_411966/redirect.js b/toolkit/components/places/tests/mochitest/bug_411966/redirect.js index c5affe85da9d..25a23095c3ad 100644 --- a/toolkit/components/places/tests/mochitest/bug_411966/redirect.js +++ b/toolkit/components/places/tests/mochitest/bug_411966/redirect.js @@ -53,8 +53,6 @@ ok(bhist != null, "Could not get Browser History Service"); var ghist = Cc["@mozilla.org/browser/global-history;2"]. getService(Ci.nsIGlobalHistory2); ok(ghist != null, "Could not get Global History Service"); -var ghist3 = ghist.QueryInterface(Ci.nsIGlobalHistory3); -ok(ghist3 != null, "Could not get Global History Service"); var ios = Cc["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService); ok(ios != null, "Could not get IO Service"); @@ -113,7 +111,6 @@ StreamListener.prototype = { // nsIChannelEventSink asyncOnChannelRedirect: function (aOldChannel, aNewChannel, aFlags, callback) { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - ghist3.addDocumentRedirect(aOldChannel, aNewChannel, aFlags, true); // If redirecting, store the new channel this.mChannel = aNewChannel; callback.onRedirectVerifyCallback(Components.results.NS_OK); diff --git a/toolkit/components/places/tests/network/test_history_redirects.js b/toolkit/components/places/tests/network/test_history_redirects.js index db910edcb5fb..eff6b06510f7 100644 --- a/toolkit/components/places/tests/network/test_history_redirects.js +++ b/toolkit/components/places/tests/network/test_history_redirects.js @@ -8,7 +8,6 @@ let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. getService(Ci.nsINavHistoryService); let bh = hs.QueryInterface(Ci.nsIBrowserHistory); -let ghist3 = hs.QueryInterface(Ci.nsIGlobalHistory3); const PERMA_REDIR_PATH = "/permaredir"; const TEMP_REDIR_PATH = "/tempredir"; @@ -181,10 +180,6 @@ ChannelListener.prototype = { do_check_true(this._got_onchannelredirect); do_check_true(this._buffer.length > 0); - // The referrer is wrong since it's the first element in the redirects - // chain, but this is good, since it will test a special path. - ghist3.addURI(uri(FOUND_URL), false, true, uri(PERMA_REDIR_URL)); - continue_test(); }, @@ -192,7 +187,6 @@ ChannelListener.prototype = { asyncOnChannelRedirect: function (aOldChannel, aNewChannel, aFlags, callback) { do_log_info("onChannelRedirect"); this._got_onchannelredirect = true; - ghist3.addDocumentRedirect(aOldChannel, aNewChannel, aFlags, true); callback.onRedirectVerifyCallback(Components.results.NS_OK); }, }; diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 943f45a5075a..ee2d6e983ee2 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -66,7 +66,6 @@ const PREFS_WHITELIST = [ "general.useragent.", "gfx.", "html5.", - "mozilla.widget.render-mode", "layers.", "javascript.", "keyword.", diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh index 45b70cdb3bed..91c2e152ca00 100644 --- a/toolkit/toolkit-makefiles.sh +++ b/toolkit/toolkit-makefiles.sh @@ -322,7 +322,6 @@ MAKEFILES_libvorbis=" MAKEFILES_libtremor=" media/libtremor/Makefile media/libtremor/lib/Makefile - media/libtremor/include/Makefile media/libtremor/include/tremor/Makefile " diff --git a/widget/public/nsILookAndFeel.h b/widget/public/nsILookAndFeel.h index 57dc89242553..3fbc0db7a1f7 100644 --- a/widget/public/nsILookAndFeel.h +++ b/widget/public/nsILookAndFeel.h @@ -249,6 +249,16 @@ public: */ eMetric_MacGraphiteTheme, + /* + * A Boolean value to determine whether the Mac OS X Lion-specific theming + * should be used. + * + * The value of this metric is not used on non-Mac platforms. These + * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this + * metric. + */ + eMetric_MacLionTheme, + /* * A Boolean value to determine whether Mameo is using the new Fremantle * theme. diff --git a/widget/src/android/AndroidJNI.cpp b/widget/src/android/AndroidJNI.cpp index 869e651d55bd..ec7c8cb33538 100644 --- a/widget/src/android/AndroidJNI.cpp +++ b/widget/src/android/AndroidJNI.cpp @@ -64,6 +64,7 @@ using namespace mozilla; extern "C" { NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_nativeInit(JNIEnv *, jclass); NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *, jclass, jobject event); + NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv *, jclass); NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobject sv); NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv *, jclass); NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onLowMemory(JNIEnv *, jclass); @@ -92,6 +93,14 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *jenv, jclass jc, nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(jenv, event)); } +NS_EXPORT void JNICALL +Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv *jenv, jclass) +{ + // poke the appshell + if (nsAppShell::gAppShell) + nsAppShell::gAppShell->ProcessNextNativeEvent(PR_FALSE); +} + NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobject obj) { diff --git a/widget/src/android/AndroidJavaWrappers.cpp b/widget/src/android/AndroidJavaWrappers.cpp index 5102cafebc92..450ef4ec2eb0 100644 --- a/widget/src/android/AndroidJavaWrappers.cpp +++ b/widget/src/android/AndroidJavaWrappers.cpp @@ -457,6 +457,19 @@ AndroidGeckoEvent::Init(int x1, int y1, int x2, int y2) mRect.SetEmpty(); } +void +AndroidGeckoEvent::Init(AndroidGeckoEvent *aResizeEvent) +{ + NS_ASSERTION(aResizeEvent->Type() == SIZE_CHANGED, "Init called on non-SIZE_CHANGED event"); + + mType = FORCED_RESIZE; + mTime = aResizeEvent->mTime; + mP0.x = aResizeEvent->mP0.x; + mP0.y = aResizeEvent->mP0.y; + mP1.x = aResizeEvent->mP1.x; + mP1.y = aResizeEvent->mP1.y; +} + void AndroidGeckoSurfaceView::Init(jobject jobj) { diff --git a/widget/src/android/AndroidJavaWrappers.h b/widget/src/android/AndroidJavaWrappers.h index d64cd51710b4..caaa4e35b796 100644 --- a/widget/src/android/AndroidJavaWrappers.h +++ b/widget/src/android/AndroidJavaWrappers.h @@ -386,10 +386,14 @@ public: AndroidGeckoEvent(JNIEnv *jenv, jobject jobj) { Init(jenv, jobj); } + AndroidGeckoEvent(AndroidGeckoEvent *aResizeEvent) { + Init(aResizeEvent); + } void Init(JNIEnv *jenv, jobject jobj); void Init(int aType); void Init(int x1, int y1, int x2, int y2); + void Init(AndroidGeckoEvent *aResizeEvent); int Action() { return mAction; } int Type() { return mType; } @@ -487,6 +491,7 @@ public: SURFACE_CREATED = 13, SURFACE_DESTROYED = 14, GECKO_EVENT_SYNC = 15, + FORCED_RESIZE = 16, dummy_java_enum_list_end }; diff --git a/widget/src/android/nsAppShell.cpp b/widget/src/android/nsAppShell.cpp index 2ce994fd3052..d746e7a91e94 100644 --- a/widget/src/android/nsAppShell.cpp +++ b/widget/src/android/nsAppShell.cpp @@ -74,6 +74,7 @@ PRLogModuleInfo *gWidgetLog = nsnull; nsDeviceMotionSystem *gDeviceMotionSystem = nsnull; nsIGeolocationUpdate *gLocationCallback = nsnull; +nsAutoPtr gLastSizeChange; nsAppShell *nsAppShell::gAppShell = nsnull; @@ -380,6 +381,15 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait) break; } + case AndroidGeckoEvent::SIZE_CHANGED: { + // store the last resize event to dispatch it to new windows with a FORCED_RESIZE event + if (curEvent != gLastSizeChange) { + gLastSizeChange = new AndroidGeckoEvent(curEvent); + } + nsWindow::OnGlobalAndroidEvent(curEvent); + break; + } + default: nsWindow::OnGlobalAndroidEvent(curEvent); } @@ -389,6 +399,13 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait) return true; } +void +nsAppShell::ResendLastResizeEvent(nsWindow* aDest) { + if (gLastSizeChange) { + nsWindow::OnGlobalAndroidEvent(gLastSizeChange); + } +} + AndroidGeckoEvent* nsAppShell::GetNextEvent() { diff --git a/widget/src/android/nsAppShell.h b/widget/src/android/nsAppShell.h index f396093568fe..03fb58b0bb9b 100644 --- a/widget/src/android/nsAppShell.h +++ b/widget/src/android/nsAppShell.h @@ -52,6 +52,8 @@ bool ProcessNextEvent(); void NotifyEvent(); } +class nsWindow; + class nsAppShell : public nsBaseAppShell { @@ -81,6 +83,7 @@ public: void CallObserver(const nsAString &aObserverKey, const nsAString &aTopic, const nsAString &aData); void RemoveObserver(const nsAString &aObserverKey); void NotifyObservers(nsISupports *aSupports, const char *aTopic, const PRUnichar *aData); + void ResendLastResizeEvent(nsWindow* aDest); protected: virtual void ScheduleNativeEventCallback(); diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index 0e0cb5658388..e95ff2c17480 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -448,14 +448,6 @@ nsWindow::Resize(PRInt32 aX, PRBool needSizeDispatch = aWidth != mBounds.width || aHeight != mBounds.height; - if (IsTopLevel()) { - ALOG("... ignoring Resize sizes on toplevel window"); - aX = 0; - aY = 0; - aWidth = gAndroidBounds.width; - aHeight = gAndroidBounds.height; - } - mBounds.x = aX; mBounds.y = aY; mBounds.width = aWidth; @@ -586,6 +578,8 @@ nsWindow::BringToFront() nsGUIEvent event(PR_TRUE, NS_ACTIVATE, this); DispatchEvent(&event); + // force a window resize + nsAppShell::gAppShell->ResendLastResizeEvent(this); nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(-1, -1, -1, -1)); } @@ -739,11 +733,19 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae) return; switch (ae->Type()) { + case AndroidGeckoEvent::FORCED_RESIZE: + win->mBounds.width = 0; + win->mBounds.height = 0; + // also resize the children + for (PRUint32 i = 0; i < win->mChildren.Length(); i++) { + win->mChildren[i]->mBounds.width = 0; + win->mChildren[i]->mBounds.height = 0; + } case AndroidGeckoEvent::SIZE_CHANGED: { int nw = ae->P0().x; int nh = ae->P0().y; - if (nw != gAndroidBounds.width || + if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width || nh != gAndroidBounds.height) { gAndroidBounds.width = nw; diff --git a/widget/src/cocoa/nsClipboard.mm b/widget/src/cocoa/nsClipboard.mm index 415b830fe953..4b0db83be8e6 100644 --- a/widget/src/cocoa/nsClipboard.mm +++ b/widget/src/cocoa/nsClipboard.mm @@ -428,8 +428,13 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable) nsCOMPtr genericDataWrapper; rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &dataSize); nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr, genericDataWrapper, &data, dataSize); + + NSString* nativeString; + if (data) + nativeString = [NSString stringWithCharacters:(const unichar*)data length:(dataSize / sizeof(PRUnichar))]; + else + nativeString = [NSString string]; - NSString* nativeString = [NSString stringWithCharacters:(const unichar*)data length:(dataSize / sizeof(PRUnichar))]; // be nice to Carbon apps, normalize the receiver's contents using Form C. nativeString = [nativeString precomposedStringWithCanonicalMapping]; diff --git a/widget/src/cocoa/nsLookAndFeel.mm b/widget/src/cocoa/nsLookAndFeel.mm index 17323270bf72..d1c9d97125d1 100644 --- a/widget/src/cocoa/nsLookAndFeel.mm +++ b/widget/src/cocoa/nsLookAndFeel.mm @@ -389,6 +389,9 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) case eMetric_MacGraphiteTheme: aMetric = [NSColor currentControlTint] == NSGraphiteControlTint; break; + case eMetric_MacLionTheme: + aMetric = nsToolkit::OnLionOrLater(); + break; case eMetric_TabFocusModel: { // we should probably cache this diff --git a/widget/src/gtk2/nsLookAndFeel.cpp b/widget/src/gtk2/nsLookAndFeel.cpp index 3a78a5ee9d5e..647131700135 100644 --- a/widget/src/gtk2/nsLookAndFeel.cpp +++ b/widget/src/gtk2/nsLookAndFeel.cpp @@ -549,6 +549,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) #endif break; case eMetric_MacGraphiteTheme: + case eMetric_MacLionTheme: aMetric = 0; res = NS_ERROR_NOT_IMPLEMENTED; break; diff --git a/widget/src/os2/nsLookAndFeel.cpp b/widget/src/os2/nsLookAndFeel.cpp index c0b8ea8fbd18..148eba76d345 100644 --- a/widget/src/os2/nsLookAndFeel.cpp +++ b/widget/src/os2/nsLookAndFeel.cpp @@ -331,6 +331,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) res = NS_ERROR_NOT_IMPLEMENTED; break; case eMetric_MacGraphiteTheme: + case eMetric_MacLionTheme: case eMetric_MaemoClassic: aMetric = 0; res = NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/windows/nsLookAndFeel.cpp b/widget/src/windows/nsLookAndFeel.cpp index e18a3ec3f1cf..03e3960c84ea 100644 --- a/widget/src/windows/nsLookAndFeel.cpp +++ b/widget/src/windows/nsLookAndFeel.cpp @@ -419,6 +419,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) aMetric = nsUXThemeData::GetNativeThemeId(); break; case eMetric_MacGraphiteTheme: + case eMetric_MacLionTheme: case eMetric_MaemoClassic: aMetric = 0; res = NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/tests/Makefile.in b/widget/tests/Makefile.in index 65885df7cf97..c6eb8563e14a 100644 --- a/widget/tests/Makefile.in +++ b/widget/tests/Makefile.in @@ -110,6 +110,7 @@ _CHROME_FILES += native_menus_window.xul \ test_key_event_counts.xul \ test_bug596600.xul \ window_bug596600.xul \ + test_bug673301.xul \ $(NULL) endif diff --git a/widget/tests/test_bug673301.xul b/widget/tests/test_bug673301.xul new file mode 100644 index 000000000000..b32242d1fc44 --- /dev/null +++ b/widget/tests/test_bug673301.xul @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/xpcom/base/FunctionTimer.h b/xpcom/base/FunctionTimer.h index 0d71ff25c0bd..cc9b3ce1b8d5 100644 --- a/xpcom/base/FunctionTimer.h +++ b/xpcom/base/FunctionTimer.h @@ -133,7 +133,7 @@ namespace mozilla { -class NS_COM FunctionTimerLog +class FunctionTimerLog { public: FunctionTimerLog(const char *fname); @@ -148,7 +148,7 @@ private: TimeStamp mLatest; }; -class NS_COM FunctionTimer +class FunctionTimer { static nsAutoPtr sLog; static char *sBuf1; diff --git a/xpcom/base/nsCycleCollector.h b/xpcom/base/nsCycleCollector.h index 6454678fa4ee..6bce43ac16f9 100644 --- a/xpcom/base/nsCycleCollector.h +++ b/xpcom/base/nsCycleCollector.h @@ -64,8 +64,8 @@ struct nsCycleCollectionLanguageRuntime nsresult nsCycleCollector_startup(); // Returns the number of collected nodes. -NS_COM PRUint32 nsCycleCollector_collect(nsICycleCollectorListener *aListener); -NS_COM PRUint32 nsCycleCollector_suspectedCount(); +PRUint32 nsCycleCollector_collect(nsICycleCollectorListener *aListener); +PRUint32 nsCycleCollector_suspectedCount(); void nsCycleCollector_shutdownThreads(); void nsCycleCollector_shutdown(); @@ -88,15 +88,15 @@ struct nsCycleCollectionJSRuntime : public nsCycleCollectionLanguageRuntime }; #ifdef DEBUG -NS_COM void nsCycleCollector_DEBUG_shouldBeFreed(nsISupports *n); -NS_COM void nsCycleCollector_DEBUG_wasFreed(nsISupports *n); +void nsCycleCollector_DEBUG_shouldBeFreed(nsISupports *n); +void nsCycleCollector_DEBUG_wasFreed(nsISupports *n); #endif // Helpers for interacting with language-identified scripts -NS_COM void nsCycleCollector_registerRuntime(PRUint32 langID, nsCycleCollectionLanguageRuntime *rt); -NS_COM nsCycleCollectionLanguageRuntime * nsCycleCollector_getRuntime(PRUint32 langID); -NS_COM void nsCycleCollector_forgetRuntime(PRUint32 langID); +void nsCycleCollector_registerRuntime(PRUint32 langID, nsCycleCollectionLanguageRuntime *rt); +nsCycleCollectionLanguageRuntime * nsCycleCollector_getRuntime(PRUint32 langID); +void nsCycleCollector_forgetRuntime(PRUint32 langID); #define NS_CYCLE_COLLECTOR_LOGGER_CID \ { 0x58be81b4, 0x39d2, 0x437c, \ diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 50ae8e2ac38e..5f5240eb0485 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -533,7 +533,7 @@ nsDebugImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) //////////////////////////////////////////////////////////////////////////////// -NS_COM nsresult +nsresult NS_ErrorAccordingToNSPR() { PRErrorCode err = PR_GetError(); @@ -559,7 +559,7 @@ NS_ErrorAccordingToNSPR() //////////////////////////////////////////////////////////////////////////////// #ifdef XP_WIN -NS_COM PRBool sXPCOMHasLoadedNewDLLs = PR_FALSE; +PRBool sXPCOMHasLoadedNewDLLs = PR_FALSE; NS_EXPORT void NS_SetHasLoadedNewDLLs() diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index db46d22ffd6a..de707c8d4cb6 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -327,7 +327,7 @@ inline int NS_SUCCEEDED(nsresult _nsresult) { * Do not depend on this function. It will be going away! *********************************************************************** */ -extern NS_COM nsresult +extern nsresult NS_ErrorAccordingToNSPR(); @@ -337,7 +337,7 @@ NS_ErrorAccordingToNSPR(); #endif #ifdef XP_WIN -extern NS_COM PRBool sXPCOMHasLoadedNewDLLs; +extern PRBool sXPCOMHasLoadedNewDLLs; NS_EXPORT void NS_SetHasLoadedNewDLLs(); #endif diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index 3600af8ac1e9..6236f92c9125 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -292,10 +292,10 @@ interface nsIMemoryReporterManager : nsISupports #define NS_MEMORY_REPORTER_NAME(_classname) MemoryReporter_##_classname -NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter); -NS_COM nsresult NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter); +nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter); +nsresult NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter); -NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter); -NS_COM nsresult NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter); +nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter); +nsresult NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter); %} diff --git a/xpcom/base/nsInterfaceRequestorAgg.h b/xpcom/base/nsInterfaceRequestorAgg.h index 7be03bda82d3..8fbe65347031 100644 --- a/xpcom/base/nsInterfaceRequestorAgg.h +++ b/xpcom/base/nsInterfaceRequestorAgg.h @@ -46,7 +46,7 @@ * failed to supply the requested interface. Both aFirst and aSecond may * be null. */ -extern NS_COM nsresult +extern nsresult NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor *aFirst, nsIInterfaceRequestor *aSecond, nsIInterfaceRequestor **aResult); diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index a0bbb74a8e3d..2b7d629f0592 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -746,7 +746,7 @@ NS_IMETHODIMP nsMemoryReporter::GetDescription(nsACString &aDescription) return NS_OK; } -NS_COM nsresult +nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); @@ -755,7 +755,7 @@ NS_RegisterMemoryReporter (nsIMemoryReporter *reporter) return mgr->RegisterReporter(reporter); } -NS_COM nsresult +nsresult NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); @@ -764,7 +764,7 @@ NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter) return mgr->RegisterMultiReporter(reporter); } -NS_COM nsresult +nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); @@ -773,7 +773,7 @@ NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter) return mgr->UnregisterReporter(reporter); } -NS_COM nsresult +nsresult NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter) { nsCOMPtr mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); diff --git a/xpcom/base/nsTraceRefcntImpl.cpp b/xpcom/base/nsTraceRefcntImpl.cpp index dc063c84dd95..2942c08c1574 100644 --- a/xpcom/base/nsTraceRefcntImpl.cpp +++ b/xpcom/base/nsTraceRefcntImpl.cpp @@ -73,7 +73,7 @@ //////////////////////////////////////////////////////////////////////////////// -NS_COM void +void NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, double *meanResult, double *stdDevResult) { @@ -507,7 +507,7 @@ class nsDefaultComparator { #endif /* NS_IMPL_REFCNT_LOGGING */ -NS_COM nsresult +nsresult nsTraceRefcntImpl::DumpStatistics(StatisticsType type, FILE* out) { #ifdef NS_IMPL_REFCNT_LOGGING @@ -570,7 +570,7 @@ nsTraceRefcntImpl::DumpStatistics(StatisticsType type, FILE* out) return NS_OK; } -NS_COM void +void nsTraceRefcntImpl::ResetStatistics() { #ifdef NS_IMPL_REFCNT_LOGGING @@ -879,7 +879,7 @@ static void PrintStackFrame(void *aPC, void *aClosure) } -NS_COM void +void nsTraceRefcntImpl::WalkTheStack(FILE* aStream) { NS_StackWalk(PrintStackFrame, 2, aStream); @@ -894,7 +894,7 @@ nsTraceRefcntImpl::WalkTheStack(FILE* aStream) #include // for free() #endif // MOZ_DEMANGLE_SYMBOLS -NS_COM void +void nsTraceRefcntImpl::DemangleSymbol(const char * aSymbol, char * aBuffer, int aBufLen) @@ -1260,12 +1260,12 @@ NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject) #endif } -NS_COM void +void nsTraceRefcntImpl::Startup() { } -NS_COM void +void nsTraceRefcntImpl::Shutdown() { #ifdef NS_IMPL_REFCNT_LOGGING @@ -1309,7 +1309,7 @@ nsTraceRefcntImpl::Shutdown() #endif } -NS_COM void +void nsTraceRefcntImpl::SetActivityIsLegal(PRBool aLegal) { #ifdef NS_IMPL_REFCNT_LOGGING diff --git a/xpcom/base/nsTraceRefcntImpl.h b/xpcom/base/nsTraceRefcntImpl.h index d7c40ff7ff4e..3dbe1eaab01e 100644 --- a/xpcom/base/nsTraceRefcntImpl.h +++ b/xpcom/base/nsTraceRefcntImpl.h @@ -48,30 +48,30 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSITRACEREFCNT - static NS_COM void Startup(); - static NS_COM void Shutdown(); + static void Startup(); + static void Shutdown(); enum StatisticsType { ALL_STATS, NEW_STATS }; - static NS_COM nsresult DumpStatistics(StatisticsType type = ALL_STATS, + static nsresult DumpStatistics(StatisticsType type = ALL_STATS, FILE* out = 0); - static NS_COM void ResetStatistics(void); + static void ResetStatistics(void); - static NS_COM void DemangleSymbol(const char * aSymbol, + static void DemangleSymbol(const char * aSymbol, char * aBuffer, int aBufLen); - static NS_COM void WalkTheStack(FILE* aStream); + static void WalkTheStack(FILE* aStream); /** * Tell nsTraceRefcnt whether refcounting, allocation, and destruction * activity is legal. This is used to trigger assertions for any such * activity that occurs because of static constructors or destructors. */ - static NS_COM void SetActivityIsLegal(PRBool aLegal); + static void SetActivityIsLegal(PRBool aLegal); static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); }; @@ -89,7 +89,7 @@ public: //////////////////////////////////////////////////////////////////////////////// // And now for that utility that you've all been asking for... -extern "C" NS_COM void +extern "C" void NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, double *meanResult, double *stdDevResult); diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index 938b2aa5bfe2..7e3435937f7e 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -34,6 +34,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + #ifndef nscore_h___ #define nscore_h___ @@ -295,10 +296,8 @@ #define XPCOM_API(type) IMPORT_XPCOM_API(type) #endif -#define NS_COM - #ifdef MOZILLA_INTERNAL_API -# define NS_COM_GLUE NS_COM +# define NS_COM_GLUE /* The frozen string API has different definitions of nsAC?String classes than the internal API. On systems that explicitly declare diff --git a/xpcom/build/Services.cpp b/xpcom/build/Services.cpp index b1daef85966c..6eec2668d383 100644 --- a/xpcom/build/Services.cpp +++ b/xpcom/build/Services.cpp @@ -64,7 +64,7 @@ using namespace mozilla::services; #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) \ static TYPE* g##NAME = nsnull; \ \ - NS_COM already_AddRefed \ + already_AddRefed \ mozilla::services::Get##NAME() \ { \ if (!g##NAME) { \ diff --git a/xpcom/build/Services.h b/xpcom/build/Services.h index 43e0c97fdd15..87c963c7ce11 100644 --- a/xpcom/build/Services.h +++ b/xpcom/build/Services.h @@ -52,7 +52,7 @@ namespace mozilla { namespace services { -#define MOZ_SERVICE(NAME, TYPE, SERVICE_CID) NS_COM already_AddRefed Get##NAME(); +#define MOZ_SERVICE(NAME, TYPE, SERVICE_CID) already_AddRefed Get##NAME(); #include "ServiceList.h" #undef MOZ_SERVICE diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index b3e8986b7b2c..c1c823a113c2 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -742,7 +742,7 @@ nsCategoryManager::SuppressNotifications(PRBool aSuppress) * this will attempt to notify the observer with the origin, observerTopic string * as parameter. */ -NS_COM void +void NS_CreateServicesFromCategory(const char *category, nsISupports *origin, const char *observerTopic) diff --git a/xpcom/components/nsCategoryManagerUtils.h b/xpcom/components/nsCategoryManagerUtils.h index b1ece17d067a..c01266950a8f 100644 --- a/xpcom/components/nsCategoryManagerUtils.h +++ b/xpcom/components/nsCategoryManagerUtils.h @@ -40,7 +40,7 @@ #include "nsICategoryManager.h" -NS_COM void +void NS_CreateServicesFromCategory(const char *category, nsISupports *origin, const char *observerTopic); diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 06737ffa054e..f211f179e0f0 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -46,11 +46,13 @@ * Date Modified by Description of modification * 04/20/2000 IBM Corp. Added PR_CALLBACK for Optlink use in OS2 */ + #include #include "nscore.h" #include "nsISupports.h" #include "nspr.h" #include "nsCRT.h" // for atoll + // Arena used by component manager for storing contractid string, dll // location strings and small objects // CAUTION: Arena align mask needs to be defined before including plarena.h @@ -107,7 +109,7 @@ static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID); using namespace mozilla; -NS_COM PRLogModuleInfo* nsComponentManagerLog = nsnull; +PRLogModuleInfo* nsComponentManagerLog = nsnull; #if 0 || defined (DEBUG_timeless) #define SHOW_DENIED_ON_SHUTDOWN @@ -1993,7 +1995,7 @@ nsFactoryEntry::GetFactory() // Static Access Functions //////////////////////////////////////////////////////////////////////////////// -NS_COM nsresult +nsresult NS_GetComponentManager(nsIComponentManager* *result) { if (!nsComponentManagerImpl::gComponentManager) @@ -2003,7 +2005,7 @@ NS_GetComponentManager(nsIComponentManager* *result) return NS_OK; } -NS_COM nsresult +nsresult NS_GetServiceManager(nsIServiceManager* *result) { if (!nsComponentManagerImpl::gComponentManager) @@ -2014,7 +2016,7 @@ NS_GetServiceManager(nsIServiceManager* *result) } -NS_COM nsresult +nsresult NS_GetComponentRegistrar(nsIComponentRegistrar* *result) { if (!nsComponentManagerImpl::gComponentManager) diff --git a/xpcom/ds/TimeStamp.h b/xpcom/ds/TimeStamp.h index 9616d5ca8374..45c143d817b2 100644 --- a/xpcom/ds/TimeStamp.h +++ b/xpcom/ds/TimeStamp.h @@ -57,7 +57,7 @@ class TimeStamp; * system-dependent unit must be constant, otherwise the semantics of * this class would be broken. */ -class NS_COM TimeDuration +class TimeDuration { public: // The default duration is 0. @@ -186,7 +186,7 @@ private: * - PRIntervalTime otherwise. We detect wraparounds of * PRIntervalTime and work around them. */ -class NS_COM TimeStamp +class TimeStamp { public: /** diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 9bff0d93cce2..d03e12b021e4 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -419,7 +419,7 @@ class CheckStaticAtomSizes } }; -NS_COM nsresult +nsresult NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount) { // this does three things: @@ -490,13 +490,13 @@ NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount) return NS_OK; } -NS_COM nsIAtom* +nsIAtom* NS_NewAtom(const char* aUTF8String) { return NS_NewAtom(nsDependentCString(aUTF8String)); } -NS_COM nsIAtom* +nsIAtom* NS_NewAtom(const nsACString& aUTF8String) { AtomTableEntry *he = GetAtomHashEntry(aUTF8String.Data(), @@ -521,13 +521,13 @@ NS_NewAtom(const nsACString& aUTF8String) return atom; } -NS_COM nsIAtom* +nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String) { return NS_NewAtom(nsDependentString(aUTF16String)); } -NS_COM nsIAtom* +nsIAtom* NS_NewAtom(const nsAString& aUTF16String) { AtomTableEntry *he = GetAtomHashEntry(aUTF16String.Data(), @@ -547,7 +547,7 @@ NS_NewAtom(const nsAString& aUTF16String) return atom; } -NS_COM nsIAtom* +nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String) { AtomTableEntry *he = GetAtomHashEntry(aUTF16String.Data(), @@ -568,13 +568,13 @@ NS_NewPermanentAtom(const nsAString& aUTF16String) return atom; } -NS_COM nsrefcnt +nsrefcnt NS_GetNumberOfAtoms(void) { return gAtomTable.entryCount; } -NS_COM nsIAtom* +nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String) { NS_PRECONDITION(gStaticAtomTable, "Static atom table not created yet."); @@ -586,7 +586,7 @@ NS_GetStaticAtom(const nsAString& aUTF16String) return atom; } -NS_COM void +void NS_SealStaticAtomTable() { gStaticAtomTableSealed = PR_TRUE; diff --git a/xpcom/ds/nsByteBuffer.cpp b/xpcom/ds/nsByteBuffer.cpp index 8761644f20dd..1cb4d106805c 100644 --- a/xpcom/ds/nsByteBuffer.cpp +++ b/xpcom/ds/nsByteBuffer.cpp @@ -151,7 +151,7 @@ ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, return nb; } -NS_COM nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, +nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, PRUint32 aBufferSize) { diff --git a/xpcom/ds/nsCRT.h b/xpcom/ds/nsCRT.h index c9790b977b1c..9fcb29ac31e6 100644 --- a/xpcom/ds/nsCRT.h +++ b/xpcom/ds/nsCRT.h @@ -95,7 +95,7 @@ extern const PRUnichar kIsoLatin1ToUCS2[256]; /// This is a wrapper class around all the C runtime functions. -class NS_COM nsCRT { +class nsCRT { public: enum { LF='\n' /* Line Feed */, diff --git a/xpcom/ds/nsCheapSets.h b/xpcom/ds/nsCheapSets.h index aab2b1c5ec7b..9f3d7a262877 100644 --- a/xpcom/ds/nsCheapSets.h +++ b/xpcom/ds/nsCheapSets.h @@ -44,7 +44,7 @@ * A string set that takes up minimal size when there are 0 or 1 strings in the * set. Use for cases where sizes of 0 and 1 are even slightly common. */ -class NS_COM nsCheapStringSet { +class nsCheapStringSet { public: nsCheapStringSet() : mValOrHash(nsnull) { @@ -119,7 +119,7 @@ private: * An integer set that takes up only 4 bytes when there are 0 or 1 integers * in the set. Use for cases where sizes of 0 and 1 are even slightly common. */ -class NS_COM nsCheapInt32Set { +class nsCheapInt32Set { public: nsCheapInt32Set() : mValOrHash(nsnull) { diff --git a/xpcom/ds/nsDoubleHashtable.h b/xpcom/ds/nsDoubleHashtable.h index 4103592472e9..e5c17b7dd8e9 100644 --- a/xpcom/ds/nsDoubleHashtable.h +++ b/xpcom/ds/nsDoubleHashtable.h @@ -398,7 +398,7 @@ void CLASSNAME::Remove(const KEY_TYPE aKey) { \ // // String-key entry // -class NS_COM PLDHashStringEntry : public PLDHashEntryHdr +class PLDHashStringEntry : public PLDHashEntryHdr { public: PLDHashStringEntry(const void* aKey) : @@ -418,7 +418,7 @@ public: // // CString-key entry // -class NS_COM PLDHashCStringEntry : public PLDHashEntryHdr +class PLDHashCStringEntry : public PLDHashEntryHdr { public: PLDHashCStringEntry(const void* aKey) : @@ -438,7 +438,7 @@ public: // // Int-key entry // -class NS_COM PLDHashInt32Entry : public PLDHashEntryHdr +class PLDHashInt32Entry : public PLDHashEntryHdr { public: PLDHashInt32Entry(const void* aKey) : @@ -459,7 +459,7 @@ public: // // Void-key entry // -class NS_COM PLDHashVoidEntry : public PLDHashEntryHdr +class PLDHashVoidEntry : public PLDHashEntryHdr { public: PLDHashVoidEntry(const void* aKey) : diff --git a/xpcom/ds/nsFixedSizeAllocator.h b/xpcom/ds/nsFixedSizeAllocator.h index 16708cdc629f..014d57959439 100644 --- a/xpcom/ds/nsFixedSizeAllocator.h +++ b/xpcom/ds/nsFixedSizeAllocator.h @@ -134,7 +134,7 @@ #define NS_SIZE_IN_HEAP(_size) (_size) -class NS_COM nsFixedSizeAllocator +class nsFixedSizeAllocator { protected: PLArenaPool mPool; diff --git a/xpcom/ds/nsHashPropertyBag.h b/xpcom/ds/nsHashPropertyBag.h index dc0927f06c4c..d1e67bcd9523 100644 --- a/xpcom/ds/nsHashPropertyBag.h +++ b/xpcom/ds/nsHashPropertyBag.h @@ -48,12 +48,7 @@ #include "nsIWritablePropertyBag2.h" #include "nsInterfaceHashtable.h" -// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration -// controls member method visibility. -#undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY - -class NS_COM nsHashPropertyBag : public nsIWritablePropertyBag +class nsHashPropertyBag : public nsIWritablePropertyBag , public nsIWritablePropertyBag2 { public: @@ -82,7 +77,7 @@ protected: // Note: NS_NewHashPropertyBag returns a HPB that // uses a non-thread-safe internal hash -extern "C" NS_COM nsresult +extern "C" nsresult NS_NewHashPropertyBag(nsIWritablePropertyBag* *_retval); #endif /* nsHashPropertyBag_h___ */ diff --git a/xpcom/ds/nsHashSets.h b/xpcom/ds/nsHashSets.h index 627a6a065960..49bb33bb3703 100644 --- a/xpcom/ds/nsHashSets.h +++ b/xpcom/ds/nsHashSets.h @@ -93,7 +93,7 @@ public: \ DHASH_WRAPPER(CLASSNAME##Super,ENTRY_CLASS,KEY_TYPE) #undef DHASH_EXPORT -#define DHASH_EXPORT NS_COM +#define DHASH_EXPORT DECL_DHASH_SET(nsStringHashSet, PLDHashStringEntry, nsAString&) DECL_DHASH_SET(nsCStringHashSet,PLDHashCStringEntry,nsACString&) diff --git a/xpcom/ds/nsHashtable.h b/xpcom/ds/nsHashtable.h index 067485c69615..6b5a14d13e51 100644 --- a/xpcom/ds/nsHashtable.h +++ b/xpcom/ds/nsHashtable.h @@ -66,7 +66,7 @@ class nsIObjectOutputStream; class nsHashtable; class nsStringKey; -class NS_COM nsHashKey { +class nsHashKey { protected: nsHashKey(void) { #ifdef DEBUG @@ -128,7 +128,7 @@ typedef void typedef nsresult (* nsHashtableWriteDataFunc)(nsIObjectOutputStream *aStream, void *aData); -class NS_COM nsHashtable { +class nsHashtable { protected: // members PRLock* mLock; @@ -163,7 +163,7 @@ class NS_COM nsHashtable { typedef void* (* nsHashtableCloneElementFunc)(nsHashKey *aKey, void *aData, void* aClosure); -class NS_COM nsObjectHashtable : public nsHashtable { +class nsObjectHashtable : public nsHashtable { public: nsObjectHashtable(nsHashtableCloneElementFunc cloneElementFun, void* cloneElementClosure, @@ -192,7 +192,7 @@ class NS_COM nsObjectHashtable : public nsHashtable { class nsISupports; -class NS_COM nsSupportsHashtable +class nsSupportsHashtable : private nsHashtable { public: @@ -231,7 +231,7 @@ class NS_COM nsSupportsHashtable #include "nsISupports.h" -class NS_COM nsISupportsKey : public nsHashKey { +class nsISupportsKey : public nsHashKey { protected: nsISupports* mKey; @@ -337,7 +337,7 @@ class nsVoidKey : public nsHashKey { #include "nsString.h" // for null-terminated c-strings -class NS_COM nsCStringKey : public nsHashKey { +class nsCStringKey : public nsHashKey { public: // NB: when serializing, NEVER_OWN keys are deserialized as OWN. @@ -371,7 +371,7 @@ class NS_COM nsCStringKey : public nsHashKey { }; // for null-terminated unicode strings -class NS_COM nsStringKey : public nsHashKey { +class nsStringKey : public nsHashKey { public: // NB: when serializing, NEVER_OWN keys are deserialized as OWN. diff --git a/xpcom/ds/nsIAtom.idl b/xpcom/ds/nsIAtom.idl index 5af73d73a59b..8ee34a8822a0 100644 --- a/xpcom/ds/nsIAtom.idl +++ b/xpcom/ds/nsIAtom.idl @@ -118,7 +118,7 @@ protected: * Find an atom that matches the given UTF-8 string. * The string is assumed to be zero terminated. */ -extern NS_COM nsIAtom* NS_NewAtom(const char* aUTF8String); +extern nsIAtom* NS_NewAtom(const char* aUTF8String); inline already_AddRefed do_GetAtom(const char* aUTF8String) { return NS_NewAtom(aUTF8String); } @@ -126,7 +126,7 @@ inline already_AddRefed do_GetAtom(const char* aUTF8String) /** * Find an atom that matches the given UTF-8 string. */ -extern NS_COM nsIAtom* NS_NewAtom(const nsACString& aUTF8String); +extern nsIAtom* NS_NewAtom(const nsACString& aUTF8String); inline already_AddRefed do_GetAtom(const nsACString& aUTF8String) { return NS_NewAtom(aUTF8String); } @@ -134,15 +134,15 @@ inline already_AddRefed do_GetAtom(const nsACString& aUTF8String) * Find an atom that matches the given UTF-16 string. * The string is assumed to be zero terminated. */ -extern NS_COM nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String); +extern nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String); inline already_AddRefed do_GetAtom(const PRUnichar* aUTF16String) { return NS_NewAtom(aUTF16String); } /** * Find an atom that matches the given UTF-16 string. */ -extern NS_COM nsIAtom* NS_NewAtom(const nsAString& aUTF16String); -extern NS_COM nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String); +extern nsIAtom* NS_NewAtom(const nsAString& aUTF16String); +extern nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String); inline already_AddRefed do_GetAtom(const nsAString& aUTF16String) { return NS_NewAtom(aUTF16String); } @@ -150,18 +150,18 @@ inline already_AddRefed do_GetAtom(const nsAString& aUTF16String) * Return a count of the total number of atoms currently * alive in the system. */ -extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void); +extern nsrefcnt NS_GetNumberOfAtoms(void); /** * Return a pointer for a static atom for the string or null if there's * no static atom for this string. */ -extern NS_COM nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String); +extern nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String); /** * Seal the static atom table */ -extern NS_COM void NS_SealStaticAtomTable(); +extern void NS_SealStaticAtomTable(); class nsAtomString : public nsString { diff --git a/xpcom/ds/nsIByteBuffer.h b/xpcom/ds/nsIByteBuffer.h index 35a73811ddbb..df55fa73e020 100644 --- a/xpcom/ds/nsIByteBuffer.h +++ b/xpcom/ds/nsIByteBuffer.h @@ -88,7 +88,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIByteBuffer, NS_IBYTEBUFFER_IID) } /** Create a new byte buffer using the given buffer size. */ -extern NS_COM nsresult +extern nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, PRUint32 aBufferSize = 0); diff --git a/xpcom/ds/nsICollection.idl b/xpcom/ds/nsICollection.idl index f97bf970d9b3..bafa1d160281 100644 --- a/xpcom/ds/nsICollection.idl +++ b/xpcom/ds/nsICollection.idl @@ -63,7 +63,7 @@ interface nsICollection : nsISerializable #include "nsCOMPtr.h" #endif -class NS_COM nsQueryElementAt : public nsCOMPtr_helper +class nsQueryElementAt : public nsCOMPtr_helper { public: nsQueryElementAt( nsICollection* aCollection, PRUint32 aIndex, nsresult* aErrorPtr ) diff --git a/xpcom/ds/nsISupportsArray.idl b/xpcom/ds/nsISupportsArray.idl index 38dcf4f6810c..1547a46a7980 100644 --- a/xpcom/ds/nsISupportsArray.idl +++ b/xpcom/ds/nsISupportsArray.idl @@ -67,7 +67,7 @@ class nsISupportsArray; // Enumerator callback function. Return PR_FALSE to stop typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData); -NS_COM nsresult +nsresult NS_NewArrayEnumerator(nsISimpleEnumerator* *result NS_OUTPARAM, nsISupportsArray* array); %} @@ -131,11 +131,11 @@ interface nsISupportsArray : nsICollection { %{C++ // Construct and return a default implementation of nsISupportsArray: -extern NS_COM nsresult +extern nsresult NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult); // Construct and return a default implementation of an enumerator for nsISupportsArrays: -extern NS_COM nsresult +extern nsresult NS_NewISupportsArrayEnumerator(nsISupportsArray* array, nsIBidirectionalEnumerator* *aInstancePtrResult); diff --git a/xpcom/ds/nsIUnicharBuffer.h b/xpcom/ds/nsIUnicharBuffer.h index 28b737e11b06..57bfc273a989 100644 --- a/xpcom/ds/nsIUnicharBuffer.h +++ b/xpcom/ds/nsIUnicharBuffer.h @@ -59,7 +59,7 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(nsIUnicharBuffer, NS_IUNICHARBUFFER_IID) /// Factory method for nsIUnicharBuffer. -extern NS_COM nsresult +extern nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, PRUint32 aBufferSize = 0); diff --git a/xpcom/ds/nsRecyclingAllocator.h b/xpcom/ds/nsRecyclingAllocator.h index d891258ad74a..7aef6335d512 100644 --- a/xpcom/ds/nsRecyclingAllocator.h +++ b/xpcom/ds/nsRecyclingAllocator.h @@ -71,7 +71,7 @@ class nsITimer; class nsIMemory; -class NS_COM nsRecyclingAllocator { +class nsRecyclingAllocator { protected: struct Block { PRSize bytes; diff --git a/xpcom/ds/nsStaticAtom.h b/xpcom/ds/nsStaticAtom.h index 0736a9ecd370..901f7879d62d 100644 --- a/xpcom/ds/nsStaticAtom.h +++ b/xpcom/ds/nsStaticAtom.h @@ -77,7 +77,7 @@ struct nsFakeStringBuffer { }; // Register static atoms with the atom table -NS_COM nsresult +nsresult NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount); #endif diff --git a/xpcom/ds/nsStaticNameTable.h b/xpcom/ds/nsStaticNameTable.h index 154a1c9ddd5f..e32fb0e850c1 100644 --- a/xpcom/ds/nsStaticNameTable.h +++ b/xpcom/ds/nsStaticNameTable.h @@ -59,7 +59,7 @@ * as long as this table object - typically a static string array. */ -class NS_COM nsStaticCaseInsensitiveNameTable +class nsStaticCaseInsensitiveNameTable { public: enum { NOT_FOUND = -1 }; diff --git a/xpcom/ds/nsStringEnumerator.cpp b/xpcom/ds/nsStringEnumerator.cpp index f117dc36b0a0..fdbf986a1908 100644 --- a/xpcom/ds/nsStringEnumerator.cpp +++ b/xpcom/ds/nsStringEnumerator.cpp @@ -191,7 +191,7 @@ StringEnumeratorTail(T** aResult NS_INPARAM) // constructors // -NS_COM nsresult +nsresult NS_NewStringEnumerator(nsIStringEnumerator** aResult, const nsTArray* aArray, nsISupports* aOwner) { @@ -203,7 +203,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult, } -NS_COM nsresult +nsresult NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, const nsTArray* aArray, nsISupports* aOwner) { @@ -214,7 +214,7 @@ NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, return StringEnumeratorTail(aResult); } -NS_COM nsresult +nsresult NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult, nsTArray* aArray) { @@ -225,7 +225,7 @@ NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult, return StringEnumeratorTail(aResult); } -NS_COM nsresult +nsresult NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, nsTArray* aArray) { @@ -237,7 +237,7 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, } // const ones internally just forward to the non-const equivalents -NS_COM nsresult +nsresult NS_NewStringEnumerator(nsIStringEnumerator** aResult, const nsTArray* aArray) { @@ -248,7 +248,7 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult, return StringEnumeratorTail(aResult); } -NS_COM nsresult +nsresult NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, const nsTArray* aArray) { diff --git a/xpcom/ds/nsStringEnumerator.h b/xpcom/ds/nsStringEnumerator.h index 3163af967d8b..305c3e7f1d6b 100644 --- a/xpcom/ds/nsStringEnumerator.h +++ b/xpcom/ds/nsStringEnumerator.h @@ -75,15 +75,15 @@ // InternalMethod(enumerator); // NS_RELEASE(enumerator); // -NS_COM nsresult +nsresult NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM, const nsTArray* aArray, nsISupports* aOwner); -NS_COM nsresult +nsresult NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM, const nsTArray* aArray); -NS_COM nsresult +nsresult NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM, const nsTArray* aArray); @@ -96,11 +96,11 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM, // nsTArray* array = new nsTArray; // array->AppendString("abcd"); // NS_NewAdoptingStringEnumerator(&result, array); -NS_COM nsresult +nsresult NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM, nsTArray* aArray); -NS_COM nsresult +nsresult NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM, nsTArray* aArray); @@ -117,7 +117,7 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM // return NS_NewStringEnumerator(aResult, mCategoryList, this); // } // -NS_COM nsresult +nsresult NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM, const nsTArray* aArray, nsISupports* aOwner); diff --git a/xpcom/ds/nsSupportsArray.cpp b/xpcom/ds/nsSupportsArray.cpp index 97bc3cb45d3b..1161097e4a26 100644 --- a/xpcom/ds/nsSupportsArray.cpp +++ b/xpcom/ds/nsSupportsArray.cpp @@ -673,7 +673,7 @@ nsSupportsArray::Clone(nsISupportsArray* *result) return NS_OK; } -NS_COM nsresult +nsresult NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult) { nsresult rv; diff --git a/xpcom/ds/nsSupportsArray.h b/xpcom/ds/nsSupportsArray.h index 617ed3210e1f..c2db6552d004 100644 --- a/xpcom/ds/nsSupportsArray.h +++ b/xpcom/ds/nsSupportsArray.h @@ -44,12 +44,7 @@ static const PRUint32 kAutoArraySize = 8; -// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration -// controls member method visibility. -#undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY - -class NS_COM nsSupportsArray : public nsISupportsArray { +class nsSupportsArray : public nsISupportsArray { public: nsSupportsArray(void); ~nsSupportsArray(void); // nonvirtual since we're not subclassed diff --git a/xpcom/ds/nsSupportsArrayEnumerator.cpp b/xpcom/ds/nsSupportsArrayEnumerator.cpp index 38d7d728d566..9c7ca4645900 100644 --- a/xpcom/ds/nsSupportsArrayEnumerator.cpp +++ b/xpcom/ds/nsSupportsArrayEnumerator.cpp @@ -130,7 +130,7 @@ nsSupportsArrayEnumerator::Prev() //////////////////////////////////////////////////////////////////////////////// -NS_COM nsresult +nsresult NS_NewISupportsArrayEnumerator(nsISupportsArray* array, nsIBidirectionalEnumerator* *aInstancePtrResult) { diff --git a/xpcom/ds/nsUnicharBuffer.cpp b/xpcom/ds/nsUnicharBuffer.cpp index 12033da04b71..30127f5517a4 100644 --- a/xpcom/ds/nsUnicharBuffer.cpp +++ b/xpcom/ds/nsUnicharBuffer.cpp @@ -121,7 +121,7 @@ UnicharBufferImpl::Grow(PRInt32 aNewSize) return PR_FALSE; } -NS_COM nsresult +nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, PRUint32 aBufferSize) diff --git a/xpcom/ds/nsVariant.h b/xpcom/ds/nsVariant.h index afb2eda256e5..46bfd1089d6c 100644 --- a/xpcom/ds/nsVariant.h +++ b/xpcom/ds/nsVariant.h @@ -113,7 +113,7 @@ struct nsDiscriminatedUnion * use to help them do all the 'standard' nsIVariant data conversions. */ -class NS_COM nsVariant : public nsIWritableVariant +class nsVariant : public nsIWritableVariant { public: NS_DECL_ISUPPORTS diff --git a/xpcom/ds/nsWindowsRegKey.h b/xpcom/ds/nsWindowsRegKey.h index 8630a6bd569e..e3ae72bc40a0 100644 --- a/xpcom/ds/nsWindowsRegKey.h +++ b/xpcom/ds/nsWindowsRegKey.h @@ -53,7 +53,7 @@ * This function may be used to instantiate a windows registry key object prior * to XPCOM being initialized. */ -extern "C" NS_COM nsresult +extern "C" nsresult NS_NewWindowsRegKey(nsIWindowsRegKey **result); //----------------------------------------------------------------------------- diff --git a/xpcom/glue/nsCycleCollectorUtils.h b/xpcom/glue/nsCycleCollectorUtils.h index 49b2d86fb45c..89bd8885bfd5 100644 --- a/xpcom/glue/nsCycleCollectorUtils.h +++ b/xpcom/glue/nsCycleCollectorUtils.h @@ -43,7 +43,7 @@ #if defined(MOZILLA_INTERNAL_API) #define NS_IsCycleCollectorThread NS_IsCycleCollectorThread_P #if defined(XP_WIN) -NS_COM bool NS_IsCycleCollectorThread(); +bool NS_IsCycleCollectorThread(); #elif defined(NS_TLS) // Defined in nsThreadManager.cpp. extern NS_TLS mozilla::threads::ID gTLSThreadID; diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index 2f24d61e5185..ab3957e3957e 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -105,7 +105,7 @@ extern NS_COM_GLUE NS_METHOD NS_GetMainThread(nsIThread **result); #if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN) -NS_COM bool NS_IsMainThread(); +bool NS_IsMainThread(); #elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS) // This is defined in nsThreadManager.cpp and initialized to `Main` for the // main thread by nsThreadManager::Init. diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index bdcf8cd5cefb..0f5b2eabd18d 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -105,7 +105,7 @@ static nsGetKnownFolderPath gGetKnownFolderPath = NULL; static HINSTANCE gShell32DLLInst = NULL; #endif -NS_COM void StartupSpecialSystemDirectory() +void StartupSpecialSystemDirectory() { #if defined (XP_WIN) // SHGetKnownFolderPath is only available on Windows Vista @@ -119,7 +119,7 @@ NS_COM void StartupSpecialSystemDirectory() #endif } -NS_COM void ShutdownSpecialSystemDirectory() +void ShutdownSpecialSystemDirectory() { #if defined (XP_WIN) if (gShell32DLLInst) diff --git a/xpcom/io/SpecialSystemDirectory.h b/xpcom/io/SpecialSystemDirectory.h index 617c4e3bc111..2f0302e0e366 100644 --- a/xpcom/io/SpecialSystemDirectory.h +++ b/xpcom/io/SpecialSystemDirectory.h @@ -50,9 +50,8 @@ #include "prenv.h" #endif - -extern NS_COM void StartupSpecialSystemDirectory(); -extern NS_COM void ShutdownSpecialSystemDirectory(); +extern void StartupSpecialSystemDirectory(); +extern void ShutdownSpecialSystemDirectory(); enum SystemDirectories { diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index 420ac48183ee..9f9a78dbed6c 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -156,7 +156,7 @@ static char* nsEscapeCount( } //---------------------------------------------------------------------------------------- -NS_COM char* nsEscape(const char * str, nsEscapeMask flags) +char* nsEscape(const char * str, nsEscapeMask flags) //---------------------------------------------------------------------------------------- { if(!str) @@ -165,7 +165,7 @@ NS_COM char* nsEscape(const char * str, nsEscapeMask flags) } //---------------------------------------------------------------------------------------- -NS_COM char* nsUnescape(char * str) +char* nsUnescape(char * str) //---------------------------------------------------------------------------------------- { nsUnescapeCount(str); @@ -173,7 +173,7 @@ NS_COM char* nsUnescape(char * str) } //---------------------------------------------------------------------------------------- -NS_COM PRInt32 nsUnescapeCount(char * str) +PRInt32 nsUnescapeCount(char * str) //---------------------------------------------------------------------------------------- { register char *src = str; @@ -219,7 +219,7 @@ NS_COM PRInt32 nsUnescapeCount(char * str) } /* NET_UnEscapeCnt */ -NS_COM char * +char * nsEscapeHTML(const char * string) { char *rv = nsnull; @@ -285,7 +285,7 @@ nsEscapeHTML(const char * string) return(rv); } -NS_COM PRUnichar * +PRUnichar * nsEscapeHTML2(const PRUnichar *aSourceBuffer, PRInt32 aSourceBufferLen) { // if the caller didn't calculate the length @@ -391,7 +391,7 @@ const int EscapeChars[256] = esc_Forced = 1024 */ -NS_COM PRBool NS_EscapeURL(const char *part, +PRBool NS_EscapeURL(const char *part, PRInt32 partLen, PRUint32 flags, nsACString &result) @@ -477,7 +477,7 @@ NS_COM PRBool NS_EscapeURL(const char *part, #define ISHEX(c) memchr(hexChars, c, sizeof(hexChars)-1) -NS_COM PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result) +PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result) { if (!str) { NS_NOTREACHED("null pointer"); diff --git a/xpcom/io/nsEscape.h b/xpcom/io/nsEscape.h index 33e631b83cad..c60b04307148 100644 --- a/xpcom/io/nsEscape.h +++ b/xpcom/io/nsEscape.h @@ -68,23 +68,23 @@ extern "C" { * @return A newly allocated escaped string that must be free'd with * nsCRT::free, or null on failure */ -NS_COM char * nsEscape(const char * str, nsEscapeMask mask); +char * nsEscape(const char * str, nsEscapeMask mask); -NS_COM char * nsUnescape(char * str); +char * nsUnescape(char * str); /* decode % escaped hex codes into character values, * modifies the parameter, returns the same buffer */ -NS_COM PRInt32 nsUnescapeCount (char * str); +PRInt32 nsUnescapeCount (char * str); /* decode % escaped hex codes into character values, * modifies the parameter buffer, returns the length of the result * (result may contain \0's). */ -NS_COM char * +char * nsEscapeHTML(const char * string); -NS_COM PRUnichar * +PRUnichar * nsEscapeHTML2(const PRUnichar *aSourceBuffer, PRInt32 aSourceBufferLen = -1); /* @@ -142,7 +142,7 @@ enum EscapeMask { * * @return TRUE if escaping was performed, FALSE otherwise. */ -NS_COM PRBool NS_EscapeURL(const char *str, +PRBool NS_EscapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result); @@ -158,7 +158,7 @@ NS_COM PRBool NS_EscapeURL(const char *str, * * @return TRUE if unescaping was performed, FALSE otherwise. */ -NS_COM PRBool NS_UnescapeURL(const char *str, +PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result); diff --git a/xpcom/io/nsIInputStreamTee.idl b/xpcom/io/nsIInputStreamTee.idl index 2db8a1b9b4cf..5acba9636470 100644 --- a/xpcom/io/nsIInputStreamTee.idl +++ b/xpcom/io/nsIInputStreamTee.idl @@ -63,12 +63,12 @@ interface nsIInputStreamTee : nsIInputStream %{C++ // factory methods -extern NS_COM nsresult +extern nsresult NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream nsIInputStream *source, nsIOutputStream *sink); -extern NS_COM nsresult +extern nsresult NS_NewInputStreamTeeAsync(nsIInputStream **tee, // read from this input stream nsIInputStream *source, nsIOutputStream *sink, diff --git a/xpcom/io/nsIPipe.idl b/xpcom/io/nsIPipe.idl index 4b26bf467f2e..4db774a56cab 100644 --- a/xpcom/io/nsIPipe.idl +++ b/xpcom/io/nsIPipe.idl @@ -161,7 +161,7 @@ interface nsISearchableInputStream : nsISupports * pass reference to nsIMemory to have all pipe allocations use this * allocator (pass null to use the default allocator) */ -extern NS_COM nsresult +extern nsresult NS_NewPipe2(nsIAsyncInputStream **pipeIn, nsIAsyncOutputStream **pipeOut, PRBool nonBlockingInput = PR_FALSE, @@ -198,7 +198,7 @@ NS_NewPipe2(nsIAsyncInputStream **pipeIn, * pass reference to nsIMemory to have all pipe allocations use this * allocator (pass null to use the default allocator) */ -extern NS_COM nsresult +extern nsresult NS_NewPipe(nsIInputStream **pipeIn, nsIOutputStream **pipeOut, PRUint32 segmentSize = 0, diff --git a/xpcom/io/nsIStorageStream.idl b/xpcom/io/nsIStorageStream.idl index 148136b9d318..f401ac18424e 100644 --- a/xpcom/io/nsIStorageStream.idl +++ b/xpcom/io/nsIStorageStream.idl @@ -102,6 +102,6 @@ interface nsIStorageStream : nsISupports %{C++ // Factory method -NS_COM nsresult +nsresult NS_NewStorageStream(PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result); %} diff --git a/xpcom/io/nsInputStreamTee.cpp b/xpcom/io/nsInputStreamTee.cpp index 2c6830fdd21b..67a73642ae5c 100644 --- a/xpcom/io/nsInputStreamTee.cpp +++ b/xpcom/io/nsInputStreamTee.cpp @@ -338,7 +338,7 @@ nsInputStreamTee::GetEventTarget(nsIEventTarget **anEventTarget) } -NS_COM nsresult +nsresult NS_NewInputStreamTeeAsync(nsIInputStream **result, nsIInputStream *source, nsIOutputStream *sink, @@ -363,7 +363,7 @@ NS_NewInputStreamTeeAsync(nsIInputStream **result, return rv; } -NS_COM nsresult +nsresult NS_NewInputStreamTee(nsIInputStream **result, nsIInputStream *source, nsIOutputStream *sink) diff --git a/xpcom/io/nsLinebreakConverter.h b/xpcom/io/nsLinebreakConverter.h index 56df91bce5bb..816ebed5c3a0 100644 --- a/xpcom/io/nsLinebreakConverter.h +++ b/xpcom/io/nsLinebreakConverter.h @@ -38,13 +38,12 @@ #ifndef nsLinebreakConverter_h_ #define nsLinebreakConverter_h_ - #include "nscore.h" #include "nsString.h" // utility class for converting between different line breaks. -class NS_COM nsLinebreakConverter +class nsLinebreakConverter { public: @@ -152,7 +151,4 @@ public: }; - - - #endif // nsLinebreakConverter_h_ diff --git a/xpcom/io/nsLocalFileOS2.h b/xpcom/io/nsLocalFileOS2.h index 70bbe0969b84..446590ee1a02 100644 --- a/xpcom/io/nsLocalFileOS2.h +++ b/xpcom/io/nsLocalFileOS2.h @@ -67,8 +67,8 @@ class TypeEaEnumerator; -class NS_COM nsLocalFile : public nsILocalFileOS2, - public nsIHashable +class nsLocalFile : public nsILocalFileOS2, + public nsIHashable { public: NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID) diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 3d93c407fe41..90cf308d1f59 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -132,7 +132,7 @@ static nsresult MacErrorMapper(OSErr inErr); PR_END_MACRO /* directory enumerator */ -class NS_COM +class nsDirEnumeratorUnix : public nsISimpleEnumerator, public nsIDirectoryEnumerator { diff --git a/xpcom/io/nsLocalFileUnix.h b/xpcom/io/nsLocalFileUnix.h index 705ce878c10d..f7e62dbcab4d 100644 --- a/xpcom/io/nsLocalFileUnix.h +++ b/xpcom/io/nsLocalFileUnix.h @@ -108,7 +108,7 @@ #endif -class NS_COM nsLocalFile : +class nsLocalFile : #ifdef XP_MACOSX public nsILocalFileMac, #else diff --git a/xpcom/io/nsNativeCharsetUtils.cpp b/xpcom/io/nsNativeCharsetUtils.cpp index 86e17985a2cd..2e0fb62874c7 100644 --- a/xpcom/io/nsNativeCharsetUtils.cpp +++ b/xpcom/io/nsNativeCharsetUtils.cpp @@ -51,14 +51,14 @@ #include "nsReadableUtils.h" #include "nsString.h" -NS_COM nsresult +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) { CopyUTF8toUTF16(input, output); return NS_OK; } -NS_COM nsresult +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) { CopyUTF16toUTF8(input, output); @@ -802,7 +802,7 @@ nsNativeCharsetConverter::IsNativeUTF8() // API implementation //----------------------------------------------------------------------------- -NS_COM nsresult +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) { output.Truncate(); @@ -839,7 +839,7 @@ NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) return rv; } -NS_COM nsresult +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) { output.Truncate(); @@ -868,7 +868,7 @@ NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) return NS_OK; } -NS_COM PRBool +PRBool NS_IsNativeUTF8() { return nsNativeCharsetConverter::IsNativeUTF8(); @@ -905,7 +905,7 @@ NS_ShutdownNativeCharsetUtils() #include "nsAString.h" #include "nsReadableUtils.h" -NS_COM nsresult +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) { PRUint32 inputLen = input.Length(); @@ -935,7 +935,7 @@ NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) return NS_OK; } -NS_COM nsresult +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) { PRUint32 inputLen = input.Length(); @@ -972,13 +972,13 @@ NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) } // moved from widget/src/windows/nsToolkit.cpp -NS_COM PRInt32 +PRInt32 NS_ConvertAtoW(const char *aStrInA, int aBufferSize, PRUnichar *aStrOutW) { return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, aStrOutW, aBufferSize); } -NS_COM PRInt32 +PRInt32 NS_ConvertWtoA(const PRUnichar *aStrInW, int aBufferSizeOut, char *aStrOutA, const char *aDefault) { @@ -1022,7 +1022,7 @@ NS_ConvertWtoA(const PRUnichar *aStrInW, int aBufferSizeOut, static UconvObject UnicodeConverter = NULL; -NS_COM nsresult +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) { PRUint32 inputLen = input.Length(); @@ -1062,7 +1062,7 @@ NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) return NS_OK; } -NS_COM nsresult +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) { size_t inputLen = input.Length(); @@ -1136,14 +1136,14 @@ NS_ShutdownNativeCharsetUtils() #include "nsReadableUtils.h" -NS_COM nsresult +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output) { CopyASCIItoUTF16(input, output); return NS_OK; } -NS_COM nsresult +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output) { LossyCopyUTF16toASCII(input, output); diff --git a/xpcom/io/nsNativeCharsetUtils.h b/xpcom/io/nsNativeCharsetUtils.h index a5990a1347a0..97603aa06c97 100644 --- a/xpcom/io/nsNativeCharsetUtils.h +++ b/xpcom/io/nsNativeCharsetUtils.h @@ -54,8 +54,8 @@ /** * thread-safe conversion routines that do not depend on uconv libraries. */ -NS_COM nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output); -NS_COM nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output); +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output); +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output); /* * This function indicates whether the character encoding used in the file @@ -71,7 +71,7 @@ NS_COM nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &outp * and other platforms (e.g. OS2), it's never UTF-8. */ #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID) -NS_COM PRBool NS_IsNativeUTF8(); +PRBool NS_IsNativeUTF8(); #else inline PRBool NS_IsNativeUTF8() { diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index 78b35bbd4dc5..00bf5f7dc9bc 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -1258,7 +1258,7 @@ nsPipeOutputStream::AsyncWait(nsIOutputStreamCallback *callback, //////////////////////////////////////////////////////////////////////////////// -NS_COM nsresult +nsresult NS_NewPipe(nsIInputStream **pipeIn, nsIOutputStream **pipeOut, PRUint32 segmentSize, @@ -1288,7 +1288,7 @@ NS_NewPipe(nsIInputStream **pipeIn, return NS_OK; } -NS_COM nsresult +nsresult NS_NewPipe2(nsIAsyncInputStream **pipeIn, nsIAsyncOutputStream **pipeOut, PRBool nonBlockingInput, diff --git a/xpcom/io/nsSegmentedBuffer.cpp b/xpcom/io/nsSegmentedBuffer.cpp index 3df912acd477..3f1c49c4d577 100644 --- a/xpcom/io/nsSegmentedBuffer.cpp +++ b/xpcom/io/nsSegmentedBuffer.cpp @@ -168,7 +168,7 @@ nsSegmentedBuffer::Empty() } #if 0 -NS_COM void +void TestSegmentedBuffer() { nsSegmentedBuffer* buf = new nsSegmentedBuffer(); diff --git a/xpcom/io/nsSegmentedBuffer.h b/xpcom/io/nsSegmentedBuffer.h index 436206324c55..a1e0f0e6535d 100644 --- a/xpcom/io/nsSegmentedBuffer.h +++ b/xpcom/io/nsSegmentedBuffer.h @@ -56,10 +56,10 @@ public: } - NS_COM nsresult Init(PRUint32 segmentSize, PRUint32 maxSize, + nsresult Init(PRUint32 segmentSize, PRUint32 maxSize, nsIMemory* allocator = nsnull); - NS_COM char* AppendNewSegment(); // pushes at end + char* AppendNewSegment(); // pushes at end // returns true if no more segments remain: PRBool DeleteFirstSegment(); // pops from beginning @@ -71,7 +71,7 @@ public: // consumption when data is not an exact multiple of segment size. PRBool ReallocLastSegment(size_t newSize); - NS_COM void Empty(); // frees all segments + void Empty(); // frees all segments inline PRUint32 GetSegmentCount() { if (mFirstSegmentIndex <= mLastSegmentIndex) diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index ead96a87ffa3..069067145bbb 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -543,7 +543,7 @@ nsStorageInputStream::Seek(PRUint32 aPosition) return NS_OK; } -NS_COM nsresult +nsresult NS_NewStorageStream(PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result) { NS_ENSURE_ARG(result); diff --git a/xpcom/io/nsStreamUtils.cpp b/xpcom/io/nsStreamUtils.cpp index b2a606752d5f..2c487dd04896 100644 --- a/xpcom/io/nsStreamUtils.cpp +++ b/xpcom/io/nsStreamUtils.cpp @@ -207,7 +207,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsOutputStreamReadyEvent, nsIRunnable, //----------------------------------------------------------------------------- -NS_COM nsresult +nsresult NS_NewInputStreamReadyEvent(nsIInputStreamCallback **event, nsIInputStreamCallback *callback, nsIEventTarget *target) @@ -221,7 +221,7 @@ NS_NewInputStreamReadyEvent(nsIInputStreamCallback **event, return NS_OK; } -NS_COM nsresult +nsresult NS_NewOutputStreamReadyEvent(nsIOutputStreamCallback **event, nsIOutputStreamCallback *callback, nsIEventTarget *target) @@ -584,7 +584,7 @@ public: //----------------------------------------------------------------------------- -NS_COM nsresult +nsresult NS_AsyncCopy(nsIInputStream *source, nsIOutputStream *sink, nsIEventTarget *target, @@ -626,7 +626,7 @@ NS_AsyncCopy(nsIInputStream *source, //----------------------------------------------------------------------------- -NS_COM nsresult +nsresult NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason) { nsAStreamCopier *copier = static_cast( @@ -636,7 +636,7 @@ NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason) //----------------------------------------------------------------------------- -NS_COM nsresult +nsresult NS_ConsumeStream(nsIInputStream *stream, PRUint32 maxCount, nsACString &result) { nsresult rv = NS_OK; @@ -691,7 +691,7 @@ TestInputStream(nsIInputStream *inStr, return NS_ERROR_ABORT; // don't call me anymore } -NS_COM PRBool +PRBool NS_InputStreamIsBuffered(nsIInputStream *stream) { PRBool result = PR_FALSE; @@ -714,7 +714,7 @@ TestOutputStream(nsIOutputStream *outStr, return NS_ERROR_ABORT; // don't call me anymore } -NS_COM PRBool +PRBool NS_OutputStreamIsBuffered(nsIOutputStream *stream) { PRBool result = PR_FALSE; @@ -725,7 +725,7 @@ NS_OutputStreamIsBuffered(nsIOutputStream *stream) //----------------------------------------------------------------------------- -NS_COM NS_METHOD +NS_METHOD NS_CopySegmentToStream(nsIInputStream *inStr, void *closure, const char *buffer, @@ -747,7 +747,7 @@ NS_CopySegmentToStream(nsIInputStream *inStr, return NS_OK; } -NS_COM NS_METHOD +NS_METHOD NS_CopySegmentToBuffer(nsIInputStream *inStr, void *closure, const char *buffer, @@ -761,7 +761,7 @@ NS_CopySegmentToBuffer(nsIInputStream *inStr, return NS_OK; } -NS_COM NS_METHOD +NS_METHOD NS_DiscardSegment(nsIInputStream *inStr, void *closure, const char *buffer, @@ -775,7 +775,7 @@ NS_DiscardSegment(nsIInputStream *inStr, //----------------------------------------------------------------------------- -NS_COM NS_METHOD +NS_METHOD NS_WriteSegmentThunk(nsIInputStream *inStr, void *closure, const char *buffer, diff --git a/xpcom/io/nsStreamUtils.h b/xpcom/io/nsStreamUtils.h index b80603a2785c..dd994a5abe64 100644 --- a/xpcom/io/nsStreamUtils.h +++ b/xpcom/io/nsStreamUtils.h @@ -56,7 +56,7 @@ class nsIEventTarget; * This function is designed to be used to implement AsyncWait when the * aTarget parameter is non-null. */ -extern NS_COM nsresult +extern nsresult NS_NewInputStreamReadyEvent(nsIInputStreamCallback **aEvent, nsIInputStreamCallback *aNotify, nsIEventTarget *aTarget); @@ -71,7 +71,7 @@ NS_NewInputStreamReadyEvent(nsIInputStreamCallback **aEvent, * This function is designed to be used to implement AsyncWait when the * aTarget parameter is non-null. */ -extern NS_COM nsresult +extern nsresult NS_NewOutputStreamReadyEvent(nsIOutputStreamCallback **aEvent, nsIOutputStreamCallback *aNotify, nsIEventTarget *aTarget); @@ -105,7 +105,7 @@ typedef void (* nsAsyncCopyCallbackFun)(void *closure, nsresult status); * * Caller can obtain aCopierCtx to be able to cancel copying. */ -extern NS_COM nsresult +extern nsresult NS_AsyncCopy(nsIInputStream *aSource, nsIOutputStream *aSink, nsIEventTarget *aTarget, @@ -126,7 +126,7 @@ NS_AsyncCopy(nsIInputStream *aSource, * A failure code indicating why the operation is being canceled. * It is an error to pass a success code. */ -extern NS_COM nsresult +extern nsresult NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason); /** @@ -152,7 +152,7 @@ NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason); * Note: The data copied to the string may contain null bytes and may * contain non-ASCII values. */ -extern NS_COM nsresult +extern nsresult NS_ConsumeStream(nsIInputStream *aSource, PRUint32 aMaxCount, nsACString &aBuffer); @@ -169,7 +169,7 @@ NS_ConsumeStream(nsIInputStream *aSource, PRUint32 aMaxCount, * @param aInputStream * The input stream to test. */ -extern NS_COM PRBool +extern PRBool NS_InputStreamIsBuffered(nsIInputStream *aInputStream); /** @@ -185,7 +185,7 @@ NS_InputStreamIsBuffered(nsIInputStream *aInputStream); * @param aOutputStream * The output stream to test. */ -extern NS_COM PRBool +extern PRBool NS_OutputStreamIsBuffered(nsIOutputStream *aOutputStream); /** @@ -195,7 +195,7 @@ NS_OutputStreamIsBuffered(nsIOutputStream *aOutputStream); * * @see nsIInputStream.idl for a description of this function's parameters. */ -extern NS_COM NS_METHOD +extern NS_METHOD NS_CopySegmentToStream(nsIInputStream *aInputStream, void *aClosure, const char *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount); @@ -208,7 +208,7 @@ NS_CopySegmentToStream(nsIInputStream *aInputStream, void *aClosure, * * @see nsIInputStream.idl for a description of this function's parameters. */ -extern NS_COM NS_METHOD +extern NS_METHOD NS_CopySegmentToBuffer(nsIInputStream *aInputStream, void *aClosure, const char *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount); @@ -220,7 +220,7 @@ NS_CopySegmentToBuffer(nsIInputStream *aInputStream, void *aClosure, * * @see nsIInputStream.idl for a description of this function's parameters. */ -extern NS_COM NS_METHOD +extern NS_METHOD NS_DiscardSegment(nsIInputStream *aInputStream, void *aClosure, const char *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount); @@ -236,7 +236,7 @@ NS_DiscardSegment(nsIInputStream *aInputStream, void *aClosure, * This function comes in handy when implementing ReadSegments in terms of an * inner stream's ReadSegments. */ -extern NS_COM NS_METHOD +extern NS_METHOD NS_WriteSegmentThunk(nsIInputStream *aInputStream, void *aClosure, const char *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount); diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index d39a340aceea..9b7130ab4faf 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -387,7 +387,7 @@ nsStringInputStream::Write(IPC::Message *aMsg) WriteParam(aMsg, value); } -NS_COM nsresult +nsresult NS_NewByteInputStream(nsIInputStream** aStreamResult, const char* aStringToRead, PRInt32 aLength, nsAssignmentType aAssignment) @@ -425,7 +425,7 @@ NS_NewByteInputStream(nsIInputStream** aStreamResult, return NS_OK; } -NS_COM nsresult +nsresult NS_NewStringInputStream(nsIInputStream** aStreamResult, const nsAString& aStringToRead) { @@ -441,7 +441,7 @@ NS_NewStringInputStream(nsIInputStream** aStreamResult, return rv; } -NS_COM nsresult +nsresult NS_NewCStringInputStream(nsIInputStream** aStreamResult, const nsACString& aStringToRead) { diff --git a/xpcom/io/nsStringStream.h b/xpcom/io/nsStringStream.h index c73b949e1196..986a92fd7d34 100644 --- a/xpcom/io/nsStringStream.h +++ b/xpcom/io/nsStringStream.h @@ -80,7 +80,7 @@ * If aLength is less than zero, then the length of aStringToRead will be * determined by scanning the buffer for the first null byte. */ -extern NS_COM nsresult +extern nsresult NS_NewByteInputStream(nsIInputStream** aStreamResult, const char* aStringToRead, PRInt32 aLength = -1, nsAssignmentType aAssignment = NS_ASSIGNMENT_DEPEND); @@ -93,7 +93,7 @@ NS_NewByteInputStream(nsIInputStream** aStreamResult, * truncation (i.e., the high-order byte of each character will be discarded). * This could result in data-loss, so be careful when using this function. */ -extern NS_COM nsresult +extern nsresult NS_NewStringInputStream(nsIInputStream** aStreamResult, const nsAString& aStringToRead); @@ -101,7 +101,7 @@ NS_NewStringInputStream(nsIInputStream** aStreamResult, * Factory method to get an nsInputStream from an nsACString. Result will * implement nsIStringInputStream and nsISeekableStream. */ -extern NS_COM nsresult +extern nsresult NS_NewCStringInputStream(nsIInputStream** aStreamResult, const nsACString& aStringToRead); diff --git a/xpcom/io/nsUnicharInputStream.h b/xpcom/io/nsUnicharInputStream.h index fdeadd5d9475..8e4359dbcf60 100644 --- a/xpcom/io/nsUnicharInputStream.h +++ b/xpcom/io/nsUnicharInputStream.h @@ -56,7 +56,7 @@ public: NS_DECL_NSIFACTORY NS_DECL_NSISIMPLEUNICHARSTREAMFACTORY - static NS_COM nsSimpleUnicharStreamFactory* GetInstance(); + static nsSimpleUnicharStreamFactory* GetInstance(); private: static const nsSimpleUnicharStreamFactory kInstance; diff --git a/xpcom/io/nsWildCard.cpp b/xpcom/io/nsWildCard.cpp index 7fcf3e1dbb8e..85b02756be98 100644 --- a/xpcom/io/nsWildCard.cpp +++ b/xpcom/io/nsWildCard.cpp @@ -170,13 +170,13 @@ NS_WildCardValid_(const T *expr) return (x < 0 ? x : VALID_SXP); } -NS_COM int +int NS_WildCardValid(const char *expr) { return NS_WildCardValid_(expr); } -NS_COM int +int NS_WildCardValid(const PRUnichar *expr) { return NS_WildCardValid_(expr); @@ -444,7 +444,7 @@ ns_WildCardMatch(const T *str, const T *xp, PRBool case_insensitive) } template -NS_COM int +int NS_WildCardMatch_(const T *str, const T *expr, PRBool case_insensitive) { int is_valid = NS_WildCardValid(expr); @@ -456,14 +456,14 @@ NS_WildCardMatch_(const T *str, const T *expr, PRBool case_insensitive) } } -NS_COM int +int NS_WildCardMatch(const char *str, const char *xp, PRBool case_insensitive) { return NS_WildCardMatch_(str, xp, case_insensitive); } -NS_COM int +int NS_WildCardMatch(const PRUnichar *str, const PRUnichar *xp, PRBool case_insensitive) { diff --git a/xpcom/io/nsWildCard.h b/xpcom/io/nsWildCard.h index 33ce579b7fe2..2dfeeadfc1f8 100644 --- a/xpcom/io/nsWildCard.h +++ b/xpcom/io/nsWildCard.h @@ -70,9 +70,9 @@ #define INVALID_SXP -2 #define VALID_SXP 1 -NS_COM int NS_WildCardValid(const char *expr); +int NS_WildCardValid(const char *expr); -NS_COM int NS_WildCardValid(const PRUnichar *expr); +int NS_WildCardValid(const PRUnichar *expr); /* return values for the search routines */ #define MATCH 0 @@ -87,10 +87,10 @@ NS_COM int NS_WildCardValid(const PRUnichar *expr); * Returns 0 on match and 1 on non-match. */ -NS_COM int NS_WildCardMatch(const char *str, const char *expr, +int NS_WildCardMatch(const char *str, const char *expr, PRBool case_insensitive); -NS_COM int NS_WildCardMatch(const PRUnichar *str, const PRUnichar *expr, +int NS_WildCardMatch(const PRUnichar *str, const PRUnichar *expr, PRBool case_insensitive); #endif /* nsWildCard_h__ */ diff --git a/xpcom/proxy/public/nsIProxyObjectManager.idl b/xpcom/proxy/public/nsIProxyObjectManager.idl index 16f2e5e3b9c4..b37d295d52a1 100644 --- a/xpcom/proxy/public/nsIProxyObjectManager.idl +++ b/xpcom/proxy/public/nsIProxyObjectManager.idl @@ -137,7 +137,7 @@ interface nsIProxyObjectManager : nsISupports * manager themselves every single time, thus making the calling code more * readable. The parameters are the same as for GetProxyForObject. */ -extern NS_COM nsresult +extern nsresult NS_GetProxyForObject(nsIEventTarget *target, REFNSIID iid, nsISupports* object, PRInt32 proxyType, void** result); #endif diff --git a/xpcom/proxy/src/nsProxyObjectManager.cpp b/xpcom/proxy/src/nsProxyObjectManager.cpp index 8dc947177a3c..acc2b90fe184 100644 --- a/xpcom/proxy/src/nsProxyObjectManager.cpp +++ b/xpcom/proxy/src/nsProxyObjectManager.cpp @@ -326,7 +326,7 @@ nsProxyObjectManager::GetClass(REFNSIID aIID, nsProxyEventClass **aResult) * themselves every single time, thus making the calling code more * readable. */ -NS_COM nsresult +nsresult NS_GetProxyForObject(nsIEventTarget *target, REFNSIID aIID, nsISupports* aObj, diff --git a/xpcom/string/public/nsAString.h b/xpcom/string/public/nsAString.h index b9a7d0d63c75..c86f0ee923f7 100644 --- a/xpcom/string/public/nsAString.h +++ b/xpcom/string/public/nsAString.h @@ -74,7 +74,7 @@ * ASCII case-insensitive comparator. (for Unicode case-insensitive * comparision, see nsUnicharUtils.h) */ -class NS_COM nsCaseInsensitiveCStringComparator +class nsCaseInsensitiveCStringComparator : public nsCStringComparator { public: diff --git a/xpcom/string/public/nsCharTraits.h b/xpcom/string/public/nsCharTraits.h index 8ac282207299..5d2f933c5a54 100644 --- a/xpcom/string/public/nsCharTraits.h +++ b/xpcom/string/public/nsCharTraits.h @@ -151,7 +151,7 @@ struct nsCharTraits typedef PRUint16 unsigned_char_type; typedef char incompatible_char_type; - NS_COM static char_type *sEmptyBuffer; + static char_type *sEmptyBuffer; static void @@ -441,7 +441,7 @@ struct nsCharTraits typedef unsigned char unsigned_char_type; typedef PRUnichar incompatible_char_type; - NS_COM static char_type *sEmptyBuffer; + static char_type *sEmptyBuffer; static void diff --git a/xpcom/string/public/nsPrintfCString.h b/xpcom/string/public/nsPrintfCString.h index 3f3d04d3dc86..e63303a11e05 100644 --- a/xpcom/string/public/nsPrintfCString.h +++ b/xpcom/string/public/nsPrintfCString.h @@ -67,7 +67,7 @@ * much more efficiently handled with |NS_LITERAL_[C]STRING| and |nsLiteral[C]String|. */ -class NS_COM nsPrintfCString : public nsCString +class nsPrintfCString : public nsCString { typedef nsCString string_type; diff --git a/xpcom/string/public/nsReadableUtils.h b/xpcom/string/public/nsReadableUtils.h index d86da93dfe93..1769936d447e 100644 --- a/xpcom/string/public/nsReadableUtils.h +++ b/xpcom/string/public/nsReadableUtils.h @@ -59,29 +59,29 @@ inline size_t Distance( const nsReadingIterator& start, const nsReadingIte return end.get() - start.get(); } -NS_COM void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest NS_OUTPARAM ); -NS_COM void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM ); +void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest NS_OUTPARAM ); +void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM ); -NS_COM void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM ); -NS_COM void CopyASCIItoUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM ); +void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM ); +void CopyASCIItoUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM ); -NS_COM void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest NS_OUTPARAM ); -NS_COM void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM ); +void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest NS_OUTPARAM ); +void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM ); -NS_COM void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM ); -NS_COM void CopyUTF8toUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM ); +void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM ); +void CopyUTF8toUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM ); -NS_COM void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest ); -NS_COM void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest ); +void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest ); +void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest ); -NS_COM void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ); -NS_COM void AppendASCIItoUTF16( const char* aSource, nsAString& aDest ); +void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ); +void AppendASCIItoUTF16( const char* aSource, nsAString& aDest ); -NS_COM void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest ); -NS_COM void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest ); +void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest ); +void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest ); -NS_COM void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ); -NS_COM void AppendUTF8toUTF16( const char* aSource, nsAString& aDest ); +void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ); +void AppendUTF8toUTF16( const char* aSource, nsAString& aDest ); /** * Returns a new |char| buffer containing a zero-terminated copy of |aSource|. @@ -94,7 +94,7 @@ NS_COM void AppendUTF8toUTF16( const char* aSource, nsAString& aDest ); * @param aSource a 16-bit wide string * @return a new |char| buffer you must free with |nsMemory::Free|. */ -NS_COM char* ToNewCString( const nsAString& aSource ); +char* ToNewCString( const nsAString& aSource ); /** @@ -106,7 +106,7 @@ NS_COM char* ToNewCString( const nsAString& aSource ); * @param aSource an 8-bit wide string * @return a new |char| buffer you must free with |nsMemory::Free|. */ -NS_COM char* ToNewCString( const nsACString& aSource ); +char* ToNewCString( const nsACString& aSource ); /** * Returns a new |char| buffer containing a zero-terminated copy of |aSource|. @@ -123,7 +123,7 @@ NS_COM char* ToNewCString( const nsACString& aSource ); * @return a new |char| buffer you must free with |nsMemory::Free|. */ -NS_COM char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = nsnull ); +char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = nsnull ); /** @@ -138,7 +138,7 @@ NS_COM char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = n * @param aSource a UTF-16 string * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|. */ -NS_COM PRUnichar* ToNewUnicode( const nsAString& aSource ); +PRUnichar* ToNewUnicode( const nsAString& aSource ); /** @@ -152,7 +152,7 @@ NS_COM PRUnichar* ToNewUnicode( const nsAString& aSource ); * @param aSource an 8-bit wide string (a C-string, NOT UTF-8) * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|. */ -NS_COM PRUnichar* ToNewUnicode( const nsACString& aSource ); +PRUnichar* ToNewUnicode( const nsACString& aSource ); /** * Returns a new |PRUnichar| buffer containing a zero-terminated copy @@ -169,7 +169,7 @@ NS_COM PRUnichar* ToNewUnicode( const nsACString& aSource ); * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|. * (UTF-16 encoded) */ -NS_COM PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count = nsnull ); +PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count = nsnull ); /** * Copies |aLength| 16-bit code units from the start of |aSource| to the @@ -183,7 +183,7 @@ NS_COM PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16C * @param aLength the number of 16-bit code units to copy * @return pointer to destination buffer - identical to |aDest| */ -NS_COM PRUnichar* CopyUnicodeTo( const nsAString& aSource, +PRUnichar* CopyUnicodeTo( const nsAString& aSource, PRUint32 aSrcOffset, PRUnichar* aDest, PRUint32 aLength ); @@ -200,7 +200,7 @@ NS_COM PRUnichar* CopyUnicodeTo( const nsAString& aSource, * @param aSrcEnd end source iterator * @param aDest destination for the copy */ -NS_COM void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart, +void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart, const nsAString::const_iterator& aSrcEnd, nsAString& aDest ); @@ -214,7 +214,7 @@ NS_COM void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart, * @param aSrcEnd end source iterator * @param aDest destination for the copy */ -NS_COM void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart, +void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart, const nsAString::const_iterator& aSrcEnd, nsAString& aDest ); @@ -223,15 +223,14 @@ NS_COM void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart, * * @param aString a 16-bit wide string to scan */ -NS_COM PRBool IsASCII( const nsAString& aString ); +PRBool IsASCII( const nsAString& aString ); /** * Returns |PR_TRUE| if |aString| contains only ASCII characters, that is, characters in the range (0x00, 0x7F). * * @param aString a 8-bit wide string to scan */ -NS_COM PRBool IsASCII( const nsACString& aString ); - +PRBool IsASCII( const nsACString& aString ); /** * Returns |PR_TRUE| if |aString| is a valid UTF-8 string. @@ -251,28 +250,28 @@ NS_COM PRBool IsASCII( const nsACString& aString ); * * @param aString an 8-bit wide string to scan */ -NS_COM PRBool IsUTF8( const nsACString& aString ); +PRBool IsUTF8( const nsACString& aString ); -NS_COM PRBool ParseString(const nsACString& aAstring, char aDelimiter, +PRBool ParseString(const nsACString& aAstring, char aDelimiter, nsTArray& aArray); /** * Converts case in place in the argument string. */ -NS_COM void ToUpperCase( nsACString& ); +void ToUpperCase( nsACString& ); -NS_COM void ToLowerCase( nsACString& ); +void ToLowerCase( nsACString& ); -NS_COM void ToUpperCase( nsCSubstring& ); +void ToUpperCase( nsCSubstring& ); -NS_COM void ToLowerCase( nsCSubstring& ); +void ToLowerCase( nsCSubstring& ); /** * Converts case from string aSource to aDest. */ -NS_COM void ToUpperCase( const nsACString& aSource, nsACString& aDest ); +void ToUpperCase( const nsACString& aSource, nsACString& aDest ); -NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest ); +void ToLowerCase( const nsACString& aSource, nsACString& aDest ); /** * Finds the leftmost occurrence of |aPattern|, if any in the range |aSearchStart|..|aSearchEnd|. @@ -284,8 +283,8 @@ NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest ); * If we need something faster, then we can implement that later. */ -NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() ); -NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() ); +PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() ); +PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() ); /* sometimes we don't care about where the string was, just that we * found it or not */ @@ -306,7 +305,7 @@ inline PRBool FindInReadable( const nsACString& aPattern, const nsACString& aSou } -NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& ); +PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& ); /** * Finds the rightmost occurrence of |aPattern| @@ -314,8 +313,8 @@ NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACStr * point to the match. If no match was found, returns |PR_FALSE| and makes |aSearchStart == aSearchEnd|. * */ -NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() ); -NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() ); +PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() ); +PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() ); /** * Finds the leftmost occurrence of |aChar|, if any in the range @@ -325,37 +324,36 @@ NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_ite * point to the match. If no match was found, returns |PR_FALSE| and * makes |aSearchStart == aSearchEnd|. */ -NS_COM PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd ); -NS_COM PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd ); +PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd ); +PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd ); /** * Finds the number of occurences of |aChar| in the string |aStr| */ -NS_COM PRUint32 CountCharInReadable( const nsAString& aStr, +PRUint32 CountCharInReadable( const nsAString& aStr, PRUnichar aChar ); -NS_COM PRUint32 CountCharInReadable( const nsACString& aStr, +PRUint32 CountCharInReadable( const nsACString& aStr, char aChar ); -NS_COM PRBool +PRBool StringBeginsWith( const nsAString& aSource, const nsAString& aSubstring, const nsStringComparator& aComparator = nsDefaultStringComparator() ); -NS_COM PRBool +PRBool StringBeginsWith( const nsACString& aSource, const nsACString& aSubstring, const nsCStringComparator& aComparator = nsDefaultCStringComparator() ); -NS_COM PRBool +PRBool StringEndsWith( const nsAString& aSource, const nsAString& aSubstring, const nsStringComparator& aComparator = nsDefaultStringComparator() ); -NS_COM PRBool +PRBool StringEndsWith( const nsACString& aSource, const nsACString& aSubstring, const nsCStringComparator& aComparator = nsDefaultCStringComparator() ); -NS_COM const nsAFlatString& EmptyString(); -NS_COM const nsAFlatCString& EmptyCString(); - +const nsAFlatString& EmptyString(); +const nsAFlatCString& EmptyCString(); /** * Compare a UTF-8 string to an UTF-16 string. @@ -365,11 +363,11 @@ NS_COM const nsAFlatCString& EmptyCString(); * error (eg the strings are not valid UTF8 and UTF16 respectively), * this method will return PR_INT32_MIN. */ -NS_COM PRInt32 +PRInt32 CompareUTF8toUTF16(const nsASingleFragmentCString& aUTF8String, const nsASingleFragmentString& aUTF16String); -NS_COM void +void AppendUCS4ToUTF16(const PRUint32 aSource, nsAString& aDest); template diff --git a/xpcom/string/public/nsStringBuffer.h b/xpcom/string/public/nsStringBuffer.h index e1ab05ae1ea5..935630ce37a8 100644 --- a/xpcom/string/public/nsStringBuffer.h +++ b/xpcom/string/public/nsStringBuffer.h @@ -73,7 +73,7 @@ class nsStringBuffer * * @return new string buffer or null if out of memory. */ - NS_COM static nsStringBuffer* Alloc(size_t storageSize); + static nsStringBuffer* Alloc(size_t storageSize); /** * Resizes the given string buffer to the specified storage size. This @@ -86,18 +86,18 @@ class nsStringBuffer * * @see IsReadonly */ - NS_COM static nsStringBuffer* Realloc(nsStringBuffer* buf, size_t storageSize); + static nsStringBuffer* Realloc(nsStringBuffer* buf, size_t storageSize); /** * Increment the reference count on this string buffer. */ - NS_COM void NS_FASTCALL AddRef(); + void NS_FASTCALL AddRef(); /** * Decrement the reference count on this string buffer. The string * buffer will be destroyed when its reference count reaches zero. */ - NS_COM void NS_FASTCALL Release(); + void NS_FASTCALL Release(); /** * This method returns the string buffer corresponding to the given data @@ -148,8 +148,8 @@ class nsStringBuffer * the returned string buffer must have its reference count incremented * via a call to the AddRef method. */ - NS_COM static nsStringBuffer* FromString(const nsAString &str); - NS_COM static nsStringBuffer* FromString(const nsACString &str); + static nsStringBuffer* FromString(const nsAString &str); + static nsStringBuffer* FromString(const nsACString &str); /** * The ToString methods assign this string buffer to a given string @@ -165,9 +165,9 @@ class nsStringBuffer * however, string length is always measured in storage units * (2-byte units for wide strings). */ - NS_COM void ToString(PRUint32 len, nsAString &str, + void ToString(PRUint32 len, nsAString &str, PRBool aMoveOwnership = PR_FALSE); - NS_COM void ToString(PRUint32 len, nsACString &str, + void ToString(PRUint32 len, nsACString &str, PRBool aMoveOwnership = PR_FALSE); }; diff --git a/xpcom/string/public/nsTDependentString.h b/xpcom/string/public/nsTDependentString.h index 4bd57b30859f..a9192e02a4c2 100644 --- a/xpcom/string/public/nsTDependentString.h +++ b/xpcom/string/public/nsTDependentString.h @@ -117,7 +117,7 @@ class nsTDependentString_CharT : public nsTString_CharT Rebind(data, PRUint32(char_traits::length(data))); } - NS_COM void Rebind( const char_type* data, size_type length ); + void Rebind( const char_type* data, size_type length ); void Rebind( const char_type* start, const char_type* end ) { diff --git a/xpcom/string/public/nsTDependentSubstring.h b/xpcom/string/public/nsTDependentSubstring.h index 33c3ae3558c9..be3f93b2c028 100644 --- a/xpcom/string/public/nsTDependentSubstring.h +++ b/xpcom/string/public/nsTDependentSubstring.h @@ -57,9 +57,9 @@ class nsTDependentSubstring_CharT : public nsTSubstring_CharT public: - NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) ); + void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) ); - NS_COM void Rebind( const char_type* start, const char_type* end ); + void Rebind( const char_type* start, const char_type* end ); nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) ) : substring_type() diff --git a/xpcom/string/public/nsTPromiseFlatString.h b/xpcom/string/public/nsTPromiseFlatString.h index 008f0cdc948d..0fc04655bf20 100644 --- a/xpcom/string/public/nsTPromiseFlatString.h +++ b/xpcom/string/public/nsTPromiseFlatString.h @@ -99,7 +99,7 @@ class nsTPromiseFlatString_CharT : public nsTString_CharT private: - NS_COM void Init( const substring_type& ); + void Init( const substring_type& ); // NOT TO BE IMPLEMENTED void operator=( const self_type& ); diff --git a/xpcom/string/public/nsTString.h b/xpcom/string/public/nsTString.h index b70289a8e0a7..34be105e0bb8 100644 --- a/xpcom/string/public/nsTString.h +++ b/xpcom/string/public/nsTString.h @@ -150,12 +150,12 @@ class nsTString_CharT : public nsTSubstring_CharT * @return offset in string, or kNotFound */ - NS_COM PRInt32 Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; - NS_COM PRInt32 Find( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; + PRInt32 Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; + PRInt32 Find( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; #ifdef CharT_is_PRUnichar - NS_COM PRInt32 Find( const nsAFlatString& aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; - NS_COM PRInt32 Find( const PRUnichar* aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; + PRInt32 Find( const nsAFlatString& aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; + PRInt32 Find( const PRUnichar* aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; #endif @@ -171,12 +171,12 @@ class nsTString_CharT : public nsTSubstring_CharT * @return offset in string, or kNotFound */ - NS_COM PRInt32 RFind( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; - NS_COM PRInt32 RFind( const char* aCString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; + PRInt32 RFind( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; + PRInt32 RFind( const char* aCString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; #ifdef CharT_is_PRUnichar - NS_COM PRInt32 RFind( const nsAFlatString& aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; - NS_COM PRInt32 RFind( const PRUnichar* aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; + PRInt32 RFind( const nsAFlatString& aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; + PRInt32 RFind( const PRUnichar* aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; #endif @@ -191,7 +191,7 @@ class nsTString_CharT : public nsTSubstring_CharT */ // PRInt32 FindChar( PRUnichar aChar, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const; - NS_COM PRInt32 RFindChar( PRUnichar aChar, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; + PRInt32 RFindChar( PRUnichar aChar, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const; /** @@ -204,14 +204,14 @@ class nsTString_CharT : public nsTSubstring_CharT * @return offset in string, or kNotFound */ - NS_COM PRInt32 FindCharInSet( const char* aString, PRInt32 aOffset=0 ) const; + PRInt32 FindCharInSet( const char* aString, PRInt32 aOffset=0 ) const; PRInt32 FindCharInSet( const self_type& aString, PRInt32 aOffset=0 ) const { return FindCharInSet(aString.get(), aOffset); } #ifdef CharT_is_PRUnichar - NS_COM PRInt32 FindCharInSet( const PRUnichar* aString, PRInt32 aOffset=0 ) const; + PRInt32 FindCharInSet( const PRUnichar* aString, PRInt32 aOffset=0 ) const; #endif @@ -225,7 +225,7 @@ class nsTString_CharT : public nsTSubstring_CharT * @return offset in string, or kNotFound */ - NS_COM PRInt32 RFindCharInSet( const char_type* aString, PRInt32 aOffset=-1 ) const; + PRInt32 RFindCharInSet( const char_type* aString, PRInt32 aOffset=-1 ) const; PRInt32 RFindCharInSet( const self_type& aString, PRInt32 aOffset=-1 ) const { return RFindCharInSet(aString.get(), aOffset); @@ -242,7 +242,7 @@ class nsTString_CharT : public nsTSubstring_CharT */ #ifdef CharT_is_char - NS_COM PRInt32 Compare( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1 ) const; + PRInt32 Compare( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1 ) const; #endif @@ -259,7 +259,7 @@ class nsTString_CharT : public nsTSubstring_CharT return Compare(aString, PR_TRUE, aCount) == 0; } #else - NS_COM PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const; + PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const; #endif // !CharT_is_PRUnichar @@ -270,7 +270,7 @@ class nsTString_CharT : public nsTSubstring_CharT * @param aErrorCode will contain error if one occurs * @return double-precision float rep of string value */ - NS_COM double ToDouble( PRInt32* aErrorCode ) const; + double ToDouble( PRInt32* aErrorCode ) const; /** * Perform string to single-precision float conversion. @@ -289,7 +289,7 @@ class nsTString_CharT : public nsTSubstring_CharT * @param aRadix tells us which radix to assume; kAutoDetect tells us to determine the radix for you. * @return int rep of string value, and possible (out) error code */ - NS_COM PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const; + PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const; PRInt32 ToInteger( nsresult* aErrorCode, PRUint32 aRadix=kRadix10 ) const { return ToInteger(reinterpret_cast(aErrorCode), aRadix); } @@ -311,7 +311,7 @@ class nsTString_CharT : public nsTSubstring_CharT * aWritable = Substring(aReadable, 0, 17); */ - NS_COM size_type Mid( self_type& aResult, PRUint32 aStartPos, PRUint32 aCount ) const; + size_type Mid( self_type& aResult, PRUint32 aStartPos, PRUint32 aCount ) const; size_type Left( self_type& aResult, size_type aCount ) const { @@ -333,7 +333,7 @@ class nsTString_CharT : public nsTSubstring_CharT * @return TRUE if successful */ - NS_COM PRBool SetCharAt( PRUnichar aChar, PRUint32 aIndex ); + PRBool SetCharAt( PRUnichar aChar, PRUint32 aIndex ); /** @@ -342,23 +342,23 @@ class nsTString_CharT : public nsTSubstring_CharT * * @param aSet -- characters to be cut from this */ - NS_COM void StripChars( const char* aSet ); + void StripChars( const char* aSet ); /** * This method strips whitespace throughout the string. */ - NS_COM void StripWhitespace(); + void StripWhitespace(); /** * swaps occurence of 1 string for another */ - NS_COM void ReplaceChar( char_type aOldChar, char_type aNewChar ); - NS_COM void ReplaceChar( const char* aSet, char_type aNewChar ); - NS_COM void ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue); - NS_COM void ReplaceSubstring( const char_type* aTarget, const char_type* aNewValue); + void ReplaceChar( char_type aOldChar, char_type aNewChar ); + void ReplaceChar( const char* aSet, char_type aNewChar ); + void ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue); + void ReplaceSubstring( const char_type* aTarget, const char_type* aNewValue); /** @@ -371,7 +371,7 @@ class nsTString_CharT : public nsTSubstring_CharT * @param aIgnoreQuotes -- if true, causes surrounding quotes to be ignored * @return this */ - NS_COM void Trim( const char* aSet, PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE, PRBool aIgnoreQuotes=PR_FALSE ); + void Trim( const char* aSet, PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE, PRBool aIgnoreQuotes=PR_FALSE ); /** * This method strips whitespace from string. @@ -381,18 +381,18 @@ class nsTString_CharT : public nsTSubstring_CharT * @param aEliminateLeading controls stripping of leading ws * @param aEliminateTrailing controls stripping of trailing ws */ - NS_COM void CompressWhitespace( PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE ); + void CompressWhitespace( PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE ); /** * assign/append/insert with _LOSSY_ conversion */ - NS_COM void AssignWithConversion( const nsTAString_IncompatibleCharT& aString ); - NS_COM void AssignWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 ); + void AssignWithConversion( const nsTAString_IncompatibleCharT& aString ); + void AssignWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 ); - NS_COM void AppendWithConversion( const nsTAString_IncompatibleCharT& aString ); - NS_COM void AppendWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 ); + void AppendWithConversion( const nsTAString_IncompatibleCharT& aString ); + void AppendWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 ); #endif // !MOZ_STRING_WITH_OBSOLETE_API @@ -701,7 +701,7 @@ class nsTAdoptingString_CharT : public nsTXPIDLString_CharT // Adopt(), if possible, when assigning to a self_type&. Note // that this violates the constness of str, str is always // truncated when this operator is called. - NS_COM self_type& operator=( const self_type& str ); + self_type& operator=( const self_type& str ); private: // NOT TO BE IMPLEMENTED. diff --git a/xpcom/string/public/nsTSubstring.h b/xpcom/string/public/nsTSubstring.h index a9d97eccd870..f1262c881ff6 100644 --- a/xpcom/string/public/nsTSubstring.h +++ b/xpcom/string/public/nsTSubstring.h @@ -43,7 +43,7 @@ /** * The base for string comparators */ -class NS_COM nsTStringComparator_CharT +class nsTStringComparator_CharT { public: typedef CharT char_type; @@ -57,7 +57,7 @@ class NS_COM nsTStringComparator_CharT /** * The default string comparator (case-sensitive comparision) */ -class NS_COM nsTDefaultStringComparator_CharT +class nsTDefaultStringComparator_CharT : public nsTStringComparator_CharT { public: @@ -252,32 +252,32 @@ class nsTSubstring_CharT return mData[mLength - 1]; } - NS_COM size_type NS_FASTCALL CountChar( char_type ) const; - NS_COM PRInt32 NS_FASTCALL FindChar( char_type, index_type offset = 0 ) const; + size_type NS_FASTCALL CountChar( char_type ) const; + PRInt32 NS_FASTCALL FindChar( char_type, index_type offset = 0 ) const; /** * equality */ - NS_COM PRBool NS_FASTCALL Equals( const self_type& ) const; - NS_COM PRBool NS_FASTCALL Equals( const self_type&, const comparator_type& ) const; + PRBool NS_FASTCALL Equals( const self_type& ) const; + PRBool NS_FASTCALL Equals( const self_type&, const comparator_type& ) const; - NS_COM PRBool NS_FASTCALL Equals( const char_type* data ) const; - NS_COM PRBool NS_FASTCALL Equals( const char_type* data, const comparator_type& comp ) const; + PRBool NS_FASTCALL Equals( const char_type* data ) const; + PRBool NS_FASTCALL Equals( const char_type* data, const comparator_type& comp ) const; /** * An efficient comparison with ASCII that can be used even * for wide strings. Call this version when you know the * length of 'data'. */ - NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data, size_type len ) const; + PRBool NS_FASTCALL EqualsASCII( const char* data, size_type len ) const; /** * An efficient comparison with ASCII that can be used even * for wide strings. Call this version when 'data' is * null-terminated. */ - NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data ) const; + PRBool NS_FASTCALL EqualsASCII( const char* data ) const; // EqualsLiteral must ONLY be applied to an actual literal string. // Do not attempt to use it with a regular char* pointer, or with a char @@ -308,8 +308,8 @@ class nsTSubstring_CharT // *not* lowercased for you. If you compare to an ASCII or literal // string that contains an uppercase character, it is guaranteed to // return false. We will throw assertions too. - NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data, size_type len ) const; - NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data ) const; + PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data, size_type len ) const; + PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data ) const; // LowerCaseEqualsLiteral must ONLY be applied to an actual // literal string. Do not attempt to use it with a regular char* @@ -338,13 +338,13 @@ class nsTSubstring_CharT * assignment */ - NS_COM void NS_FASTCALL Assign( char_type c ); - NS_COM void NS_FASTCALL Assign( const char_type* data, size_type length = size_type(-1) ); - NS_COM void NS_FASTCALL Assign( const self_type& ); - NS_COM void NS_FASTCALL Assign( const substring_tuple_type& ); + void NS_FASTCALL Assign( char_type c ); + void NS_FASTCALL Assign( const char_type* data, size_type length = size_type(-1) ); + void NS_FASTCALL Assign( const self_type& ); + void NS_FASTCALL Assign( const substring_tuple_type& ); - NS_COM void NS_FASTCALL AssignASCII( const char* data, size_type length ); - NS_COM void NS_FASTCALL AssignASCII( const char* data ); + void NS_FASTCALL AssignASCII( const char* data, size_type length ); + void NS_FASTCALL AssignASCII( const char* data ); // AssignLiteral must ONLY be applied to an actual literal string. // Do not attempt to use it with a regular char* pointer, or with a char @@ -366,19 +366,19 @@ class nsTSubstring_CharT self_type& operator=( const self_type& str ) { Assign(str); return *this; } self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; } - NS_COM void NS_FASTCALL Adopt( char_type* data, size_type length = size_type(-1) ); + void NS_FASTCALL Adopt( char_type* data, size_type length = size_type(-1) ); /** * buffer manipulation */ - NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, char_type c ); - NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) ); + void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, char_type c ); + void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) ); void Replace( index_type cutStart, size_type cutLength, const self_type& str ) { Replace(cutStart, cutLength, str.Data(), str.Length()); } - NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& tuple ); + void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& tuple ); - NS_COM void NS_FASTCALL ReplaceASCII( index_type cutStart, size_type cutLength, const char* data, size_type length = size_type(-1) ); + void NS_FASTCALL ReplaceASCII( index_type cutStart, size_type cutLength, const char* data, size_type length = size_type(-1) ); void Append( char_type c ) { Replace(mLength, 0, c); } void Append( const char_type* data, size_type length = size_type(-1) ) { Replace(mLength, 0, data, length); } @@ -388,7 +388,7 @@ class nsTSubstring_CharT void AppendASCII( const char* data, size_type length = size_type(-1) ) { ReplaceASCII(mLength, 0, data, length); } // AppendPrintf truncates output to 31 ASCII characters - NS_COM void AppendPrintf( const char* format, ... ); + void AppendPrintf( const char* format, ... ); void AppendInt( PRInt32 aInteger ) { AppendPrintf( "%d", aInteger ); } void AppendInt( PRInt32 aInteger, int aRadix ) @@ -426,7 +426,7 @@ class nsTSubstring_CharT void AppendFloat( double aFloat ) { DoAppendFloat(aFloat, 15); } private: - NS_COM void NS_FASTCALL DoAppendFloat( double aFloat, int digits ); + void NS_FASTCALL DoAppendFloat( double aFloat, int digits ); public: // AppendLiteral must ONLY be applied to an actual literal string. @@ -469,9 +469,9 @@ class nsTSubstring_CharT * PR_FALSE on out-of-memory, or if requesting a size bigger * than a string can hold (2^31 chars). */ - NS_COM PRBool NS_FASTCALL SetCapacity( size_type newCapacity ); + PRBool NS_FASTCALL SetCapacity( size_type newCapacity ); - NS_COM void NS_FASTCALL SetLength( size_type newLength ); + void NS_FASTCALL SetLength( size_type newLength ); void Truncate( size_type newLength = 0 ) { @@ -525,7 +525,7 @@ class nsTSubstring_CharT * string will be truncated. @see nsTSubstring::IsVoid */ - NS_COM void NS_FASTCALL SetIsVoid( PRBool ); + void NS_FASTCALL SetIsVoid( PRBool ); /** * This method is used to remove all occurrences of aChar from this @@ -535,7 +535,7 @@ class nsTSubstring_CharT * @param aOffset -- where in this string to start stripping chars */ - NS_COM void StripChar( char_type aChar, PRInt32 aOffset=0 ); + void StripChar( char_type aChar, PRInt32 aOffset=0 ); /** * This method is used to remove all occurrences of aChars from this @@ -545,7 +545,7 @@ class nsTSubstring_CharT * @param aOffset -- where in this string to start stripping chars */ - NS_COM void StripChars( const char_type* aChars, PRUint32 aOffset=0 ); + void StripChars( const char_type* aChars, PRUint32 aOffset=0 ); /** * If the string uses a shared buffer, this method @@ -584,7 +584,7 @@ class nsTSubstring_CharT // XXXbz or can I just include nscore.h and use NS_BUILD_REFCNT_LOGGING? #if defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING) #define XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE - NS_COM nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags ); + nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags ); #else #undef XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags ) @@ -628,7 +628,7 @@ class nsTSubstring_CharT * any of its member variables. in other words, this function acts * like a destructor. */ - void NS_COM NS_FASTCALL Finalize(); + void NS_FASTCALL Finalize(); /** * this function prepares mData to be mutated. @@ -702,7 +702,7 @@ class nsTSubstring_CharT * this helper function can be called prior to directly manipulating * the contents of mData. see, for example, BeginWriting. */ - NS_COM PRBool NS_FASTCALL EnsureMutable( size_type newLen = size_type(-1) ); + PRBool NS_FASTCALL EnsureMutable( size_type newLen = size_type(-1) ); /** * returns true if this string overlaps with the given string fragment. @@ -787,7 +787,6 @@ class nsTSubstring_CharT // }; -NS_COM int NS_FASTCALL Compare( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs, const nsTStringComparator_CharT& = nsTDefaultStringComparator_CharT() ); diff --git a/xpcom/string/public/nsTSubstringTuple.h b/xpcom/string/public/nsTSubstringTuple.h index bfd98da2fb54..95eecbf66e72 100644 --- a/xpcom/string/public/nsTSubstringTuple.h +++ b/xpcom/string/public/nsTSubstringTuple.h @@ -73,20 +73,20 @@ class nsTSubstringTuple_CharT /** * computes the aggregate string length */ - NS_COM size_type Length() const; + size_type Length() const; /** * writes the aggregate string to the given buffer. bufLen is assumed * to be equal to or greater than the value returned by the Length() * method. the string written to |buf| is not null-terminated. */ - NS_COM void WriteTo(char_type *buf, PRUint32 bufLen) const; + void WriteTo(char_type *buf, PRUint32 bufLen) const; /** * returns true if this tuple is dependent on (i.e., overlapping with) * the given char sequence. */ - NS_COM PRBool IsDependentOn(const char_type *start, const char_type *end) const; + PRBool IsDependentOn(const char_type *start, const char_type *end) const; private: diff --git a/xpcom/string/src/nsReadableUtils.cpp b/xpcom/string/src/nsReadableUtils.cpp index 81b9cc00ed97..4a3fdd359b32 100644 --- a/xpcom/string/src/nsReadableUtils.cpp +++ b/xpcom/string/src/nsReadableUtils.cpp @@ -41,7 +41,6 @@ #include "nsString.h" #include "nsUTF8Utils.h" -NS_COM void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest ) { @@ -49,7 +48,6 @@ LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest ) LossyAppendUTF16toASCII(aSource, aDest); } -NS_COM void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest ) { @@ -57,7 +55,6 @@ CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest ) AppendASCIItoUTF16(aSource, aDest); } -NS_COM void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ) { @@ -67,7 +64,6 @@ LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ) } } -NS_COM void CopyASCIItoUTF16( const char* aSource, nsAString& aDest ) { @@ -77,7 +73,6 @@ CopyASCIItoUTF16( const char* aSource, nsAString& aDest ) } } -NS_COM void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest ) { @@ -85,7 +80,6 @@ CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest ) AppendUTF16toUTF8(aSource, aDest); } -NS_COM void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest ) { @@ -93,7 +87,6 @@ CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest ) AppendUTF8toUTF16(aSource, aDest); } -NS_COM void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ) { @@ -101,7 +94,6 @@ CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ) AppendUTF16toUTF8(aSource, aDest); } -NS_COM void CopyUTF8toUTF16( const char* aSource, nsAString& aDest ) { @@ -130,7 +122,6 @@ SetLengthForWritingC(nsACString& aDest, PRUint32 aDesiredLength) } -NS_COM void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest ) { @@ -151,7 +142,6 @@ LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest ) copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter); } -NS_COM void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest ) { @@ -172,7 +162,6 @@ AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest ) copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter); } -NS_COM void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ) { @@ -181,7 +170,6 @@ LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest ) } } -NS_COM void AppendASCIItoUTF16( const char* aSource, nsAString& aDest ) { @@ -190,7 +178,6 @@ AppendASCIItoUTF16( const char* aSource, nsAString& aDest ) } } -NS_COM void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest ) { @@ -221,7 +208,6 @@ AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest ) } } -NS_COM void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest ) { @@ -259,7 +245,6 @@ AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest ) } } -NS_COM void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ) { @@ -268,7 +253,6 @@ AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest ) } } -NS_COM void AppendUTF8toUTF16( const char* aSource, nsAString& aDest ) { @@ -294,7 +278,6 @@ AllocateStringCopy( const FromStringT& aSource, ToCharT* ) } -NS_COM char* ToNewCString( const nsAString& aSource ) { @@ -308,7 +291,6 @@ ToNewCString( const nsAString& aSource ) return result; } -NS_COM char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count ) { @@ -333,7 +315,6 @@ ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count ) return result; } -NS_COM char* ToNewCString( const nsACString& aSource ) { @@ -349,7 +330,6 @@ ToNewCString( const nsACString& aSource ) return result; } -NS_COM PRUnichar* ToNewUnicode( const nsAString& aSource ) { @@ -365,7 +345,6 @@ ToNewUnicode( const nsAString& aSource ) return result; } -NS_COM PRUnichar* ToNewUnicode( const nsACString& aSource ) { @@ -379,7 +358,6 @@ ToNewUnicode( const nsACString& aSource ) return result; } -NS_COM PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count ) { @@ -404,7 +382,6 @@ UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count ) return result; } -NS_COM PRUnichar* CopyUnicodeTo( const nsAString& aSource, PRUint32 aSrcOffset, PRUnichar* aDest, PRUint32 aLength ) { @@ -414,8 +391,7 @@ CopyUnicodeTo( const nsAString& aSource, PRUint32 aSrcOffset, PRUnichar* aDest, return aDest; } -NS_COM -void +void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart, const nsAString::const_iterator& aSrcEnd, nsAString& aDest ) @@ -430,8 +406,7 @@ CopyUnicodeTo( const nsAString::const_iterator& aSrcStart, copy_string(fromBegin, aSrcEnd, writer); } -NS_COM -void +void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart, const nsAString::const_iterator& aSrcEnd, nsAString& aDest ) @@ -447,7 +422,6 @@ AppendUnicodeTo( const nsAString::const_iterator& aSrcStart, copy_string(fromBegin, aSrcEnd, writer); } -NS_COM PRBool IsASCII( const nsAString& aString ) { @@ -472,7 +446,6 @@ IsASCII( const nsAString& aString ) return PR_TRUE; } -NS_COM PRBool IsASCII( const nsACString& aString ) { @@ -497,7 +470,6 @@ IsASCII( const nsACString& aString ) return PR_TRUE; } -NS_COM PRBool IsUTF8( const nsACString& aString ) { @@ -612,7 +584,6 @@ class ConvertToUpperCase } }; -NS_COM void ToUpperCase( nsCSubstring& aCString ) { @@ -657,7 +628,6 @@ class CopyToUpperCase nsACString::iterator& mIter; }; -NS_COM void ToUpperCase( const nsACString& aSource, nsACString& aDest ) { @@ -693,7 +663,6 @@ class ConvertToLowerCase } }; -NS_COM void ToLowerCase( nsCSubstring& aCString ) { @@ -738,7 +707,6 @@ class CopyToLowerCase nsACString::iterator& mIter; }; -NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest ) { @@ -751,7 +719,6 @@ ToLowerCase( const nsACString& aSource, nsACString& aDest ) copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter); } -NS_COM PRBool ParseString(const nsACString& aSource, char aDelimiter, nsTArray& aArray) @@ -910,43 +877,37 @@ RFindInReadable_Impl( const StringT& aPattern, IteratorT& aSearchStart, Iterator return PR_FALSE; } -NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd, const nsStringComparator& aComparator ) { return FindInReadable_Impl(aPattern, aSearchStart, aSearchEnd, aComparator); } -NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd, const nsCStringComparator& aComparator) { return FindInReadable_Impl(aPattern, aSearchStart, aSearchEnd, aComparator); } -NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd ) { return FindInReadable_Impl(aPattern, aSearchStart, aSearchEnd, nsCaseInsensitiveCStringComparator()); } -NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd, const nsStringComparator& aComparator) { return RFindInReadable_Impl(aPattern, aSearchStart, aSearchEnd, aComparator); } -NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator& aSearchStart, nsACString::const_iterator& aSearchEnd, const nsCStringComparator& aComparator) { return RFindInReadable_Impl(aPattern, aSearchStart, aSearchEnd, aComparator); } -NS_COM -PRBool +PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd ) { PRInt32 fragmentLength = aSearchEnd.get() - aSearchStart.get(); @@ -961,8 +922,7 @@ FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, co return PR_FALSE; } -NS_COM -PRBool +PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd ) { PRInt32 fragmentLength = aSearchEnd.get() - aSearchStart.get(); @@ -975,10 +935,9 @@ FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const aSearchStart.advance(fragmentLength); return PR_FALSE; - } + } -NS_COM -PRUint32 +PRUint32 CountCharInReadable( const nsAString& aStr, PRUnichar aChar ) { @@ -998,8 +957,7 @@ CountCharInReadable( const nsAString& aStr, return count; } -NS_COM -PRUint32 +PRUint32 CountCharInReadable( const nsACString& aStr, char aChar ) { @@ -1019,7 +977,7 @@ CountCharInReadable( const nsACString& aStr, return count; } -NS_COM PRBool +PRBool StringBeginsWith( const nsAString& aSource, const nsAString& aSubstring, const nsStringComparator& aComparator ) { @@ -1030,7 +988,7 @@ StringBeginsWith( const nsAString& aSource, const nsAString& aSubstring, return Substring(aSource, 0, sub_len).Equals(aSubstring, aComparator); } -NS_COM PRBool +PRBool StringBeginsWith( const nsACString& aSource, const nsACString& aSubstring, const nsCStringComparator& aComparator ) { @@ -1041,7 +999,7 @@ StringBeginsWith( const nsACString& aSource, const nsACString& aSubstring, return Substring(aSource, 0, sub_len).Equals(aSubstring, aComparator); } -NS_COM PRBool +PRBool StringEndsWith( const nsAString& aSource, const nsAString& aSubstring, const nsStringComparator& aComparator ) { @@ -1053,7 +1011,7 @@ StringEndsWith( const nsAString& aSource, const nsAString& aSubstring, aComparator); } -NS_COM PRBool +PRBool StringEndsWith( const nsACString& aSource, const nsACString& aSubstring, const nsCStringComparator& aComparator ) { @@ -1069,7 +1027,6 @@ StringEndsWith( const nsACString& aSource, const nsACString& aSubstring, static const PRUnichar empty_buffer[1] = { '\0' }; -NS_COM const nsAFlatString& EmptyString() { @@ -1078,7 +1035,6 @@ EmptyString() return sEmpty; } -NS_COM const nsAFlatCString& EmptyCString() { @@ -1087,7 +1043,7 @@ EmptyCString() return sEmpty; } -NS_COM PRInt32 +PRInt32 CompareUTF8toUTF16(const nsASingleFragmentCString& aUTF8String, const nsASingleFragmentString& aUTF16String) { @@ -1164,7 +1120,6 @@ CompareUTF8toUTF16(const nsASingleFragmentCString& aUTF8String, return 0; } -NS_COM void AppendUCS4ToUTF16(const PRUint32 aSource, nsAString& aDest) { diff --git a/xpcom/string/src/nsTString.cpp b/xpcom/string/src/nsTString.cpp index 0bbf3b54ff2d..c5ac310f8d2a 100644 --- a/xpcom/string/src/nsTString.cpp +++ b/xpcom/string/src/nsTString.cpp @@ -37,7 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ -NS_COM nsTAdoptingString_CharT& +nsTAdoptingString_CharT& nsTAdoptingString_CharT::operator=( const self_type& str ) { // This'll violate the constness of this argument, that's just diff --git a/xpcom/string/src/nsTStringComparator.cpp b/xpcom/string/src/nsTStringComparator.cpp index 48a4223f6db1..8824005073c7 100644 --- a/xpcom/string/src/nsTStringComparator.cpp +++ b/xpcom/string/src/nsTStringComparator.cpp @@ -36,7 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ -NS_COM int NS_FASTCALL +int NS_FASTCALL Compare( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs, const nsTStringComparator_CharT& comp ) { typedef nsTSubstring_CharT::size_type size_type; diff --git a/xpcom/tests/TestPipes.cpp b/xpcom/tests/TestPipes.cpp index 8194d49185cb..40202e556f60 100644 --- a/xpcom/tests/TestPipes.cpp +++ b/xpcom/tests/TestPipes.cpp @@ -472,7 +472,7 @@ RunTests(PRUint32 segSize, PRUint32 segCount) //////////////////////////////////////////////////////////////////////////////// #if 0 -extern NS_COM void +extern void TestSegmentedBuffer(); #endif diff --git a/xpcom/threads/nsEventQueue.h b/xpcom/threads/nsEventQueue.h index 29ff4fc2e990..8a76d925abac 100644 --- a/xpcom/threads/nsEventQueue.h +++ b/xpcom/threads/nsEventQueue.h @@ -44,7 +44,7 @@ #include "nsIRunnable.h" // A threadsafe FIFO event queue... -class NS_COM nsEventQueue +class nsEventQueue { typedef mozilla::ReentrantMonitor ReentrantMonitor; diff --git a/xpcom/threads/nsThreadUtilsInternal.h b/xpcom/threads/nsThreadUtilsInternal.h index f99929030e04..e11b70996b0b 100644 --- a/xpcom/threads/nsThreadUtilsInternal.h +++ b/xpcom/threads/nsThreadUtilsInternal.h @@ -54,7 +54,7 @@ class nsIThreadObserver; * other threads will return an error. */ extern nsresult -NS_COM NS_SetGlobalThreadObserver(nsIThreadObserver* aObserver); +NS_SetGlobalThreadObserver(nsIThreadObserver* aObserver); #endif // MOZILLA_INTERNAL_API